Class DmtData
DmtSession
interface.
Different constructors are available to create nodes with different formats.
Nodes of null
format can be created using the static
NULL_VALUE
constant instance of this class.
FORMAT_RAW_BINARY
and FORMAT_RAW_STRING
enable the support
of future data formats. When using these formats, the actual format name is
specified as a String
. The application is responsible for the proper
encoding of the data according to the specified format.
- "Immutable"
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DmtData
Constant instance representing a booleanfalse
value.static final int
The node holds an OMA DMb64
value.static final int
The node holds an OMA DMbin
value.static final int
The node holds an OMA DMbool
value.static final int
The node holds an OMA DMdate
value.static final int
The node holds a Date object.static final int
The node holds an OMA DMfloat
value.static final int
The node holds an OMA DMint
value.static final int
The node holds a long value.static final int
Format specifier of an internal node.static final int
The node holds an OMA DMnull
value.static final int
The node holds raw protocol data encoded in binary format.static final int
The node holds raw protocol data encoded asString
.static final int
The node holds an OMA DMchr
value.static final int
The node holds an OMA DMtime
value.static final int
The node holds an OMA DMxml
value.static final DmtData
Constant instance representing a leaf node ofnull
format.static final DmtData
Constant instance representing a booleantrue
value. -
Constructor Summary
ConstructorDescriptionDmtData
(boolean bool) Create aDmtData
instance ofbool
format and set its value.DmtData
(byte[] bytes) Create aDmtData
instance ofbin
format and set its value.DmtData
(byte[] bytes, boolean base64) Create aDmtData
instance ofbin
orb64
format and set its value.DmtData
(byte[] bytes, int format) Create aDmtData
instance of the specified format and set its value based on the givenbyte[]
.DmtData
(float flt) Create aDmtData
instance offloat
format and set its value.DmtData
(int integer) Create aDmtData
instance ofint
format and set its value.DmtData
(long lng) Create aDmtData
instance oflong
format and set its value.Create aDmtData
instance ofnode
format with the given object value.Create aDmtData
instance ofchr
format with the given string value.Create aDmtData
instance inFORMAT_RAW_BINARY
format.Create aDmtData
instance of the specified format and set its value based on the given string.Create aDmtData
instance inFORMAT_RAW_STRING
format.Create aDmtData
instance ofdateTime
format with the given Date value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares the specified object with thisDmtData
instance.byte[]
Gets the value of a node with base 64 (b64
) format.byte[]
Gets the value of a node with binary (bin
) format.boolean
Gets the value of a node with boolean (bool
) format.getDate()
Gets the value of a node with date format.Gets the value of a node withdateTime
format.float
getFloat()
Gets the value of a node withfloat
format.int
Get the node's format, expressed in terms of type constants defined in this class.Returns the format of thisDmtData
asString
.int
getInt()
Gets the value of a node with integer (int
) format.long
getLong()
Gets the value of a node with long format.getNode()
Gets the complex data associated with an interior node (node
format).byte[]
Gets the value of a node in raw binary (FORMAT_RAW_BINARY
) format.Gets the value of a node in rawString
(FORMAT_RAW_STRING
) format.int
getSize()
Get the size of the data.Gets the value of a node with string (chr
) format.getTime()
Gets the value of a node with time format.getXml()
Gets the value of a node withxml
format.int
hashCode()
Returns the hash code value for thisDmtData
instance.toString()
Gets the string representation of theDmtData
.
-
Field Details
-
FORMAT_INTEGER
public static final int FORMAT_INTEGERThe node holds an OMA DMint
value.- See Also:
-
FORMAT_FLOAT
public static final int FORMAT_FLOATThe node holds an OMA DMfloat
value.- See Also:
-
FORMAT_STRING
public static final int FORMAT_STRINGThe node holds an OMA DMchr
value.- See Also:
-
FORMAT_BOOLEAN
public static final int FORMAT_BOOLEANThe node holds an OMA DMbool
value.- See Also:
-
FORMAT_DATE
public static final int FORMAT_DATEThe node holds an OMA DMdate
value.- See Also:
-
FORMAT_TIME
public static final int FORMAT_TIMEThe node holds an OMA DMtime
value.- See Also:
-
FORMAT_BINARY
public static final int FORMAT_BINARYThe node holds an OMA DMbin
value. The value of the node corresponds to the Javabyte[]
type.- See Also:
-
FORMAT_BASE64
public static final int FORMAT_BASE64The node holds an OMA DMb64
value. LikeFORMAT_BINARY
, this format is also represented by the Javabyte[]
type, the difference is only in the corresponding OMA DM format. This format does not affect the internal storage format of the data asbyte[]
. It is intended as a hint for the external representation of this data. Protocol Adapters can use this hint for their further processing.- See Also:
-
FORMAT_XML
public static final int FORMAT_XMLThe node holds an OMA DMxml
value.- See Also:
-
FORMAT_NULL
public static final int FORMAT_NULLThe node holds an OMA DMnull
value. This corresponds to the Javanull
type.- See Also:
-
FORMAT_NODE
public static final int FORMAT_NODEFormat specifier of an internal node. An interior node can hold a Java object as value (seeDmtData(Object)
andgetNode()
). This value can be used by Java programs that know a specific URI understands the associated Java type. This type is further used as a return value of theMetaNode.getFormat()
method for interior nodes.- See Also:
-
FORMAT_RAW_STRING
public static final int FORMAT_RAW_STRINGThe node holds raw protocol data encoded asString
. ThegetFormatName()
method can be used to get the actual format name.- See Also:
-
FORMAT_RAW_BINARY
public static final int FORMAT_RAW_BINARYThe node holds raw protocol data encoded in binary format. ThegetFormatName()
method can be used to get the actual format name.- See Also:
-
FORMAT_LONG
public static final int FORMAT_LONGThe node holds a long value. ThegetFormatName()
method can be used to get the actual format name.- Since:
- 2.0
- See Also:
-
FORMAT_DATE_TIME
public static final int FORMAT_DATE_TIMEThe node holds a Date object. If the getTime() equals zero then the date time is not known. If the getTime() is negative it must be interpreted as a relative number of milliseconds.- Since:
- 2.0
- See Also:
-
NULL_VALUE
Constant instance representing a leaf node ofnull
format. -
TRUE_VALUE
Constant instance representing a booleantrue
value.- Since:
- 2.0
-
FALSE_VALUE
Constant instance representing a booleanfalse
value.- Since:
- 2.0
-
-
Constructor Details
-
DmtData
Create aDmtData
instance ofchr
format with the given string value. Thenull
string argument is valid.- Parameters:
string
- the string value to set
-
DmtData
Create aDmtData
instance ofdateTime
format with the given Date value. The given Date value must be a non-nullDate
object.- Parameters:
date
- the Date object to set
-
DmtData
Create aDmtData
instance ofnode
format with the given object value. The value represents complex data associated with an interior node.Certain interior nodes can support access to their subtrees through such complex values, making it simpler to retrieve or update all leaf nodes in a subtree.
The given value must be a non-
null
immutable object.- Parameters:
complex
- the complex data object to set
-
DmtData
Create aDmtData
instance of the specified format and set its value based on the given string. Only the following string-based formats can be created using this constructor:FORMAT_STRING
- value can be any stringFORMAT_XML
- value must contain an XML fragment (the validity is not checked by this constructor)FORMAT_DATE
- value must be parsable to an ISO 8601 calendar date in complete representation, basic format (patternCCYYMMDD
)FORMAT_TIME
- value must be parsable to an ISO 8601 time of day in either local time, complete representation, basic format (patternhhmmss
) or Coordinated Universal Time, basic format (patternhhmmssZ
)
null
string argument is only valid if the format is string or XML.- Parameters:
value
- the string, XML, date, or time value to setformat
- the format of theDmtData
instance to be created, must be one of the formats specified above- Throws:
IllegalArgumentException
- ifformat
is not one of the allowed formats, orvalue
is not a valid string for the given formatNullPointerException
- if a string, XML, date, or time is constructed andvalue
isnull
-
DmtData
public DmtData(int integer) Create aDmtData
instance ofint
format and set its value.- Parameters:
integer
- the integer value to set
-
DmtData
public DmtData(float flt) Create aDmtData
instance offloat
format and set its value.- Parameters:
flt
- the float value to set
-
DmtData
public DmtData(long lng) Create aDmtData
instance oflong
format and set its value.- Parameters:
lng
- the long value to set- Since:
- 2.0
-
DmtData
public DmtData(boolean bool) Create aDmtData
instance ofbool
format and set its value.- Parameters:
bool
- the boolean value to set
-
DmtData
public DmtData(byte[] bytes) Create aDmtData
instance ofbin
format and set its value.- Parameters:
bytes
- the byte array to set, must not benull
- Throws:
NullPointerException
- ifbytes
isnull
-
DmtData
public DmtData(byte[] bytes, boolean base64) Create aDmtData
instance ofbin
orb64
format and set its value. The chosen format is specified by thebase64
parameter.- Parameters:
bytes
- the byte array to set, must not benull
base64
- iftrue
, the new instance will haveb64
format, iffalse
, it will havebin
format- Throws:
NullPointerException
- ifbytes
isnull
-
DmtData
public DmtData(byte[] bytes, int format) Create aDmtData
instance of the specified format and set its value based on the givenbyte[]
. Only the followingbyte[]
based formats can be created using this constructor:- Parameters:
bytes
- the byte array to set, must not benull
format
- the format of the DmtData instance to be created, must be one of the formats specified above- Throws:
IllegalArgumentException
- if format is not one of the allowed formatsNullPointerException
- ifbytes
isnull
-
DmtData
Create aDmtData
instance inFORMAT_RAW_STRING
format. The data is provided encoded as aString
. The actual data format is specified informatName
. The encoding used indata
must conform to this format.- Parameters:
formatName
- the name of the format, must not benull
data
- the data encoded according to the specified format, must not benull
- Throws:
NullPointerException
- ifformatName
ordata
isnull
-
DmtData
Create aDmtData
instance inFORMAT_RAW_BINARY
format. The data is provided encoded as binary. The actual data format is specified informatName
. The encoding used indata
must conform to this format.- Parameters:
formatName
- the name of the format, must not benull
data
- the data encoded according to the specified format, must not benull
- Throws:
NullPointerException
- ifformatName
ordata
isnull
-
-
Method Details
-
getString
Gets the value of a node with string (chr
) format.- Returns:
- the string value
- Throws:
DmtIllegalStateException
- if the format of the node is not string
-
getDate
Gets the value of a node with date format. The returned date string is formatted according to the ISO 8601 definition of a calendar date in complete representation, basic format (patternCCYYMMDD
).- Returns:
- the date value
- Throws:
DmtIllegalStateException
- if the format of the node is not date
-
getTime
Gets the value of a node with time format. The returned time string is formatted according to the ISO 8601 definition of the time of day. The exact format depends on the value the object was initialized with: either local time, complete representation, basic format (patternhhmmss
) or Coordinated Universal Time, basic format (patternhhmmssZ
).- Returns:
- the time value
- Throws:
DmtIllegalStateException
- if the format of the node is not time
-
getDateTime
Gets the value of a node withdateTime
format.- Returns:
- the Date value
- Throws:
DmtIllegalStateException
- if the format of the node is not time- Since:
- 2.0
-
getXml
Gets the value of a node withxml
format.- Returns:
- the XML value
- Throws:
DmtIllegalStateException
- if the format of the node is notxml
-
getInt
public int getInt()Gets the value of a node with integer (int
) format.- Returns:
- the integer value
- Throws:
DmtIllegalStateException
- if the format of the node is not integer
-
getLong
public long getLong()Gets the value of a node with long format.- Returns:
- the long value
- Throws:
DmtIllegalStateException
- if the format of the node is not long- Since:
- 2.0
-
getFloat
public float getFloat()Gets the value of a node withfloat
format.- Returns:
- the float value
- Throws:
DmtIllegalStateException
- if the format of the node is notfloat
-
getBoolean
public boolean getBoolean()Gets the value of a node with boolean (bool
) format.- Returns:
- the boolean value
- Throws:
DmtIllegalStateException
- if the format of the node is not boolean
-
getBinary
public byte[] getBinary()Gets the value of a node with binary (bin
) format.- Returns:
- the binary value
- Throws:
DmtIllegalStateException
- if the format of the node is not binary
-
getRawBinary
public byte[] getRawBinary()Gets the value of a node in raw binary (FORMAT_RAW_BINARY
) format.- Returns:
- the data value in raw binary format
- Throws:
DmtIllegalStateException
- if the format of the node is not raw binary
-
getRawString
Gets the value of a node in rawString
(FORMAT_RAW_STRING
) format.- Returns:
- the data value in raw
String
format - Throws:
DmtIllegalStateException
- if the format of the node is not rawString
-
getBase64
public byte[] getBase64()Gets the value of a node with base 64 (b64
) format.- Returns:
- the binary value
- Throws:
DmtIllegalStateException
- if the format of the node is not base 64.
-
getNode
Gets the complex data associated with an interior node (node
format).Certain interior nodes can support access to their subtrees through complex values, making it simpler to retrieve or update all leaf nodes in the subtree.
- Returns:
- the data object associated with an interior node
- Throws:
DmtIllegalStateException
- if the format of the data is notnode
-
getFormat
public int getFormat()Get the node's format, expressed in terms of type constants defined in this class. Note that the 'format' term is a legacy from OMA DM, it is more customary to think of this as 'type'.- Returns:
- the format of the node
-
getFormatName
Returns the format of thisDmtData
asString
. For the predefined data formats this is the OMA DM defined name of the format. ForFORMAT_RAW_STRING
andFORMAT_RAW_BINARY
this is the format specified when the object was created.- Returns:
- the format name as
String
-
getSize
public int getSize()Get the size of the data. The returned value depends on the format of data in the node:FORMAT_STRING
,FORMAT_XML
,FORMAT_BINARY
,FORMAT_BASE64
,FORMAT_RAW_STRING
, andFORMAT_RAW_BINARY
: the length of the stored data, or 0 if the data isnull
FORMAT_INTEGER
andFORMAT_FLOAT
: 4FORMAT_LONG
andFORMAT_DATE_TIME
: 8FORMAT_DATE
andFORMAT_TIME
: the length of the date or time in its string representationFORMAT_BOOLEAN
: 1FORMAT_NODE
: -1 (unknown)FORMAT_NULL
: 0
- Returns:
- the size of the data stored by this object
-
toString
Gets the string representation of theDmtData
. This method works for all formats.For string format data - including
FORMAT_RAW_STRING
- the string value itself is returned, while for XML, date, time, integer, float, boolean, long and node formats the string form of the value is returned. Binary - includingFORMAT_RAW_BINARY
- base64 data is represented by two-digit hexadecimal numbers for each byte separated by spaces. TheNULL_VALUE
data has the string form of "null
". Data of string or XML format containing the Javanull
value is represented by an empty string. DateTime data is formatted asyyyy-MM-dd'T'HH:mm:SS'Z'
). -
equals
Compares the specified object with thisDmtData
instance. TwoDmtData
objects are considered equal if their format is the same, and their data (selected by the format) is equal.In case of
FORMAT_RAW_BINARY
andFORMAT_RAW_STRING
the textual name of the data format - as returned bygetFormatName()
- must be equal as well. -
hashCode
public int hashCode()Returns the hash code value for thisDmtData
instance. The hash code is calculated based on the data (selected by the format) of this object.
-