|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cc.framework.util.TreeIterator
Iterates over the tree. Preorder traversal is used, i.e., node is processed
before its children.
Depth of traversal can be limited by setMaxDepth
.
Branches can be traversed selectively using skipChildren()
.
Nested Class Summary | |
private static class |
TreeIterator.AbstractLevelIterator
Base class for all LevelIterator's |
static interface |
TreeIterator.LevelIterator
Iterator for one level in a tree structure |
private static class |
TreeIterator.RootIterator
Specialized iterator for the root element of the tree |
private static class |
TreeIterator.SimpleLevelIterator
Iterator for simple Group Nodes |
private static class |
TreeIterator.VirtualTreeLevelIterator
Iterator for virtual group nodes. |
Field Summary | |
private TreeIterator.LevelIterator |
levelIter
|
private boolean |
skipChildren
|
private TreeStateModel |
state
The State Model that holds the expansion states |
Constructor Summary | |
TreeIterator(TreeNodeDataModel root)
Creates iterator and sets the root of a tree and tree adapter. |
|
TreeIterator(TreeNodeDataModel root,
int maxDepth)
Creates iterator and sets the root of a tree, tree adapter and depth of the traversal. |
|
TreeIterator(TreeNodeDataModel root,
TreeStateModel state)
Creates iterator and sets the root of a tree and tree adapter. |
Method Summary | |
static TreeIterator.LevelIterator |
createLevelIterator(TreeNodeDataModel root)
Factory method to create a LevelIterator |
TreeNodeDataModel |
current()
Returns the current node. |
int |
currentIndex()
Returns index of the of the current node among siblings. |
java.lang.String |
currentKey()
Returns key of the of the current node. |
boolean |
done()
|
int |
getDepth()
Returns the depth of the level being traversed. |
int |
getMaxDepth()
Returns the maximum depth of the traversal. |
boolean |
hasChildren()
Returns true if current node has children and iterator is
allowed to traverse them. |
boolean |
hasNext()
Returns true if not all elements of the tree have been
traversed. |
boolean |
isExpanded()
Returns true if current node is expanded. |
boolean |
isMaxDepth()
Returns true if the maximum allowed level is reached. |
void |
next()
Returns the next element of a tree. |
void |
setMaxDepth(int maxDepth)
Sets the maximum depth of the traversal. |
void |
skipChildren()
After this method is called, next() will skip children of
the current node and move to the next sibling instead. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private TreeIterator.LevelIterator levelIter
private boolean skipChildren
private TreeStateModel state
Constructor Detail |
public TreeIterator(TreeNodeDataModel root)
root
- root of the tree; note that next()
moves to the
first child, not to the rootpublic TreeIterator(TreeNodeDataModel root, TreeStateModel state)
root
- root of the tree; note that next()
moves to the
first child, not to the rootstate
- the tree state that holds the expansion informationpublic TreeIterator(TreeNodeDataModel root, int maxDepth)
root
- root of the treemaxDepth
- depth of the traversal;
Method Detail |
public static TreeIterator.LevelIterator createLevelIterator(TreeNodeDataModel root)
root
- the root element of the tree
public TreeNodeDataModel current()
next()
call moves current to the next node.
public void setMaxDepth(int maxDepth)
maxDepth
- depth of the traversal;
public int getMaxDepth()
setMaxDepth()
.public void skipChildren()
next()
will skip children of
the current node and move to the next sibling instead.
public boolean isMaxDepth()
true
if the maximum allowed level is reached.
setMaxDepth()
public int getDepth()
public int currentIndex()
public java.lang.String currentKey()
public boolean hasNext()
true
if not all elements of the tree have been
traversed.
true
if end of tree is not reachedpublic boolean hasChildren()
true
if current node has children and iterator is
allowed to traverse them.
true
if current node has childrenpublic boolean isExpanded()
true
if current node is expanded.
true
if current node is expandedpublic void next()
public boolean done()
true
when the iterator has reached the
last element of the iteration. after done() has returned
true
it is not valid to call current()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |