| java.lang.Object org.apache.cocoon.forms.formmodel.tree.TreeWalker
TreeWalker | public class TreeWalker implements Iterator(Code) | | A helper to crawl a tree and quickly access important node-related information.
It's an Iterator on the "current level" of the tree. This level starts
at the root node (and therefore obviously contains only one element), and can then
be changed to children of the current node using
TreeWalker.enterChildren() or popped
back to the parent level using
TreeWalker.leave() .
The
TreeWalker.next() method will return the next node in the iteration,
and set the current node used by many convenience methods giving information about
that node.
This class was primarily written for page templates containing
Tree s (see
org/apache/cocoon/forms/generation/jx-macros.xml ) but can of course be
used in other places as well.
version: $Id: TreeWalker.java 449149 2006-09-23 03:58:05Z crossley $ |
enterChildren | public TreeWalker enterChildren()(Code) | | Starts iterating the children of the current node. The current iterator is pushed
on a stack and will be restored on
TreeWalker.leave() .
Right after calling this method, there is no current node. Calling
TreeWalker.next() will move to the first child, if any.
the current tree walker (i.e. this ). |
getDepth | public int getDepth()(Code) | | Get the current depth of this walker (can be used e.g. to compute indentation margins
or CSS styles). If root node is visible (see
Tree.isRootVisible ), depth 0 is
for the root. Otherwise, children of the root node are at depth 0.
the current depth |
getIconType | public String getIconType()(Code) | | Get the "icon type" that should be used for this node, according to the common
visual paradigms used to render trees:
- "
leaf " for leaf nodes (will be e.g. a file icon),
- "
expanded " for non-leaf expanded nodes (will be e.g. a "minus" icon)
- "
collapsed " for non-leaf collapsed nodes (will be e.g. a "plus" icon)
the icon type |
getPath | public TreePath getPath()(Code) | | Get the path of the current node.
the path |
getSelectionType | public String getSelectionType()(Code) | | Get the "selection type" that should be used for this node, that can be used e.g. as
a CSS class name:
- "
selected " for selected nodes,
- "
unselected " for unselected nodes.
the selection type |
hasNext | public boolean hasNext()(Code) | | Are there more nodes to iterate on at this level?
|
isCollapsed | public boolean isCollapsed()(Code) | | Is the current node collapsed?
|
isExpanded | public boolean isExpanded()(Code) | | Is the current node expanded?
|
isLeaf | public boolean isLeaf()(Code) | | Is the current node a leaf?
|
isSelected | public boolean isSelected()(Code) | | Is the current node selected?
|
isVisible | public boolean isVisible()(Code) | | Is the current node visible (i.e. its parent is expanded)?
|
leave | public void leave()(Code) | | Go back to the parent node, restoring the iterator at this node.
|
next | public Object next()(Code) | | Get the next node in the current iteration level.
|
|
|