Top Description Methods
org.apache.derby.iapi.sql.compile

public Interface Visitor

Known Direct Subinterfaces
org.apache.derby.iapi.sql.compile.ASTVisitor
Known Direct Implementers
org.apache.derby.impl.sql.compile.BaseTableNumbersVisitor, org.apache.derby.impl.sql.compile.CollectNodesVisitor, org.apache.derby.impl.sql.compile.ConditionalNode.ReplaceCaseOperandVisitor, org.apache.derby.impl.sql.compile.ConstantExpressionVisitor, org.apache.derby.impl.sql.compile.OffsetOrderVisitor, org.apache.derby.impl.sql.compile.HasCorrelatedCRsVisitor, org.apache.derby.impl.sql.compile.HasNodeVisitor, org.apache.derby.impl.sql.compile.HasVariantValueNodeVisitor, org.apache.derby.impl.sql.compile.ReferencedTablesVisitor, org.apache.derby.impl.sql.compile.RemapCRsVisitor, org.apache.derby.impl.sql.compile.ReplaceAggregatesWithCRVisitor, org.apache.derby.impl.sql.compile.ReplaceNodeVisitor, org.apache.derby.impl.sql.compile.ReplaceWindowFuncCallsWithCRVisitor, org.apache.derby.impl.sql.compile.SubstituteExpressionVisitor, org.apache.derby.impl.sql.compile.VerifyAggregateExpressionsVisitor, org.apache.derby.impl.sql.compile.VTIDeferModPolicy
Imports
org.apache.derby.shared.common.error.StandardException

A visitor is an object that traverses the querytree and performs some action.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true/false
skipChildren
(Visitable
the node to process
node
)

Method that is called to indicate whether we should skip all nodes below this node for traversal.

public boolean

Returns:

true/false
stopTraversal
()

Method that is called to see if query tree traversal should be stopped before visiting all nodes.

public Visitable

Returns:

a query tree node. Often times this is the same node that was passed in, but Visitors that replace nodes with other nodes will use this to return the new replacement node.
visit
(Visitable
the node to process
node
)

This is the default visit operation on a QueryTreeNode.

public boolean

Returns:

true if node's children should be visited before node, false otherwise
visitChildrenFirst
(Visitable
the top node of a sub-tree about to be visited
node
)

Method that is called to see if visit() should be called on the children of node before it is called on node itself.

Method Detail

skipChildrenback to summary
public boolean skipChildren(Visitable node) throws StandardException

Method that is called to indicate whether we should skip all nodes below this node for traversal. Useful if we want to effectively ignore/prune all branches under a particular node.

Differs from stopTraversal() in that it only affects subtrees, rather than the entire traversal.

Parameters
node:Visitable

the node to process

Returns:boolean

true/false

stopTraversalback to summary
public boolean stopTraversal()

Method that is called to see if query tree traversal should be stopped before visiting all nodes. Useful for short circuiting traversal if we already know we are done.

Returns:boolean

true/false

visitback to summary
public Visitable visit(Visitable node) throws StandardException

This is the default visit operation on a QueryTreeNode. It just returns the node. This will typically suffice as the default visit operation for most visitors unless the visitor needs to count the number of nodes visited or something like that.

Visitors will overload this method by implementing a version with a signature that matches a specific type of node. For example, if I want to do something special with aggregate nodes, then that Visitor will implement a visit(AggregateNode node) method which does the aggregate specific processing.

Parameters
node:Visitable

the node to process

Returns:Visitable

a query tree node. Often times this is the same node that was passed in, but Visitors that replace nodes with other nodes will use this to return the new replacement node.

Exceptions
StandardException:
may be throw an error as needed by the visitor (i.e. may be a normal error if a particular node is found, e.g. if checking a group by, we don't expect to find any ColumnReferences that aren't under an AggregateNode -- the easiest thing to do is just throw an error when we find the questionable node).
visitChildrenFirstback to summary
public boolean visitChildrenFirst(Visitable node)

Method that is called to see if visit() should be called on the children of node before it is called on node itself. If this method always returns true, the visitor will walk the tree bottom-up. If it always returns false, the tree is visited top-down.

Parameters
node:Visitable

the top node of a sub-tree about to be visited

Returns:boolean

true if node's children should be visited before node, false otherwise