org.apache.wicket.util.iterator
Class ComponentHierarchyIterator

java.lang.Object
  extended by org.apache.wicket.util.iterator.AbstractHierarchyIterator<N,I>
      extended by org.apache.wicket.util.iterator.AbstractHierarchyIteratorWithFilter<Component,Component>
          extended by org.apache.wicket.util.iterator.ComponentHierarchyIterator
All Implemented Interfaces:
java.lang.Iterable<Component>, java.util.Iterator<Component>

public class ComponentHierarchyIterator
extends AbstractHierarchyIteratorWithFilter<Component,Component>

Iterator over the complete Component hierarchy. The implementation is parent first, meaning that first the parent gets returned upon next() and only than it's children.

A fluent or builder type of API is provided to configure the iterator with filters.

Author:
Juergen Donnerstag

Constructor Summary
ComponentHierarchyIterator(Component component)
          Construct.
ComponentHierarchyIterator(Component component, java.lang.Class<?> clazz)
          Convenience Constructor
ComponentHierarchyIterator(Component component, java.lang.Class<?> clazz, boolean visible, boolean enabled)
          Convenience Constructor
 
Method Summary
 ComponentHierarchyIterator addFilter(IteratorFilter<Component> filter)
          Add a filter (fluent API)
 ComponentHierarchyIterator addTraverseFilters(IteratorFilter<Component> filter)
          Add a filter to the traversal filter list (fluent API).
 ComponentHierarchyIterator filterByClass(java.lang.Class<?> clazz)
          Ignore components which don't implement (instanceof) the class provided.
 ComponentHierarchyIterator filterById(java.lang.String match)
          Ignore all components which don't match the id (regex).
 ComponentHierarchyIterator filterByVisibility()
          Ignore all Components which not visible.
 ComponentHierarchyIterator filterEnabled()
          Ignore all Components which not enabled (disabled) in the hierarchy
 ComponentHierarchyIterator filterLeavesOnly()
          Add a filter which returns only leaf components.
protected  boolean hasChildren(Component elem)
          Only MarkupContainer's might have children
protected  java.util.Iterator<Component> newIterator(Component node)
          The component must be a MarkupContainer to contain children
 
Methods inherited from class org.apache.wicket.util.iterator.AbstractHierarchyIteratorWithFilter
getFilters, getFirst, getTraverseFilters, onFilter, onTraversalFilter, replaceFilterSet, toList
 
Methods inherited from class org.apache.wicket.util.iterator.AbstractHierarchyIterator
dontGoDeeper, hasNext, iterator, next, remove, setChildFirst, skipRemainingSiblings, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComponentHierarchyIterator

public ComponentHierarchyIterator(Component component)
Construct.

Parameters:
component - Iterate over the containers children

ComponentHierarchyIterator

public ComponentHierarchyIterator(Component component,
                                  java.lang.Class<?> clazz,
                                  boolean visible,
                                  boolean enabled)
Convenience Constructor

Parameters:
component - Iterate over the containers children
clazz - Add filter by class
visible - Add filter by visibility
enabled - Add filter by "enabled"

ComponentHierarchyIterator

public ComponentHierarchyIterator(Component component,
                                  java.lang.Class<?> clazz)
Convenience Constructor

Parameters:
component - Iterate over the containers children
clazz - Add filter by class
Method Detail

newIterator

protected java.util.Iterator<Component> newIterator(Component node)
The component must be a MarkupContainer to contain children

Specified by:
newIterator in class AbstractHierarchyIterator<Component,Component>
Returns:
container iterator

hasChildren

protected boolean hasChildren(Component elem)
Only MarkupContainer's might have children

Specified by:
hasChildren in class AbstractHierarchyIterator<Component,Component>
Returns:
True, if node is a container and has at least one child.

filterLeavesOnly

public final ComponentHierarchyIterator filterLeavesOnly()
Add a filter which returns only leaf components.

Returns:
this

filterByClass

public ComponentHierarchyIterator filterByClass(java.lang.Class<?> clazz)
Ignore components which don't implement (instanceof) the class provided.

Parameters:
clazz -
Returns:
this

filterByVisibility

public ComponentHierarchyIterator filterByVisibility()
Ignore all Components which not visible.

Returns:
this

filterEnabled

public ComponentHierarchyIterator filterEnabled()
Ignore all Components which not enabled (disabled) in the hierarchy

Returns:
this

filterById

public ComponentHierarchyIterator filterById(java.lang.String match)
Ignore all components which don't match the id (regex).

Parameters:
match - Regex to find Components matching
Returns:
this

addFilter

public ComponentHierarchyIterator addFilter(IteratorFilter<Component> filter)
Description copied from class: AbstractHierarchyIteratorWithFilter
Add a filter (fluent API)

Overrides:
addFilter in class AbstractHierarchyIteratorWithFilter<Component,Component>
Returns:
this

addTraverseFilters

public ComponentHierarchyIterator addTraverseFilters(IteratorFilter<Component> filter)
Description copied from class: AbstractHierarchyIteratorWithFilter
Add a filter to the traversal filter list (fluent API).

Overrides:
addTraverseFilters in class AbstractHierarchyIteratorWithFilter<Component,Component>
Returns:
this


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.