Interface TreeVisitor

  • All Known Subinterfaces:
    ExprTreeVisitor
    All Known Implementing Classes:
    ExprTreeVisitorDefault, JavaExprPrinter.Visitor, MapBasedPrinter.ExprTreeVisitor, NodeTransformer, SmtExprPrinter.Visitor, SmtTextBuilder, TextExprPrinter.Visitor

    public interface TreeVisitor
    The TreeVisitor 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 the onEnd methods. Likewise, traversal of any non-terminal node of the structure starts with calling a method with the Begin suffix and ends with calling a method with the End suffix.

    Steps taken in the traversal process depend on the current status of the visitor (see TreeVisitor.Status). There are three possible statuses:

    1. OK - continue traversal;
    2. SKIP - skip child nodes;
    3. 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 the Begin suffix, the SKIP status is set (not ABORT and not OK), nested elements of the visited node (child nodes or subtrees) are not traversed and a corresponding terminating method (that has the End suffix) is called.

    • 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.