public static class EncodedInteger.GenericCodec extends EncodedInteger.Codec
| Constructor and Description |
|---|
EncodedInteger.GenericCodec(int minValue,
int maxValue,
int width,
boolean bigEndian,
boolean signed) |
| Modifier and Type | Method and Description |
|---|---|
int |
decode(byte[] data,
int start,
int len)
Decode a value from some part of a bytearray
|
byte[] |
encode(int value)
Encode the given value to a new bytearray
|
void |
encodeTo(int value,
byte[] toArray,
int start)
Encode the given value to some location in an existing bytearray
|
void |
rangeCheck(int value)
Check if a given value is in the encodable range for this codec.
|
decodepublic EncodedInteger.GenericCodec(int minValue,
int maxValue,
int width,
boolean bigEndian,
boolean signed)
minValue - the minimum acceptable valuemaxValue - the maximum acceptable valuewidth - how many bytes to encode tobigEndian - if true, encode MSB first; if false, encode LSB firstsigned - if true, treat the most significant bit as a sign bit when decodingpublic byte[] encode(int value)
EncodedInteger.Codecencode in class EncodedInteger.Codecvalue - the valuepublic void encodeTo(int value,
byte[] toArray,
int start)
EncodedInteger.CodecencodeTo in class EncodedInteger.Codecvalue - the valuetoArray - the array to populatestart - the start index to begin encoding atpublic int decode(byte[] data,
int start,
int len)
EncodedInteger.Codecdecode in class EncodedInteger.Codecdata - the bytearraystart - where to start decodinglen - how many bytes to decodepublic void rangeCheck(int value)
throws EncodeException
EncodedInteger.CodecrangeCheck in class EncodedInteger.Codecvalue - the value to checkEncodeException - if value is out of range