com.metamatrix.query.sql.symbol
Class Constant

java.lang.Object
  extended by com.metamatrix.query.sql.symbol.Constant
All Implemented Interfaces:
LanguageObject, Expression, java.io.Serializable, java.lang.Cloneable

public class Constant
extends java.lang.Object
implements Expression

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.

See Also:
Serialized Form

Constructor Summary
Constant(java.lang.Object value)
          Construct a constant with a value, which may be null.
Constant(java.lang.Object value, java.lang.Class type)
          Construct a typed constant.
 
Method Summary
 void acceptVisitor(LanguageVisitor visitor)
          Method for accepting a visitor.
 java.lang.Object clone()
          Return a shallow copy of this object - value is NOT cloned!
 boolean equals(java.lang.Object obj)
          Compare this constant to another constant for equality.
 java.lang.Class getType()
          Get type of constant, if known
 java.lang.Object getValue()
          Get value of constant
 int hashCode()
          Define hash code to be that of the underlying object to make it stable.
 boolean isMultiValued()
           
 boolean isNull()
          Return true if the constant is null.
 boolean isResolved()
          Return true if expression has been fully resolved.
 void setMultiValued(java.util.List<?> value)
           
 java.lang.String toString()
          Return a String representation of this object using SQLStringVisitor.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Constant

public Constant(java.lang.Object value,
                java.lang.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(java.lang.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 java.lang.Class getType()
Get type of constant, if known

Specified by:
getType in interface Expression
Returns:
Java class name of type

getValue

public java.lang.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

isResolved

public boolean isResolved()
Return true if expression has been fully resolved. Typically the QueryResolver component will handle resolution of an expression.

Specified by:
isResolved in interface Expression
Returns:
True if resolved

setMultiValued

public void setMultiValued(java.util.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(java.lang.Object obj)
Compare this constant to another constant for equality.

Overrides:
equals in class java.lang.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 java.lang.Object
Returns:
Hash code, based on value

clone

public java.lang.Object clone()
Return a shallow copy of this object - value is NOT cloned!

Specified by:
clone in interface LanguageObject
Overrides:
clone in class java.lang.Object
Returns:
Shallow copy of object

toString

public java.lang.String toString()
Return a String representation of this object using SQLStringVisitor.

Overrides:
toString in class java.lang.Object
Returns:
String representation using SQLStringVisitor


Copyright © 2009. All Rights Reserved.