public final class TypeConverter
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static int |
byteToInt(byte value)
Because Java doesn't support unsigned byte values, simple type casting
leads to overflows and wrong values.
|
static int |
decode1sComplement(int value,
int msb)
Decodes 1's complement value that is encoded on lesser than 16 number of
bits.
|
static int |
decode2sComplement(int value,
int msb)
Decodes 2's complement value that is encoded on lesser than 16 number of
bits.
|
static java.lang.String |
decode6bitAscii(byte[] text) |
static java.lang.String |
decodeBcdPlus(byte[] text)
Decodes text encoded in BCD plus format.
|
static java.util.Date |
decodeDate(int date)
Decodes date encoded as number of seconds from 00:00:00, January 1, 1970
GMT.
|
static byte |
intToByte(int value)
Because Java doesn't support unsigned byte values, simple type casting
leads to overflows and wrong values.
|
static byte[] |
intToByteArray(int value)
Converts int to byte array in BigEndian convention.
|
static byte[] |
intToLittleEndianByteArray(int value)
Converts int to byte array in LittleEndian convention.
|
static int |
littleEndianBcdByteToInt(byte value)
Converts BCD encoded byte with bits 7:4 holding the Least Significant
digit of the revision and bits 3:0 holding the Most Significant bits.
|
static int |
littleEndianByteArrayToInt(byte[] value)
Converts byte array in LittleEndian convention to int.
|
public static byte[] intToByteArray(int value)
value
- intToByte(int)
public static byte[] intToLittleEndianByteArray(int value)
value
- intToByte(int)
public static int littleEndianByteArrayToInt(byte[] value) throws java.lang.IndexOutOfBoundsException
value
- Byte array holding values.java.lang.IndexOutOfBoundsException
- when value's length is not 4.intToByte(int)
public static byte intToByte(int value) throws java.lang.IllegalArgumentException
value
- int value (must be in range 0-255)java.lang.IllegalArgumentException
- when value is out of range.public static int byteToInt(byte value)
value
- byte valuepublic static int littleEndianBcdByteToInt(byte value)
value
- decoded valuepublic static int decode2sComplement(int value, int msb)
value
- - value to be decodedmsb
- - 0-based index at which the encoded value beginspublic static int decode1sComplement(int value, int msb)
value
- - value to be decodedmsb
- - 0-based index at which the encoded value beginspublic static java.lang.String decodeBcdPlus(byte[] text)
public static java.lang.String decode6bitAscii(byte[] text)
public static java.util.Date decodeDate(int date)