Interface Codec<T>

    • Method Detail

      • className

        String className()
        Codec native type
        Returns:
        code native return type
      • canDecode

        boolean canDecode​(org.mariadb.jdbc.client.ColumnDecoder column,
                          Class<?> type)
        If codec can decode this a server datatype to a java class type
        Parameters:
        column - server datatype
        type - java return class
        Returns:
        true if codec can decode it
      • canEncode

        boolean canEncode​(Object value)
        Can Codec encode the java object type
        Parameters:
        value - java object type
        Returns:
        true if codec can encode java type
      • decodeText

        T decodeText​(org.mariadb.jdbc.client.ReadableByteBuf buffer,
                     MutableInt fieldLength,
                     org.mariadb.jdbc.client.ColumnDecoder column,
                     Calendar cal)
              throws SQLDataException
        Decode from a mysql packet text encoded a value to codec java type
        Parameters:
        buffer - mysql packet buffer
        fieldLength - encoded value length
        column - server column metadata
        cal - calendar
        Returns:
        decoded value
        Throws:
        SQLDataException - if unexpected error occurs during decoding
      • decodeBinary

        T decodeBinary​(org.mariadb.jdbc.client.ReadableByteBuf buffer,
                       MutableInt fieldLength,
                       org.mariadb.jdbc.client.ColumnDecoder column,
                       Calendar cal)
                throws SQLDataException
        Decode from a mysql packet binary encoded a value to codec java type
        Parameters:
        buffer - mysql packet buffer
        fieldLength - encoded value length
        column - server column metadata
        cal - calendar
        Returns:
        decoded value
        Throws:
        SQLDataException - if unexpected error occurs during decoding
      • encodeText

        void encodeText​(Writer encoder,
                        org.mariadb.jdbc.client.Context context,
                        Object value,
                        Calendar cal,
                        Long length)
                 throws IOException,
                        SQLException
        Text encode value to writer
        Parameters:
        encoder - writer
        context - connection context
        value - value to encode
        cal - calendar
        length - maximum value length
        Throws:
        IOException - if any socket error occurs
        SQLException - if encoding error occurs
      • canEncodeLongData

        default boolean canEncodeLongData()
        Indicate if can encode long data
        Returns:
        true if possible
      • encodeLongData

        default void encodeLongData​(Writer encoder,
                                    T value,
                                    Long length)
                             throws IOException,
                                    SQLException
        binary encoding value to a long data packet
        Parameters:
        encoder - writer
        value - value to encode
        length - maximum length value
        Throws:
        IOException - if any socket error occurs
        SQLException - if encoding error occurs
      • encodeData

        default byte[] encodeData​(T value,
                                  Long length)
                           throws IOException,
                                  SQLException
        binary encoding value to a byte[]
        Parameters:
        value - value to encode
        length - maximum length value
        Returns:
        encoded value
        Throws:
        IOException - if any socket error occurs
        SQLException - if encoding error occurs
      • getBinaryEncodeType

        int getBinaryEncodeType()
        Return server encoding data type
        Returns:
        server encoding data type