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

  1. Direct composition: Each member of a collection is again a collection.
  2. the method getComponents() in the interface Composition.
  3. Defining a CompositionView that contains the method calls for each class, that return the children.


Constructor Summary
DepthFirstIterator(Object pObject)
          Constructs a DepthFirstIterator.
DepthFirstIterator(Object pObject, CompositionView pCompositionView)
          Constructs a DepthFirstIterator.
 
Method Summary
 boolean hasNext()
           
 Object next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 tree
pCompositionView - 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
Method Detail

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 tree
IllegalStateException - 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.