Package org.postgresql.jdbc
Class ArrayEncoding.AbstractArrayEncoder<A>
java.lang.Object
org.postgresql.jdbc.ArrayEncoding.AbstractArrayEncoder<A>
- Type Parameters:
A- Base array type supported.
- All Implemented Interfaces:
ArrayEncoding.ArrayEncoder<A>
- Direct Known Subclasses:
ArrayEncoding.FixedSizePrimitiveArrayEncoder,ArrayEncoding.NumberArrayEncoder
- Enclosing class:
ArrayEncoding
private abstract static class ArrayEncoding.AbstractArrayEncoder<A>
extends Object
implements ArrayEncoding.ArrayEncoder<A>
Base class to implement
ArrayEncoding.ArrayEncoder and provide
multi-dimensional support.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) intcountNulls(A array) Counts the number ofnullelements in array.intBy default returns the arrayOid this instance was instantiated with.(package private) intgetTypeOID(int arrayOid) booleansupportBinaryRepresentation(int oid) By default returnstrueif oid matches the arrayOid this instance was instantiated with.toArrayString(char delim, A array) CreatesStringrepresentation of the array.(package private) abstract byte[]toSingleDimensionBinaryRepresentation(BaseConnection connection, A array) Createsbyte[]of just the raw data (no metadata).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.postgresql.jdbc.ArrayEncoding.ArrayEncoder
appendArray, toBinaryRepresentation
-
Field Details
-
oid
private final int oid -
arrayOid
final int arrayOid
-
-
Constructor Details
-
AbstractArrayEncoder
AbstractArrayEncoder(int oid, int arrayOid) - Parameters:
oid- The default/primary base oid type.arrayOid- The default/primary array oid type.
-
-
Method Details
-
getTypeOID
int getTypeOID(int arrayOid) - Parameters:
arrayOid- The array oid to get base oid type for.- Returns:
- The base oid type for the given array oid type given to
ArrayEncoding.ArrayEncoder.toBinaryRepresentation(BaseConnection, Object, int).
-
getDefaultArrayTypeOid
public int getDefaultArrayTypeOid()By default returns the arrayOid this instance was instantiated with.- Specified by:
getDefaultArrayTypeOidin interfaceArrayEncoding.ArrayEncoder<A>- Returns:
- The default array type oid supported by this instance.
-
countNulls
Counts the number ofnullelements in array.- Parameters:
array- The array to countnullelements in.- Returns:
- The number of
nullelements in array.
-
toSingleDimensionBinaryRepresentation
abstract byte[] toSingleDimensionBinaryRepresentation(BaseConnection connection, A array) throws SQLException, SQLFeatureNotSupportedException Createsbyte[]of just the raw data (no metadata).- Parameters:
connection- The connection the binary representation will be used on.array- The array to create binary representation of. Will not benull, but may containnullelements.- Returns:
byte[]of just the raw data (no metadata).- Throws:
SQLFeatureNotSupportedException- IfsupportBinaryRepresentation(int)is false for oid.SQLException
-
toArrayString
CreatesStringrepresentation of the array.- Specified by:
toArrayStringin interfaceArrayEncoding.ArrayEncoder<A>- Parameters:
delim- The character to use to delimit between elements.array- The array to represent as aString.- Returns:
Stringrepresentation of the array.
-
supportBinaryRepresentation
public boolean supportBinaryRepresentation(int oid) By default returnstrueif oid matches the arrayOid this instance was instantiated with.- Specified by:
supportBinaryRepresentationin 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.
-