org.apache.jdo.jdoql.tree
Class TreeWalker

java.lang.Object
  extended by org.apache.jdo.jdoql.tree.TreeWalker

public final class TreeWalker
extends java.lang.Object

An instance of this class is used to walk any query node. It provides a walk method which takes a node and a node visitor as arguments. It delegates to methods Node.arrive, Node.leave/code> and Node.walkNextChild. Node implementations are required to delegate these calls to corresponding methods of the supplied node visitor.

Author:
Michael Watzek

Constructor Summary
TreeWalker()
           
 
Method Summary
 java.lang.Object walk(Node node, NodeVisitor visitor)
          Walks the tree specified by the argument node implementing a depth first algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeWalker

public TreeWalker()
Method Detail

walk

public java.lang.Object walk(Node node,
                             NodeVisitor visitor)
Walks the tree specified by the argument node implementing a depth first algorithm. Executes the visitor instance callback arrive when starting to walk the argument node. Subsequently iterates that node's children and executes the visitor instance callback walkNextChild before the current child is walked. For the case that walkNextChild returns true, this tree walker walkes the next child. Otherwise, the next child and all remaining childs are not walked. In both cases, this tree walker executes the visitor instance callback leave indicating that the argument node and its children have been walked. The result of leave is returned. when starting to traverse a node.

Parameters:
node - the tree instance
visitor - the node visitor instance
Returns:
the object returned by the visitor instance callback leave


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.