Class Select

  • All Implemented Interfaces:
    Cloneable, LanguageObject

    public class Select
    extends Object
    implements LanguageObject
    This class represents the SELECT clause of a query, which defines what elements or expressions are returned from the query.
    • Constructor Detail

      • Select

        public Select()
        Constructs a default instance of this class.
      • Select

        public Select​(List<? extends Expression> symbols)
        Constructs an instance of this class from an ordered set of symbols.
        Parameters:
        symbols - The ordered list of symbols
    • Method Detail

      • getCount

        public int getCount()
        Returns the number of symbols in select.
        Returns:
        Get count of number of symbols in select
      • isStar

        public boolean isStar()
        Checks for a Select * clause
        Returns:
        True if Select * is used
      • getSymbols

        public List<Expression> getSymbols()
        Returns an ordered list of the symbols in the select.
      • setSymbols

        public void setSymbols​(Collection<? extends Expression> symbols)
        Sets an ordered list of the symbols in the select. Reuses the current symbol list.
        Parameters:
        symbols - list of SelectSymbol in SELECT
      • getSymbol

        public Expression getSymbol​(int index)
        Returns the select symbol at the specified index.
        Parameters:
        index - Index to get
        Returns:
        The variable identifier at the index
      • addSymbol

        public void addSymbol​(Expression symbol)
        Parameters:
        symbol - New symbol
      • clearSymbols

        public void clearSymbols()
        Remove all current symbols
      • containsSymbol

        public boolean containsSymbol​(Expression symbol)
        Checks if a symbol is in the Select.
        Parameters:
        symbol - Symbol to check for
        Returns:
        True if the Select contains the symbol
      • setDistinct

        public void setDistinct​(boolean isDistinct)
        Set whether select is distinct.
        Parameters:
        isDistinct - True if SELECT is distinct
      • isDistinct

        public boolean isDistinct()
        Checks whether the select is distinct
        Returns:
        True if select is distinct
      • acceptVisitor

        public void acceptVisitor​(LanguageVisitor visitor)
        Description copied from interface: LanguageObject
        Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.
        Specified by:
        acceptVisitor in interface LanguageObject
        Parameters:
        visitor - Visitor being used
      • getProjectedSymbols

        public List<Expression> getProjectedSymbols()
        Get the ordered list of all elements returned by this select. These elements may be ElementSymbols or ExpressionSymbols but in all cases each represents a single column.
        Returns:
        Ordered list of SingleElementSymbol
      • equals

        public boolean equals​(Object obj)
        Compare two Selects for equality. Order is important in the select (for determining the order of the returned columns), so this is a compare with order, not just a set comparison.
        Overrides:
        equals in class Object
        Parameters:
        obj - Other object
        Returns:
        True if equal
      • hashCode

        public int hashCode()
        Get hashcode for Select. WARNING: The hash code relies on the variables in the select, so changing the variables will change the hash code, causing a select to be lost in a hash structure. Do not hash a Select if you plan to change it.
        Overrides:
        hashCode in class Object
        Returns:
        Hash code
      • toString

        public String toString()
        Returns a string representation of an instance of this class.
        Overrides:
        toString in class Object
        Returns:
        String representation of object