public interface TreeWalker
Node
s. The order of visiting the nodes is defined by the
implementation.
The walk(Node, NodeCallback)
method allows to provide callbacks which allows to perform actions at certain
moments of the walk-through. The moment when a callback is called depends of the interfaces that are implemented by a
specific callback. Possible callbacks and their purposes are:
EveryNodeCallback
: The single method of this callback will be called once for every node in the tree in
the order of the walkthrough.
BottomNodeCallback
: The single method of this callback will be called for every node in the tree, which
is a bottom node (has no children).
SkipNodeAndSubTreesCallback
: The method of this callback is called before a node (or its children) are
visited. Its sole method can return a boolean flag. If the callback returns true
, then the node (and all the
subtree starting from there) is skipped. If false
is returned, the sub tree is processed normally.
StepUpCallback
: The sole method of this callback is called when some children of a node were visited and
before the actual node is visited.
Modifier and Type | Method and Description |
---|---|
void |
walk(Node startingNode,
NodeCallback callback)
Walks through the tree starting from the given node and calls back on every node to the given callback
|
void walk(Node startingNode, NodeCallback callback)
startingNode
- the node where to start walkingcallback
- the callback to call on each node