Class ArrayEncoding.NumberArrayEncoder<N extends java.lang.Number>

    • Field Detail

      • fieldSize

        private final int fieldSize
    • Constructor Detail

      • NumberArrayEncoder

        NumberArrayEncoder​(int fieldSize,
                           int oid,
                           int arrayOid)
        Parameters:
        fieldSize - The fixed size to represent each value in binary.
        oid - The base type oid.
        arrayOid - The array type oid.
    • Method Detail

      • countNulls

        final int countNulls​(N[] array)
        Counts the number of null elements in array.
        Overrides:
        countNulls in class ArrayEncoding.AbstractArrayEncoder<N extends java.lang.Number[]>
        Parameters:
        array - The array to count null elements in.
        Returns:
        The number of null elements in array.
      • toBinaryRepresentation

        public final byte[] toBinaryRepresentation​(BaseConnection connection,
                                                   N[] array,
                                                   int oid)
                                            throws java.sql.SQLException,
                                                   java.sql.SQLFeatureNotSupportedException
        Creates binary representation of the array.
        Parameters:
        connection - The connection the binary representation will be used on. Attributes from the connection might impact how values are translated to binary.
        array - The array to binary encode. Must not be null, but may contain null elements.
        oid - The array type oid to use. Calls to ArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int) must have returned true.
        Returns:
        The binary representation of array.
        Throws:
        java.sql.SQLFeatureNotSupportedException - If ArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int) is false for oid.
        java.sql.SQLException
      • toSingleDimensionBinaryRepresentation

        final byte[] toSingleDimensionBinaryRepresentation​(BaseConnection connection,
                                                           N[] array)
                                                    throws java.sql.SQLException,
                                                           java.sql.SQLFeatureNotSupportedException
        Creates byte[] of just the raw data (no metadata).
        Specified by:
        toSingleDimensionBinaryRepresentation in class ArrayEncoding.AbstractArrayEncoder<N extends java.lang.Number[]>
        Parameters:
        connection - The connection the binary representation will be used on.
        array - The array to create binary representation of. Will not be null, but may contain null elements.
        Returns:
        byte[] of just the raw data (no metadata).
        Throws:
        java.sql.SQLFeatureNotSupportedException - If ArrayEncoding.AbstractArrayEncoder.supportBinaryRepresentation(int) is false for oid.
        java.sql.SQLException
      • writeBytes

        private byte[] writeBytes​(N[] array,
                                  int nullCount,
                                  int offset)
      • write

        protected abstract void write​(N number,
                                      byte[] bytes,
                                      int offset)
        Write single value (number) to bytes beginning at offset.
        Parameters:
        number - The value to write to bytes. This will never be null.
        bytes - The byte[] to write to.
        offset - The offset into bytes to write the number value.
      • appendArray

        public final void appendArray​(java.lang.StringBuilder sb,
                                      char delim,
                                      N[] array)
        Append String representation of array to sb.
        Parameters:
        sb - The StringBuilder to append to.
        delim - The delimiter between elements.
        array - The array to represent. Will not be null, but may contain null elements.