Package org.postgresql.jdbc
Class ArrayEncoding.TwoDimensionPrimitiveArrayEncoder<A>
- java.lang.Object
-
- org.postgresql.jdbc.ArrayEncoding.TwoDimensionPrimitiveArrayEncoder<A>
-
- All Implemented Interfaces:
ArrayEncoding.ArrayEncoder<A[]>
- Enclosing class:
- ArrayEncoding
private static final class ArrayEncoding.TwoDimensionPrimitiveArrayEncoder<A> extends java.lang.Object implements ArrayEncoding.ArrayEncoder<A[]>
Wraps anArrayEncoding.AbstractArrayEncoder
implementation and provides optimized support for 2 dimensions.
-
-
Field Summary
Fields Modifier and Type Field Description private ArrayEncoding.AbstractArrayEncoder<A>
support
-
Constructor Summary
Constructors Constructor Description TwoDimensionPrimitiveArrayEncoder(ArrayEncoding.AbstractArrayEncoder<A> support)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendArray(java.lang.StringBuilder sb, char delim, A[] array)
AppendString
representation of array to sb.int
getDefaultArrayTypeOid()
The default array type oid supported by this instance.boolean
supportBinaryRepresentation(int oid)
Indicates if an array can be encoded in binary form to array oid.java.lang.String
toArrayString(char delim, A[] array)
CreatesString
representation of the array.byte[]
toBinaryRepresentation(BaseConnection connection, A[] array, int oid)
Creates binary representation of the array.
-
-
-
Field Detail
-
support
private final ArrayEncoding.AbstractArrayEncoder<A> support
-
-
Constructor Detail
-
TwoDimensionPrimitiveArrayEncoder
TwoDimensionPrimitiveArrayEncoder(ArrayEncoding.AbstractArrayEncoder<A> support)
- Parameters:
support
- The instance providing support for the base array type.
-
-
Method Detail
-
getDefaultArrayTypeOid
public int getDefaultArrayTypeOid()
The default array type oid supported by this instance.- Specified by:
getDefaultArrayTypeOid
in interfaceArrayEncoding.ArrayEncoder<A>
- Returns:
- The default array type oid supported by this instance.
-
toArrayString
public java.lang.String toArrayString(char delim, A[] array)
CreatesString
representation of the array.- Specified by:
toArrayString
in interfaceArrayEncoding.ArrayEncoder<A>
- Parameters:
delim
- The character to use to delimit between elements.array
- The array to represent as aString
.- Returns:
String
representation of the array.
-
appendArray
public void appendArray(java.lang.StringBuilder sb, char delim, A[] array)
AppendString
representation of array to sb.- Specified by:
appendArray
in interfaceArrayEncoding.ArrayEncoder<A>
- Parameters:
sb
- TheStringBuilder
to append to.delim
- The delimiter between elements.array
- The array to represent. Will not benull
, but may containnull
elements.
-
supportBinaryRepresentation
public boolean supportBinaryRepresentation(int oid)
Indicates if an array can be encoded in binary form to array oid.- Specified by:
supportBinaryRepresentation
in interfaceArrayEncoding.ArrayEncoder<A>
- Parameters:
oid
- The array oid to see check for binary support.- Returns:
- Indication of whether
ArrayEncoding.ArrayEncoder.toBinaryRepresentation(BaseConnection, Object, int)
is supported for oid.
-
toBinaryRepresentation
public byte[] toBinaryRepresentation(BaseConnection connection, A[] array, int oid) throws java.sql.SQLException, java.sql.SQLFeatureNotSupportedException
Creates binary representation of the array. 4 bytes - dimension 4 bytes - oid 4 bytes - ? 8*d bytes - dimension length- Specified by:
toBinaryRepresentation
in interfaceArrayEncoding.ArrayEncoder<A>
- 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 benull
, but may containnull
elements.oid
- The array type oid to use. Calls toArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int)
must have returnedtrue
.- Returns:
- The binary representation of array.
- Throws:
java.sql.SQLFeatureNotSupportedException
- IfArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int)
is false for oid.java.sql.SQLException
-
-