org.firebirdsql.gds.ng

## Interface DatatypeCoder

- All Known Implementing Classes:
    BigEndianDatatypeCoder, DefaultDatatypeCoder, LittleEndianDatatypeCoder

      public interface DatatypeCoder

  Interface defining the encoding and decoding for Firebird (numerical) data types.
  Since:
    3.0
  Author:
    Mark Rotteveel

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `DatatypeCoder.RawDateTimeStruct` Raw date/time value.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `FRACTIONS_PER_HOUR`
    `static int` | `FRACTIONS_PER_MILLISECOND`
    `static int` | `FRACTIONS_PER_MINUTE`
    `static int` | `FRACTIONS_PER_SECOND`
    `static int` | `NANOSECONDS_PER_FRACTION`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `decodeBoolean(byte[] data)` Decode boolean from supplied data.
    `java.sql.Date` | `decodeDate(byte[] byte_int)` Decode a `byte` array into a `Date` value.
    `java.sql.Date` | `decodeDate(java.sql.Date d, java.util.Calendar cal)` Decode a `Date` value using a given `Calendar`.
    `java.sql.Date` | `decodeDateCalendar(byte[] byte_int, java.util.Calendar c)`
    `DatatypeCoder.RawDateTimeStruct` | `decodeDateRaw(byte[] byte_int)` Decode a `byte` array into a raw date time struct.
    `double` | `decodeDouble(byte[] byte_int)` Decode a `byte` array into a `double` value.
    `float` | `decodeFloat(byte[] byte_int)` Decode a `byte` array into a `float` value.
    `int` | `decodeInt(byte[] byte_int)` Decode a `byte` array into an `int` value.
    `long` | `decodeLong(byte[] byte_int)` Decode a `byte` array into a `long` value.
    `short` | `decodeShort(byte[] byte_int)` Decode a `byte` array into a `short` value.
    `java.lang.String` | `decodeString(byte[] value, Encoding encoding, java.lang.String mappingPath)` Deprecated. To be removed in Jaybird 4
    `java.lang.String` | `decodeString(byte[] value, java.lang.String javaEncoding, java.lang.String mappingPath)` Deprecated. To be removed in Jaybird 4
    `java.sql.Time` | `decodeTime(byte[] int_byte)` Decode a `byte` array into a `Time` value.
    `java.sql.Time` | `decodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)` Decode a `Time` value using a given `Calendar`.
    `java.sql.Time` | `decodeTimeCalendar(byte[] int_byte, java.util.Calendar c)`
    `DatatypeCoder.RawDateTimeStruct` | `decodeTimeRaw(byte[] int_byte)` Decode a `byte` array into a raw date time struct.
    `java.sql.Timestamp` | `decodeTimestamp(byte[] byte_long)` Decode a 8-byte `byte` array into a `Timestamp`.
    `java.sql.Timestamp` | `decodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal)` Decode a `Timestamp` value using a given `Calendar`.
    `java.sql.Timestamp` | `decodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)` Decode a `Timestamp` value using a given `Calendar`.
    `java.sql.Timestamp` | `decodeTimestampCalendar(byte[] byte_long, java.util.Calendar c)`
    `DatatypeCoder.RawDateTimeStruct` | `decodeTimestampRaw(byte[] byte_long)` Decode a 8-byte `byte` array into a raw date time struct.
    `byte[]` | `encodeBoolean(boolean value)` Encodes boolean to 1 byte data.
    `byte[]` | `encodeDate(java.sql.Date d)` Encode a `Date` value into a `byte` array.
    `java.sql.Date` | `encodeDate(java.sql.Date d, java.util.Calendar cal)` Encode a given `Date` value using a given `Calendar`.
    `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 a `byte` array.
    `byte[]` | `encodeDouble(double value)` Encode a `double` value as a `byte` array.
    `byte[]` | `encodeFloat(float value)` Encode a `float` value as a `byte` array.
    `byte[]` | `encodeInt(int value)` Encode an `int` value as a `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 a `long` value as a `byte` array.
    `byte[]` | `encodeShort(int value)` Encode a `short` value as a `byte` array.
    `byte[]` | `encodeShort(short value)` Encode a `short` value as a `byte` array.
    `byte[]` | `encodeString(java.lang.String value, Encoding encoding, java.lang.String mappingPath)` Deprecated. To be removed in Jaybird 4
    `byte[]` | `encodeString(java.lang.String value, java.lang.String javaEncoding, java.lang.String mappingPath)` Deprecated. To be removed in Jaybird 4
    `byte[]` | `encodeTime(java.sql.Time d)` Encode a `Time` value into a `byte` array.
    `java.sql.Time` | `encodeTime(java.sql.Time d, java.util.Calendar cal, boolean invertTimeZone)` Encode a given `Time` value using a given `Calendar`.
    `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 a `byte` array.
    `byte[]` | `encodeTimestamp(java.sql.Timestamp value)` Encode a `Timestamp` as a `byte` array.
    `java.sql.Timestamp` | `encodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal)` Encode a `Timestamp` using a given `Calendar`.
    `java.sql.Timestamp` | `encodeTimestamp(java.sql.Timestamp value, java.util.Calendar cal, boolean invertTimeZone)` Encode a `Timestamp` using a given `Calendar`.
    `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 a `byte` array.
    `IEncodingFactory` | `getEncodingFactory()`

- - ### Field Detail

    - #### NANOSECONDS_PER_FRACTION

          static final int NANOSECONDS_PER_FRACTION

      See Also:
        Constant Field Values

    - #### FRACTIONS_PER_MILLISECOND

          static final int FRACTIONS_PER_MILLISECOND

      See Also:
        Constant Field Values

    - #### FRACTIONS_PER_SECOND

          static final int FRACTIONS_PER_SECOND

      See Also:
        Constant Field Values

    - #### FRACTIONS_PER_MINUTE

          static final int FRACTIONS_PER_MINUTE

      See Also:
        Constant Field Values

    - #### FRACTIONS_PER_HOUR

          static final int FRACTIONS_PER_HOUR

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### encodeShort

          byte[] encodeShort(short value)

      Encode a `short` value as a `byte` array.
      Parameters:
        `value` - The value to be encoded
      Returns:
        The value of `value` encoded as a `byte` array
      See Also:
        `encodeShort(int)`

    - #### encodeShort

          byte[] encodeShort(int value)

      Encode a `short` value as a `byte` array.
      Parameters:
        `value` - The value to be encoded
      Returns:
        The value of `value` encoded as a `byte` array

    - #### decodeShort

          short decodeShort(byte[] byte_int)

      Decode a `byte` array into a `short` value.
      Parameters:
        `byte_int` - The `byte` array to be decoded
      Returns:
        The `short` value of the decoded `byte` array

    - #### encodeInt

          byte[] encodeInt(int value)

      Encode an `int` value as a `byte` array.
      Parameters:
        `value` - The value to be encoded
      Returns:
        The value of `value` encoded as a `byte` array

    - #### decodeInt

          int decodeInt(byte[] byte_int)

      Decode a `byte` array into an `int` value.
      Parameters:
        `byte_int` - The `byte` array to be decoded
      Returns:
        The `int` value of the decoded `byte` array

    - #### encodeLong

          byte[] encodeLong(long value)

      Encode a `long` value as a `byte` array.
      Parameters:
        `value` - The value to be encoded
      Returns:
        The value of `value` encoded as a `byte` array

    - #### decodeLong

          long decodeLong(byte[] byte_int)

      Decode a `byte` array into a `long` value.
      Parameters:
        `byte_int` - The `byte` array to be decoded
      Returns:
        The `long` value of the decoded `byte` array

    - #### encodeFloat

          byte[] encodeFloat(float value)

      Encode a `float` value as a `byte` array.
      Parameters:
        `value` - The value to be encoded
      Returns:
        The value of `value` encoded as a `byte` array

    - #### decodeFloat

          float decodeFloat(byte[] byte_int)

      Decode a `byte` array into a `float` value.
      Parameters:
        `byte_int` - The `byte` array to be decoded
      Returns:
        The `float` value of the decoded `byte` array

    - #### encodeDouble

          byte[] encodeDouble(double value)

      Encode a `double` value as a `byte` array.
      Parameters:
        `value` - The value to be encoded
      Returns:
        The value of `value` encoded as a `byte` array

    - #### decodeDouble

          double decodeDouble(byte[] byte_int)

      Decode a `byte` array into a `double` value.
      Parameters:
        `byte_int` - The `byte` array to be decoded
      Returns:
        The `double` value of the decoded `byte` array

    - #### encodeString

          @Deprecated
          byte[] encodeString(java.lang.String value,
                                           java.lang.String javaEncoding,
                                           java.lang.String mappingPath)
                                    throws java.sql.SQLException

      Deprecated. To be removed in Jaybird 4
      Encode a `String` value into a `byte` array using a given encoding.
      Parameters:
        `value` - The `String` to be encoded
        `javaEncoding` - The java encoding to use in the encoding process
        `mappingPath` - The character mapping path to be used in the encoding
      Returns:
        The value of `value` as a `byte` array
      Throws:
        `java.sql.SQLException` - if the given encoding cannot be found, or an error occurs during the encoding

    - #### encodeString

          @Deprecated
          byte[] encodeString(java.lang.String value,
                                           Encoding encoding,
                                           java.lang.String mappingPath)
                                    throws java.sql.SQLException

      Deprecated. To be removed in Jaybird 4
      Throws:
        `java.sql.SQLException`

    - #### decodeString

          @Deprecated
          java.lang.String decodeString(byte[] value,
                                                     java.lang.String javaEncoding,
                                                     java.lang.String mappingPath)
                                              throws java.sql.SQLException

      Deprecated. To be removed in Jaybird 4
      Decode an encoded `byte` array into a `String` using a given encoding.
      Parameters:
        `value` - The value to be decoded
        `javaEncoding` - The java encoding to be used in the decoding process
        `mappingPath` - The character mapping path to be used in the decoding
      Returns:
        The decoded `String`
      Throws:
        `java.sql.SQLException` - if the given encoding cannot be found, or an error occurs during the decoding

    - #### decodeString

          @Deprecated
          java.lang.String decodeString(byte[] value,
                                                     Encoding encoding,
                                                     java.lang.String mappingPath)
                                              throws java.sql.SQLException

      Deprecated. To be removed in Jaybird 4
      Throws:
        `java.sql.SQLException`

    - #### encodeTimestamp

          java.sql.Timestamp encodeTimestamp(java.sql.Timestamp value,
                                             java.util.Calendar cal)

      Encode a `Timestamp` using a given `Calendar`.
      Parameters:
        `value` - The `Timestamp` to be encoded
        `cal` - The `Calendar` to be used for encoding, may be `null`

    - #### encodeTimestamp

          java.sql.Timestamp encodeTimestamp(java.sql.Timestamp value,
                                             java.util.Calendar cal,
                                             boolean invertTimeZone)

      Encode a `Timestamp` using a given `Calendar`.
      Parameters:
        `value` - The `Timestamp` to be encoded
        `cal` - The `Calendar` to be used for encoding, may be `null`
        `invertTimeZone` - If `true`, the timezone offset value will be subtracted from the encoded value, otherwise it will be added
      Returns:
        The encoded `Timestamp`

    - #### encodeTimestamp

          byte[] encodeTimestamp(java.sql.Timestamp value)

      Encode a `Timestamp` as a `byte` array.
      Parameters:
        `value` - The `Timestamp` to be encoded
      Returns:
        The array of `byte`s that represents the given `Timestamp` value

    - #### encodeTimestampRaw

          byte[] encodeTimestampRaw(DatatypeCoder.RawDateTimeStruct raw)

      Encode the date and time portions of a raw date time struct into a `byte` array.
      Parameters:
        `raw` - The `RawDateTimeStruct` to be encoded
      Returns:
        The array of `byte`s representing the date and time of the given `RawDateTimeStruct`

    - #### encodeTimestampCalendar

          byte[] encodeTimestampCalendar(java.sql.Timestamp value,
                                         java.util.Calendar c)

    - #### decodeTimestamp

          java.sql.Timestamp decodeTimestamp(java.sql.Timestamp value,
                                             java.util.Calendar cal)

      Decode a `Timestamp` value using a given `Calendar`.
      Parameters:
        `value` - The `Timestamp` to be decoded
        `cal` - The `Calendar` to be used in decoding, may be `null`
      Returns:
        The decoded `Timestamp`

    - #### decodeTimestamp

          java.sql.Timestamp decodeTimestamp(java.sql.Timestamp value,
                                             java.util.Calendar cal,
                                             boolean invertTimeZone)

      Decode a `Timestamp` value using a given `Calendar`.
      Parameters:
        `value` - The `Timestamp` to be decoded
        `cal` - The `Calendar` to be used in decoding, may be `null`
        `invertTimeZone` - If `true`, the timezone offset value will be subtracted from the decoded value, otherwise it will be added
      Returns:
        The encoded `Timestamp`

    - #### decodeTimestamp

          java.sql.Timestamp decodeTimestamp(byte[] byte_long)

      Decode a 8-byte `byte` array into a `Timestamp`.
      Parameters:
        `byte_long` - The `byte` array to be decoded
      Returns:
        A `Timestamp` value from the decoded bytes

    - #### decodeTimestampRaw

          DatatypeCoder.RawDateTimeStruct decodeTimestampRaw(byte[] byte_long)

      Decode a 8-byte `byte` array into a raw date time struct.
      Parameters:
        `byte_long` - The `byte` array to be decoded
      Returns:
        A `DatatypeCoder.RawDateTimeStruct`.

    - #### decodeTimestampCalendar

          java.sql.Timestamp decodeTimestampCalendar(byte[] byte_long,
                                                     java.util.Calendar c)

    - #### encodeTime

          java.sql.Time encodeTime(java.sql.Time d,
                                   java.util.Calendar cal,
                                   boolean invertTimeZone)

      Encode a given `Time` value using a given `Calendar`.
      Parameters:
        `d` - The `Time` to be encoded
        `cal` - The `Calendar` to be used in the encoding, may be `null`
      Returns:
        The encoded `Time`

    - #### encodeTime

          byte[] encodeTime(java.sql.Time d)

      Encode a `Time` value into a `byte` array.
      Parameters:
        `d` - The `Time` to be encoded
      Returns:
        The array of `byte`s representing the given `Time`

    - #### encodeTimeRaw

          byte[] encodeTimeRaw(DatatypeCoder.RawDateTimeStruct raw)

      Encode the time portion of a raw date time struct into a `byte` array.
      Parameters:
        `raw` - The `RawDateTimeStruct` to be encoded
      Returns:
        The array of `byte`s representing the time of the given `RawDateTimeStruct`

    - #### encodeTimeCalendar

          byte[] encodeTimeCalendar(java.sql.Time d,
                                    java.util.Calendar c)

    - #### decodeTime

          java.sql.Time decodeTime(java.sql.Time d,
                                   java.util.Calendar cal,
                                   boolean invertTimeZone)

      Decode a `Time` value using a given `Calendar`.
      Parameters:
        `d` - The `Time` to be decoded
        `cal` - The `Calendar` to be used in the decoding, may be `null`
      Returns:
        The decooded `Time`

    - #### decodeTime

          java.sql.Time decodeTime(byte[] int_byte)

      Decode a `byte` array into a `Time` value.
      Parameters:
        `int_byte` - The `byte` array to be decoded
      Returns:
        The decoded `Time`

    - #### decodeTimeRaw

          DatatypeCoder.RawDateTimeStruct decodeTimeRaw(byte[] int_byte)

      Decode a `byte` array into a raw date time struct.
      Parameters:
        `int_byte` - The `byte` array to be decoded
      Returns:
        The `DatatypeCoder.RawDateTimeStruct`

    - #### decodeTimeCalendar

          java.sql.Time decodeTimeCalendar(byte[] int_byte,
                                           java.util.Calendar c)

    - #### encodeDate

          java.sql.Date encodeDate(java.sql.Date d,
                                   java.util.Calendar cal)

      Encode a given `Date` value using a given `Calendar`.
      Parameters:
        `d` - The `Date` to be encoded
        `cal` - The `Calendar` to be used in the encoding, may be `null`
      Returns:
        The encoded `Date`

    - #### encodeDate

          byte[] encodeDate(java.sql.Date d)

      Encode a `Date` value into a `byte` array.
      Parameters:
        `d` - The `Date` to be encoded
      Returns:
        The array of `byte`s representing the given `Date`

    - #### encodeDateRaw

          byte[] encodeDateRaw(DatatypeCoder.RawDateTimeStruct raw)

      Encode the date portion of a raw date time struct into a `byte` array.
      Parameters:
        `raw` - The `RawDateTimeStruct` to be encoded
      Returns:
        The array of `byte`s representing the date of the given `RawDateTimeStruct`

    - #### encodeDateCalendar

          byte[] encodeDateCalendar(java.sql.Date d,
                                    java.util.Calendar c)

    - #### decodeDate

          java.sql.Date decodeDate(java.sql.Date d,
                                   java.util.Calendar cal)

      Decode a `Date` value using a given `Calendar`.
      Parameters:
        `d` - The `Date` to be decoded
        `cal` - The `Calendar` to be used in the decoding, may be `null`
      Returns:
        The decoded `Date`

    - #### decodeDate

          java.sql.Date decodeDate(byte[] byte_int)

      Decode a `byte` array into a `Date` value.
      Parameters:
        `byte_int` - The `byte` array to be decoded
      Returns:
        The decoded `Date`

    - #### decodeDateRaw

          DatatypeCoder.RawDateTimeStruct decodeDateRaw(byte[] byte_int)

      Decode a `byte` array into a raw date time struct.
      Parameters:
        `byte_int` - The `byte` array to be decoded
      Returns:
        The `DatatypeCoder.RawDateTimeStruct`

    - #### decodeDateCalendar

          java.sql.Date decodeDateCalendar(byte[] byte_int,
                                           java.util.Calendar c)

    - #### decodeBoolean

          boolean decodeBoolean(byte[] data)

      Decode boolean from supplied data.
      Parameters:
        `data` - (expected) 1 bytes
      Returns:
        `false` when 0, `true` for all other values

    - #### encodeBoolean

          byte[] encodeBoolean(boolean value)

      Encodes boolean to 1 byte data.
      Parameters:
        `value` - Boolean value to encode
      Returns:
        `true` as 1, `false` as 0.

    - #### encodeLocalTime

          byte[] encodeLocalTime(int hour,
                                 int minute,
                                 int second,
                                 int nanos)

      Encodes a java.time.LocalTime equivalent to time bytes.
      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

          byte[] encodeLocalDate(int year,
                                 int month,
                                 int day)

      Encodes a java.time.LocalDate equivalent to date bytes.
      Parameters:
        `year` - Year
        `month` - Month (is assumed to be 1..12)
        `day` - Day (is assumed to be valid for year and month)
      Returns:
        Byte array for date

    - #### encodeLocalDateTime

          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.
      Parameters:
        `year` - Year
        `month` - 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

    - #### getEncodingFactory

          IEncodingFactory getEncodingFactory()

      Returns:
        The encoding factory.

Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.