Package fr.dyade.aaa.common.encoding
Class ByteBufferDecoder
- java.lang.Object
-
- fr.dyade.aaa.common.encoding.ByteBufferDecoder
-
-
Field Summary
Fields Modifier and Type Field Description private ByteBufferbuf
-
Constructor Summary
Constructors Constructor Description ByteBufferDecoder(ByteBuffer buf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description shortdecode16()Decodes a signed short integer.intdecode32()Decodes a signed integer.longdecode64()Decodes a signed long integer.booleandecodeBoolean()Decodes a boolean.bytedecodeByte()Decodes a byte.byte[]decodeByteArray()Decodes a byte array that cannot be null.byte[]decodeByteArray(int length)Decodes a byte array that cannot be null.doubledecodeDouble()Decodes a double.floatdecodeFloat()Decodes a float.byte[]decodeNullableByteArray()Decodes a byte array that can be null.StringdecodeNullableString()Decodes a string that can be null.intdecodeSignedInt()Decodes a signed integer.longdecodeSignedLong()Decodes a signed long integer.shortdecodeSignedShort()Decodes a signed short integer.StringdecodeString()Decodes a string that cannot be null.StringdecodeString(int length)Decodes a string that cannot be null.intdecodeUnsignedInt()Decodes an unsigned integer.longdecodeUnsignedLong()Decodes an unsigned long integer.shortdecodeUnsignedShort()Decodes an unsigned short integer.private booleanisNull()
-
-
-
Field Detail
-
buf
private ByteBuffer buf
-
-
Constructor Detail
-
ByteBufferDecoder
public ByteBufferDecoder(ByteBuffer buf)
-
-
Method Detail
-
decodeSignedShort
public short decodeSignedShort() throws ExceptionDescription copied from interface:DecoderDecodes a signed short integer. The encoding format depends on the implementation.- Specified by:
decodeSignedShortin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeUnsignedShort
public short decodeUnsignedShort() throws ExceptionDescription copied from interface:DecoderDecodes an unsigned short integer. The encoding format depends on the implementation.- Specified by:
decodeUnsignedShortin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decode16
public short decode16() throws ExceptionDescription copied from interface:DecoderDecodes a signed short integer. The encoding format is the 2's complement representation encoded in 2 bytes.
-
decodeSignedInt
public int decodeSignedInt() throws ExceptionDescription copied from interface:DecoderDecodes a signed integer. The encoding format depends on the implementation.- Specified by:
decodeSignedIntin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeUnsignedInt
public int decodeUnsignedInt() throws ExceptionDescription copied from interface:DecoderDecodes an unsigned integer. The encoding format depends on the implementation.- Specified by:
decodeUnsignedIntin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decode32
public int decode32() throws ExceptionDescription copied from interface:DecoderDecodes a signed integer. The encoding format is the 2's complement representation encoded in 4 bytes.
-
decodeUnsignedLong
public long decodeUnsignedLong() throws ExceptionDescription copied from interface:DecoderDecodes an unsigned long integer. The encoding format depends on the implementation.- Specified by:
decodeUnsignedLongin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeSignedLong
public long decodeSignedLong() throws ExceptionDescription copied from interface:DecoderDecodes a signed long integer. The encoding format depends on the implementation.- Specified by:
decodeSignedLongin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decode64
public long decode64() throws ExceptionDescription copied from interface:DecoderDecodes a signed long integer. The encoding format is the 2's complement representation encoded in 8 bytes.
-
decodeNullableString
public String decodeNullableString() throws Exception
Description copied from interface:DecoderDecodes a string that can be null. Be careful, since Joram 5.19, by default String are encoded using UTF-8.- Specified by:
decodeNullableStringin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeString
public String decodeString() throws Exception
Description copied from interface:DecoderDecodes a string that cannot be null. Be careful, since Joram 5.19, by default String are encoded using UTF-8.- Specified by:
decodeStringin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeString
public String decodeString(int length) throws Exception
Description copied from interface:DecoderDecodes a string that cannot be null. Be careful, since Joram 5.19, by default String are encoded using UTF-8.- Specified by:
decodeStringin interfaceDecoder- Parameters:
length- the length of the string- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeByte
public byte decodeByte() throws ExceptionDescription copied from interface:DecoderDecodes a byte.- Specified by:
decodeBytein interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeNullableByteArray
public byte[] decodeNullableByteArray() throws ExceptionDescription copied from interface:DecoderDecodes a byte array that can be null.- Specified by:
decodeNullableByteArrayin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeByteArray
public byte[] decodeByteArray() throws ExceptionDescription copied from interface:DecoderDecodes a byte array that cannot be null.- Specified by:
decodeByteArrayin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeByteArray
public byte[] decodeByteArray(int length) throws ExceptionDescription copied from interface:DecoderDecodes a byte array that cannot be null.- Specified by:
decodeByteArrayin interfaceDecoder- Parameters:
length- the length of the array- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeBoolean
public boolean decodeBoolean() throws ExceptionDescription copied from interface:DecoderDecodes a boolean.- Specified by:
decodeBooleanin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeFloat
public float decodeFloat() throws ExceptionDescription copied from interface:DecoderDecodes a float.- Specified by:
decodeFloatin interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
decodeDouble
public double decodeDouble() throws ExceptionDescription copied from interface:DecoderDecodes a double.- Specified by:
decodeDoublein interfaceDecoder- Returns:
- the decoded value
- Throws:
Exception- if an error occurs during decoding
-
-