Package edu.caltech.nanodb.expressions
Class Expression.SymbolFinder
- java.lang.Object
-
- edu.caltech.nanodb.expressions.Expression.SymbolFinder
-
- All Implemented Interfaces:
ExpressionProcessor
- Enclosing class:
- Expression
private static class Expression.SymbolFinder extends java.lang.Object implements ExpressionProcessor
This
ExpressionProcessor
implementation traverses an expression and finds all symbols that appear within the expression. It is used by theExpression.getAllSymbols(Collection)
method. It has two major modes of operation. First, it can be used to identify whether or not an expression has symbols (using theSymbolFinder()
constructor), and/or it can be used to identify the symbols themselves (using theSymbolFinder(Collection)
constructor).This symbol-finder ignores two important situations: First, it ignores wildcard expressions, even
tablename.*
wildcards. Second, it ignores subqueries.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
hasSymbols
A flag indicating whether the expression has any symbols.private java.util.Collection<ColumnName>
symbols
If notnull
, this is the collection of symbols that have been found in the expression.
-
Constructor Summary
Constructors Modifier Constructor Description private
SymbolFinder()
Construct a symbol-finder that only identifies whether an expression has symbols or not, but does not collect the symbols themselves.private
SymbolFinder(java.util.Collection<ColumnName> symbols)
Construct a symbol-finder that can identify whether an expression has symbols or not, as well as optionally collecting the symbols themselves into thesymbols
collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enter(Expression e)
This method is called when expression-traversal is entering a particular node in the expression tree.Expression
leave(Expression e)
This method is called when expression-traversal is leaving a particular node in the expression tree.
-
-
-
Field Detail
-
hasSymbols
private boolean hasSymbols
A flag indicating whether the expression has any symbols.
-
symbols
private java.util.Collection<ColumnName> symbols
If notnull
, this is the collection of symbols that have been found in the expression.
-
-
Constructor Detail
-
SymbolFinder
private SymbolFinder(java.util.Collection<ColumnName> symbols)
Construct a symbol-finder that can identify whether an expression has symbols or not, as well as optionally collecting the symbols themselves into thesymbols
collection.- Parameters:
symbols
- An optional collection to receive the symbols found by this expression processor. This may benull
if theSymbolFinder
is only being used to identify whether an expression includes symbols.
-
SymbolFinder
private SymbolFinder()
Construct a symbol-finder that only identifies whether an expression has symbols or not, but does not collect the symbols themselves.
-
-
Method Detail
-
enter
public void enter(Expression e)
Description copied from interface:ExpressionProcessor
This method is called when expression-traversal is entering a particular node in the expression tree. It is not possible to replace a node when entering it, because this would unnecessarily complicate the semantics of expression-tree traversal.- Specified by:
enter
in interfaceExpressionProcessor
- Parameters:
e
- theExpression
node being entered
-
leave
public Expression leave(Expression e)
Description copied from interface:ExpressionProcessor
This method is called when expression-traversal is leaving a particular node in the expression tree. To facilitate mutation of expression trees, this method must return anExpression
object: If the expression processor wants to replace the node being left with a different node, this method can return the replacement node; otherwise, the method should return the passed-in node.- Specified by:
leave
in interfaceExpressionProcessor
- Parameters:
e
- theExpression
node being left- Returns:
- the
Expression
object to use for the node being left; eithernode
if no changes are to be made, or a newExpression
object ifnode
should be replaced.
-
-