com.guiseframework.component
Class Components

java.lang.Object
  extended by com.guiseframework.component.Components

public class Components
extends java.lang.Object

Utility methods for working with components.

Author:
Garret Wilson

Constructor Summary
Components()
           
 
Method Summary
static
<C,T extends java.util.Collection<C>>
T
getChildComponents(CompositeComponent compositeComponent, java.lang.Class<C> componentClass, T componentCollection, boolean deep, boolean below)
          Retrieves all child components that are instances of the of the given class.
static java.util.Collection<Component> getComponents(Component component)
          Retrieves all components, including the given component and all descendant components.
static
<C,T extends java.util.Collection<C>>
T
getComponents(Component component, java.lang.Class<C> componentClass, T componentCollection, boolean deep, boolean below)
          Retrieves all components, including the given component, that are instances of the of the given class.
static
<T extends java.util.Collection<Component>>
T
getComponents(Component component, T componentCollection)
          Retrieves all components, including the given component and all descendant components.
static java.util.Collection<Component> getDescendantComponents(CompositeComponent compositeComponent)
          Retrieves all descendant components.
static
<T extends java.util.Collection<Component>>
T
getDescendantComponents(CompositeComponent compositeComponent, T componentCollection)
          Retrieves all descendant components.
static boolean hasChildComponent(CompositeComponent compositeComponent, Component component)
          Determines if the given composite component has the given component as one of its descendants.
static boolean hasChildComponent(CompositeComponent compositeComponent, Component component, boolean deep)
          Determines if the given composite component has the given component as one of its descendants.
static boolean hasComponent(Component component, Component hasComponent)
          Determines if the given component is or has as a descendant the given other component.
static boolean hasComponent(Component component, Component hasComponent, boolean deep)
          Determines if the given component is or has as a descendant the given other component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Components

public Components()
Method Detail

getComponents

public static java.util.Collection<Component> getComponents(Component component)
Retrieves all components, including the given component and all descendant components.

Parameters:
component - The component to search.
Returns:
The collection of components.
Throws:
java.lang.NullPointerException - if the given component is null.

getComponents

public static <T extends java.util.Collection<Component>> T getComponents(Component component,
                                                                          T componentCollection)
Retrieves all components, including the given component and all descendant components.

Parameters:
component - The component to search.
componentCollection - The collection into which the components will be collected.
Returns:
The component collection.
Throws:
java.lang.NullPointerException - if the given component and/or collection is null.

getComponents

public static <C,T extends java.util.Collection<C>> T getComponents(Component component,
                                                                    java.lang.Class<C> componentClass,
                                                                    T componentCollection,
                                                                    boolean deep,
                                                                    boolean below)
Retrieves all components, including the given component, that are instances of the of the given class. If deep is set to true, the component's child components are recursively searched if the component is a composite component. If below is set to true, the child components of any composite component that is an instance of the given class are also recursively searched.

Parameters:
component - The component to search.
componentClass - The type of component to retrieve.
componentCollection - The collection into which the components will be collected.
deep - true if the children of composite components should resursively be searched.
below - true if the children of composite components that are instances of the given class should resursively be searched, if deep is set to true.
Returns:
The component collection.
Throws:
java.lang.NullPointerException - if the given component, component class, and/or collection is null.

getDescendantComponents

public static java.util.Collection<Component> getDescendantComponents(CompositeComponent compositeComponent)
Retrieves all descendant components.

Parameters:
component - The component to search.
Returns:
The collection of components.
Throws:
java.lang.NullPointerException - if the given component is null.

getDescendantComponents

public static <T extends java.util.Collection<Component>> T getDescendantComponents(CompositeComponent compositeComponent,
                                                                                    T componentCollection)
Retrieves all descendant components.

Parameters:
compositeComponent - The component to search.
componentCollection - The collection into which the components will be collected.
Returns:
The component collection.
Throws:
java.lang.NullPointerException - if the given component and/or collection is null.

getChildComponents

public static <C,T extends java.util.Collection<C>> T getChildComponents(CompositeComponent compositeComponent,
                                                                         java.lang.Class<C> componentClass,
                                                                         T componentCollection,
                                                                         boolean deep,
                                                                         boolean below)
Retrieves all child components that are instances of the of the given class. If deep is set to true, a component's child components are recursively searched if that component is a composite component. If below is set to true, the child components of any composite component that is an instance of the given class are also recursively searched.

Parameters:
compositeComponent - The component to search.
componentClass - The type of component to retrieve.
componentCollection - The collection into which the components will be collected.
deep - true if the children of composite components should resursively be searched.
below - true if the children of composite components that are instances of the given class should resursively be searched, if deep is set to true.
Returns:
The component collection.
Throws:
java.lang.NullPointerException - if the given component, component class, and/or collection is null.

hasComponent

public static boolean hasComponent(Component component,
                                   Component hasComponent)
Determines if the given component is or has as a descendant the given other component.

Parameters:
component - The component to search.
hasComponent - The component to find.
Returns:
true if the given component is the composite component or is a descendant of the given composite component.
Throws:
java.lang.NullPointerException - if one of the given components is null.

hasComponent

public static boolean hasComponent(Component component,
                                   Component hasComponent,
                                   boolean deep)
Determines if the given component is or has as a descendant the given other component.

Parameters:
component - The component to search.
hasComponent - The component to find.
deep - true if the children of composite components should resursively be searched.
Returns:
true if the given component is the composite component or is a descendant of the given composite component.
Throws:
java.lang.NullPointerException - if one of the given components is null.

hasChildComponent

public static boolean hasChildComponent(CompositeComponent compositeComponent,
                                        Component component)
Determines if the given composite component has the given component as one of its descendants.

Parameters:
compositeComponent - The component to search.
component - The component to find.
Returns:
Whether the given component is a descendant of the given composite component.
Throws:
java.lang.NullPointerException - if the given composite component or component is null.

hasChildComponent

public static boolean hasChildComponent(CompositeComponent compositeComponent,
                                        Component component,
                                        boolean deep)
Determines if the given composite component has the given component as one of its descendants.

Parameters:
compositeComponent - The component to search.
component - The component to find.
deep - true if the children of composite components should resursively be searched.
Returns:
Whether the given component is a descendant of the given composite component.
Throws:
java.lang.NullPointerException - if the given composite component or component is null.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.