Class Data
-
-
Method Summary
Modifier and Type Method Description final ByteArraygetTag()final BytegetType()final ByteArraygetValue()final TagtagObject()Returns the tag object to the tag final DataTypetypeObject()Returns the DataType object to the type. final List<Data>valueAsContainer(DataParser parser)If typeObject is of type DataType.CONTAINER, the data block is processed using the parser object and the result is returned. final BytevalueAsByte()If typeObject is a valid byte type (see DataType.isByteType), the data block is interpreted as Byte and returned. final ShortvalueAsShort()If typeObject is a valid short type (see DataType.isShortType), the data block is interpreted as Short and returned. final IntegervalueAsInt()If typeObject is a valid int type (see DataType.isIntType), the data block is interpreted as Int and returned. final LongvalueAsLong()If typeObject is a valid long type (see DataType.isLongType), the data block is interpreted as Long and returned. final FloatvalueAsFloat()If typeObject is of type DataType.FLOAT32, the data block is interpreted as Float and returned. final DoublevalueAsDouble()If typeObject is of type DataType.DOUBLE64, the data block is interpreted as Double and returned. final BooleanvalueAsBoolean()If typeObject is of type DataType.BOOL, the data block is interpreted as Boolean and returned. final StringvalueAsString()Regardless of the typeObject result, the data block is converted to a String. final InstantvalueAsInstant()If typeObject is of type DataType.TIMESTAMP, the data block is interpreted as E3DC timestamp and converted to an Instant object and returned. final DurationvalueAsDuration()If typeObject is of type DataType.TIMESTAMP, the data block is interpreted as E3DC timestamp and converted to an Duration object and returned. final ByteArrayasByteArray()Returns the complete ByteArray of this data block as it was sent to or received from the E3DC home power plant. final ResultCodevalueAsResultCode()Reads the Int value of the data block and converts it into a ResultCode. final ErrorCodevalueAsErrorCode()Reads the Int value of the data block and converts it into a ErrorCode. final BooleanisErrorResponse()Checks if the response type is of type error. Booleanequals(Object other)IntegerhashCode()StringtoString()-
-
Method Detail
-
typeObject
final DataType typeObject()
- Returns:
DataType Object
- Since:
2.0
-
valueAsContainer
final List<Data> valueAsContainer(DataParser parser)
If typeObject is of type DataType.CONTAINER, the data block is processed using the parser object and the result is returned.
In all other cases an empty list is returned.
- Parameters:
parser- Parser to process the data block- Returns:
Result of the parsing
- Since:
2.0
-
valueAsByte
final Byte valueAsByte()
If typeObject is a valid byte type (see DataType.isByteType), the data block is interpreted as Byte and returned.
In all other cases, null is returned.
- Returns:
Data block as Byte or zero if the data type does not fit
- Since:
2.0
-
valueAsShort
final Short valueAsShort()
If typeObject is a valid short type (see DataType.isShortType), the data block is interpreted as Short and returned.
In all other cases, null is returned.
- Returns:
Data block as Short or zero if the data type does not fit
- Since:
2.0
-
valueAsInt
final Integer valueAsInt()
If typeObject is a valid int type (see DataType.isIntType), the data block is interpreted as Int and returned.
In all other cases, null is returned.
- Returns:
Data block as Int or zero if the data type does not fit
- Since:
2.0
-
valueAsLong
final Long valueAsLong()
If typeObject is a valid long type (see DataType.isLongType), the data block is interpreted as Long and returned.
In all other cases, null is returned.
- Returns:
Data block as Long or zero if the data type does not fit
- Since:
2.0
-
valueAsFloat
final Float valueAsFloat()
If typeObject is of type DataType.FLOAT32, the data block is interpreted as Float and returned.
In all other cases, null is returned.
- Returns:
Data block as Float or zero if the data type does not fit
- Since:
2.0
-
valueAsDouble
final Double valueAsDouble()
If typeObject is of type DataType.DOUBLE64, the data block is interpreted as Double and returned.
In all other cases, null is returned.
- Returns:
Data block as Double or zero if the data type does not fit
- Since:
2.0
-
valueAsBoolean
final Boolean valueAsBoolean()
If typeObject is of type DataType.BOOL, the data block is interpreted as Boolean and returned.
In all other cases, null is returned.
- Returns:
Data block as Boolean or zero if the data type does not fit
- Since:
2.0
-
valueAsString
final String valueAsString()
Regardless of the typeObject result, the data block is converted to a String.
Depending on the data type, the conversion is performed according to different rules:
DataType.NONE -> The fixed string "
[NONE]" is returnedDataType.BOOL -> The result of String.format with the parameter
%bis returnedAll integer types -> The result of String.format with the parameter
%dis returnedAll floating point types -> The result of String.format with the parameter
%.2fis returnedDataType.BITFIELD -> The result of String.format with the parameter
%bis returnedDataType.STRING -> The data block is interpreted as a string with the character set Charsets.UTF_8 and returned
DataType.CONTAINER -> The fixed string "
[CONTAINER]" is returnedDataType.TIMESTAMP -> The data block is interpreted as Instant and converted with the time zone information ZoneOffset.UTC into a string with the format DateTimeFormatter.ISO_LOCAL_DATE_TIME and returned
Everything else -> All other types (also unknown), return the value as hex string
- Returns:
Data block as string interpretation, depending on type (See typeObject.
- Since:
2.0
-
valueAsInstant
final Instant valueAsInstant()
If typeObject is of type DataType.TIMESTAMP, the data block is interpreted as E3DC timestamp and converted to an Instant object and returned.
In all other cases, null is returned.
- Returns:
Data block as Instant or zero if the data type does not fit
- Since:
2.0
-
valueAsDuration
final Duration valueAsDuration()
If typeObject is of type DataType.TIMESTAMP, the data block is interpreted as E3DC timestamp and converted to an Duration object and returned.
In all other cases, null is returned.
- Returns:
Data block as Duration or zero if the data type does not fit
- Since:
2.0
-
asByteArray
final ByteArray asByteArray()
Returns the complete ByteArray of this data block as it was sent to or received from the E3DC home power plant.
- Returns:
ByteArray in RSCP format
- Since:
2.0
-
valueAsResultCode
final ResultCode valueAsResultCode()
Reads the Int value of the data block and converts it into a ResultCode.
- Returns:
ResultCode value
- Since:
2.0
-
valueAsErrorCode
final ErrorCode valueAsErrorCode()
Reads the Int value of the data block and converts it into a ErrorCode.
- Returns:
ErrorCode Value
- Since:
2.1
-
isErrorResponse
final Boolean isErrorResponse()
Checks if the response type is of type error.
If a request fails, for whatever reason, you get the normal tag back as a response, but the type is DataType.ERROR.
- Returns:
true if it is an error response, otherwise false
- Since:
2.0
-
-
-
-