public class BitInterpreter extends CharInterpreter
arraySeparator, arraySizeInterpreter, fixArraySizes, NB_BYTES, nbItems, strNullValue, TYPE_LABEL
Constructor | Description |
---|---|
BitInterpreter(int[] arraysizes) |
Modifier and Type | Method | Description |
---|---|---|
protected java.lang.Character |
convertPrimary(java.lang.Object value) |
Converts/Casts the given object into an object of type T.
|
java.lang.Character[] |
decode(java.io.InputStream input) |
Decodes the binary data coming from the given input stream.
|
java.lang.Character |
decodePrimary(byte[] bytes,
int offset) |
Decodes only one data of type T from the given bytes array.
|
void |
encode(java.io.OutputStream output,
java.lang.Object value) |
Encodes the given value in binary and writes it in the given output stream.
|
byte[] |
encodePrimary(java.lang.Character value) |
Encodes a single value of type T in binary.
|
protected java.lang.Class<java.lang.Character[]> |
getArrayClass() |
Gets the precise array type.
|
byte[] |
getPadding(int length) |
Creates an array of the given length with padding values (0x00).
|
arraySizeToString, convertIntoArray, convertToString, createEmptyArray, createInterpreter, getArraySize, getPadding, readBytes
public BitInterpreter(int[] arraysizes) throws BinaryInterpreterException
BinaryInterpreterException
public java.lang.Character[] decode(java.io.InputStream input) throws java.io.IOException, BinaryInterpreterException
BinaryFieldInterpreter
Decodes the binary data coming from the given input stream.
Basically, this method gets the array-size (particularly if variable), creates an empty array of the good dimension(s) and fills it by decoding one by one data of type T.
decode
in class BinaryFieldInterpreter<java.lang.Character>
input
- Data to decode.null
if EOF, else the decoded data of type T.java.io.IOException
- If the EOF has been reached in an unexpected manner
or if an error occurs while reading bytes from the given input stream.BinaryInterpreterException
BinaryFieldInterpreter.getArraySize(InputStream)
,
BinaryFieldInterpreter.readBytes(InputStream, int)
,
BinaryFieldInterpreter.createEmptyArray(int)
,
BinaryFieldInterpreter.decodePrimary(byte[],int)
public java.lang.Character decodePrimary(byte[] bytes, int offset) throws java.lang.UnsupportedOperationException
BinaryFieldInterpreter
Decodes only one data of type T from the given bytes array.
WARNING: bytes
is supposed to contain enough bytes (>= BinaryFieldInterpreter.NB_BYTES
) from the given offset.
decodePrimary
in class CharInterpreter
bytes
- Array to use to extract enough bytes so that decoding one data of type T.offset
- Position from which bytes must be read.java.lang.UnsupportedOperationException
protected java.lang.Class<java.lang.Character[]> getArrayClass()
BinaryFieldInterpreter
Gets the precise array type.
Generally: T[].class
, where T must be a concrete class.
getArrayClass
in class CharInterpreter
protected java.lang.Character convertPrimary(java.lang.Object value) throws BinaryInterpreterException
BinaryFieldInterpreter
convertPrimary
in class CharInterpreter
value
- The value to cast. (MAY BE NULL)BinaryInterpreterException
- If there is an error while converting the given value.public void encode(java.io.OutputStream output, java.lang.Object value) throws java.io.IOException, BinaryInterpreterException
BinaryFieldInterpreter
encode
in class BinaryFieldInterpreter<java.lang.Character>
output
- Stream in which the encoded value must be written.value
- The value to write once encoded in binary.java.io.IOException
- If there is an error while writing in the given stream.BinaryInterpreterException
- If there is an error while encoding the given value.BinaryFieldInterpreter.convertIntoArray(Object)
,
BinaryFieldInterpreter.encodePrimary(Object)
,
BinaryFieldInterpreter.getPadding()
public byte[] encodePrimary(java.lang.Character value) throws BinaryInterpreterException
BinaryFieldInterpreter
Encodes a single value of type T in binary.
NOTE: If the given value is null, BinaryFieldInterpreter.getPadding()
will be returned.
encodePrimary
in class CharInterpreter
value
- The value to encode. (MAY BE NULL).BinaryInterpreterException
- If there is an error while encoding the given value.public byte[] getPadding(int length)
BinaryFieldInterpreter
getPadding
in class BinaryFieldInterpreter<java.lang.Character>