Package fr.dyade.aaa.common.encoding
Class ByteBufferEncoder
- java.lang.Object
-
- fr.dyade.aaa.common.encoding.ByteBufferEncoder
-
-
Field Summary
Fields Modifier and Type Field Description private ByteBufferbuf
-
Constructor Summary
Constructors Constructor Description ByteBufferEncoder(ByteBuffer buf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidencode16(short s)Encodes a signed short integer.voidencode32(int i)Encodes a signed integer.voidencode64(long l)Encodes a signed long integer.voidencodeBoolean(boolean bool)Encodes a boolean.voidencodeByte(byte b)Encodes a byte.voidencodeByteArray(byte[] tab)Encodes a byte array that cannot be null.voidencodeByteArray(byte[] tab, int offset, int length)Encodes a byte array that cannot be null.voidencodeDouble(double d)Encodes a double.voidencodeFloat(float f)Encodes a float.voidencodeNullableByteArray(byte[] tab)Encodes a byte array that can be null.voidencodeNullableByteArray(byte[] tab, int offset, int length)Encodes a byte array that can be null.voidencodeNullableString(String str)Encodes a string that can be null.private voidencodeNullFlag(Object o)voidencodeSignedInt(int i)Encodes a signed integer.voidencodeSignedLong(long l)Encodes a signed long integer.voidencodeSignedShort(short s)Encodes a signed short integer.voidencodeString(String str)Encodes a string that cannot be null.voidencodeUnsignedInt(int i)Encodes an unsigned integer.voidencodeUnsignedLong(long l)Encodes an unsigned long integer.voidencodeUnsignedShort(short s)Encodes an unsigned short integer.
-
-
-
Field Detail
-
buf
private ByteBuffer buf
-
-
Constructor Detail
-
ByteBufferEncoder
public ByteBufferEncoder(ByteBuffer buf)
-
-
Method Detail
-
encodeBoolean
public void encodeBoolean(boolean bool) throws ExceptionDescription copied from interface:EncoderEncodes a boolean.- Specified by:
encodeBooleanin interfaceEncoder- Parameters:
bool- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeByte
public void encodeByte(byte b) throws ExceptionDescription copied from interface:EncoderEncodes a byte.- Specified by:
encodeBytein interfaceEncoder- Parameters:
b- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeSignedShort
public void encodeSignedShort(short s) throws ExceptionDescription copied from interface:EncoderEncodes a signed short integer. The encoding format depends on the implementation.- Specified by:
encodeSignedShortin interfaceEncoder- Parameters:
s- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeUnsignedShort
public void encodeUnsignedShort(short s) throws ExceptionDescription copied from interface:EncoderEncodes an unsigned short integer. The encoding format depends on the implementation.- Specified by:
encodeUnsignedShortin interfaceEncoder- Parameters:
s- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encode16
public void encode16(short s) throws ExceptionDescription copied from interface:EncoderEncodes a signed short integer. The encoding format is the 2's complement representation encoded in 2 bytes.
-
encodeSignedInt
public void encodeSignedInt(int i) throws ExceptionDescription copied from interface:EncoderEncodes a signed integer. The encoding format depends on the implementation.- Specified by:
encodeSignedIntin interfaceEncoder- Parameters:
i- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeUnsignedInt
public void encodeUnsignedInt(int i) throws ExceptionDescription copied from interface:EncoderEncodes an unsigned integer. The encoding format depends on the implementation.- Specified by:
encodeUnsignedIntin interfaceEncoder- Parameters:
i- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encode32
public void encode32(int i) throws ExceptionDescription copied from interface:EncoderEncodes a signed integer. The encoding format is the 2's complement representation encoded in 4 bytes.
-
encodeSignedLong
public void encodeSignedLong(long l) throws ExceptionDescription copied from interface:EncoderEncodes a signed long integer. The encoding format depends on the implementation.- Specified by:
encodeSignedLongin interfaceEncoder- Parameters:
l- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeUnsignedLong
public void encodeUnsignedLong(long l) throws ExceptionDescription copied from interface:EncoderEncodes an unsigned long integer. The encoding format depends on the implementation.- Specified by:
encodeUnsignedLongin interfaceEncoder- Parameters:
l- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encode64
public void encode64(long l) throws ExceptionDescription copied from interface:EncoderEncodes a signed long integer. The encoding format is the 2's complement representation encoded in 8 bytes.
-
encodeNullableString
public void encodeNullableString(String str) throws Exception
Description copied from interface:EncoderEncodes a string that can be null. Be careful, since Joram 5.19, by default String are encoded using UTF-8.- Specified by:
encodeNullableStringin interfaceEncoder- Parameters:
str- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeString
public void encodeString(String str) throws Exception
Description copied from interface:EncoderEncodes a string that cannot be null. Be careful, since Joram 5.19, by default String are encoded using UTF-8.- Specified by:
encodeStringin interfaceEncoder- Parameters:
str- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeNullableByteArray
public void encodeNullableByteArray(byte[] tab) throws ExceptionDescription copied from interface:EncoderEncodes a byte array that can be null.- Specified by:
encodeNullableByteArrayin interfaceEncoder- Parameters:
tab- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeByteArray
public void encodeByteArray(byte[] tab) throws ExceptionDescription copied from interface:EncoderEncodes a byte array that cannot be null.- Specified by:
encodeByteArrayin interfaceEncoder- Parameters:
tab- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeNullableByteArray
public void encodeNullableByteArray(byte[] tab, int offset, int length) throws ExceptionDescription copied from interface:EncoderEncodes a byte array that can be null.- Specified by:
encodeNullableByteArrayin interfaceEncoder- Parameters:
tab- the value to encodeoffset- the starting index in array blength- the number of bytes to be encoded- Throws:
Exception- if an error occurs during encoding
-
encodeByteArray
public void encodeByteArray(byte[] tab, int offset, int length) throws ExceptionDescription copied from interface:EncoderEncodes a byte array that cannot be null.- Specified by:
encodeByteArrayin interfaceEncoder- Parameters:
tab- the value to encodeoffset- the starting index in array blength- the number of bytes to be encoded- Throws:
Exception- if an error occurs during encoding
-
encodeFloat
public void encodeFloat(float f) throws ExceptionDescription copied from interface:EncoderEncodes a float.- Specified by:
encodeFloatin interfaceEncoder- Parameters:
f- the value to encode- Throws:
Exception- if an error occurs during encoding
-
encodeDouble
public void encodeDouble(double d) throws ExceptionDescription copied from interface:EncoderEncodes a double.- Specified by:
encodeDoublein interfaceEncoder- Parameters:
d- the value to encode- Throws:
Exception- if an error occurs during encoding
-
-