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 ArrayEncoding.AbstractArrayEncoder
arrayOid -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) final intcountNulls(A array) Counts the number ofnullelements 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 voidWrite the entire contents of array to bytes starting at offset without metadata describing type or length.Methods inherited from class ArrayEncoding.AbstractArrayEncoder
getDefaultArrayTypeOid, getTypeOID, supportBinaryRepresentation, toArrayStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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 ofnullelements in array.Always returns
0.- Overrides:
countNullsin classArrayEncoding.AbstractArrayEncoder<A>- Parameters:
array- The array to countnullelements in.- Returns:
- The number of
nullelements 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 containnullelements.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:
toSingleDimensionBinaryRepresentationin 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 containnullelements.- 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.
-