|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectat.spardat.xma.mdl.Atom
This class is an immutable implementation of the IAtomic interface.
Sinces is immutable, this class provides a set of type specific constructors
and a set of static objects that may be used for empty Atom of the
various types.
| Field Summary | |
static Atom |
EMPTY_BCD
Empty Atom of type T_BCD |
static Atom |
EMPTY_BOOLEAN
Empty Atom of type T_BOOLEAN |
static Atom |
EMPTY_DATE
Empty Atom of type T_DATE |
static Atom |
EMPTY_DOM
Empty Atom of type T_DOM |
static Atom |
EMPTY_STRING
Empty Atom of type T_STRING |
static Atom |
EMPTY_TIMESTAMP
Empty Atom of type T_TIMESTAMP |
protected byte |
type_
One of the type codes in enterprise.util.Types. |
protected java.lang.String |
value_
A string encoded value of a particular type. |
| Constructor Summary | |
Atom()
Constructor for internal use. |
|
Atom(java.math.BigDecimal value)
Constructs an T_BCD Atom from an BigDecimal. |
|
Atom(boolean value)
Constructs a T_BOOLEAN Atom with the provided value. |
|
Atom(byte type,
java.util.Date date)
Constructs a T_DATE or T_TIMESTAMP Atom. |
|
Atom(double value)
Constructs a T_BCD Atom from a double. |
|
Atom(double value,
int numNK)
Constructs a T_BCD Atom. |
|
Atom(int value)
Constructs a T_BCD Atom from an int. |
|
Atom(long value)
Constructs a T_BCD Atom from a long. |
|
Atom(java.lang.String s)
Constructs an Atom with type T_STRING and the provided value. |
|
Atom(java.sql.Timestamp timeStamp)
Constructs a T_TIMESTAMP Atom. |
|
| Method Summary | |
Atom |
clear()
Returns an empty Atom having the same type as this. |
int |
compareTo(java.lang.Object o)
|
void |
describe(DNode n)
describe puts all relevant information about this into the provided node. |
boolean |
equals(java.lang.Object obj)
|
int |
estimateMemory()
Estimates the number of bytes this object consumes in memory. |
static void |
externalize(Atom a,
XmaOutput o)
Writes the state to an output stream. |
java.lang.String |
getEncodedValue()
Returns the String encoded value of this. |
byte |
getType()
Returns the type constant. |
int |
hashCode()
|
boolean |
hasValue()
Returns true if this Atom holds a value. |
static Atom |
internalize(XmaInput i)
Reads an Atom from an input stream and returns it. |
boolean |
isTrue()
Returns true if getType() equals T_BOOLEAN and the stored value equals TRUE. |
static Atom |
newInstance(byte type,
java.lang.String internalValue)
Constructs an atom by providing its instance variables. |
static Atom |
newInstance(java.lang.Object o)
Constructs an atom from various java types. |
static Atom |
newRandomInstance()
Randomly contructs an Atom and returns it. |
static Atom |
newTransportInstance(java.lang.String encoded)
Constructs an Atom from a String that has been produced using toTransportString. |
static int |
streamedSize(Atom a)
Returns the estimated length of the byte stream resulting from streaming an Atom. |
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. |
static java.util.Date |
toDateImpl(byte type,
java.lang.String internal)
Helper method to convert date- and timestamp-atomics to java.util.Date. |
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()
Requires that this is either empty or contains an integer T_BCD value. |
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. |
static java.lang.String |
toStringImpl(byte type,
java.lang.String internal)
Returns a string representation of an IAtomic given its type and its internal encoding. |
java.lang.String |
toTransportString()
Converts this to a transport encoding string s that has the property that an Atom created with newTransportInstance(s) is equal to this. |
static java.lang.String |
type2String(byte t)
Returns a describing short string for a type code. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final Atom EMPTY_STRING
public static final Atom EMPTY_BCD
public static final Atom EMPTY_DATE
public static final Atom EMPTY_TIMESTAMP
public static final Atom EMPTY_BOOLEAN
public static final Atom EMPTY_DOM
protected byte type_
protected java.lang.String value_
| Constructor Detail |
public Atom()
public Atom(java.lang.String s)
s - the value to set
java.lang.IllegalArgumentException - if argument null
public Atom(double value,
int numNK)
value - the numeric value to set.numNK - number of digits after the comma to be used
when the provided double is converted to a String
(which has to be done since Atoms are
string encoded). If numNK
equals -1, the number of the resulting places
after the comma is unknown.public Atom(double value)
value - the input double valuepublic Atom(java.math.BigDecimal value)
value - the BigDecimal providing the numeric value.public Atom(int value)
value - public Atom(long value)
value -
public Atom(byte type,
java.util.Date date)
type - may be T_DATE or T_TIMESTAMPdate - the value of the Atom
java.lang.IllegalArgumentException - if argument nullpublic Atom(java.sql.Timestamp timeStamp)
timeStamp - the value of the Atom
java.lang.IllegalArgumentException - if argument nullpublic Atom(boolean value)
value - the boolean value to construct this with.| Method Detail |
public static Atom newInstance(byte type,
java.lang.String internalValue)
You may only use this method if you are working with formatters at.spardat.enterprise.fmt.IFmt and need to construct an Atom from an formatter-internal encoding.
type - the type codeinternalValue - the internally stored string encoding of the type.
public static Atom newInstance(java.lang.Object o)
o - must be of the types String, Boolean, Folat, Double, Date,
Byte, Short, Integer, Long
java.lang.IllegalArgumentException - if Object is of unsupported typepublic static Atom newRandomInstance()
public java.lang.String toTransportString()
public static Atom newTransportInstance(java.lang.String encoded)
encoded - as defined in method toTransportString
java.lang.IllegalArgumentException - if the argument was not created by toTransportString.public Atom clear()
public boolean hasValue()
hasValue in interface IAtomicpublic byte getType()
getType in interface IAtomicpublic java.lang.String toString()
IAtomic
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.
toString in interface IAtomicIAtomic.toString()
public static java.lang.String toStringImpl(byte type,
java.lang.String internal)
This method may not be called from outside the framework.
public java.lang.String toString(at.spardat.enterprise.fmt.IFmt formatter)
toString in interface IAtomicformatter - the IFmt formatter. May be null.
public double toDouble()
toDouble in interface IAtomicpublic float toFloat()
IAtomic
toFloat in interface IAtomicIAtomic.toFloat()public int toInt()
toInt in interface IAtomicjava.lang.NumberFormatException - if this does not fit into an intpublic long toLong()
IAtomic
toLong in interface IAtomicIAtomic.toLong()public byte toByte()
IAtomic
toByte in interface IAtomicIAtomic.toByte()public short toShort()
IAtomic
toShort in interface IAtomicIAtomic.toShort()public java.math.BigDecimal toBigDecimal()
IAtomic
toBigDecimal in interface IAtomicIAtomic.toBigDecimal()public java.lang.Byte toBYTE()
IAtomic
toBYTE in interface IAtomicIAtomic.toByte()public java.lang.Short toSHORT()
IAtomic
toSHORT in interface IAtomicIAtomic.toSHORT()public java.lang.Integer toINTEGER()
IAtomic
toINTEGER in interface IAtomicIAtomic.toINTEGER()public java.lang.Long toLONG()
IAtomic
toLONG in interface IAtomicIAtomic.toLONG()public java.lang.Float toFLOAT()
IAtomic
toFLOAT in interface IAtomicIAtomic.toFLOAT()public java.lang.Double toDOUBLE()
IAtomic
toDOUBLE in interface IAtomicIAtomic.toDOUBLE()public java.util.Date toDate()
toDate in interface IAtomic
public static java.util.Date toDateImpl(byte type,
java.lang.String internal)
public boolean isTrue()
isTrue in interface IAtomicpublic static int streamedSize(Atom a)
public static Atom internalize(XmaInput i)
throws java.io.IOException
java.io.IOException
public static void externalize(Atom a,
XmaOutput o)
throws java.io.IOException
java.io.IOExceptionpublic int compareTo(java.lang.Object o)
compareTo in interface java.lang.ComparableComparable.compareTo(java.lang.Object)public static java.lang.String type2String(byte t)
public void describe(DNode n)
Descriptive
describe in interface Descriptiven - the node going to hold information about this.Descriptive.describe(at.spardat.xma.mdl.util.DNode)public boolean equals(java.lang.Object obj)
Object.equals(java.lang.Object)public int estimateMemory()
public java.lang.String getEncodedValue()
IAtomic
getEncodedValue in interface IAtomicIAtomic.getEncodedValue()public int hashCode()
Object.hashCode()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||