public class DataObject
extends java.lang.Object
Either stores a Number
, List
of DataObject
s, a byte array, BitString
or a subtype
CosemDateFormat
.
Modifier and Type | Class and Description |
---|---|
static class |
DataObject.Type |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getRawValue()
Returns the raw object-value.
|
DataObject.Type |
getType()
The type of the current
DataObject . |
<T> T |
getValue()
Returns the value.
|
boolean |
isBitString()
Is used to determine if the data contains a
BitString object. |
boolean |
isBoolean()
Checks if the data of this container is a boolean.
|
boolean |
isByteArray()
Checks if the data of this container is a byte array.
|
boolean |
isComplex()
Checks if the data of this container is of a complex type.
|
boolean |
isCosemDateFormat()
Checks if the data of this container is a
CosemDateFormat object. |
boolean |
isNull()
Checks if the data of this container is
null . |
boolean |
isNumber()
Checks if the data of this container is a number
|
static DataObject |
newArrayData(java.util.List<DataObject> array)
Constructs a array data.
|
static DataObject |
newBcdData(byte bcd)
Constructs a 2 digit BCD number data
|
static DataObject |
newBitStringData(BitString bitString)
Constructs a bit string data.
|
static DataObject |
newBoolData(boolean bool)
Constructs a bool data.
|
static DataObject |
newCompactArrayData(CompactArray compactArray) |
static DataObject |
newDateData(CosemDate date)
Constructs a calendar datum holding a date
|
static DataObject |
newDateTimeData(CosemDateTime dateTime)
Constructs a calendar datum holding date and time
|
static DataObject |
newEnumerateData(int enumVal)
Constructs a enum data.
|
static DataObject |
newFloat32Data(float float32)
Constructs a 32 bit floating point number data.
|
static DataObject |
newFloat64Data(double float64)
Constructs a 64 bit floating point number data.
|
static DataObject |
newInteger16Data(short int16)
Constructs a int 16 data
|
static DataObject |
newInteger32Data(int int32)
Constructs a int 32 data.
|
static DataObject |
newInteger64Data(long int64)
Constructs a int 64 data.
|
static DataObject |
newInteger8Data(byte int8)
Constructs a int 8 data
|
static DataObject |
newNullData()
Constructs a empty datum.
|
static DataObject |
newOctetStringData(byte[] string)
Constructs a byte array data.
|
static DataObject |
newStructureData(DataObject... element)
Constructs a structure data.
|
static DataObject |
newStructureData(java.util.List<DataObject> structure)
Constructs a structure data.
|
static DataObject |
newTimeData(CosemTime time)
Constructs a calendar datum holding a time
|
static DataObject |
newUInteger16Data(int uInt16)
Constructs a unsigned int 16 data.
|
static DataObject |
newUInteger32Data(long uIn32)
Constructs a unsigned int 32 data.
|
static DataObject |
newUInteger64Data(long uInt64)
Constructs a unsigned int 64 data
|
static DataObject |
newUInteger8Data(short uInt8)
Constructs a unsigned int 8 data
|
static DataObject |
newUtf8StringData(byte[] string)
Constructs a UTF-8 string, encoded as byte array data.
|
static DataObject |
newVisibleStringData(byte[] string)
Constructs a string, encoded as byte array data.
|
java.lang.String |
toString()
Returns a string representation of the
DataObject . |
public static DataObject newNullData()
COSEM Type DataObject.Type.NULL_DATA
public static DataObject newArrayData(java.util.List<DataObject> array) throws java.lang.IllegalArgumentException
COSEM Type DataObject.Type.ARRAY
array
- The array of valuesjava.lang.IllegalArgumentException
- If a sub element of array has another data type than the firstpublic static DataObject newCompactArrayData(CompactArray compactArray)
public static DataObject newStructureData(java.util.List<DataObject> structure)
COSEM Type DataObject.Type.STRUCTURE
structure
- The structure of valuesnewStructureData(DataObject...)
public static DataObject newStructureData(DataObject... element)
COSEM Type DataObject.Type.STRUCTURE
element
- the structure values.newStructureData(List)
public static DataObject newBoolData(boolean bool)
COSEM Type DataObject.Type.BOOLEAN
bool
- The structure of valuespublic static DataObject newBitStringData(BitString bitString) throws java.lang.IllegalArgumentException
COSEM Type DataObject.Type.BIT_STRING
bitString
- The BitString
object holding the bit stringjava.lang.IllegalArgumentException
public static DataObject newInteger32Data(int int32)
COSEM Type DataObject.Type.DOUBLE_LONG
int32
- he number to storepublic static DataObject newUInteger32Data(long uIn32)
COSEM Type DataObject.Type.DOUBLE_LONG_UNSIGNED
uIn32
- he number to storejava.lang.IllegalArgumentException
- if uInt32 is > 2^(32)-1 or negativepublic static DataObject newOctetStringData(byte[] string)
COSEM Type DataObject.Type.OCTET_STRING
string
- The byte array to storepublic static DataObject newVisibleStringData(byte[] string)
COSEM Type DataObject.Type.VISIBLE_STRING
string
- The byte string to storepublic static DataObject newUtf8StringData(byte[] string)
COSEM Type DataObject.Type.UTF8_STRING
string
- The byte string to storepublic static DataObject newBcdData(byte bcd) throws java.lang.IllegalArgumentException
COSEM Type DataObject.Type.BCD
bcd
- The BCD number to storejava.lang.IllegalArgumentException
public static DataObject newInteger8Data(byte int8) throws java.lang.IllegalArgumentException
COSEM Type DataObject.Type.INTEGER
int8
- The number to storejava.lang.IllegalArgumentException
public static DataObject newUInteger8Data(short uInt8) throws java.lang.IllegalArgumentException
COSEM Type DataObject.Type.UNSIGNED
uInt8
- The number to storejava.lang.IllegalArgumentException
- if uInt8 > 2^(8)-1 or negativepublic static DataObject newInteger16Data(short int16)
COSEM Type DataObject.Type.LONG_INTEGER
int16
- The number to storepublic static DataObject newUInteger16Data(int uInt16)
COSEM Type DataObject.Type.LONG_UNSIGNED
uInt16
- The number to storejava.lang.IllegalArgumentException
- If newVal > 2^(16)-1 or negativepublic static DataObject newInteger64Data(long int64)
COSEM Type DataObject.Type.LONG64
int64
- The number to storepublic static DataObject newUInteger64Data(long uInt64)
COSEM Type DataObject.Type.LONG64_UNSIGNED
uInt64
- The number to storejava.lang.IllegalArgumentException
- if uInt64 is negativepublic static DataObject newEnumerateData(int enumVal)
COSEM Type DataObject.Type.ENUMERATE
enumVal
- The enum value to storejava.lang.IllegalArgumentException
- if newVal is > 2^(8)-1 or negativepublic static DataObject newFloat32Data(float float32)
COSEM Type DataObject.Type.FLOAT32
float32
- The number to storepublic static DataObject newFloat64Data(double float64)
COSEM Type DataObject.Type.FLOAT64
float64
- The number to storepublic static DataObject newDateTimeData(CosemDateTime dateTime)
COSEM Type DataObject.Type.DATE_TIME
dateTime
- The date and time to storepublic static DataObject newDateData(CosemDate date)
COSEM Type DataObject.Type.DATE
date
- The date storepublic static DataObject newTimeData(CosemTime time)
COSEM Type DataObject.Type.TIME
time
- The time storepublic DataObject.Type getType()
DataObject
.public <T> T getValue() throws java.lang.ClassCastException
T
- the type in which the raw data should be cast.java.lang.ClassCastException
- when the value doesn't match the assigned type.getType()
public java.lang.Object getRawValue()
public boolean isBitString()
BitString
object.BitString
object.public boolean isNumber()
public boolean isComplex()
A complex container holds one or more sub container of type DataObject
as values.
A container is of complex type if getType()
returns either DataObject.Type.ARRAY
,
DataObject.Type.STRUCTURE
or DataObject.Type.COMPACT_ARRAY
.
DataObject
holds a List
of DataObject
.public boolean isByteArray()
A container is a byte array if getType()
returns either DataObject.Type.OCTET_STRING
,
DataObject.Type.VISIBLE_STRING, DataObject.Type.BIT_STRING or DataObject.Type.UTF8_STRING.
byte[]
).public boolean isBoolean()
true
if the data is a boolean.public boolean isCosemDateFormat()
CosemDateFormat
object.
A container is a calendar if getType()
returns either DataObject.Type.DATE_TIME
,
DataObject.Type.DATE
or DataObject.Type.TIME
.
true
if the data is a CosemDateFormat
.public boolean isNull()
null
.true
if the data is null
.public java.lang.String toString()
DataObject
.toString
in class java.lang.Object