Package org.teiid.query.sql.symbol
Class Constant
- java.lang.Object
-
- org.teiid.query.sql.symbol.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<Object>
COMPARATOR
static Constant
NULL_CONSTANT
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.Object
clone()
Return a shallow copy of this object - value is NOT cloned!int
compareTo(Constant o)
boolean
equals(Object obj)
Compare this constant to another constant for equality.Class<?>
getType()
Get type of constant, if knownObject
getValue()
Get value of constantint
hashCode()
Define hash code to be that of the underlying object to make it stable.boolean
isBindEligible()
boolean
isMultiValued()
boolean
isNull()
Return true if the constant is null.void
setBindEligible(boolean bindEligible)
void
setMultiValued(List<?> value)
void
setType(Class<?> type)
TODO: remove me when a null type is supportedString
toString()
Return a String representation of this object using SQLStringVisitor.
-
-
-
Field Detail
-
NULL_CONSTANT
public static final Constant NULL_CONSTANT
-
COMPARATOR
public static final Comparator<Object> COMPARATOR
-
-
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 nulltype
- 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 interfaceExpression
- 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 interfaceLanguageObject
- Parameters:
visitor
- Visitor being used
-
equals
public boolean equals(Object obj)
Compare this constant to another constant for equality.
-
hashCode
public int hashCode()
Define hash code to be that of the underlying object to make it stable.
-
clone
public Object clone()
Return a shallow copy of this object - value is NOT cloned!- Specified by:
clone
in interfaceLanguageObject
- Overrides:
clone
in classObject
- Returns:
- Shallow copy of object
-
toString
public String toString()
Return a String representation of this object using SQLStringVisitor.
-
compareTo
public int compareTo(Constant o)
- Specified by:
compareTo
in interfaceComparable<Constant>
-
isBindEligible
public boolean isBindEligible()
-
setBindEligible
public void setBindEligible(boolean bindEligible)
-
-