cds.util
Class TreeHashMap.TreeIterator

java.lang.Object
  extended bycds.util.TreeHashMap.TreeIterator
All Implemented Interfaces:
TreeHashMapIterator
Enclosing class:
TreeHashMap

protected class TreeHashMap.TreeIterator
extends java.lang.Object
implements TreeHashMapIterator

Leaf Iterator: returns only the leaf elements from a given node


Field Summary
(package private)  java.util.Map.Entry currEntry
           
(package private)  java.util.Iterator currIter
           
(package private)  int currLevel
           
(package private)  int currState
           
(package private)  int currType
           
private static int ITEM_SET
           
(package private)  int iteratorType
           
(package private)  java.util.Stack iters
           
private static int LEAF
           
(package private)  int maxLevel
           
(package private)  java.util.Stack names
           
private static int NO_ITEM
           
private static int NODE
           
 
Constructor Summary
protected TreeHashMap.TreeIterator()
          Constructor without parameters: 1 level, returns only leaves.
protected TreeHashMap.TreeIterator(int iterType)
          Constructor with iterator type specification: LEAF, NODE or both
protected TreeHashMap.TreeIterator(int iterType, int level)
          Constuctor with iterator type and level specification
 
Method Summary
private  int getType(java.util.Map.Entry item)
           
 boolean hasNext()
          Checks if the iterator has a next element to access
 boolean isNode()
          Returns true if the current item is a node and false if it is a leaf.
 java.lang.String key()
          Returns the key nameof the current item, the one which was called by a previous next() or nextKey() method.
 int level()
          Returns the level of the current item.
 java.util.Map.Entry next()
          Returns the next item in the TreeHashMap.
 java.lang.String nextKey()
          Returns the key (always a string) of the 'next item'.
 java.lang.String path()
          Returns the path of the current item, from its root.
 void remove()
           
private  boolean setNext()
          Sets the current item.
 java.lang.Object value()
          Returns the value of the current item, the one which was called by a previous next() or nextKey() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEAF

private static final int LEAF
See Also:
Constant Field Values

NODE

private static final int NODE
See Also:
Constant Field Values

NO_ITEM

private static final int NO_ITEM
See Also:
Constant Field Values

ITEM_SET

private static final int ITEM_SET
See Also:
Constant Field Values

maxLevel

int maxLevel

iteratorType

int iteratorType

iters

java.util.Stack iters

names

java.util.Stack names

currLevel

int currLevel

currIter

java.util.Iterator currIter

currType

int currType

currEntry

java.util.Map.Entry currEntry

currState

int currState
Constructor Detail

TreeHashMap.TreeIterator

protected TreeHashMap.TreeIterator()
Constructor without parameters: 1 level, returns only leaves.


TreeHashMap.TreeIterator

protected TreeHashMap.TreeIterator(int iterType)
Constructor with iterator type specification: LEAF, NODE or both

Parameters:
iterType - LEAF, NODE or LEAF|NODE

TreeHashMap.TreeIterator

protected TreeHashMap.TreeIterator(int iterType,
                                   int level)
Constuctor with iterator type and level specification

Parameters:
iterType - LEAF, NODE or LEAF|NODE
level - max level which the iterator should follow:
0 : all levels
1 : only the node on which the iterator is defined
n : n levels down
Method Detail

getType

private int getType(java.util.Map.Entry item)

setNext

private boolean setNext()
Sets the current item. This method is internally called by next() and nextKey(). Depending on the iterator parameters, it sets the values for the next current item found by this iterator.


hasNext

public boolean hasNext()
Checks if the iterator has a next element to access

Specified by:
hasNext in interface TreeHashMapIterator
Returns:
true if yes

next

public java.util.Map.Entry next()
Description copied from interface: TreeHashMapIterator
Returns the next item in the TreeHashMap. Depending on the definition of the iterator, it can return a leaf or a node. Consecutive next() methods return consecutive elements.

Specified by:
next in interface TreeHashMapIterator

nextKey

public java.lang.String nextKey()
Description copied from interface: TreeHashMapIterator
Returns the key (always a string) of the 'next item'. Consecutive nextKey() methods return consecutive elements.

Specified by:
nextKey in interface TreeHashMapIterator

key

public java.lang.String key()
Description copied from interface: TreeHashMapIterator
Returns the key nameof the current item, the one which was called by a previous next() or nextKey() method. Consecutive calls to this method will return the same key name.

Specified by:
key in interface TreeHashMapIterator

value

public java.lang.Object value()
Description copied from interface: TreeHashMapIterator
Returns the value of the current item, the one which was called by a previous next() or nextKey() method. Consecutive calls to this method will return the same value.

Specified by:
value in interface TreeHashMapIterator

level

public int level()
Description copied from interface: TreeHashMapIterator
Returns the level of the current item. The root, towards which the iterator was defined, has level number = 1

Specified by:
level in interface TreeHashMapIterator

remove

public void remove()

isNode

public boolean isNode()
Description copied from interface: TreeHashMapIterator
Returns true if the current item is a node and false if it is a leaf.

Specified by:
isNode in interface TreeHashMapIterator

path

public java.lang.String path()
Description copied from interface: TreeHashMapIterator
Returns the path of the current item, from its root.

Specified by:
path in interface TreeHashMapIterator