Package org.firebirdsql.gds.ng.jna
Class LittleEndianDatatypeCoder
- java.lang.Object
- 
- org.firebirdsql.gds.ng.DefaultDatatypeCoder
- 
- org.firebirdsql.gds.ng.jna.LittleEndianDatatypeCoder
 
 
- 
- All Implemented Interfaces:
- DatatypeCoder
 
 public final class LittleEndianDatatypeCoder extends DefaultDatatypeCoder Datatype encoder and decoder for little endian platforms, specifically for use with the Firebird client library.For wire protocol use DefaultDatatypeCoder.- Since:
- 3.0
- Author:
- Mark Rotteveel
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.firebirdsql.gds.ng.DatatypeCoderDatatypeCoder.RawDateTimeStruct
 
- 
 - 
Field Summary- 
Fields inherited from interface org.firebirdsql.gds.ng.DatatypeCoderFRACTIONS_PER_HOUR, FRACTIONS_PER_MILLISECOND, FRACTIONS_PER_MINUTE, FRACTIONS_PER_SECOND, NANOSECONDS_PER_FRACTION
 
- 
 - 
Constructor SummaryConstructors Constructor Description LittleEndianDatatypeCoder(IEncodingFactory encodingFactory)Creates a little-endian datatype coder for native access on little-endian platforms.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Decimal128decodeDecimal128(byte[] data)Decodes a decimal128 from byte array.Decimal64decodeDecimal64(byte[] data)Decodes a decimal64 from byte array.intdecodeInt(byte[] byte_int)Decode abytearray into anintvalue.intdecodeInt(byte[] bytes, int fromIndex)Decode abytearray to anintvalue.java.math.BigIntegerdecodeInt128(byte[] data)Decodes a BigInteger from byte array.longdecodeLong(byte[] byte_int)Decode abytearray into alongvalue.shortdecodeShort(byte[] byte_int)Decode abytearray into ashortvalue.shortdecodeShort(byte[] bytes, int fromIndex)Decode from abytearray to ashortvalue.byte[]encodeDecimal128(Decimal128 decimal128)Encodes a decimal128 to a byte array.byte[]encodeDecimal64(Decimal64 decimal64)Encodes a decimal64 to a byte array.byte[]encodeInt(int value)Encode anintvalue as abytearray.voidencodeInt(int value, byte[] target, int fromIndex)Encode anintvalue into thetargetbyte array starting at indexfromIndex.byte[]encodeInt128(java.math.BigInteger bigInteger)Encodes a BigInteger to a 16-byte byte array.byte[]encodeLong(long value)Encode alongvalue as abytearray.voidencodeShort(int value, byte[] target, int fromIndex)Encode ashortvalue into thetargetbyte array starting at indexfromIndex.byte[]encodeShort(short value)Encode ashortvalue as abytearray.static LittleEndianDatatypeCoderforEncodingFactory(IEncodingFactory encodingFactory)Returns an instance ofLittleEndianDatatypeCoderfor an encoding factory.intsizeOfShort()The size of an encoded short in this data type coder.- 
Methods inherited from class org.firebirdsql.gds.ng.DefaultDatatypeCodercreateReader, createWriter, decodeBoolean, decodeDate, decodeDate, decodeDateCalendar, decodeDateRaw, decodeDouble, decodeFloat, decodeString, decodeTime, decodeTime, decodeTimeCalendar, decodeTimeRaw, decodeTimestamp, decodeTimestamp, decodeTimestamp, decodeTimestampCalendar, decodeTimestampRaw, encodeBoolean, encodeDate, encodeDate, encodeDateCalendar, encodeDateRaw, encodeDouble, encodeFloat, encodeLocalDate, encodeLocalDateTime, encodeLocalTime, encodeShort, encodeString, encodeTime, encodeTime, encodeTimeCalendar, encodeTimeRaw, encodeTimestamp, encodeTimestamp, encodeTimestamp, encodeTimestampCalendar, encodeTimestampRaw, equals, forEncodingDefinition, getEncoding, getEncodingDefinition, getEncodingFactory, hashCode, intToBytes, unwrap
 
- 
 
- 
- 
- 
Constructor Detail- 
LittleEndianDatatypeCoderpublic LittleEndianDatatypeCoder(IEncodingFactory encodingFactory) Creates a little-endian datatype coder for native access on little-endian platforms.In almost all cases, it is better to use forEncodingFactory(IEncodingFactory).- Parameters:
- encodingFactory- Encoding factory
 
 
- 
 - 
Method Detail- 
forEncodingFactorypublic static LittleEndianDatatypeCoder forEncodingFactory(IEncodingFactory encodingFactory) Returns an instance ofLittleEndianDatatypeCoderfor an encoding factory.- Parameters:
- encodingFactory- Encoding factory
- Returns:
- Datatype coder, this might be a cached instance
 
 - 
sizeOfShortpublic int sizeOfShort() Description copied from interface:DatatypeCoderThe size of an encoded short in this data type coder.- Specified by:
- sizeOfShortin interface- DatatypeCoder
- Overrides:
- sizeOfShortin class- DefaultDatatypeCoder
- Returns:
- The size of an encoded short (either 2or4bytes)
 
 - 
encodeShortpublic byte[] encodeShort(short value) Description copied from interface:DatatypeCoderEncode ashortvalue as abytearray.- Specified by:
- encodeShortin interface- DatatypeCoder
- Overrides:
- encodeShortin class- DefaultDatatypeCoder
- Parameters:
- value- The value to be encoded
- Returns:
- The value of valueencoded as abytearray
- See Also:
- DatatypeCoder.encodeShort(int)
 
 - 
encodeShortpublic void encodeShort(int value, byte[] target, int fromIndex)Description copied from interface:DatatypeCoderEncode ashortvalue into thetargetbyte array starting at indexfromIndex.- Specified by:
- encodeShortin interface- DatatypeCoder
- Overrides:
- encodeShortin class- DefaultDatatypeCoder
- Parameters:
- value- The value to be encoded
- target- Target byte array of sufficient size (warning: this may be datatype coder specific)
- fromIndex- Index to start writing
 
 - 
decodeShortpublic short decodeShort(byte[] byte_int) Description copied from interface:DatatypeCoderDecode abytearray into ashortvalue.- Specified by:
- decodeShortin interface- DatatypeCoder
- Overrides:
- decodeShortin class- DefaultDatatypeCoder
- Parameters:
- byte_int- The- bytearray to be decoded
- Returns:
- The shortvalue of the decodedbytearray
 
 - 
decodeShortpublic short decodeShort(byte[] bytes, int fromIndex)Description copied from interface:DatatypeCoderDecode from abytearray to ashortvalue.- Specified by:
- decodeShortin interface- DatatypeCoder
- Overrides:
- decodeShortin class- DefaultDatatypeCoder
- Parameters:
- bytes- The- bytearray to be decoded
- fromIndex- The index to start reading
- Returns:
- The shortvalue of the decodedbytearray
 
 - 
encodeIntpublic byte[] encodeInt(int value) Description copied from interface:DatatypeCoderEncode anintvalue as abytearray.- Specified by:
- encodeIntin interface- DatatypeCoder
- Overrides:
- encodeIntin class- DefaultDatatypeCoder
- Parameters:
- value- The value to be encoded
- Returns:
- The value of valueencoded as abytearray
 
 - 
encodeIntpublic void encodeInt(int value, byte[] target, int fromIndex)Description copied from interface:DatatypeCoderEncode anintvalue into thetargetbyte array starting at indexfromIndex.- Specified by:
- encodeIntin interface- DatatypeCoder
- Overrides:
- encodeIntin class- DefaultDatatypeCoder
- Parameters:
- value- The value to be encoded
- target- Target byte array of sufficient size
- fromIndex- Index to start writing
 
 - 
decodeIntpublic int decodeInt(byte[] byte_int) Description copied from interface:DatatypeCoderDecode abytearray into anintvalue.- Specified by:
- decodeIntin interface- DatatypeCoder
- Overrides:
- decodeIntin class- DefaultDatatypeCoder
- Parameters:
- byte_int- The- bytearray to be decoded
- Returns:
- The intvalue of the decodedbytearray
 
 - 
decodeIntpublic int decodeInt(byte[] bytes, int fromIndex)Description copied from interface:DatatypeCoderDecode abytearray to anintvalue.- Specified by:
- decodeIntin interface- DatatypeCoder
- Overrides:
- decodeIntin class- DefaultDatatypeCoder
- Parameters:
- bytes- The- bytearray to be decoded
- fromIndex- The index to start reading
- Returns:
- The intvalue of the decodedbytearray
 
 - 
encodeLongpublic byte[] encodeLong(long value) Description copied from interface:DatatypeCoderEncode alongvalue as abytearray.- Specified by:
- encodeLongin interface- DatatypeCoder
- Overrides:
- encodeLongin class- DefaultDatatypeCoder
- Parameters:
- value- The value to be encoded
- Returns:
- The value of valueencoded as abytearray
 
 - 
decodeLongpublic long decodeLong(byte[] byte_int) Description copied from interface:DatatypeCoderDecode abytearray into alongvalue.- Specified by:
- decodeLongin interface- DatatypeCoder
- Overrides:
- decodeLongin class- DefaultDatatypeCoder
- Parameters:
- byte_int- The- bytearray to be decoded
- Returns:
- The longvalue of the decodedbytearray
 
 - 
decodeDecimal64public Decimal64 decodeDecimal64(byte[] data) Description copied from interface:DatatypeCoderDecodes a decimal64 from byte array.- Specified by:
- decodeDecimal64in interface- DatatypeCoder
- Overrides:
- decodeDecimal64in class- DefaultDatatypeCoder
- Parameters:
- data- Data to decode (expected 8 bytes)
- Returns:
- Decimal64 value
 
 - 
encodeDecimal64public byte[] encodeDecimal64(Decimal64 decimal64) Description copied from interface:DatatypeCoderEncodes a decimal64 to a byte array.- Specified by:
- encodeDecimal64in interface- DatatypeCoder
- Overrides:
- encodeDecimal64in class- DefaultDatatypeCoder
- Parameters:
- decimal64- The decimal64 value to be encoded
- Returns:
- Byte array for decimal64 value
 
 - 
decodeDecimal128public Decimal128 decodeDecimal128(byte[] data) Description copied from interface:DatatypeCoderDecodes a decimal128 from byte array.- Specified by:
- decodeDecimal128in interface- DatatypeCoder
- Overrides:
- decodeDecimal128in class- DefaultDatatypeCoder
- Parameters:
- data- Data to decode (expected 16 bytes)
- Returns:
- Decimal128 value
 
 - 
encodeDecimal128public byte[] encodeDecimal128(Decimal128 decimal128) Description copied from interface:DatatypeCoderEncodes a decimal128 to a byte array.- Specified by:
- encodeDecimal128in interface- DatatypeCoder
- Overrides:
- encodeDecimal128in class- DefaultDatatypeCoder
- Parameters:
- decimal128- The decimal128 value to be encoded
- Returns:
- Byte array for decimal128 value
 
 - 
decodeInt128public java.math.BigInteger decodeInt128(byte[] data) Description copied from interface:DatatypeCoderDecodes a BigInteger from byte array.- Specified by:
- decodeInt128in interface- DatatypeCoder
- Overrides:
- decodeInt128in class- DefaultDatatypeCoder
- Parameters:
- data- Data to decode (expected 16 bytes)
- Returns:
- BigInteger value
 
 - 
encodeInt128public byte[] encodeInt128(java.math.BigInteger bigInteger) Description copied from interface:DatatypeCoderEncodes a BigInteger to a 16-byte byte array.The implementation expects to be passed a value that fits in 16 bytes. If a larger value is passed, and IllegalArgumentExceptionis thrown.- Specified by:
- encodeInt128in interface- DatatypeCoder
- Overrides:
- encodeInt128in class- DefaultDatatypeCoder
- Parameters:
- bigInteger- The BigInteger value to be encoded
- Returns:
- Byte array for bigInteger value
 
 
- 
 
-