Package org.postgresql.jdbc
Class ArrayEncoding.RecursiveArrayEncoder
java.lang.Object
org.postgresql.jdbc.ArrayEncoding.RecursiveArrayEncoder
- All Implemented Interfaces:
ArrayEncoding.ArrayEncoder
- Enclosing class:
ArrayEncoding
private static final class ArrayEncoding.RecursiveArrayEncoder
extends Object
implements ArrayEncoding.ArrayEncoder
Wraps an
ArrayEncoding.AbstractArrayEncoder
implementation and provides support for
2 or more dimensions using recursion.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private final ArrayEncoding.AbstractArrayEncoder
-
Constructor Summary
ConstructorsConstructorDescriptionRecursiveArrayEncoder
(ArrayEncoding.AbstractArrayEncoder support, int dimensions) -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendArray
(StringBuilder sb, char delim, Object array) AppendString
representation of array to sb.private void
arrayString
(StringBuilder sb, Object array, char delim, int depth) int
The default array type oid supported by this instance.private boolean
boolean
supportBinaryRepresentation
(int oid) Indicates if an array can be encoded in binary form to array oid.toArrayString
(char delim, Object array) CreatesString
representation of the array.byte[]
toBinaryRepresentation
(BaseConnection connection, Object array, int oid) Creates binary representation of the array.private void
writeArray
(BaseConnection connection, byte[] buffer, ByteArrayOutputStream baos, Object array, int depth, boolean first)
-
Field Details
-
support
-
dimensions
private final int dimensions
-
-
Constructor Details
-
RecursiveArrayEncoder
RecursiveArrayEncoder(ArrayEncoding.AbstractArrayEncoder support, int dimensions) - Parameters:
support
- The instance providing support for the base array type.
-
-
Method Details
-
getDefaultArrayTypeOid
public int getDefaultArrayTypeOid()The default array type oid supported by this instance.- Specified by:
getDefaultArrayTypeOid
in interfaceArrayEncoding.ArrayEncoder
- Returns:
- The default array type oid supported by this instance.
-
toArrayString
CreatesString
representation of the array.- Specified by:
toArrayString
in interfaceArrayEncoding.ArrayEncoder
- Parameters:
delim
- The character to use to delimit between elements.array
- The array to represent as aString
.- Returns:
String
representation of the array.
-
appendArray
AppendString
representation of array to sb.- Specified by:
appendArray
in interfaceArrayEncoding.ArrayEncoder
- Parameters:
sb
- TheStringBuilder
to append to.delim
- The delimiter between elements.array
- The array to represent. Will not benull
, but may containnull
elements.
-
arrayString
-
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
- 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.
-
hasNulls
-
toBinaryRepresentation
public byte[] toBinaryRepresentation(BaseConnection connection, Object array, int oid) throws SQLException, SQLFeatureNotSupportedException Creates binary representation of the array.- Specified by:
toBinaryRepresentation
in interfaceArrayEncoding.ArrayEncoder
- 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:
SQLFeatureNotSupportedException
- IfArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int)
is false for oid.SQLException
-
writeArray
private void writeArray(BaseConnection connection, byte[] buffer, ByteArrayOutputStream baos, Object array, int depth, boolean first) throws IOException, SQLException - Throws:
IOException
SQLException
-