public interface NodeHierarchicalVisitor
NodeHierarchicalVisitor
is used for traversing the structure of a Node
in a hierarchical fashion.
It uses a design pattern called Hierarchical Visitor.
This makes it possible to keep track of the current depth or skip a Node
s children or siblings.
Implement it in order to perform various operations on various Node
s in sequence.
Modifier and Type | Method and Description |
---|---|
boolean |
visitEnter(Node node)
Called by a concrete
Node implementation. |
boolean |
visitLeave(Node node)
Called by a concrete
Node implementation. |
boolean visitEnter(Node node)
Node
implementation.
It should happen soon after its accept(NodeHierarchicalVisitor)
method has been called, with this NodeHierarchicalVisitor
as its parameter argument.
If node
is null
, a NullPointerException
may be thrown. But no guarantees can be made.
If node
could not be traversed by this NodeHierarchicalVisitor
, a NodeTraversalException
may be thrown. But no guarantees can be made.
To visit node
s child Node
s, return true
, false
otherwise.
node
- the Node
to entertrue
if, and only if, node
s child Node
s should be visited, false
otherwiseNodeTraversalException
- thrown if, and only if, node
could not be traversed by this NodeHierarchicalVisitor
java.lang.NullPointerException
- thrown if, and only if, node
is null
boolean visitLeave(Node node)
Node
implementation.
It should happen just before its accept(NodeHierarchicalVisitor)
method returns. Actually, it should be the result returned by that method.
If node
is null
, a NullPointerException
may be thrown. But no guarantees can be made.
If node
could not be traversed by this NodeHierarchicalVisitor
, a NodeTraversalException
may be thrown. But no guarantees can be made.
To visit node
s sibling Node
s, return true
, false
otherwise.
node
- the Node
to leavetrue
if, and only if, node
s sibling Node
s should be visited, false
otherwiseNodeTraversalException
- thrown if, and only if, node
could not be traversed by this NodeHierarchicalVisitor
java.lang.NullPointerException
- thrown if, and only if, node
is null