Package org.firebirdsql.gds.ng
Class EncodingSpecificDatatypeCoder
- java.lang.Object
-
- org.firebirdsql.gds.ng.EncodingSpecificDatatypeCoder
-
- All Implemented Interfaces:
DatatypeCoder
public final class EncodingSpecificDatatypeCoder extends java.lang.Object implements DatatypeCoder
Datatype coder wrapping another datatype coder and applying a specific encoding definition, while delegating other methods to the wrapped datatype coder.- Since:
- 4.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.Reader
createReader(java.io.InputStream inputStream)
Creates a reader wrapping an input stream.java.io.Writer
createWriter(java.io.OutputStream outputStream)
Creates a writer wrapping an input stream.boolean
decodeBoolean(byte[] data)
Decode boolean from supplied data.java.sql.Date
decodeDate(byte[] byte_int)
Decode abyte
array into aDate
value.java.sql.Date
decodeDate(java.sql.Date d, java.util.Calendar cal)
Decode aDate
value using a givenCalendar
.java.sql.Date
decodeDateCalendar(byte[] byte_int, java.util.Calendar c)
DatatypeCoder.RawDateTimeStruct
decodeDateRaw(byte[] byte_int)
Decode abyte
array into a raw date time struct.Decimal128
decodeDecimal128(byte[] data)
Decodes a decimal128 from byte array.Decimal64
decodeDecimal64(byte[] data)
Decodes a decimal64 from byte array.double
decodeDouble(byte[] byte_int)
Decode abyte
array into adouble
value.float
decodeFloat(byte[] byte_int)
Decode abyte
array into afloat
value.int
decodeInt(byte[] byte_int)
Decode abyte
array into anint
value.int
decodeInt(byte[] bytes, int fromIndex)
Decode abyte
array to anint
value.java.math.BigInteger
decodeInt128(byte[] data)
Decodes a BigInteger from byte array.long
decodeLong(byte[] byte_int)
Decode abyte
array into along
value.short
decodeShort(byte[] byte_int)
Decode abyte
array into ashort
value.short
decodeShort(byte[] bytes, int fromIndex)
Decode from abyte
array to ashort
value.java.lang.String
decodeString(byte[] value)
Decode an encodedbyte
array into aString
using the encoding of this datatype coder.java.sql.Time
decodeTime(byte[] int_byte)
Decode abyte
array into aTime
value.java.sql.Time
decodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)
Decode aTime
value using a givenCalendar
.java.sql.Time
decodeTimeCalendar(byte[] int_byte, java.util.Calendar c)
DatatypeCoder.RawDateTimeStruct
decodeTimeRaw(byte[] int_byte)
Decode abyte
array into a raw date time struct.java.sql.Timestamp
decodeTimestamp(byte[] byte_long)
Decode a 8-bytebyte
array into aTimestamp
.java.sql.Timestamp
decodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal)
Decode aTimestamp
value using a givenCalendar
.java.sql.Timestamp
decodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)
Decode aTimestamp
value using a givenCalendar
.java.sql.Timestamp
decodeTimestampCalendar(byte[] byte_long, java.util.Calendar c)
DatatypeCoder.RawDateTimeStruct
decodeTimestampRaw(byte[] byte_long)
Decode a 8-bytebyte
array into a raw date time struct.byte[]
encodeBoolean(boolean value)
Encodes boolean to 1 byte data.byte[]
encodeDate(java.sql.Date d)
Encode aDate
value into abyte
array.java.sql.Date
encodeDate(java.sql.Date d, java.util.Calendar cal)
Encode a givenDate
value using a givenCalendar
.byte[]
encodeDateCalendar(java.sql.Date d, java.util.Calendar c)
byte[]
encodeDateRaw(DatatypeCoder.RawDateTimeStruct raw)
Encode the date portion of a raw date time struct into abyte
array.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 adouble
value as abyte
array.byte[]
encodeFloat(float value)
Encode afloat
value as abyte
array.byte[]
encodeInt(int value)
Encode anint
value as abyte
array.void
encodeInt(int value, byte[] target, int fromIndex)
Encode anint
value into thetarget
byte array starting at indexfromIndex
.byte[]
encodeInt128(java.math.BigInteger bigInteger)
Encodes a BigInteger to a 16-byte byte array.byte[]
encodeLocalDate(int year, int month, int day)
Encodes a java.time.LocalDate equivalent to date bytes.byte[]
encodeLocalDateTime(int year, int month, int day, int hour, int minute, int second, int nanos)
Encodes a java.time.LocalDateTime equivalent to timestamp bytes.byte[]
encodeLocalTime(int hour, int minute, int second, int nanos)
Encodes a java.time.LocalTime equivalent to time bytes.byte[]
encodeLong(long value)
Encode along
value as abyte
array.byte[]
encodeShort(int value)
Encode ashort
value as abyte
array.void
encodeShort(int value, byte[] target, int fromIndex)
Encode ashort
value into thetarget
byte array starting at indexfromIndex
.byte[]
encodeShort(short value)
Encode ashort
value as abyte
array.byte[]
encodeString(java.lang.String value)
Encode aString
value into abyte
array using the encoding of this datatype coder.byte[]
encodeTime(java.sql.Time d)
Encode aTime
value into abyte
array.java.sql.Time
encodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)
Encode a givenTime
value using a givenCalendar
.byte[]
encodeTimeCalendar(java.sql.Time d, java.util.Calendar c)
byte[]
encodeTimeRaw(DatatypeCoder.RawDateTimeStruct raw)
Encode the time portion of a raw date time struct into abyte
array.byte[]
encodeTimestamp(java.sql.Timestamp value)
Encode aTimestamp
as abyte
array.java.sql.Timestamp
encodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal)
Encode aTimestamp
using a givenCalendar
.java.sql.Timestamp
encodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)
Encode aTimestamp
using a givenCalendar
.byte[]
encodeTimestampCalendar(java.sql.Timestamp value, java.util.Calendar c)
byte[]
encodeTimestampRaw(DatatypeCoder.RawDateTimeStruct raw)
Encode the date and time portions of a raw date time struct into abyte
array.boolean
equals(java.lang.Object o)
DatatypeCoder
forEncodingDefinition(EncodingDefinition encodingDefinition)
Return a derived datatype coder that applies the supplied encoding definition for string conversions.Encoding
getEncoding()
EncodingDefinition
getEncodingDefinition()
IEncodingFactory
getEncodingFactory()
int
hashCode()
int
sizeOfShort()
The size of an encoded short in this data type coder.DatatypeCoder
unwrap()
Unwrap this datatype coder to its parent (or itself).
-
-
-
Method Detail
-
encodeString
public byte[] encodeString(java.lang.String value)
Description copied from interface:DatatypeCoder
Encode aString
value into abyte
array using the encoding of this datatype coder.- Specified by:
encodeString
in interfaceDatatypeCoder
- Parameters:
value
- TheString
to be encoded- Returns:
- The value of
value
as abyte
array
-
createWriter
public java.io.Writer createWriter(java.io.OutputStream outputStream)
Description copied from interface:DatatypeCoder
Creates a writer wrapping an input stream.- Specified by:
createWriter
in interfaceDatatypeCoder
- Parameters:
outputStream
- Input stream- Returns:
- Writer applying the encoding of this datatype when writing
-
decodeString
public java.lang.String decodeString(byte[] value)
Description copied from interface:DatatypeCoder
Decode an encodedbyte
array into aString
using the encoding of this datatype coder.- Specified by:
decodeString
in interfaceDatatypeCoder
- Parameters:
value
- The value to be decoded- Returns:
- The decoded
String
-
createReader
public java.io.Reader createReader(java.io.InputStream inputStream)
Description copied from interface:DatatypeCoder
Creates a reader wrapping an input stream.- Specified by:
createReader
in interfaceDatatypeCoder
- Parameters:
inputStream
- Input stream- Returns:
- Reader applying the encoding of this datatype coder when reading
-
forEncodingDefinition
public DatatypeCoder forEncodingDefinition(EncodingDefinition encodingDefinition)
Description copied from interface:DatatypeCoder
Return a derived datatype coder that applies the supplied encoding definition for string conversions.- Specified by:
forEncodingDefinition
in interfaceDatatypeCoder
- Parameters:
encodingDefinition
- Encoding definition- Returns:
- Derived datatype coder (may be this instance if encoding definition is the same)
-
getEncodingDefinition
public EncodingDefinition getEncodingDefinition()
- Specified by:
getEncodingDefinition
in interfaceDatatypeCoder
- Returns:
- The encoding definition used by this datatype coder for string conversions.
-
getEncoding
public Encoding getEncoding()
- Specified by:
getEncoding
in interfaceDatatypeCoder
- Returns:
- The encoding used by this datatype coder for string conversions.
-
unwrap
public DatatypeCoder unwrap()
Description copied from interface:DatatypeCoder
Unwrap this datatype coder to its parent (or itself).- Specified by:
unwrap
in interfaceDatatypeCoder
- Returns:
- Return the parent of this datatype code, or itself if it has no parent.
-
equals
public boolean equals(java.lang.Object o)
Description copied from interface:DatatypeCoder
Equality: 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:
equals
in interfaceDatatypeCoder
- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- Object to compare to- Returns:
true
if other is an equivalent datatype coder.
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceDatatypeCoder
- Overrides:
hashCode
in classjava.lang.Object
-
sizeOfShort
public int sizeOfShort()
Description copied from interface:DatatypeCoder
The size of an encoded short in this data type coder.- Specified by:
sizeOfShort
in interfaceDatatypeCoder
- Returns:
- The size of an encoded short (either
2
or4
bytes)
-
encodeShort
public byte[] encodeShort(short value)
Description copied from interface:DatatypeCoder
Encode ashort
value as abyte
array.- Specified by:
encodeShort
in interfaceDatatypeCoder
- Parameters:
value
- The value to be encoded- Returns:
- The value of
value
encoded as abyte
array - See Also:
DatatypeCoder.encodeShort(int)
-
encodeShort
public byte[] encodeShort(int value)
Description copied from interface:DatatypeCoder
Encode ashort
value as abyte
array.- Specified by:
encodeShort
in interfaceDatatypeCoder
- Parameters:
value
- The value to be encoded- Returns:
- The value of
value
encoded as abyte
array
-
encodeShort
public void encodeShort(int value, byte[] target, int fromIndex)
Description copied from interface:DatatypeCoder
Encode ashort
value into thetarget
byte array starting at indexfromIndex
.- Specified by:
encodeShort
in 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:DatatypeCoder
Decode abyte
array into ashort
value.- Specified by:
decodeShort
in interfaceDatatypeCoder
- Parameters:
byte_int
- Thebyte
array to be decoded- Returns:
- The
short
value of the decodedbyte
array
-
decodeShort
public short decodeShort(byte[] bytes, int fromIndex)
Description copied from interface:DatatypeCoder
Decode from abyte
array to ashort
value.- Specified by:
decodeShort
in interfaceDatatypeCoder
- Parameters:
bytes
- Thebyte
array to be decodedfromIndex
- The index to start reading- Returns:
- The
short
value of the decodedbyte
array
-
encodeInt
public byte[] encodeInt(int value)
Description copied from interface:DatatypeCoder
Encode anint
value as abyte
array.- Specified by:
encodeInt
in interfaceDatatypeCoder
- Parameters:
value
- The value to be encoded- Returns:
- The value of
value
encoded as abyte
array
-
encodeInt
public void encodeInt(int value, byte[] target, int fromIndex)
Description copied from interface:DatatypeCoder
Encode anint
value into thetarget
byte array starting at indexfromIndex
.- Specified by:
encodeInt
in interfaceDatatypeCoder
- Parameters:
value
- The value to be encodedtarget
- Target byte array of sufficient sizefromIndex
- Index to start writing
-
decodeInt
public int decodeInt(byte[] byte_int)
Description copied from interface:DatatypeCoder
Decode abyte
array into anint
value.- Specified by:
decodeInt
in interfaceDatatypeCoder
- Parameters:
byte_int
- Thebyte
array to be decoded- Returns:
- The
int
value of the decodedbyte
array
-
decodeInt
public int decodeInt(byte[] bytes, int fromIndex)
Description copied from interface:DatatypeCoder
Decode abyte
array to anint
value.- Specified by:
decodeInt
in interfaceDatatypeCoder
- Parameters:
bytes
- Thebyte
array to be decodedfromIndex
- The index to start reading- Returns:
- The
int
value of the decodedbyte
array
-
encodeLong
public byte[] encodeLong(long value)
Description copied from interface:DatatypeCoder
Encode along
value as abyte
array.- Specified by:
encodeLong
in interfaceDatatypeCoder
- Parameters:
value
- The value to be encoded- Returns:
- The value of
value
encoded as abyte
array
-
decodeLong
public long decodeLong(byte[] byte_int)
Description copied from interface:DatatypeCoder
Decode abyte
array into along
value.- Specified by:
decodeLong
in interfaceDatatypeCoder
- Parameters:
byte_int
- Thebyte
array to be decoded- Returns:
- The
long
value of the decodedbyte
array
-
encodeFloat
public byte[] encodeFloat(float value)
Description copied from interface:DatatypeCoder
Encode afloat
value as abyte
array.- Specified by:
encodeFloat
in interfaceDatatypeCoder
- Parameters:
value
- The value to be encoded- Returns:
- The value of
value
encoded as abyte
array
-
decodeFloat
public float decodeFloat(byte[] byte_int)
Description copied from interface:DatatypeCoder
Decode abyte
array into afloat
value.- Specified by:
decodeFloat
in interfaceDatatypeCoder
- Parameters:
byte_int
- Thebyte
array to be decoded- Returns:
- The
float
value of the decodedbyte
array
-
encodeDouble
public byte[] encodeDouble(double value)
Description copied from interface:DatatypeCoder
Encode adouble
value as abyte
array.- Specified by:
encodeDouble
in interfaceDatatypeCoder
- Parameters:
value
- The value to be encoded- Returns:
- The value of
value
encoded as abyte
array
-
decodeDouble
public double decodeDouble(byte[] byte_int)
Description copied from interface:DatatypeCoder
Decode abyte
array into adouble
value.- Specified by:
decodeDouble
in interfaceDatatypeCoder
- Parameters:
byte_int
- Thebyte
array to be decoded- Returns:
- The
double
value of the decodedbyte
array
-
encodeTimestamp
public java.sql.Timestamp encodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal)
Description copied from interface:DatatypeCoder
Encode aTimestamp
using a givenCalendar
.- Specified by:
encodeTimestamp
in interfaceDatatypeCoder
- Parameters:
value
- TheTimestamp
to be encodedcal
- TheCalendar
to be used for encoding, may benull
-
encodeTimestamp
public java.sql.Timestamp encodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)
Description copied from interface:DatatypeCoder
Encode aTimestamp
using a givenCalendar
.- Specified by:
encodeTimestamp
in interfaceDatatypeCoder
- Parameters:
value
- TheTimestamp
to be encodedcal
- TheCalendar
to be used for encoding, may benull
invertTimeZone
- Iftrue
, the timezone offset value will be subtracted from the encoded value, otherwise it will be added- Returns:
- The encoded
Timestamp
-
encodeTimestamp
public byte[] encodeTimestamp(java.sql.Timestamp value)
Description copied from interface:DatatypeCoder
Encode aTimestamp
as abyte
array.- Specified by:
encodeTimestamp
in interfaceDatatypeCoder
- Parameters:
value
- TheTimestamp
to be encoded- Returns:
- The array of
byte
s that represents the givenTimestamp
value
-
encodeTimestampRaw
public byte[] encodeTimestampRaw(DatatypeCoder.RawDateTimeStruct raw)
Description copied from interface:DatatypeCoder
Encode the date and time portions of a raw date time struct into abyte
array.- Specified by:
encodeTimestampRaw
in interfaceDatatypeCoder
- Parameters:
raw
- TheRawDateTimeStruct
to be encoded- Returns:
- The array of
byte
s representing the date and time of the givenRawDateTimeStruct
-
encodeTimestampCalendar
public byte[] encodeTimestampCalendar(java.sql.Timestamp value, java.util.Calendar c)
- Specified by:
encodeTimestampCalendar
in interfaceDatatypeCoder
-
decodeTimestamp
public java.sql.Timestamp decodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal)
Description copied from interface:DatatypeCoder
Decode aTimestamp
value using a givenCalendar
.- Specified by:
decodeTimestamp
in interfaceDatatypeCoder
- Parameters:
value
- TheTimestamp
to be decodedcal
- TheCalendar
to be used in decoding, may benull
- Returns:
- The decoded
Timestamp
-
decodeTimestamp
public java.sql.Timestamp decodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)
Description copied from interface:DatatypeCoder
Decode aTimestamp
value using a givenCalendar
.- Specified by:
decodeTimestamp
in interfaceDatatypeCoder
- Parameters:
value
- TheTimestamp
to be decodedcal
- TheCalendar
to be used in decoding, may benull
invertTimeZone
- Iftrue
, the timezone offset value will be subtracted from the decoded value, otherwise it will be added- Returns:
- The encoded
Timestamp
-
decodeTimestamp
public java.sql.Timestamp decodeTimestamp(byte[] byte_long)
Description copied from interface:DatatypeCoder
Decode a 8-bytebyte
array into aTimestamp
.- Specified by:
decodeTimestamp
in interfaceDatatypeCoder
- Parameters:
byte_long
- Thebyte
array to be decoded- Returns:
- A
Timestamp
value from the decoded bytes
-
decodeTimestampRaw
public DatatypeCoder.RawDateTimeStruct decodeTimestampRaw(byte[] byte_long)
Description copied from interface:DatatypeCoder
Decode a 8-bytebyte
array into a raw date time struct.- Specified by:
decodeTimestampRaw
in interfaceDatatypeCoder
- Parameters:
byte_long
- Thebyte
array to be decoded- Returns:
- A
DatatypeCoder.RawDateTimeStruct
.
-
decodeTimestampCalendar
public java.sql.Timestamp decodeTimestampCalendar(byte[] byte_long, java.util.Calendar c)
- Specified by:
decodeTimestampCalendar
in interfaceDatatypeCoder
-
encodeTime
public java.sql.Time encodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)
Description copied from interface:DatatypeCoder
Encode a givenTime
value using a givenCalendar
.- Specified by:
encodeTime
in interfaceDatatypeCoder
- Parameters:
d
- TheTime
to be encodedcal
- TheCalendar
to be used in the encoding, may benull
- Returns:
- The encoded
Time
-
encodeTime
public byte[] encodeTime(java.sql.Time d)
Description copied from interface:DatatypeCoder
Encode aTime
value into abyte
array.- Specified by:
encodeTime
in interfaceDatatypeCoder
- Parameters:
d
- TheTime
to be encoded- Returns:
- The array of
byte
s representing the givenTime
-
encodeTimeRaw
public byte[] encodeTimeRaw(DatatypeCoder.RawDateTimeStruct raw)
Description copied from interface:DatatypeCoder
Encode the time portion of a raw date time struct into abyte
array.- Specified by:
encodeTimeRaw
in interfaceDatatypeCoder
- Parameters:
raw
- TheRawDateTimeStruct
to be encoded- Returns:
- The array of
byte
s representing the time of the givenRawDateTimeStruct
-
encodeTimeCalendar
public byte[] encodeTimeCalendar(java.sql.Time d, java.util.Calendar c)
- Specified by:
encodeTimeCalendar
in interfaceDatatypeCoder
-
decodeTime
public java.sql.Time decodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)
Description copied from interface:DatatypeCoder
Decode aTime
value using a givenCalendar
.- Specified by:
decodeTime
in interfaceDatatypeCoder
- Parameters:
d
- TheTime
to be decodedcal
- TheCalendar
to be used in the decoding, may benull
- Returns:
- The decooded
Time
-
decodeTime
public java.sql.Time decodeTime(byte[] int_byte)
Description copied from interface:DatatypeCoder
Decode abyte
array into aTime
value.- Specified by:
decodeTime
in interfaceDatatypeCoder
- Parameters:
int_byte
- Thebyte
array to be decoded- Returns:
- The decoded
Time
-
decodeTimeRaw
public DatatypeCoder.RawDateTimeStruct decodeTimeRaw(byte[] int_byte)
Description copied from interface:DatatypeCoder
Decode abyte
array into a raw date time struct.- Specified by:
decodeTimeRaw
in interfaceDatatypeCoder
- Parameters:
int_byte
- Thebyte
array to be decoded- Returns:
- The
DatatypeCoder.RawDateTimeStruct
-
decodeTimeCalendar
public java.sql.Time decodeTimeCalendar(byte[] int_byte, java.util.Calendar c)
- Specified by:
decodeTimeCalendar
in interfaceDatatypeCoder
-
encodeDate
public java.sql.Date encodeDate(java.sql.Date d, java.util.Calendar cal)
Description copied from interface:DatatypeCoder
Encode a givenDate
value using a givenCalendar
.- Specified by:
encodeDate
in interfaceDatatypeCoder
- Parameters:
d
- TheDate
to be encodedcal
- TheCalendar
to be used in the encoding, may benull
- Returns:
- The encoded
Date
-
encodeDate
public byte[] encodeDate(java.sql.Date d)
Description copied from interface:DatatypeCoder
Encode aDate
value into abyte
array.- Specified by:
encodeDate
in interfaceDatatypeCoder
- Parameters:
d
- TheDate
to be encoded- Returns:
- The array of
byte
s representing the givenDate
-
encodeDateRaw
public byte[] encodeDateRaw(DatatypeCoder.RawDateTimeStruct raw)
Description copied from interface:DatatypeCoder
Encode the date portion of a raw date time struct into abyte
array.- Specified by:
encodeDateRaw
in interfaceDatatypeCoder
- Parameters:
raw
- TheRawDateTimeStruct
to be encoded- Returns:
- The array of
byte
s representing the date of the givenRawDateTimeStruct
-
encodeDateCalendar
public byte[] encodeDateCalendar(java.sql.Date d, java.util.Calendar c)
- Specified by:
encodeDateCalendar
in interfaceDatatypeCoder
-
decodeDate
public java.sql.Date decodeDate(java.sql.Date d, java.util.Calendar cal)
Description copied from interface:DatatypeCoder
Decode aDate
value using a givenCalendar
.- Specified by:
decodeDate
in interfaceDatatypeCoder
- Parameters:
d
- TheDate
to be decodedcal
- TheCalendar
to be used in the decoding, may benull
- Returns:
- The decoded
Date
-
decodeDate
public java.sql.Date decodeDate(byte[] byte_int)
Description copied from interface:DatatypeCoder
Decode abyte
array into aDate
value.- Specified by:
decodeDate
in interfaceDatatypeCoder
- Parameters:
byte_int
- Thebyte
array to be decoded- Returns:
- The decoded
Date
-
decodeDateRaw
public DatatypeCoder.RawDateTimeStruct decodeDateRaw(byte[] byte_int)
Description copied from interface:DatatypeCoder
Decode abyte
array into a raw date time struct.- Specified by:
decodeDateRaw
in interfaceDatatypeCoder
- Parameters:
byte_int
- Thebyte
array to be decoded- Returns:
- The
DatatypeCoder.RawDateTimeStruct
-
decodeDateCalendar
public java.sql.Date decodeDateCalendar(byte[] byte_int, java.util.Calendar c)
- Specified by:
decodeDateCalendar
in interfaceDatatypeCoder
-
decodeBoolean
public boolean decodeBoolean(byte[] data)
Description copied from interface:DatatypeCoder
Decode boolean from supplied data.- Specified by:
decodeBoolean
in interfaceDatatypeCoder
- Parameters:
data
- (expected) 1 bytes- Returns:
false
when 0,true
for all other values
-
encodeBoolean
public byte[] encodeBoolean(boolean value)
Description copied from interface:DatatypeCoder
Encodes boolean to 1 byte data.- Specified by:
encodeBoolean
in interfaceDatatypeCoder
- Parameters:
value
- Boolean value to encode- Returns:
true
as 1,false
as 0.
-
encodeLocalTime
public byte[] encodeLocalTime(int hour, int minute, int second, int nanos)
Description copied from interface:DatatypeCoder
Encodes a java.time.LocalTime equivalent to time bytes.- Specified by:
encodeLocalTime
in interfaceDatatypeCoder
- Parameters:
hour
- Number of hours (is assumed to be 0..23)minute
- Number of minutes (is assumed to be 0..59)second
- Number of seconds (is assumed to be 0..59)nanos
- Sub-second nanoseconds (actual resolution is 100 microseconds, is assumed to be 0 .. 10^9 - 1 ns)- Returns:
- Byte array for time
-
encodeLocalDate
public byte[] encodeLocalDate(int year, int month, int day)
Description copied from interface:DatatypeCoder
Encodes a java.time.LocalDate equivalent to date bytes.- Specified by:
encodeLocalDate
in interfaceDatatypeCoder
- Parameters:
year
- Yearmonth
- Month (is assumed to be 1..12)day
- Day (is assumed to be valid for year and month)- Returns:
- Byte array for date
-
encodeLocalDateTime
public byte[] encodeLocalDateTime(int year, int month, int day, int hour, int minute, int second, int nanos)
Description copied from interface:DatatypeCoder
Encodes a java.time.LocalDateTime equivalent to timestamp bytes.- Specified by:
encodeLocalDateTime
in interfaceDatatypeCoder
- Parameters:
year
- Yearmonth
- Month (is assumed to be 1..12)day
- Day (is assumed to be valid for year and month)hour
- Number of hours (is assumed to be 0..23)minute
- Number of minutes (is assumed to be 0..59)second
- Number of seconds (is assumed to be 0..59)nanos
- Sub-second nanoseconds (actual resolution is 100 microseconds, is assumed to be 0 .. 10^9 - 1 ns)- Returns:
- Byte array for timestamp
-
decodeDecimal64
public Decimal64 decodeDecimal64(byte[] data)
Description copied from interface:DatatypeCoder
Decodes a decimal64 from byte array.- Specified by:
decodeDecimal64
in interfaceDatatypeCoder
- Parameters:
data
- Data to decode (expected 8 bytes)- Returns:
- Decimal64 value
-
encodeDecimal64
public byte[] encodeDecimal64(Decimal64 decimal64)
Description copied from interface:DatatypeCoder
Encodes a decimal64 to a byte array.- Specified by:
encodeDecimal64
in 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:DatatypeCoder
Decodes a decimal128 from byte array.- Specified by:
decodeDecimal128
in interfaceDatatypeCoder
- Parameters:
data
- Data to decode (expected 16 bytes)- Returns:
- Decimal128 value
-
encodeDecimal128
public byte[] encodeDecimal128(Decimal128 decimal128)
Description copied from interface:DatatypeCoder
Encodes a decimal128 to a byte array.- Specified by:
encodeDecimal128
in 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:DatatypeCoder
Decodes a BigInteger from byte array.- Specified by:
decodeInt128
in interfaceDatatypeCoder
- Parameters:
data
- Data to decode (expected 16 bytes)- Returns:
- BigInteger value
-
encodeInt128
public byte[] encodeInt128(java.math.BigInteger bigInteger)
Description copied from interface:DatatypeCoder
Encodes 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
IllegalArgumentException
is thrown.- Specified by:
encodeInt128
in interfaceDatatypeCoder
- Parameters:
bigInteger
- The BigInteger value to be encoded- Returns:
- Byte array for bigInteger value
-
getEncodingFactory
public IEncodingFactory getEncodingFactory()
- Specified by:
getEncodingFactory
in interfaceDatatypeCoder
- Returns:
- The encoding factory.
-
-