at.spardat.xma.mdl
Interface IAtomic

All Known Subinterfaces:
ISimpleWM, ISimpleWMClient
All Known Implementing Classes:
Atom, SimpleWM, SimpleWMClient

public interface IAtomic

Classes implementing IAtomic are the types used in XMA to represent atomic values both at the client and at the server side. To facilitate transport over the network, this type has a type (from Types) and a String encoded atomic value. The typed values which are held by this are string encoded. The encodings are as follows:

 TYPE          ENCODING
 ---------------------------------------------------------------------------------------
 T_BOOLEAN     "J" or "N"
 T_STRING      the string itself
 T_BCD         canonic string format of ABcd, see ABcd.toString(). Example: -12000.32
 T_DATE        canonic string format of ADate yyyyMMdd, see ADate.toString()
 T_TIMESTAMP   encoding as defined in TimeStampUtil.
 T_DOM         key of the domain value, see at.spardat.xma.datasource.ADomX.
 
An Atom may be created from and converted to the most JDK supplied types. The following table lists the conversions:
 TYPE          may be converted to, may be constructed from
 ---------------------------------------------------------------------------------------
 T_BOOLEAN     Boolean
 T_STRING      String
 T_BCD         Double, Integer
 T_DATE        java.util.Date
 T_TIMESTAMP   java.sql.Timestamp
 


Method Summary
 java.lang.String getEncodedValue()
          Returns the String encoded value of this.
 byte getType()
          Returns the type constant.
 boolean hasValue()
          Returns true if this Atom holds a value.
 boolean isTrue()
          Returns true if getType() equals T_BOOLEAN and the stored value equals TRUE.
 java.math.BigDecimal toBigDecimal()
          If the type of this is T_BCD, the numeric value is returned as a BigDecimal.
 byte toByte()
          Returns the value of this as byte.
 java.lang.Byte toBYTE()
          Returns the value of this as Byte or null if !
 java.util.Date toDate()
          Returns a newly constructed java.util.Date object representing the value of this.
 double toDouble()
          Extracts a double from this.
 java.lang.Double toDOUBLE()
          Returns the value of this as Double or null if !
 float toFloat()
          Extracts a float from this.
 java.lang.Float toFLOAT()
          Returns the value of this as Float or null if !
 int toInt()
          Returns the value of this as int.
 java.lang.Integer toINTEGER()
          Returns the value of this as Integer or null if !
 long toLong()
          Returns the value of this as long.
 java.lang.Long toLONG()
          Returns the value of this as Long or null if !
 short toShort()
          Returns the value of this as short.
 java.lang.Short toSHORT()
          Returns the value of this as Short or null if !
 java.lang.String toString()
          Returns a String representing the value of this.
 java.lang.String toString(at.spardat.enterprise.fmt.IFmt formatter)
          Maps this Atom to string representation using a IFmt object.
 

Method Detail

hasValue

public boolean hasValue()
Returns true if this Atom holds a value.

Returns:
true if this has a non empty value.

getType

public byte getType()
Returns the type constant.

Returns:
the type constant.

toString

public java.lang.String toString(at.spardat.enterprise.fmt.IFmt formatter)
Maps this Atom to string representation using a IFmt object. The provided formatter is only used if it is type compatible with the type of this Atom. Otherwise, or if formatter is null, the internal String encoding is returned.

Parameters:
formatter - the IFmt formatter. May be null.
Returns:
non null String.

toString

public java.lang.String toString()
Returns a String representing the value of this. Depending on the type of this, the following formats are returned:
 T_BOOLEAN     "J" or "N"
 T_STRING      the string itself
 T_BCD         -12000.32
 T_DATE        yyyyMMdd
               example: 20001231, the last day in the year 2000
 T_TIMESTAMP   yyyyMMdd HH:mm:ss.SSS z
               example: 20001231 23:59:59.999 CET denoting the last millisecond in the year 2000, central european time.
 T_DOM         key of the domain value
 
The empty string is returned if this does not store a value.

Returns:
the above defined encodings or the empty string if this is unvalued (!hasValue()).

toDouble

public double toDouble()
Extracts a double from this. Returns 0.0 if getType() is not equal to T_BCD or !hasValue().

Returns:
the double value of this
Throws:
java.lang.NumberFormatException - if this does not fit into a double.

toFloat

public float toFloat()
Extracts a float from this. Returns 0.0 if getType() is not equal to T_BCD or !hasValue().

Returns:
the float value of this
Throws:
java.lang.NumberFormatException - if this does not fit into a float.

toInt

public int toInt()
Returns the value of this as int. Requires that this is either empty or contains an integer T_BCD value. If !hasValue() or the type of this is not T_BCD, zero is returned.

Returns:
the contained integer
Throws:
java.lang.NumberFormatException - if this does not fit into an int

toLong

public long toLong()
Returns the value of this as long. Requires that this is either empty or contains an T_BCD value. If !hasValue() or the type of this is not T_BCD, zero is returned.

Returns:
the contained value as long
Throws:
java.lang.NumberFormatException - if this does not fit into an long

toByte

public byte toByte()
Returns the value of this as byte. Requires that this is either empty or contains an T_BCD value. If !hasValue() or the type of this is not T_BCD, zero is returned.

Returns:
the contained value as long
Throws:
java.lang.NumberFormatException - if this does not fit into an byte

toShort

public short toShort()
Returns the value of this as short. Requires that this is either empty or contains an T_BCD value. If !hasValue() or the type of this is not T_BCD, zero is returned.

Returns:
the contained value as long
Throws:
java.lang.NumberFormatException - if this does not fit into a short

toDate

public java.util.Date toDate()
Returns a newly constructed java.util.Date object representing the value of this.

Returns:
null if the type is not equal to T_DATE or T_TIMESTAMP or !hasValue().

isTrue

public boolean isTrue()
Returns true if getType() equals T_BOOLEAN and the stored value equals TRUE. If there is no value stored or the stored value is not TRUE, false is returned.

Returns:
boolean indicating the value in this.

toBigDecimal

public java.math.BigDecimal toBigDecimal()
If the type of this is T_BCD, the numeric value is returned as a BigDecimal. If the type is another than T_BCD or !hasValue() is true, then null is returned.


getEncodedValue

public java.lang.String getEncodedValue()
Returns the String encoded value of this. Returns the empty String if !hasValue().


toBYTE

public java.lang.Byte toBYTE()
Returns the value of this as Byte or null if !hasValue() or the type is not T_BCD.

Throws:
java.lang.RuntimeException - if the value stored in this does not fit into a Byte.

toSHORT

public java.lang.Short toSHORT()
Returns the value of this as Short or null if !hasValue() or the type is not T_BCD.

Throws:
java.lang.RuntimeException - if the value stored in this does not fit into a Short.

toINTEGER

public java.lang.Integer toINTEGER()
Returns the value of this as Integer or null if !hasValue() or the type is not T_BCD.

Throws:
java.lang.RuntimeException - if the value stored in this does not fit into a Integer.

toLONG

public java.lang.Long toLONG()
Returns the value of this as Long or null if !hasValue() or the type is not T_BCD.

Throws:
java.lang.RuntimeException - if the value stored in this does not fit into a Long.

toFLOAT

public java.lang.Float toFLOAT()
Returns the value of this as Float or null if !hasValue() or the type is not T_BCD.


toDOUBLE

public java.lang.Double toDOUBLE()
Returns the value of this as Double or null if !hasValue() or the type is not T_BCD.