Class 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 the Expression.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 the SymbolFinder() constructor), and/or it can be used to identify the symbols themselves (using the SymbolFinder(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 not null, 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 the symbols 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • hasSymbols

        private boolean hasSymbols
        A flag indicating whether the expression has any symbols.
      • symbols

        private java.util.Collection<ColumnName> symbols
        If not null, 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 the symbols collection.
        Parameters:
        symbols - An optional collection to receive the symbols found by this expression processor. This may be null if the SymbolFinder 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 interface ExpressionProcessor
        Parameters:
        e - the Expression 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 an Expression 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 interface ExpressionProcessor
        Parameters:
        e - the Expression node being left
        Returns:
        the Expression object to use for the node being left; either node if no changes are to be made, or a new Expression object if node should be replaced.