Package org.postgresql.jdbc
Class ArrayEncoding.FixedSizePrimitiveArrayEncoder<A>
java.lang.Object
org.postgresql.jdbc.ArrayEncoding.AbstractArrayEncoder<A>
org.postgresql.jdbc.ArrayEncoding.FixedSizePrimitiveArrayEncoder<A>
- Type Parameters:
A
- The primitive array to support.
- All Implemented Interfaces:
ArrayEncoding.ArrayEncoder<A>
- Enclosing class:
- ArrayEncoding
private abstract static class ArrayEncoding.FixedSizePrimitiveArrayEncoder<A>
extends ArrayEncoding.AbstractArrayEncoder<A>
Base support for primitive arrays.
-
Field Summary
FieldsFields inherited from class org.postgresql.jdbc.ArrayEncoding.AbstractArrayEncoder
arrayOid
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final int
countNulls
(A array) Counts the number ofnull
elements in array.final byte[]
toBinaryRepresentation
(BaseConnection connection, A array, int oid) Creates binary representation of the array.(package private) final byte[]
toSingleDimensionBinaryRepresentation
(BaseConnection connection, A array) Createsbyte[]
of just the raw data (no metadata).protected abstract void
Write the entire contents of array to bytes starting at offset without metadata describing type or length.Methods inherited from class org.postgresql.jdbc.ArrayEncoding.AbstractArrayEncoder
getDefaultArrayTypeOid, getTypeOID, supportBinaryRepresentation, toArrayString
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
appendArray
-
Field Details
-
fieldSize
private final int fieldSize
-
-
Constructor Details
-
FixedSizePrimitiveArrayEncoder
FixedSizePrimitiveArrayEncoder(int fieldSize, int oid, int arrayOid)
-
-
Method Details
-
countNulls
Counts the number ofnull
elements in array.Always returns
0
.- Overrides:
countNulls
in classArrayEncoding.AbstractArrayEncoder<A>
- Parameters:
array
- The array to countnull
elements in.- Returns:
- The number of
null
elements in array.
-
toBinaryRepresentation
public final byte[] toBinaryRepresentation(BaseConnection connection, A array, int oid) throws SQLException, SQLFeatureNotSupportedException Creates binary representation of the array.- 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
-
toSingleDimensionBinaryRepresentation
final byte[] toSingleDimensionBinaryRepresentation(BaseConnection connection, A array) throws SQLException, SQLFeatureNotSupportedException Createsbyte[]
of just the raw data (no metadata).- Specified by:
toSingleDimensionBinaryRepresentation
in classArrayEncoding.AbstractArrayEncoder<A>
- 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:
SQLFeatureNotSupportedException
- IfArrayEncoding.AbstractArrayEncoder.supportBinaryRepresentation(int)
is false for oid.SQLException
-
write
Write the entire contents of array to bytes starting at offset without metadata describing type or length.- Parameters:
array
- The array to write.bytes
- Thebyte[]
to write to.offset
- The offset into bytes to start writing.
-