This visitor replaces a ValueNode with a node representing a
constant value, if the ValueNode is known to always evaluate to the
same value. It may for instance replace a sub-tree representing 1=1
with a constant TRUE.
The actual evaluation of the ValueNodes is performed by invoking
ValueNode#evaluateConstantExpressions() on every ValueNode
in the query tree.
In contrast to most other visitors, this visitor walks the tree bottom-up.
Top-down processing of the tree would only evaluate constant expressions
at the leaf level, so for instance (1=1)=(1=2) would only be
simplified to TRUE=FALSE. With bottom-up processing, the top-level
= node will be processed after the leaves, and it sees the intermediate
tree TRUE=FALSE which it is able to transform into the even simpler
tree FALSE.
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: false, since the entire tree should be visitedthe node to process node)Implements org. Method that is called to indicate whether we should skip all nodes below this node for traversal. |
| public boolean | Returns: false, since the entire tree should be visitedImplements org. Method that is called to see if query tree traversal should be stopped before visiting all nodes. |
| public Visitable | visit(Visitable
the node to process node)Implements org. Visit the node and call |
| public boolean | Returns: true, since the tree should be walked bottom-upthe top node of a sub-tree about to be visited node)Implements org. Method that is called to see if |
| ConstantExpressionVisitor | back to summary |
|---|---|
| pack-priv ConstantExpressionVisitor() | |
| skipChildren | back to summary |
|---|---|
| public boolean skipChildren(Visitable node) Implements org. Doc from org. 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.
| |
| stopTraversal | back to summary |
|---|---|
| public boolean stopTraversal() Implements org. Doc from org. 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.
| |
| visit | back to summary |
|---|---|
| public Visitable visit(Visitable node) throws StandardException Implements org. Visit the node and call
| |
| visitChildrenFirst | back to summary |
|---|---|
| public boolean visitChildrenFirst(Visitable node) Implements org. Doc from org. Method that is called to see if
| |