Interface DatatypeCoder

    • Method Detail

      • sizeOfShort

        int sizeOfShort()
        The size of an encoded short in this data type coder.
        Returns:
        The size of an encoded short (either 2 or 4 bytes)
        Since:
        4.0
      • 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
      • encodeShort

        void encodeShort​(int value,
                         byte[] target,
                         int fromIndex)
        Encode a short value into the target byte array starting at index fromIndex.
        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
        Since:
        4.0
      • 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
      • decodeShort

        short decodeShort​(byte[] bytes,
                          int fromIndex)
        Decode from a byte array to a short value.
        Parameters:
        bytes - The byte array to be decoded
        fromIndex - The index to start reading
        Returns:
        The short value of the decoded byte array
        Since:
        4.0
      • 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
      • encodeInt

        void encodeInt​(int value,
                       byte[] target,
                       int fromIndex)
        Encode an int value into the target byte array starting at index fromIndex.
        Parameters:
        value - The value to be encoded
        target - Target byte array of sufficient size
        fromIndex - Index to start writing
        Since:
        4.0
      • 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
      • decodeInt

        int decodeInt​(byte[] bytes,
                      int fromIndex)
        Decode a byte array to an int value.
        Parameters:
        bytes - The byte array to be decoded
        fromIndex - The index to start reading
        Returns:
        The int value of the decoded byte array
        Since:
        4.0
      • 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

        byte[] encodeString​(java.lang.String value)
        Encode a String value into a byte array using the encoding of this datatype coder.
        Parameters:
        value - The String to be encoded
        Returns:
        The value of value as a byte array
        Since:
        4.0
      • createWriter

        java.io.Writer createWriter​(java.io.OutputStream outputStream)
        Creates a writer wrapping an input stream.
        Parameters:
        outputStream - Input stream
        Returns:
        Writer applying the encoding of this datatype when writing
        Since:
        4.0
      • decodeString

        java.lang.String decodeString​(byte[] value)
        Decode an encoded byte array into a String using the encoding of this datatype coder.
        Parameters:
        value - The value to be decoded
        Returns:
        The decoded String
        Since:
        4.0
      • createReader

        java.io.Reader createReader​(java.io.InputStream inputStream)
        Creates a reader wrapping an input stream.
        Parameters:
        inputStream - Input stream
        Returns:
        Reader applying the encoding of this datatype coder when reading
        Since:
        4.0
      • encodeTimestamp

        @Deprecated
        java.sql.Timestamp encodeTimestamp​(java.sql.Timestamp value,
                                           java.util.Calendar cal,
                                           boolean invertTimeZone)
        Deprecated.
        will be removed in Jaybird 6
        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
      • encodeTimestampRaw

        @Deprecated
        byte[] encodeTimestampRaw​(DatatypeCoder.RawDateTimeStruct raw)
        Deprecated.
        use encodeLocalDateTime(LocalDateTime); will be removed in Jaybird 6
        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 bytes representing the date and time of the given RawDateTimeStruct
      • encodeTimestampCalendar

        @Deprecated
        byte[] encodeTimestampCalendar​(java.sql.Timestamp value,
                                       java.util.Calendar c)
        Deprecated.
        use encodeLocalDateTime(LocalDateTime); will be removed in Jaybird 6
        Encode a Timestamp as a byte array.
        Parameters:
        value - The Timestamp to be encoded
        c - Calendar to use for time zone calculation
        Returns:
        The array of bytes that represents the given Timestamp value
      • decodeTimestamp

        @Deprecated
        java.sql.Timestamp decodeTimestamp​(java.sql.Timestamp value,
                                           java.util.Calendar cal,
                                           boolean invertTimeZone)
        Deprecated.
        will be removed in Jaybird 6
        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
      • decodeTimestampCalendar

        @Deprecated
        java.sql.Timestamp decodeTimestampCalendar​(byte[] byte_long,
                                                   java.util.Calendar c)
        Deprecated.
        use decodeLocalDateTime(byte[]); will be removed in Jaybird 6
        Decode an 8-byte byte array into a Timestamp.
        Parameters:
        byte_long - The byte array to be decoded
        c - Calendar to use for time zone calculation
        Returns:
        A Timestamp value from the decoded bytes
      • encodeTime

        @Deprecated
        java.sql.Time encodeTime​(java.sql.Time d,
                                 java.util.Calendar cal,
                                 boolean invertTimeZone)
        Deprecated.
        use encodeLocalTime(LocalTime); will be removed in Jaybird 6
        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
      • encodeTimeRaw

        @Deprecated
        byte[] encodeTimeRaw​(DatatypeCoder.RawDateTimeStruct raw)
        Deprecated.
        use encodeLocalTime(LocalTime); will be removed in Jaybird 6
        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 bytes representing the time of the given RawDateTimeStruct
      • encodeTimeCalendar

        @Deprecated
        byte[] encodeTimeCalendar​(java.sql.Time d,
                                  java.util.Calendar c)
        Deprecated.
        will be removed in Jaybird 6
        Encode a Time value into a byte array.
        Parameters:
        d - The Time to be encoded
        c - Calendar to use for time zone calculation
        Returns:
        The array of bytes representing the given Time
      • decodeTime

        @Deprecated
        java.sql.Time decodeTime​(java.sql.Time d,
                                 java.util.Calendar cal,
                                 boolean invertTimeZone)
        Deprecated.
        will be removed in Jaybird 6
        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 decoded Time
      • decodeTimeCalendar

        @Deprecated
        java.sql.Time decodeTimeCalendar​(byte[] int_byte,
                                         java.util.Calendar c)
        Deprecated.
        use decodeLocalTime(byte[]); will be removed in Jaybird 6
        Decode a byte array into a Time value.
        Parameters:
        int_byte - The byte array to be decoded
        c - Calendar to use for time zone calculation
        Returns:
        The decoded Time
      • encodeDate

        @Deprecated
        java.sql.Date encodeDate​(java.sql.Date d,
                                 java.util.Calendar cal)
        Deprecated.
        will be removed in Jaybird 6
        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
      • encodeDateRaw

        @Deprecated
        byte[] encodeDateRaw​(DatatypeCoder.RawDateTimeStruct raw)
        Deprecated.
        use encodeLocalDate(LocalDate); will be removed in Jaybird 6
        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 bytes representing the date of the given RawDateTimeStruct
      • encodeDateCalendar

        @Deprecated
        byte[] encodeDateCalendar​(java.sql.Date d,
                                  java.util.Calendar c)
        Deprecated.
        use encodeLocalDate(LocalDate); will be removed in Jaybird 6
        Encode a Date value into a byte array.
        Parameters:
        d - The Date to be encoded
        c - Calendar to use for time zone calculation
        Returns:
        The array of bytes representing the given Date
      • decodeDate

        @Deprecated
        java.sql.Date decodeDate​(java.sql.Date d,
                                 java.util.Calendar cal)
        Deprecated.
        will be removed in Jaybird 6
        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
      • decodeDateCalendar

        @Deprecated
        java.sql.Date decodeDateCalendar​(byte[] byte_int,
                                         java.util.Calendar c)
        Deprecated.
        use decodeLocalDate(byte[]); will be removed in Jaybird 6
        Decode a byte array into a Date value.
        Parameters:
        byte_int - The byte array to be decoded
        c - Calendar to use for time zone calculation
        Returns:
        The decoded Date
      • 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.
      • decodeLocalTime

        java.time.LocalTime decodeLocalTime​(byte[] data)
        Decode LocalTime from supplied data.
        Parameters:
        data - (expected) 4 bytes
        Returns:
        LocalTime value
        Since:
        5
      • encodeLocalTime

        byte[] encodeLocalTime​(java.time.LocalTime value)
        Encodes a java.time.LocalTime to time bytes.
        Parameters:
        value - LocalTime value to encode
        Returns:
        Byte array for time
        Since:
        5
      • decodeLocalDate

        java.time.LocalDate decodeLocalDate​(byte[] data)
        Decode LocalDate from supplied data.
        Parameters:
        data - (expected) 4 bytes
        Returns:
        LocalDate value
        Since:
        5
      • encodeLocalDate

        byte[] encodeLocalDate​(java.time.LocalDate value)
        Encodes a java.time.LocalDate to date bytes.
        Parameters:
        value - LocalDate to encode
        Returns:
        Byte array for date
        Since:
        5
      • decodeLocalDateTime

        java.time.LocalDateTime decodeLocalDateTime​(byte[] data)
        Decode LocalDateTime from supplied data.
        Parameters:
        data - (expected) 8 bytes
        Returns:
        LocalDateTime value
        Since:
        5
      • encodeLocalDateTime

        byte[] encodeLocalDateTime​(java.time.LocalDateTime value)
        Encodes a java.time.LocalDateTime to timestamp bytes.
        Parameters:
        value - LocalDateTime to encode
        Returns:
        Byte array for date
        Since:
        5
      • decodeDecimal64

        Decimal64 decodeDecimal64​(byte[] data)
        Decodes a decimal64 from byte array.
        Parameters:
        data - Data to decode (expected 8 bytes)
        Returns:
        Decimal64 value
      • encodeDecimal64

        byte[] encodeDecimal64​(Decimal64 decimal64)
        Encodes a decimal64 to a byte array.
        Parameters:
        decimal64 - The decimal64 value to be encoded
        Returns:
        Byte array for decimal64 value
      • decodeDecimal128

        Decimal128 decodeDecimal128​(byte[] data)
        Decodes a decimal128 from byte array.
        Parameters:
        data - Data to decode (expected 16 bytes)
        Returns:
        Decimal128 value
      • encodeDecimal128

        byte[] encodeDecimal128​(Decimal128 decimal128)
        Encodes a decimal128 to a byte array.
        Parameters:
        decimal128 - The decimal128 value to be encoded
        Returns:
        Byte array for decimal128 value
      • decodeInt128

        java.math.BigInteger decodeInt128​(byte[] data)
        Decodes a BigInteger from byte array.
        Parameters:
        data - Data to decode (expected 16 bytes)
        Returns:
        BigInteger value
      • encodeInt128

        byte[] encodeInt128​(java.math.BigInteger bigInteger)
        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.

        Parameters:
        bigInteger - The BigInteger value to be encoded
        Returns:
        Byte array for bigInteger value
      • getEncodingFactory

        IEncodingFactory getEncodingFactory()
        Returns:
        The encoding factory.
      • getEncodingDefinition

        EncodingDefinition getEncodingDefinition()
        Returns:
        The encoding definition used by this datatype coder for string conversions.
      • getEncoding

        Encoding getEncoding()
        Returns:
        The encoding used by this datatype coder for string conversions.
      • forEncodingDefinition

        DatatypeCoder forEncodingDefinition​(EncodingDefinition encodingDefinition)
        Return a derived datatype coder that applies the supplied encoding definition for string conversions.
        Parameters:
        encodingDefinition - Encoding definition
        Returns:
        Derived datatype coder (this instance, if encoding definition is the same)
        Since:
        4.0
      • unwrap

        DatatypeCoder unwrap()
        Unwrap this datatype coder to its parent (or itself).
        Returns:
        Return the parent of this datatype code, or itself if it has no parent.
        Since:
        4.0
      • equals

        boolean equals​(java.lang.Object other)

        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.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - Object to compare to
        Returns:
        true if other is an equivalent datatype coder.
      • hashCode

        int hashCode()
        Overrides:
        hashCode in class java.lang.Object