com.sri.emo.dbobj.model_tree
Class ModelDepthFirstIterator

java.lang.Object
  extended by com.sri.emo.dbobj.model_tree.ModelDepthFirstIterator
All Implemented Interfaces:
Iterator

public class ModelDepthFirstIterator
extends Object
implements Iterator

Implementation of Iterator that allows depth first iteratation over all the nodes in a model. This iterator does not allow for removal of individual nodes: it is read only.

Author:
Michael Rimov

Constructor Summary
ModelDepthFirstIterator(ModelNode root)
          Constructor that takes the root of what it is suppsoed to iterate.
ModelDepthFirstIterator(ModelNode root, TreeTraversalListener listener)
          Constructor that takes a listener as well as a root of what it is supposed to iterate.
 
Method Summary
 boolean hasNext()
          Returns true if the iteration has more elements.
 Object next()
          Returns the next element in the iteration.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelDepthFirstIterator

public ModelDepthFirstIterator(ModelNode root)
Constructor that takes the root of what it is suppsoed to iterate.

Parameters:
root - ModelCompositeNode

ModelDepthFirstIterator

public ModelDepthFirstIterator(ModelNode root,
                               TreeTraversalListener listener)
Constructor that takes a listener as well as a root of what it is supposed to iterate.

Parameters:
root - ModelNode the root composite node that we're iterating in a depth first fashion.
listener - TreeTraversalListener the notification sink that receives notifications of traversal down or up the tree. This iterator is guaranteed to only traverse down one level at a time, although it may traverse up several levels.
Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements.

Specified by:
hasNext in interface Iterator
Returns:
true if the iterator has more elements.

next

public Object next()
Returns the next element in the iteration.

Specified by:
next in interface Iterator
Returns:
the next element in the iteration.

remove

public void remove()
Removes from the underlying collection the last element returned by the iterator (optional operation).

Specified by:
remove in interface Iterator


Copyright © 2004-2006 Codeguild, Inc.. All Rights Reserved.