Package org.firebirdsql.gds.ng
Class DefaultDatatypeCoder
- java.lang.Object
-
- org.firebirdsql.gds.ng.DefaultDatatypeCoder
-
- All Implemented Interfaces:
DatatypeCoder
- Direct Known Subclasses:
BigEndianDatatypeCoder,LittleEndianDatatypeCoder
public class DefaultDatatypeCoder extends java.lang.Object implements DatatypeCoder
The default datatype coder.Implements the encoding and decoding for the wire protocol.
As a lot of the implementation also applies to the big endian and little endian decoders for the JNA implementation, this class is not placed in package
org.firebirdsql.gds.ng.wire- Since:
- 3.0
- Author:
- Mark Rotteveel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.firebirdsql.gds.ng.DatatypeCoder
DatatypeCoder.RawDateTimeStruct
-
-
Field Summary
-
Fields inherited from interface org.firebirdsql.gds.ng.DatatypeCoder
FRACTIONS_PER_HOUR, FRACTIONS_PER_MILLISECOND, FRACTIONS_PER_MINUTE, FRACTIONS_PER_SECOND, NANOSECONDS_PER_FRACTION
-
-
Constructor Summary
Constructors Constructor Description DefaultDatatypeCoder(IEncodingFactory encodingFactory)Creates a default datatype coder for the wire protocol.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.ReadercreateReader(java.io.InputStream inputStream)Creates a reader wrapping an input stream.java.io.WritercreateWriter(java.io.OutputStream outputStream)Creates a writer wrapping an input stream.booleandecodeBoolean(byte[] data)Decode boolean from supplied data.java.sql.DatedecodeDate(java.sql.Date d, java.util.Calendar cal)Decode aDatevalue using a givenCalendar.java.sql.DatedecodeDateCalendar(byte[] byte_int, java.util.Calendar c)Decode abytearray into aDatevalue.DatatypeCoder.RawDateTimeStructdecodeDateRaw(byte[] byte_int)Decode abytearray into a raw date time struct.Decimal128decodeDecimal128(byte[] data)Decodes a decimal128 from byte array.Decimal64decodeDecimal64(byte[] data)Decodes a decimal64 from byte array.doubledecodeDouble(byte[] byte_int)Decode abytearray into adoublevalue.floatdecodeFloat(byte[] byte_int)Decode abytearray into afloatvalue.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.java.time.LocalDatedecodeLocalDate(byte[] data)Decode LocalDate from supplied data.java.time.LocalDateTimedecodeLocalDateTime(byte[] data)Decode LocalDateTime from supplied data.java.time.LocalTimedecodeLocalTime(byte[] data)Decode LocalTime from supplied data.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.java.lang.StringdecodeString(byte[] value)Decode an encodedbytearray into aStringusing the encoding of this datatype coder.java.sql.TimedecodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)Decode aTimevalue using a givenCalendar.java.sql.TimedecodeTimeCalendar(byte[] int_byte, java.util.Calendar c)Decode abytearray into aTimevalue.DatatypeCoder.RawDateTimeStructdecodeTimeRaw(byte[] int_byte)Decode abytearray into a raw date time struct.java.sql.TimestampdecodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)Decode aTimestampvalue using a givenCalendar.java.sql.TimestampdecodeTimestampCalendar(byte[] byte_long, java.util.Calendar c)Decode an 8-bytebytearray into aTimestamp.DatatypeCoder.RawDateTimeStructdecodeTimestampRaw(byte[] byte_long)Decode an 8-bytebytearray into a raw date time struct.byte[]encodeBoolean(boolean value)Encodes boolean to 1 byte data.java.sql.DateencodeDate(java.sql.Date d, java.util.Calendar cal)Encode a givenDatevalue using a givenCalendar.byte[]encodeDateCalendar(java.sql.Date d, java.util.Calendar c)Encode aDatevalue into abytearray.byte[]encodeDateRaw(DatatypeCoder.RawDateTimeStruct raw)Encode the date portion of a raw date time struct into abytearray.byte[]encodeDecimal128(Decimal128 decimal128)Encodes a decimal128 to a byte array.byte[]encodeDecimal64(Decimal64 decimal64)Encodes a decimal64 to a byte array.byte[]encodeDouble(double value)Encode adoublevalue as abytearray.byte[]encodeFloat(float value)Encode afloatvalue as abytearray.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[]encodeLocalDate(java.time.LocalDate value)Encodes a java.time.LocalDate to date bytes.byte[]encodeLocalDateTime(java.time.LocalDateTime value)Encodes a java.time.LocalDateTime to timestamp bytes.byte[]encodeLocalTime(java.time.LocalTime value)Encodes a java.time.LocalTime to time bytes.byte[]encodeLong(long value)Encode alongvalue as abytearray.byte[]encodeShort(int value)Encode ashortvalue 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.byte[]encodeString(java.lang.String value)Encode aStringvalue into abytearray using the encoding of this datatype coder.java.sql.TimeencodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)Encode a givenTimevalue using a givenCalendar.byte[]encodeTimeCalendar(java.sql.Time d, java.util.Calendar c)Encode aTimevalue into abytearray.byte[]encodeTimeRaw(DatatypeCoder.RawDateTimeStruct raw)Encode the time portion of a raw date time struct into abytearray.java.sql.TimestampencodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)Encode aTimestampusing a givenCalendar.byte[]encodeTimestampCalendar(java.sql.Timestamp value, java.util.Calendar c)Encode aTimestampas abytearray.byte[]encodeTimestampRaw(DatatypeCoder.RawDateTimeStruct raw)Encode the date and time portions of a raw date time struct into abytearray.booleanequals(java.lang.Object o)DatatypeCoderforEncodingDefinition(EncodingDefinition encodingDefinition)Return a derived datatype coder that applies the supplied encoding definition for string conversions.static DefaultDatatypeCoderforEncodingFactory(IEncodingFactory encodingFactory)Returns an instance ofDefaultDatatypeCoderfor an encoding factory.EncodinggetEncoding()EncodingDefinitiongetEncodingDefinition()IEncodingFactorygetEncodingFactory()inthashCode()protected byte[]intToBytes(int value)Encode anintvalue as abytearray in network-order(big-endian) representation.intsizeOfShort()The size of an encoded short in this data type coder.DatatypeCoderunwrap()Unwrap this datatype coder to its parent (or itself).
-
-
-
Constructor Detail
-
DefaultDatatypeCoder
public DefaultDatatypeCoder(IEncodingFactory encodingFactory)
Creates a default datatype coder for the wire protocol.In almost all cases, it is better to use
forEncodingFactory(IEncodingFactory).- Parameters:
encodingFactory- Encoding factory
-
-
Method Detail
-
forEncodingFactory
public static DefaultDatatypeCoder forEncodingFactory(IEncodingFactory encodingFactory)
Returns an instance ofDefaultDatatypeCoderfor an encoding factory.- Parameters:
encodingFactory- Encoding factory- Returns:
- Datatype coder, this might be a cached instance
-
sizeOfShort
public int sizeOfShort()
Description copied from interface:DatatypeCoderThe size of an encoded short in this data type coder.- Specified by:
sizeOfShortin interfaceDatatypeCoder- Returns:
- The size of an encoded short (either
2or4bytes)
-
encodeShort
public byte[] encodeShort(short value)
Description copied from interface:DatatypeCoderEncode ashortvalue as abytearray.- Specified by:
encodeShortin interfaceDatatypeCoder- Parameters:
value- The value to be encoded- Returns:
- The value of
valueencoded as abytearray - See Also:
DatatypeCoder.encodeShort(int)
-
encodeShort
public byte[] encodeShort(int value)
Description copied from interface:DatatypeCoderEncode ashortvalue as abytearray.- Specified by:
encodeShortin interfaceDatatypeCoder- Parameters:
value- The value to be encoded- Returns:
- The value of
valueencoded as abytearray
-
encodeShort
public void encodeShort(int value, byte[] target, int fromIndex)Description copied from interface:DatatypeCoderEncode ashortvalue into thetargetbyte array starting at indexfromIndex.- Specified by:
encodeShortin interfaceDatatypeCoder- Parameters:
value- The value to be encodedtarget- Target byte array of sufficient size (warning: this may be datatype coder specific)fromIndex- Index to start writing
-
decodeShort
public short decodeShort(byte[] byte_int)
Description copied from interface:DatatypeCoderDecode abytearray into ashortvalue.- Specified by:
decodeShortin interfaceDatatypeCoder- Parameters:
byte_int- Thebytearray to be decoded- Returns:
- The
shortvalue of the decodedbytearray
-
decodeShort
public short decodeShort(byte[] bytes, int fromIndex)Description copied from interface:DatatypeCoderDecode from abytearray to ashortvalue.- Specified by:
decodeShortin interfaceDatatypeCoder- Parameters:
bytes- Thebytearray to be decodedfromIndex- The index to start reading- Returns:
- The
shortvalue of the decodedbytearray
-
encodeInt
public byte[] encodeInt(int value)
Description copied from interface:DatatypeCoderEncode anintvalue as abytearray.- Specified by:
encodeIntin interfaceDatatypeCoder- Parameters:
value- The value to be encoded- Returns:
- The value of
valueencoded as abytearray
-
encodeInt
public void encodeInt(int value, byte[] target, int fromIndex)Description copied from interface:DatatypeCoderEncode anintvalue into thetargetbyte array starting at indexfromIndex.- Specified by:
encodeIntin interfaceDatatypeCoder- Parameters:
value- The value to be encodedtarget- Target byte array of sufficient sizefromIndex- Index to start writing
-
intToBytes
protected byte[] intToBytes(int value)
Encode anintvalue as abytearray in network-order(big-endian) representation.- Parameters:
value- The value to be encoded- Returns:
- The value of
valueencoded as abytearray
-
decodeInt
public int decodeInt(byte[] byte_int)
Description copied from interface:DatatypeCoderDecode abytearray into anintvalue.- Specified by:
decodeIntin interfaceDatatypeCoder- Parameters:
byte_int- Thebytearray to be decoded- Returns:
- The
intvalue of the decodedbytearray
-
decodeInt
public int decodeInt(byte[] bytes, int fromIndex)Description copied from interface:DatatypeCoderDecode abytearray to anintvalue.- Specified by:
decodeIntin interfaceDatatypeCoder- Parameters:
bytes- Thebytearray to be decodedfromIndex- The index to start reading- Returns:
- The
intvalue of the decodedbytearray
-
encodeLong
public byte[] encodeLong(long value)
Description copied from interface:DatatypeCoderEncode alongvalue as abytearray.- Specified by:
encodeLongin interfaceDatatypeCoder- Parameters:
value- The value to be encoded- Returns:
- The value of
valueencoded as abytearray
-
decodeLong
public long decodeLong(byte[] byte_int)
Description copied from interface:DatatypeCoderDecode abytearray into alongvalue.- Specified by:
decodeLongin interfaceDatatypeCoder- Parameters:
byte_int- Thebytearray to be decoded- Returns:
- The
longvalue of the decodedbytearray
-
encodeFloat
public byte[] encodeFloat(float value)
Description copied from interface:DatatypeCoderEncode afloatvalue as abytearray.- Specified by:
encodeFloatin interfaceDatatypeCoder- Parameters:
value- The value to be encoded- Returns:
- The value of
valueencoded as abytearray
-
decodeFloat
public float decodeFloat(byte[] byte_int)
Description copied from interface:DatatypeCoderDecode abytearray into afloatvalue.- Specified by:
decodeFloatin interfaceDatatypeCoder- Parameters:
byte_int- Thebytearray to be decoded- Returns:
- The
floatvalue of the decodedbytearray
-
encodeDouble
public byte[] encodeDouble(double value)
Description copied from interface:DatatypeCoderEncode adoublevalue as abytearray.- Specified by:
encodeDoublein interfaceDatatypeCoder- Parameters:
value- The value to be encoded- Returns:
- The value of
valueencoded as abytearray
-
decodeDouble
public double decodeDouble(byte[] byte_int)
Description copied from interface:DatatypeCoderDecode abytearray into adoublevalue.- Specified by:
decodeDoublein interfaceDatatypeCoder- Parameters:
byte_int- Thebytearray to be decoded- Returns:
- The
doublevalue of the decodedbytearray
-
encodeString
public final byte[] encodeString(java.lang.String value)
Description copied from interface:DatatypeCoderEncode aStringvalue into abytearray using the encoding of this datatype coder.- Specified by:
encodeStringin interfaceDatatypeCoder- Parameters:
value- TheStringto be encoded- Returns:
- The value of
valueas abytearray
-
createWriter
public final java.io.Writer createWriter(java.io.OutputStream outputStream)
Description copied from interface:DatatypeCoderCreates a writer wrapping an input stream.- Specified by:
createWriterin interfaceDatatypeCoder- Parameters:
outputStream- Input stream- Returns:
- Writer applying the encoding of this datatype when writing
-
decodeString
public final java.lang.String decodeString(byte[] value)
Description copied from interface:DatatypeCoderDecode an encodedbytearray into aStringusing the encoding of this datatype coder.- Specified by:
decodeStringin interfaceDatatypeCoder- Parameters:
value- The value to be decoded- Returns:
- The decoded
String
-
createReader
public final java.io.Reader createReader(java.io.InputStream inputStream)
Description copied from interface:DatatypeCoderCreates a reader wrapping an input stream.- Specified by:
createReaderin interfaceDatatypeCoder- Parameters:
inputStream- Input stream- Returns:
- Reader applying the encoding of this datatype coder when reading
-
encodeTimestamp
public java.sql.Timestamp encodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)Description copied from interface:DatatypeCoderEncode aTimestampusing a givenCalendar.- Specified by:
encodeTimestampin interfaceDatatypeCoder- Parameters:
value- TheTimestampto be encodedcal- TheCalendarto be used for encoding, may benullinvertTimeZone- Iftrue, the timezone offset value will be subtracted from the encoded value, otherwise it will be added- Returns:
- The encoded
Timestamp
-
encodeTimestampRaw
public byte[] encodeTimestampRaw(DatatypeCoder.RawDateTimeStruct raw)
Description copied from interface:DatatypeCoderEncode the date and time portions of a raw date time struct into abytearray.- Specified by:
encodeTimestampRawin interfaceDatatypeCoder- Parameters:
raw- TheRawDateTimeStructto be encoded- Returns:
- The array of
bytes representing the date and time of the givenRawDateTimeStruct
-
encodeTimestampCalendar
public byte[] encodeTimestampCalendar(java.sql.Timestamp value, java.util.Calendar c)Description copied from interface:DatatypeCoderEncode aTimestampas abytearray.- Specified by:
encodeTimestampCalendarin interfaceDatatypeCoder- Parameters:
value- TheTimestampto be encodedc- Calendar to use for time zone calculation- Returns:
- The array of
bytes that represents the givenTimestampvalue
-
decodeTimestamp
public java.sql.Timestamp decodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)Description copied from interface:DatatypeCoderDecode aTimestampvalue using a givenCalendar.- Specified by:
decodeTimestampin interfaceDatatypeCoder- Parameters:
value- TheTimestampto be decodedcal- TheCalendarto be used in decoding, may benullinvertTimeZone- Iftrue, the timezone offset value will be subtracted from the decoded value, otherwise it will be added- Returns:
- The encoded
Timestamp
-
decodeTimestampRaw
public DatatypeCoder.RawDateTimeStruct decodeTimestampRaw(byte[] byte_long)
Description copied from interface:DatatypeCoderDecode an 8-bytebytearray into a raw date time struct.- Specified by:
decodeTimestampRawin interfaceDatatypeCoder- Parameters:
byte_long- Thebytearray to be decoded- Returns:
- A
DatatypeCoder.RawDateTimeStruct.
-
decodeTimestampCalendar
public java.sql.Timestamp decodeTimestampCalendar(byte[] byte_long, java.util.Calendar c)Description copied from interface:DatatypeCoderDecode an 8-bytebytearray into aTimestamp.- Specified by:
decodeTimestampCalendarin interfaceDatatypeCoder- Parameters:
byte_long- Thebytearray to be decodedc- Calendar to use for time zone calculation- Returns:
- A
Timestampvalue from the decoded bytes
-
encodeTime
public java.sql.Time encodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)Description copied from interface:DatatypeCoderEncode a givenTimevalue using a givenCalendar.- Specified by:
encodeTimein interfaceDatatypeCoder- Parameters:
d- TheTimeto be encodedcal- TheCalendarto be used in the encoding, may benull- Returns:
- The encoded
Time
-
encodeTimeRaw
public byte[] encodeTimeRaw(DatatypeCoder.RawDateTimeStruct raw)
Description copied from interface:DatatypeCoderEncode the time portion of a raw date time struct into abytearray.- Specified by:
encodeTimeRawin interfaceDatatypeCoder- Parameters:
raw- TheRawDateTimeStructto be encoded- Returns:
- The array of
bytes representing the time of the givenRawDateTimeStruct
-
encodeTimeCalendar
public byte[] encodeTimeCalendar(java.sql.Time d, java.util.Calendar c)Description copied from interface:DatatypeCoderEncode aTimevalue into abytearray.- Specified by:
encodeTimeCalendarin interfaceDatatypeCoder- Parameters:
d- TheTimeto be encodedc- Calendar to use for time zone calculation- Returns:
- The array of
bytes representing the givenTime
-
decodeTime
public java.sql.Time decodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)Description copied from interface:DatatypeCoderDecode aTimevalue using a givenCalendar.- Specified by:
decodeTimein interfaceDatatypeCoder- Parameters:
d- TheTimeto be decodedcal- TheCalendarto be used in the decoding, may benull- Returns:
- The decoded
Time
-
decodeTimeRaw
public DatatypeCoder.RawDateTimeStruct decodeTimeRaw(byte[] int_byte)
Description copied from interface:DatatypeCoderDecode abytearray into a raw date time struct.- Specified by:
decodeTimeRawin interfaceDatatypeCoder- Parameters:
int_byte- Thebytearray to be decoded- Returns:
- The
DatatypeCoder.RawDateTimeStruct
-
decodeTimeCalendar
public java.sql.Time decodeTimeCalendar(byte[] int_byte, java.util.Calendar c)Description copied from interface:DatatypeCoderDecode abytearray into aTimevalue.- Specified by:
decodeTimeCalendarin interfaceDatatypeCoder- Parameters:
int_byte- Thebytearray to be decodedc- Calendar to use for time zone calculation- Returns:
- The decoded
Time
-
encodeDate
public java.sql.Date encodeDate(java.sql.Date d, java.util.Calendar cal)Description copied from interface:DatatypeCoderEncode a givenDatevalue using a givenCalendar.- Specified by:
encodeDatein interfaceDatatypeCoder- Parameters:
d- TheDateto be encodedcal- TheCalendarto be used in the encoding, may benull- Returns:
- The encoded
Date
-
encodeDateRaw
public byte[] encodeDateRaw(DatatypeCoder.RawDateTimeStruct raw)
Description copied from interface:DatatypeCoderEncode the date portion of a raw date time struct into abytearray.- Specified by:
encodeDateRawin interfaceDatatypeCoder- Parameters:
raw- TheRawDateTimeStructto be encoded- Returns:
- The array of
bytes representing the date of the givenRawDateTimeStruct
-
encodeDateCalendar
public byte[] encodeDateCalendar(java.sql.Date d, java.util.Calendar c)Description copied from interface:DatatypeCoderEncode aDatevalue into abytearray.- Specified by:
encodeDateCalendarin interfaceDatatypeCoder- Parameters:
d- TheDateto be encodedc- Calendar to use for time zone calculation- Returns:
- The array of
bytes representing the givenDate
-
decodeDate
public java.sql.Date decodeDate(java.sql.Date d, java.util.Calendar cal)Description copied from interface:DatatypeCoderDecode aDatevalue using a givenCalendar.- Specified by:
decodeDatein interfaceDatatypeCoder- Parameters:
d- TheDateto be decodedcal- TheCalendarto be used in the decoding, may benull- Returns:
- The decoded
Date
-
decodeDateRaw
public DatatypeCoder.RawDateTimeStruct decodeDateRaw(byte[] byte_int)
Description copied from interface:DatatypeCoderDecode abytearray into a raw date time struct.- Specified by:
decodeDateRawin interfaceDatatypeCoder- Parameters:
byte_int- Thebytearray to be decoded- Returns:
- The
DatatypeCoder.RawDateTimeStruct
-
decodeDateCalendar
public java.sql.Date decodeDateCalendar(byte[] byte_int, java.util.Calendar c)Description copied from interface:DatatypeCoderDecode abytearray into aDatevalue.- Specified by:
decodeDateCalendarin interfaceDatatypeCoder- Parameters:
byte_int- Thebytearray to be decodedc- Calendar to use for time zone calculation- Returns:
- The decoded
Date
-
decodeBoolean
public boolean decodeBoolean(byte[] data)
Description copied from interface:DatatypeCoderDecode boolean from supplied data.- Specified by:
decodeBooleanin interfaceDatatypeCoder- Parameters:
data- (expected) 1 bytes- Returns:
falsewhen 0,truefor all other values
-
encodeBoolean
public byte[] encodeBoolean(boolean value)
Description copied from interface:DatatypeCoderEncodes boolean to 1 byte data.- Specified by:
encodeBooleanin interfaceDatatypeCoder- Parameters:
value- Boolean value to encode- Returns:
trueas 1,falseas 0.
-
decodeLocalTime
public java.time.LocalTime decodeLocalTime(byte[] data)
Description copied from interface:DatatypeCoderDecode LocalTime from supplied data.- Specified by:
decodeLocalTimein interfaceDatatypeCoder- Parameters:
data- (expected) 4 bytes- Returns:
- LocalTime value
-
encodeLocalTime
public byte[] encodeLocalTime(java.time.LocalTime value)
Description copied from interface:DatatypeCoderEncodes a java.time.LocalTime to time bytes.- Specified by:
encodeLocalTimein interfaceDatatypeCoder- Parameters:
value- LocalTime value to encode- Returns:
- Byte array for time
-
decodeLocalDate
public java.time.LocalDate decodeLocalDate(byte[] data)
Description copied from interface:DatatypeCoderDecode LocalDate from supplied data.- Specified by:
decodeLocalDatein interfaceDatatypeCoder- Parameters:
data- (expected) 4 bytes- Returns:
- LocalDate value
-
encodeLocalDate
public byte[] encodeLocalDate(java.time.LocalDate value)
Description copied from interface:DatatypeCoderEncodes a java.time.LocalDate to date bytes.- Specified by:
encodeLocalDatein interfaceDatatypeCoder- Parameters:
value- LocalDate to encode- Returns:
- Byte array for date
-
decodeLocalDateTime
public java.time.LocalDateTime decodeLocalDateTime(byte[] data)
Description copied from interface:DatatypeCoderDecode LocalDateTime from supplied data.- Specified by:
decodeLocalDateTimein interfaceDatatypeCoder- Parameters:
data- (expected) 8 bytes- Returns:
- LocalDateTime value
-
encodeLocalDateTime
public byte[] encodeLocalDateTime(java.time.LocalDateTime value)
Description copied from interface:DatatypeCoderEncodes a java.time.LocalDateTime to timestamp bytes.- Specified by:
encodeLocalDateTimein interfaceDatatypeCoder- Parameters:
value- LocalDateTime to encode- Returns:
- Byte array for date
-
decodeDecimal64
public Decimal64 decodeDecimal64(byte[] data)
Description copied from interface:DatatypeCoderDecodes a decimal64 from byte array.- Specified by:
decodeDecimal64in interfaceDatatypeCoder- Parameters:
data- Data to decode (expected 8 bytes)- Returns:
- Decimal64 value
-
encodeDecimal64
public byte[] encodeDecimal64(Decimal64 decimal64)
Description copied from interface:DatatypeCoderEncodes a decimal64 to a byte array.- Specified by:
encodeDecimal64in interfaceDatatypeCoder- Parameters:
decimal64- The decimal64 value to be encoded- Returns:
- Byte array for decimal64 value
-
decodeDecimal128
public Decimal128 decodeDecimal128(byte[] data)
Description copied from interface:DatatypeCoderDecodes a decimal128 from byte array.- Specified by:
decodeDecimal128in interfaceDatatypeCoder- Parameters:
data- Data to decode (expected 16 bytes)- Returns:
- Decimal128 value
-
encodeDecimal128
public byte[] encodeDecimal128(Decimal128 decimal128)
Description copied from interface:DatatypeCoderEncodes a decimal128 to a byte array.- Specified by:
encodeDecimal128in interfaceDatatypeCoder- Parameters:
decimal128- The decimal128 value to be encoded- Returns:
- Byte array for decimal128 value
-
decodeInt128
public java.math.BigInteger decodeInt128(byte[] data)
Description copied from interface:DatatypeCoderDecodes a BigInteger from byte array.- Specified by:
decodeInt128in interfaceDatatypeCoder- Parameters:
data- Data to decode (expected 16 bytes)- Returns:
- BigInteger value
-
encodeInt128
public 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 interfaceDatatypeCoder- Parameters:
bigInteger- The BigInteger value to be encoded- Returns:
- Byte array for bigInteger value
-
getEncodingFactory
public final IEncodingFactory getEncodingFactory()
- Specified by:
getEncodingFactoryin interfaceDatatypeCoder- Returns:
- The encoding factory.
-
getEncodingDefinition
public final EncodingDefinition getEncodingDefinition()
- Specified by:
getEncodingDefinitionin interfaceDatatypeCoder- Returns:
- The encoding definition used by this datatype coder for string conversions.
-
getEncoding
public final Encoding getEncoding()
- Specified by:
getEncodingin interfaceDatatypeCoder- Returns:
- The encoding used by this datatype coder for string conversions.
-
forEncodingDefinition
public final DatatypeCoder forEncodingDefinition(EncodingDefinition encodingDefinition)
Description copied from interface:DatatypeCoderReturn a derived datatype coder that applies the supplied encoding definition for string conversions.- Specified by:
forEncodingDefinitionin interfaceDatatypeCoder- Parameters:
encodingDefinition- Encoding definition- Returns:
- Derived datatype coder (this instance, if encoding definition is the same)
-
unwrap
public DatatypeCoder unwrap()
Description copied from interface:DatatypeCoderUnwrap this datatype coder to its parent (or itself).- Specified by:
unwrapin interfaceDatatypeCoder- Returns:
- Return the parent of this datatype code, or itself if it has no parent.
-
equals
public final boolean equals(java.lang.Object o)
Description copied from interface:DatatypeCoderEquality: same basic type (ie: wire protocol/JNA type + endianness) and same encoding definition.
This does not need to take into account the encoding factory, as usage should be limited to datatype coders derived from the same connection.
- Specified by:
equalsin interfaceDatatypeCoder- Overrides:
equalsin classjava.lang.Object- Parameters:
o- Object to compare to- Returns:
trueif other is an equivalent datatype coder.
-
hashCode
public final int hashCode()
- Specified by:
hashCodein interfaceDatatypeCoder- Overrides:
hashCodein classjava.lang.Object
-
-