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 java.lang.Object implements ArrayEncoding.ArrayEncoder
Wraps anArrayEncoding.AbstractArrayEncoderimplementation and provides support for 2 or more dimensions using recursion.
-
-
Field Summary
Fields Modifier and Type Field Description private intdimensionsprivate ArrayEncoding.AbstractArrayEncodersupport
-
Constructor Summary
Constructors Constructor Description RecursiveArrayEncoder(ArrayEncoding.AbstractArrayEncoder support, int dimensions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendArray(java.lang.StringBuilder sb, char delim, java.lang.Object array)AppendStringrepresentation of array to sb.private voidarrayString(java.lang.StringBuilder sb, java.lang.Object array, char delim, int depth)intgetDefaultArrayTypeOid()The default array type oid supported by this instance.private booleanhasNulls(java.lang.Object array, int depth)booleansupportBinaryRepresentation(int oid)Indicates if an array can be encoded in binary form to array oid.java.lang.StringtoArrayString(char delim, java.lang.Object array)CreatesStringrepresentation of the array.byte[]toBinaryRepresentation(BaseConnection connection, java.lang.Object array, int oid)Creates binary representation of the array.private voidwriteArray(BaseConnection connection, byte[] buffer, java.io.ByteArrayOutputStream baos, java.lang.Object array, int depth, boolean first)
-
-
-
Field Detail
-
support
private final ArrayEncoding.AbstractArrayEncoder support
-
dimensions
private final int dimensions
-
-
Constructor Detail
-
RecursiveArrayEncoder
RecursiveArrayEncoder(ArrayEncoding.AbstractArrayEncoder support, int dimensions)
- 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:
getDefaultArrayTypeOidin interfaceArrayEncoding.ArrayEncoder- Returns:
- The default array type oid supported by this instance.
-
toArrayString
public java.lang.String toArrayString(char delim, java.lang.Object array)CreatesStringrepresentation of the array.- Specified by:
toArrayStringin interfaceArrayEncoding.ArrayEncoder- Parameters:
delim- The character to use to delimit between elements.array- The array to represent as aString.- Returns:
Stringrepresentation of the array.
-
appendArray
public void appendArray(java.lang.StringBuilder sb, char delim, java.lang.Object array)AppendStringrepresentation of array to sb.- Specified by:
appendArrayin interfaceArrayEncoding.ArrayEncoder- Parameters:
sb- TheStringBuilderto append to.delim- The delimiter between elements.array- The array to represent. Will not benull, but may containnullelements.
-
arrayString
private void arrayString(java.lang.StringBuilder sb, java.lang.Object array, char delim, int depth)
-
supportBinaryRepresentation
public boolean supportBinaryRepresentation(int oid)
Indicates if an array can be encoded in binary form to array oid.- Specified by:
supportBinaryRepresentationin 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
private boolean hasNulls(java.lang.Object array, int depth)
-
toBinaryRepresentation
public byte[] toBinaryRepresentation(BaseConnection connection, java.lang.Object array, int oid) throws java.sql.SQLException, java.sql.SQLFeatureNotSupportedException
Creates binary representation of the array.- Specified by:
toBinaryRepresentationin 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 containnullelements.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
-
writeArray
private void writeArray(BaseConnection connection, byte[] buffer, java.io.ByteArrayOutputStream baos, java.lang.Object array, int depth, boolean first) throws java.io.IOException, java.sql.SQLException
- Throws:
java.io.IOExceptionjava.sql.SQLException
-
-