Class Constant

  • All Implemented Interfaces:
    Cloneable, Comparable<Constant>, LanguageObject, Expression

    public class Constant
    extends Object
    implements Expression, Comparable<Constant>
    This class represents a literal value in a SQL string. The Constant object has a value and a type for that value. In many cases, the type can be derived from the type of the value, but that is not true if the value is null. In that case, the type is unknown and is set to the null type until the type is resolved at a later point.
    • Constructor Detail

      • Constant

        public Constant​(Object value,
                        Class<?> type)
        Construct a typed constant. The specified value is not verified to be a value of the specified type. If this is not true, stuff probably won't work later on.
        Parameters:
        value - Constant value, may be null
        type - Type for the constant, should never be null
      • Constant

        public Constant​(Object value)
        Construct a constant with a value, which may be null. The data type is determined automatically from the type of the value.
        Parameters:
        value - Constant value, may be null
    • Method Detail

      • getType

        public Class<?> getType()
        Get type of constant, if known
        Specified by:
        getType in interface Expression
        Returns:
        Java class name of type
      • setType

        public void setType​(Class<?> type)
        TODO: remove me when a null type is supported
        Parameters:
        type -
      • getValue

        public Object getValue()
        Get value of constant
        Returns:
        Constant value
      • isNull

        public boolean isNull()
        Return true if the constant is null.
        Returns:
        True if value is null
      • setMultiValued

        public void setMultiValued​(List<?> value)
      • isMultiValued

        public boolean isMultiValued()
      • 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
      • equals

        public boolean equals​(Object obj)
        Compare this constant to another constant for equality.
        Overrides:
        equals in class Object
        Parameters:
        obj - Other object
        Returns:
        True if constants are equal
      • hashCode

        public int hashCode()
        Define hash code to be that of the underlying object to make it stable.
        Overrides:
        hashCode in class Object
        Returns:
        Hash code, based on value
      • clone

        public Object clone()
        Return a shallow copy of this object - value is NOT cloned!
        Specified by:
        clone in interface LanguageObject
        Overrides:
        clone in class Object
        Returns:
        Shallow copy of object
      • toString

        public String toString()
        Return a String representation of this object using SQLStringVisitor.
        Overrides:
        toString in class Object
        Returns:
        String representation using SQLStringVisitor
      • isBindEligible

        public boolean isBindEligible()
      • setBindEligible

        public void setBindEligible​(boolean bindEligible)