- java.lang.Object
-
- com.rabbitmq.jms.parse.ParseTreeTraverser
-
public abstract class ParseTreeTraverser extends java.lang.ObjectThis traverser class encapsulates two methods of traversing a tree, calling aVisitorfor each subtree of aParseTree<Node>.Each subtree can be visited in ‘pre-order’ as well asO in ‘post-order’. ‘Pre-order’ visits each subtree before any of its child subtrees, and ‘post-order’ visits each subtree after visiting its child subtrees.
traverse(ParseTree, Visitor)visits each subtree twice: combining ‘pre-order’ and ‘post-order’ traversal in one pass.The
Visitorcontract returns abooleanflag from its visit methods which these traversal algorithms interpret as immediate abort: no further visits will be made after the first returns false. Each traversal method returnstrueif all the tree is visited, andfalseif any visit aborted.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <Node> booleantraverse(ParseTree<Node> tree, Visitor<Node> visitor)Visits each subtree in both ‘pre-order’ and ‘post-order’, in one pass.
-
-
-
Method Detail
-
traverse
public static <Node> boolean traverse(ParseTree<Node> tree, Visitor<Node> visitor)
Visits each subtree in both ‘pre-order’ and ‘post-order’, in one pass. Each subtree is visited before (by callingVisitor.visitBefore(Object, Object[])) and after (by callingVisitor.visitAfter(Object, Object[])) all of its child subtrees are visited.- Parameters:
tree- the tree all of whose subtrees are to be visitedvisitor- theVisitorwhoseVisitor.visitBefore(Object, Object[])andVisitor.visitAfter(Object, Object[])methods are passed each subtree’s node and child nodes.- Returns:
trueif the traversal completed,falseif it was aborted prematurely
-
-