Class ByteHelperKt
-
- All Implemented Interfaces:
public final class ByteHelperKt
-
-
Field Summary
Fields Modifier and Type Field Description private final static FieldSizesSIZESprivate final static FieldPositionsPOSITIONSprivate final static FixedValuesFIXED_VALUESprivate final static Map<String, Tag>tagsByHexString
-
Method Summary
Modifier and Type Method Description final FieldSizesgetSIZES()Helper object that defines the fixed sizes of individual fields in the RSCP protocol. final FieldPositionsgetPOSITIONS()Helper object that defines the fixed positions of the individual fields in a FrameHeader. final FixedValuesgetFIXED_VALUES()Helper object that defines some fixed values from the RSCP protocol final Map<String, Tag>getTagsByHexString()Map containing all known tags. final static ByteArrayfromHexString(String $self)Creates a byte array from the string assuming that the string is in valid hex format. final static StringtoHexString(ByteArray $self)Creates a string from the ByteArray in hex format, without prefix final static Longcrc32(ByteArray $self)Calculates the CRC32 checksum of the ByteArray. final static ByteBufferfillCRC32forFrame(ByteBuffer $self)Calculates the CRC32 checksum assuming that the byte buffer is an E3DC RSCP frame. final static ByteBufferemptyByteBuffer(Integer size)Creates an empty ByteBuffer with the specified size size in bytes. final static TagtagFromByteArray(ByteArray byteArray)Returns the Tag for the given byteArray. -
-
Method Detail
-
getSIZES
final FieldSizes getSIZES()
Helper object that defines the fixed sizes of individual fields in the RSCP protocol.
-
getPOSITIONS
final FieldPositions getPOSITIONS()
Helper object that defines the fixed positions of the individual fields in a FrameHeader.
-
getFIXED_VALUES
final FixedValues getFIXED_VALUES()
Helper object that defines some fixed values from the RSCP protocol
-
getTagsByHexString
final Map<String, Tag> getTagsByHexString()
Map containing all known tags. The key is the respective hex code as string in lowercase with leading prefix 0x
-
fromHexString
final static ByteArray fromHexString(String $self)
Creates a byte array from the string assuming that the string is in valid hex format.
The call works for strings with and without prefix 0x. There is no validation if the string is a valid hex string.
- Returns:
ByteArray representation of the hex string
- Since:
2.0
-
toHexString
final static String toHexString(ByteArray $self)
Creates a string from the ByteArray in hex format, without prefix
- Returns:
Hex String representation of the ByteArray
- Since:
2.0
-
crc32
final static Long crc32(ByteArray $self)
Calculates the CRC32 checksum of the ByteArray.
- Returns:
Checksum of the ByteArray
- Since:
2.0
-
fillCRC32forFrame
final static ByteBuffer fillCRC32forFrame(ByteBuffer $self)
Calculates the CRC32 checksum assuming that the byte buffer is an E3DC RSCP frame. This means that the checksum is formed over all bytes of the buffer, minus the last 4. See SIZES.
- Returns:
ByteBuffer with filled checksum.
-
emptyByteBuffer
final static ByteBuffer emptyByteBuffer(Integer size)
Creates an empty ByteBuffer with the specified size size in bytes.
The ByteOrder, as required by E3DC, is ByteOrder.LITTLE_ENDIAN.
- Parameters:
size- Size of the ByteBuffer in byte- Returns:
Empty ByteBuffer object, with the requested size, in ByteOrder.LITTLE_ENDIAN order.
- Since:
2.0
-
tagFromByteArray
final static Tag tagFromByteArray(ByteArray byteArray)
Returns the Tag for the given byteArray.
If the tag is not known, an instance of UnknownTag is returned.
- Returns:
Tag object to the given byteArray.
- Since:
2.0
-
-
-
-