com.metamatrix.common.tree
Class TreeNodeIteratorWithStack

java.lang.Object
  extended by com.metamatrix.common.tree.TreeNodeIteratorWithStack
All Implemented Interfaces:
java.util.Iterator

public class TreeNodeIteratorWithStack
extends java.lang.Object
implements java.util.Iterator

This iterator implementation extends TreeNodeIterator by maintaining a stack of TreeNodes from the root to the last node returned by next().

This class has the ability to track with each TreeNode instance in the stack a payload object. However, in order to use this feature, this class must be extended by subclassing the createPayload(TreeNode) method must be overridden.

Also, the stack is accessed with the getStack() method and contains instances of TreeNodeIteratorWithStack.StackEntry instances.


Nested Class Summary
static class TreeNodeIteratorWithStack.StackEntry
           
 
Constructor Summary
TreeNodeIteratorWithStack(TreeNode startingNode, TreeView view)
          Construct an instance of XMLNamespaceAwareIterator.
TreeNodeIteratorWithStack(TreeNode startingNode, TreeView view, java.util.Iterator iter)
          Construct an instance that wraps the supplied iterator.
 
Method Summary
protected  java.lang.Object createPayload(TreeNode node)
           
 java.util.LinkedList getStack()
          Return the list of StackEntry objects that each have a target and a payload.
 TreeView getTreeView()
           
 boolean hasNext()
           
protected  boolean isStartingNode(TreeNode node)
           
 java.lang.Object next()
           
protected  void process(java.lang.Object object)
           
 void remove()
           
protected  void synchronizeStack(TreeNode obj)
           
 java.lang.String toString()
           
protected  java.lang.String toStringPayload(java.lang.Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeNodeIteratorWithStack

public TreeNodeIteratorWithStack(TreeNode startingNode,
                                 TreeView view)
Construct an instance of XMLNamespaceAwareIterator.

Parameters:
startingNode -
view -

TreeNodeIteratorWithStack

public TreeNodeIteratorWithStack(TreeNode startingNode,
                                 TreeView view,
                                 java.util.Iterator iter)
Construct an instance that wraps the supplied iterator.

Parameters:
startingNode -
view -
iter - the iterator that provides the set of TreeNodes over which the iteration is to occur.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator

remove

public void remove()
Specified by:
remove in interface java.util.Iterator

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator

process

protected void process(java.lang.Object object)

synchronizeStack

protected void synchronizeStack(TreeNode obj)
Parameters:
entity -

isStartingNode

protected boolean isStartingNode(TreeNode node)
Parameters:
node -
Returns:

createPayload

protected java.lang.Object createPayload(TreeNode node)

getStack

public java.util.LinkedList getStack()
Return the list of StackEntry objects that each have a target and a payload.

Returns:

getTreeView

public TreeView getTreeView()
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringPayload

protected java.lang.String toStringPayload(java.lang.Object obj)


Copyright © 2009. All Rights Reserved.