org.apache.wicket.util.iterator
Class GenericComponentHierarchyIterator<I extends Component>

java.lang.Object
  extended by org.apache.wicket.util.iterator.AbstractHierarchyIterator<N,I>
      extended by org.apache.wicket.util.iterator.AbstractHierarchyIteratorWithFilter<Component,I>
          extended by org.apache.wicket.util.iterator.GenericComponentHierarchyIterator<I>
Type Parameters:
I - The type which next() should return (the iterator type)
All Implemented Interfaces:
java.lang.Iterable<I>, java.util.Iterator<I>

public class GenericComponentHierarchyIterator<I extends Component>
extends AbstractHierarchyIteratorWithFilter<Component,I>

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
GenericComponentHierarchyIterator(Component component, java.lang.Class<? extends I> clazz)
          Construct.
 
Method Summary
 GenericComponentHierarchyIterator<I> addFilter(IteratorFilter<Component> filter)
          Add a filter (fluent API)
 GenericComponentHierarchyIterator<I> addTraverseFilters(IteratorFilter<Component> filter)
          Add a filter to the traversal filter list (fluent API).
 GenericComponentHierarchyIterator<I> filterByClass(java.lang.Class<?> clazz)
          Ignore components which don't implement (instanceof) the class provided.
 GenericComponentHierarchyIterator<I> filterById(java.lang.String match)
          Ignore all components which don't match the id (regex).
 GenericComponentHierarchyIterator<I> filterByVisibility()
          Ignore all Components which not visible.
 GenericComponentHierarchyIterator<I> filterEnabled()
          Ignore all Components which not enabled (disabled) in the hierarchy
 GenericComponentHierarchyIterator<I> 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

GenericComponentHierarchyIterator

public GenericComponentHierarchyIterator(Component component,
                                         java.lang.Class<? extends I> clazz)
Construct.

Parameters:
component - Iterate over the containers children
clazz - Must be the same as the iterator type provided
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,I extends Component>
Returns:
container iterator

hasChildren

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

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

filterLeavesOnly

public final GenericComponentHierarchyIterator<I> filterLeavesOnly()
Add a filter which returns only leaf components.

Returns:
this

filterByClass

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

Parameters:
clazz -
Returns:
this

filterByVisibility

public GenericComponentHierarchyIterator<I> filterByVisibility()
Ignore all Components which not visible.

Returns:
this

filterEnabled

public GenericComponentHierarchyIterator<I> filterEnabled()
Ignore all Components which not enabled (disabled) in the hierarchy

Returns:
this

filterById

public GenericComponentHierarchyIterator<I> 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 GenericComponentHierarchyIterator<I> addFilter(IteratorFilter<Component> filter)
Description copied from class: AbstractHierarchyIteratorWithFilter
Add a filter (fluent API)

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

addTraverseFilters

public GenericComponentHierarchyIterator<I> 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,I extends Component>
Returns:
this


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