Stay organized with collections
Save and categorize content based on your preferences.
publicclassQueryTreeWalker<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:
classMyVisitorimplementsQueryTreeVisitor{...}classMyContextextendsQueryTreeContext<MyContext>{...@OverrideprotectedMyContextnewChildContext(){returnnewMyContext();}}MyContextcontext=newMyContext();QueryTreeWalker<MyContext>walker=newQueryTreeWalker<MyContext>(newMyVisitor());Treeroot=parser.query(queryStr);walker.walk(root,context);// retrieve whatever information you need from context
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003eQueryTreeWalker<T>\u003c/code\u003e traverses a parsed query tree using a depth-first search, visiting child nodes before their parent.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eQueryTreeVisitor\u003c/code\u003e instance, passed during construction, handles the visit actions on each node.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ewalk(Tree tree, T context)\u003c/code\u003e method initiates the tree traversal with a given root \u003ccode\u003etree\u003c/code\u003e and a \u003ccode\u003econtext\u003c/code\u003e object of type \u003ccode\u003eT\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides a \u003ccode\u003esimplify(Tree tree)\u003c/code\u003e static method to simplify a tree, returning an \u003ccode\u003eorg.antlr.runtime.tree.Tree\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epostBooleanExpression(T context)\u003c/code\u003e protected method is invoked after visiting a boolean expression within the tree, using a context parameter of type \u003ccode\u003eT\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Class QueryTreeWalker<T> (2.0.0)\n\n public class QueryTreeWalker\u003cT\u003e\n\nThe walking of the query tree. This class takes care of visiting\na tree resulting from parsing a query. As it traverses the tree\nit calls appropriate methods of the visitor, set at the construction\ntime. The class uses a depth-first search, visiting all children\nof a node, before visiting the node. The visit is done by calling\nan appropriate method of the visitor. Typical code should match\nthe following pattern: \n\n\n class MyVisitor implements QueryTreeVisitor {\n ...\n }\n class MyContext extends QueryTreeContext\u003cMyContext\u003e {\n ...\n @Override\n protected MyContext newChildContext() {\n return new MyContext();\n }\n }\n\n MyContext context = new MyContext();\n QueryTreeWalker\u003cMyContext\u003e walker = new QueryTreeWalker\u003cMyContext\u003e(new MyVisitor());\n Tree root = parser.query(queryStr);\n walker.walk(root, context);\n // retrieve whatever information you need from context\n \nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e QueryTreeWalker\\\u003cT\\\u003e \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### simplify(Tree tree)\n\n public static Tree simplify(Tree tree)\n\nConstructors\n------------\n\n### QueryTreeWalker(QueryTreeVisitor\\\u003cT\\\u003e visitor)\n\n public QueryTreeWalker(QueryTreeVisitor\u003cT\u003e visitor)\n\nCreates a new query walker that calls the given `visitor`.\n\nMethods\n-------\n\n### postBooleanExpression(T context)\n\n protected void postBooleanExpression(T context)\n\n### walk(Tree tree, T context)\n\n public void walk(Tree tree, T context)"]]