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 java.lang.Object implements ArrayEncoding.ArrayEncoder<A>
Base class to implementArrayEncoding.ArrayEncoder
and provide multi-dimensional support.
-
-
Constructor Summary
Constructors Constructor Description AbstractArrayEncoder(int oid, int arrayOid)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract void
appendArray(java.lang.StringBuilder sb, char delim, A array)
AppendString
representation of array to sb.(package private) int
countNulls(A array)
Counts the number ofnull
elements in array.int
getDefaultArrayTypeOid()
By default returns the arrayOid this instance was instantiated with.(package private) int
getTypeOID(int arrayOid)
boolean
supportBinaryRepresentation(int oid)
By default returnstrue
if oid matches the arrayOid this instance was instantiated with.java.lang.String
toArrayString(char delim, A array)
CreatesString
representation 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, wait
-
Methods inherited from interface org.postgresql.jdbc.ArrayEncoding.ArrayEncoder
toBinaryRepresentation
-
-
-
-
Method Detail
-
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:
getDefaultArrayTypeOid
in interfaceArrayEncoding.ArrayEncoder<A>
- Returns:
- The default array type oid supported by this instance.
-
countNulls
int countNulls(A array)
Counts the number ofnull
elements in array.- Parameters:
array
- The array to countnull
elements in.- Returns:
- The number of
null
elements in array.
-
toSingleDimensionBinaryRepresentation
abstract byte[] toSingleDimensionBinaryRepresentation(BaseConnection connection, A array) throws java.sql.SQLException, java.sql.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 containnull
elements.- Returns:
byte[]
of just the raw data (no metadata).- Throws:
java.sql.SQLFeatureNotSupportedException
- IfsupportBinaryRepresentation(int)
is false for oid.java.sql.SQLException
-
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
abstract void appendArray(java.lang.StringBuilder sb, char delim, A array)
AppendString
representation of array to sb.- 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)
By default returnstrue
if oid matches the arrayOid this instance was instantiated with.- 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.
-
-