SMILA (incubation) API documentation

org.eclipse.smila.datamodel.record.impl
Class LiteralImpl

java.lang.Object
  extended by org.eclipse.smila.datamodel.record.impl.AnnotatableImpl
      extended by org.eclipse.smila.datamodel.record.impl.AttributeValueImpl
          extended by org.eclipse.smila.datamodel.record.impl.LiteralImpl
All Implemented Interfaces:
java.io.Serializable, Annotatable, AttributeValue, Literal

public class LiteralImpl
extends AttributeValueImpl
implements Literal

Default implementation of SMILA Literals.

Author:
jschumacher
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.smila.datamodel.record.Literal
Literal.DataType
 
Constructor Summary
LiteralImpl()
          create new empty literal.
LiteralImpl(java.lang.Object value)
          create new literal from value.
 
Method Summary
static LiteralImpl ensureImpl(Literal someLiteral)
          convert value to LiteralImpl if it is of another implementation.
 boolean equals(java.lang.Object obj)
           Literals are equals when their values and datatypes are equal.
 java.lang.Boolean getBoolValue()
          get the boolean value of the literal if this is a boolean literal.
 Literal.DataType getDataType()
          data type of literal value.
 java.util.Date getDateTimeValue()
          get the datetime value of the literal if this is a datetime literal.
 java.util.Date getDateValue()
          get the date value of the literal if this is a date literal.
 java.lang.Double getFpValue()
          get the floating point value of the literal if this is a floating point literal.
 java.lang.Long getIntValue()
          get the integer value of the literal if this is an integer literal.
 java.lang.String getStringValue()
          get the value object as a string.
 java.util.Date getTimeValue()
          get the time value of the literal if this is a time literal.
 java.lang.Object getValue()
          get the value object.
 int hashCode()
          
 void setBoolValue(java.lang.Boolean value)
          set a boolean value for this literal.
 void setDateTimeValue(java.util.Date value)
          set a datetime value for this literal.
 void setDateValue(java.util.Date value)
          set a date value for this literal.
 void setFpValue(java.lang.Double value)
          set a floating point value for this literal.
 void setIntValue(java.lang.Integer value)
          set an integer value for this literal. just a convenience method that converts to java.lang.Long
 void setIntValue(java.lang.Long value)
          set an integer value for this literal.
 void setStringValue(java.lang.String value)
          set a string value for this literal.
 void setTimeValue(java.util.Date value)
          set a time value for this literal.
 void setValue(java.lang.Object value)
          set a new value object for this literal.
 java.lang.String toString()
          
 
Methods inherited from class org.eclipse.smila.datamodel.record.impl.AttributeValueImpl
getSemanticType, setSemanticType
 
Methods inherited from class org.eclipse.smila.datamodel.record.impl.AnnotatableImpl
addAnnotation, annotationsSize, getAnnotation, getAnnotationNames, getAnnotations, hasAnnotation, hasAnnotations, removeAnnotations, removeAnnotations, setAnnotation, setAnnotations
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.smila.datamodel.record.AttributeValue
getSemanticType, setSemanticType
 
Methods inherited from interface org.eclipse.smila.datamodel.record.Annotatable
addAnnotation, annotationsSize, getAnnotation, getAnnotationNames, getAnnotations, hasAnnotation, hasAnnotations, removeAnnotations, removeAnnotations, setAnnotation, setAnnotations
 

Constructor Detail

LiteralImpl

public LiteralImpl()
create new empty literal.


LiteralImpl

public LiteralImpl(java.lang.Object value)
            throws InvalidTypeException
create new literal from value.

Parameters:
value - value object
Throws:
InvalidTypeException - if value object cannot be used by LiteralImpl
Method Detail

ensureImpl

public static LiteralImpl ensureImpl(Literal someLiteral)
convert value to LiteralImpl if it is of another implementation.

Parameters:
someLiteral - literal in any implementation
Returns:
same literal in LiteralImpl.

getDataType

public Literal.DataType getDataType()
data type of literal value. See DataType enum in this interface for values.

Specified by:
getDataType in interface Literal
Returns:
data type object.
See Also:
Literal.getDataType()

getBoolValue

public java.lang.Boolean getBoolValue()
get the boolean value of the literal if this is a boolean literal.

Specified by:
getBoolValue in interface Literal
Returns:
the value Boolean object if this literal is a boolean literal, else null
See Also:
Literal.getBoolValue()

getDateTimeValue

public java.util.Date getDateTimeValue()
get the datetime value of the literal if this is a datetime literal.

Specified by:
getDateTimeValue in interface Literal
Returns:
the value Date object if this literal is a datetime literal, else null
See Also:
Literal.getDateTimeValue()

getDateValue

public java.util.Date getDateValue()
get the date value of the literal if this is a date literal.

Specified by:
getDateValue in interface Literal
Returns:
the value Date object if this literal is a date literal, else null
See Also:
Literal.getDateValue()

getFpValue

public java.lang.Double getFpValue()
get the floating point value of the literal if this is a floating point literal.

Specified by:
getFpValue in interface Literal
Returns:
the value Double object if this literal is a floating point literal, else null
See Also:
Literal.getFpValue()

getIntValue

public java.lang.Long getIntValue()
get the integer value of the literal if this is an integer literal.

Specified by:
getIntValue in interface Literal
Returns:
the value Long object if this literal is an integer literal, else null
See Also:
Literal.getIntValue()

getStringValue

public java.lang.String getStringValue()
get the value object as a string. If the actual object is instance of string already, it is returned immediately. Else, toString() is used on the object to create a string representation.

Specified by:
getStringValue in interface Literal
Returns:
the string value object.
See Also:
Literal.getStringValue()

getTimeValue

public java.util.Date getTimeValue()
get the time value of the literal if this is a time literal.

Specified by:
getTimeValue in interface Literal
Returns:
the value Date object if this literal is a time literal, else null
See Also:
Literal.getTimeValue()

getValue

public java.lang.Object getValue()
get the value object.

Specified by:
getValue in interface Literal
Returns:
the value object.
See Also:
Literal.getValue()

setBoolValue

public void setBoolValue(java.lang.Boolean value)
set a boolean value for this literal.

Specified by:
setBoolValue in interface Literal
Parameters:
value - new boolean value
See Also:
Literal.setBoolValue(java.lang.Boolean)

setDateTimeValue

public void setDateTimeValue(java.util.Date value)
set a datetime value for this literal.

Specified by:
setDateTimeValue in interface Literal
Parameters:
value - new datetime value
See Also:
Literal.setDateTimeValue(java.util.Date)

setDateValue

public void setDateValue(java.util.Date value)
set a date value for this literal.

Specified by:
setDateValue in interface Literal
Parameters:
value - new date value
See Also:
Literal.setDateValue(java.util.Date)

setFpValue

public void setFpValue(java.lang.Double value)
set a floating point value for this literal.

Specified by:
setFpValue in interface Literal
Parameters:
value - new floating point value.
See Also:
Literal.setFpValue(java.lang.Double)

setIntValue

public void setIntValue(java.lang.Long value)
set an integer value for this literal.

Specified by:
setIntValue in interface Literal
Parameters:
value - new integer value.
See Also:
Literal.setIntValue(java.lang.Long)

setIntValue

public void setIntValue(java.lang.Integer value)
set an integer value for this literal. just a convenience method that converts to java.lang.Long

Specified by:
setIntValue in interface Literal
Parameters:
value - new integer value.
See Also:
Literal.setIntValue(java.lang.Integer)

setStringValue

public void setStringValue(java.lang.String value)
set a string value for this literal.

Specified by:
setStringValue in interface Literal
Parameters:
value - new string value.
See Also:
Literal.setStringValue(java.lang.String)

setTimeValue

public void setTimeValue(java.util.Date value)
set a time value for this literal.

Specified by:
setTimeValue in interface Literal
Parameters:
value - new date/time/datetime value
See Also:
Literal.setTimeValue(java.util.Date)

setValue

public void setValue(java.lang.Object value)
              throws InvalidTypeException
set a new value object for this literal. An exception is throws if the object is not an instance of one of the supported classes or cannot be converted to one in a useful way. Apart from the supported classes this implementation also automatically converts Floats and BigDecimals to Doubles and all other subclasses of Number to Long.

Specified by:
setValue in interface Literal
Parameters:
value - new value object.
Throws:
InvalidTypeException - illegal class of value object.
See Also:
Literal.setValue(java.lang.Object)

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object obj)
Literals are equals when their values and datatypes are equal.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

SMILA (incubation) API documentation