net.sf.molae.pipe.tree
Class DepthFirstIterator
java.lang.Object
|
+--net.sf.molae.pipe.tree.DepthFirstIterator
- All Implemented Interfaces:
- Iterator
- public final class DepthFirstIterator
- extends Object
- implements Iterator
Provides an Iterator that runs depth first through a tree.
For each tree node a method that returns its children as a
collection is required.
This can be done by
- Direct composition: Each member of a collection is again a collection.
- the method
getComponents() in the
interface Composition.
- Defining a
CompositionView
that contains the method calls for each class, that return the children.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DepthFirstIterator
public DepthFirstIterator(Object pObject,
CompositionView pCompositionView)
- Constructs a
DepthFirstIterator.
- Parameters:
pObject - The root of the tree to be traversed
or an iterator defining the topmost level of the treepCompositionView - if null the
DEFAULT_COMPOSITION_VIEW is used.
DepthFirstIterator
public DepthFirstIterator(Object pObject)
- Constructs a
DepthFirstIterator.
- Parameters:
pObject - The root of the tree to be traversed
or an iterator defining the topmost level of the tree
hasNext
public boolean hasNext()
- Specified by:
hasNext in interface Iterator
next
public Object next()
- Specified by:
next in interface Iterator
- Throws:
NoSuchElementException - iteration has no more elements.
remove
public void remove()
- Specified by:
remove in interface Iterator
- Throws:
UnsupportedOperationException - depending on the collections of
the base treeIllegalStateException - if the next method has not
yet been called, or the remove method has already
been called after the last call to the next method.