T
- the context used by the visitorpublic class QueryTreeWalker<T extends QueryTreeContext<T>>
extends java.lang.Object
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
Constructor and Description |
---|
QueryTreeWalker(QueryTreeVisitor<T> visitor)
Creates a new query walker that calls the given
visitor . |
public QueryTreeWalker(QueryTreeVisitor<T> visitor)
visitor
.visitor
- the visitor to be called by this walkerpublic void walk(Tree tree, T context) throws QueryTreeException
tree
- the tree to be walkedcontext
- the context in which the tree is walkedQueryTreeException
public static Tree simplify(Tree tree)