Class QueryTreeWalker<T> (2.0.0)

public class QueryTreeWalker<T>

The walking of the query tree. This class takes care of visiting a tree resulting from parsing a query. As it traverses the tree it calls appropriate methods of the visitor, set at the construction time. The class uses a depth-first search, visiting all children of a node, before visiting the node. The visit is done by calling an appropriate method of the visitor. Typical code should match the following pattern:


 class MyVisitor implements QueryTreeVisitor {
   ...
 }
 class MyContext extends QueryTreeContext<MyContext> {
   ...
   @Override
   protected MyContext newChildContext() {
     return new MyContext();
   }
 }

 MyContext context = new MyContext();
 QueryTreeWalker<MyContext> walker = new QueryTreeWalker<MyContext>(new MyVisitor());
 Tree root = parser.query(queryStr);
 walker.walk(root, context);
 // retrieve whatever information you need from context
 

Inheritance

java.lang.Object > QueryTreeWalker<T>

Type Parameter

NameDescription
T

Static Methods

simplify(Tree tree)

public static Tree simplify(Tree tree)
Parameter
NameDescription
treeorg.antlr.runtime.tree.Tree
Returns
TypeDescription
org.antlr.runtime.tree.Tree

Constructors

QueryTreeWalker(QueryTreeVisitor<T> visitor)

public QueryTreeWalker(QueryTreeVisitor<T> visitor)

Creates a new query walker that calls the given visitor.

Parameter
NameDescription
visitorQueryTreeVisitor<T>

the visitor to be called by this walker

Methods

postBooleanExpression(T context)

protected void postBooleanExpression(T context)
Parameter
NameDescription
contextT

walk(Tree tree, T context)

public void walk(Tree tree, T context)
Parameters
NameDescription
treeorg.antlr.runtime.tree.Tree

the tree to be walked

contextT

the context in which the tree is walked

Exceptions
TypeDescription
QueryTreeException