Interface TreeVisitor
-
- All Known Subinterfaces:
ExprTreeVisitor
- All Known Implementing Classes:
ExprTreeVisitorDefault
,JavaExprPrinter.Visitor
,MapBasedPrinter.ExprTreeVisitor
,NodeTransformer
,SmtExprPrinter.Visitor
,SmtTextBuilder
,TextExprPrinter.Visitor
public interface TreeVisitor
TheTreeVisitor
interface is to be implemented by all visitor objects that are applied to hierarchical (tree-like or forest-like) structures to collect information or to perform transformations. The interface describes the protocol for traversal of hierarchical structures. The general idea is:Traversal of hierarchical structures starts with calling the
onBegin
method and ends with calling theonEnd
methods. Likewise, traversal of any non-terminal node of the structure starts with calling a method with theBegin
suffix and ends with calling a method with theEnd
suffix.Steps taken in the traversal process depend on the current status of the visitor (see
TreeVisitor.Status
). There are three possible statuses:OK
- continue traversal;SKIP
- skip child nodes;ABORT
- stop traversal.
The status is checked after calling any visitor method. Once
ABORT
is set, all traversal methods return. If after a call to a method having theBegin
suffix, theSKIP
status is set (notABORT
and notOK
), nested elements of the visited node (child nodes or subtrees) are not traversed and a corresponding terminating method (that has theEnd
suffix) is called.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
TreeVisitor.Status
TheTreeVisitor.Status
enumeration describes possible statuses of the visitor.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TreeVisitor.Status
getStatus()
Returns the current status of the visitor.void
onBegin()
Notifies that processing of a hierarchical structure has been started.void
onEnd()
Notifies that processing of a hierarchical structure has been finished.
-
-
-
Method Detail
-
getStatus
TreeVisitor.Status getStatus()
Returns the current status of the visitor. The status guides further actions of the walker.- Returns:
- Current visitor status.
-
onBegin
void onBegin()
Notifies that processing of a hierarchical structure has been started.
-
onEnd
void onEnd()
Notifies that processing of a hierarchical structure has been finished.
-
-