Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

public Class CollectNodesVisitor<T extends Visitable>

extends Object
implements Visitor
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.compile.Visitor
Imports
java.util.ArrayList, .List, org.apache.derby.iapi.sql.compile.Visitable, .Visitor

Collect all nodes of the designated type to be returned in a list.

Can find any type of node -- the class or class name of the target node is passed in as a constructor parameter.

Field Summary

Modifier and TypeField and Description
private final Class<T>
private final List<T>
private final Class<? extends Visitable>

Constructor Summary

AccessConstructor and Description
public
CollectNodesVisitor(Class<T>
the class of the node that we are looking for.
nodeClass
)

Construct a visitor

public
CollectNodesVisitor(Class<T>
the class of the node that we are looking for.
nodeClass
,
Class<? extends Visitable>
do not go below this node when searching for nodeClass.
skipOverClass
)

Construct a visitor

Method Summary

Modifier and TypeMethod and Description
public List<T>
getList()

Return the list of matching nodes.

public boolean

Returns:

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

Implements org.apache.derby.iapi.sql.compile.Visitor.skipChildren.

Don't visit children under the skipOverClass node, if it isn't null.

public boolean
stopTraversal()

Implements org.apache.derby.iapi.sql.compile.Visitor.stopTraversal.

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

public Visitable

Returns:

me
visit
(Visitable
the node to process
node
)

Implements org.apache.derby.iapi.sql.compile.Visitor.visit.

If we have found the target node, we are done.

public boolean
visitChildrenFirst(Visitable
the top node of a sub-tree about to be visited
node
)

Implements org.apache.derby.iapi.sql.compile.Visitor.visitChildrenFirst.

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nodeClassback to summary
private final Class<T> nodeClass
nodeListback to summary
private final List<T> nodeList
skipOverClassback to summary
private final Class<? extends Visitable> skipOverClass

Constructor Detail

CollectNodesVisitorback to summary
public CollectNodesVisitor(Class<T> nodeClass)

Construct a visitor

Parameters
nodeClass:Class<T>

the class of the node that we are looking for.

CollectNodesVisitorback to summary
public CollectNodesVisitor(Class<T> nodeClass, Class<? extends Visitable> skipOverClass)

Construct a visitor

Parameters
nodeClass:Class<T>

the class of the node that we are looking for.

skipOverClass:Class<? extends Visitable>

do not go below this node when searching for nodeClass.

Method Detail

getListback to summary
public List<T> getList()

Return the list of matching nodes. The returned list may be empty, if there are no matching nodes. It is never null.

skipChildrenback to summary
public boolean skipChildren(Visitable node)

Implements org.apache.derby.iapi.sql.compile.Visitor.skipChildren.

Don't visit children under the skipOverClass node, if it isn't null.

Parameters
node:Visitable

Doc from org.apache.derby.iapi.sql.compile.Visitor.skipChildren.

the node to process

Returns:boolean

true/false

stopTraversalback to summary
public boolean stopTraversal()

Implements org.apache.derby.iapi.sql.compile.Visitor.stopTraversal.

Doc from org.apache.derby.iapi.sql.compile.Visitor.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)

Implements org.apache.derby.iapi.sql.compile.Visitor.visit.

If we have found the target node, we are done.

Parameters
node:Visitable

the node to process

Returns:Visitable

me

visitChildrenFirstback to summary
public boolean visitChildrenFirst(Visitable node)

Implements org.apache.derby.iapi.sql.compile.Visitor.visitChildrenFirst.

Doc from org.apache.derby.iapi.sql.compile.Visitor.visitChildrenFirst.

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