net.sf.molae.pipe.tree
Class LeafFilter<E>

java.lang.Object
  extended by net.sf.molae.pipe.tree.LeafFilter<E>
All Implemented Interfaces:
TypedPredicate<E>

public final class LeafFilter<E>
extends Object
implements TypedPredicate<E>

Filters all leafs of a tree defined by a CompositionView.


Method Summary
 boolean evaluate(E input)
          Checks if the specified object is a leaf of the given CompositionView.
static
<E> Collection<E>
leafCollection(E base, CompositionView<E> compositionView)
          Provides a collection that contains only the leafs of a recursive collection.
static Collection<Object> leafCollection(Object base)
          Provides a collection that contains only the leafs of a recursive collection.
static
<E> Iterator<E>
leafIterator(E pObject, CompositionView<E> pCompositionView)
          Provides an iterator that returns only the leafs of a recursive collection.
static Iterator<Object> leafIterator(Object pObject)
          Provides an iterator that returns only the leafs of a recursive collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

evaluate

public boolean evaluate(E input)
Checks if the specified object is a leaf of the given CompositionView.

Specified by:
evaluate in interface TypedPredicate<E>
Parameters:
input - object to evaluate.
Returns:
true, iff input is a leaf of the given CompositionView

leafIterator

public static <E> Iterator<E> leafIterator(E pObject,
                                           CompositionView<E> pCompositionView)
Provides an iterator that returns only the leafs of a recursive collection.

Parameters:
pObject - the root object of the tree or an iterator defining the topmost level of the tree
pCompositionView - the compositionView to be used
Returns:
an iterator that contains the leafs of the tree defined by the specified object and the specified composition view.

leafIterator

public static Iterator<Object> leafIterator(Object pObject)
Provides an iterator that returns only the leafs of a recursive collection.

Parameters:
pObject - the root object of the tree or an iterator defining the topmost level of the tree
Returns:
an iterator that contains the leafs of the tree defined by the specified object.

leafCollection

public static <E> Collection<E> leafCollection(E base,
                                               CompositionView<E> compositionView)
Provides a collection that contains only the leafs of a recursive collection.

Parameters:
base - the root object of the tree - must not be an Iterator.
compositionView - the compositionView to be used
Returns:
a collection that contains the leafs of the tree defined by the specified object and the specified composition view.

leafCollection

public static Collection<Object> leafCollection(Object base)
Provides a collection that contains only the leafs of a recursive collection.

Parameters:
base - the root object of the tree - must not be an Iterator.
Returns:
a collection that contains the leafs of the tree defined by the specified object.