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
Fields Modifier and Type Field Description private int
fieldSize
-
Fields inherited from class org.postgresql.jdbc.ArrayEncoding.AbstractArrayEncoder
arrayOid
-
-
Constructor Summary
Constructors Constructor Description FixedSizePrimitiveArrayEncoder(int fieldSize, int oid, int arrayOid)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) int
countNulls(A array)
Counts the number ofnull
elements in array.byte[]
toBinaryRepresentation(BaseConnection connection, A array, int oid)
Creates binary representation of the array.(package private) byte[]
toSingleDimensionBinaryRepresentation(BaseConnection connection, A array)
Createsbyte[]
of just the raw data (no metadata).protected abstract void
write(A array, byte[] bytes, int offset)
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
-
-
-
-
Method Detail
-
countNulls
final int countNulls(A array)
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 java.sql.SQLException, java.sql.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:
java.sql.SQLFeatureNotSupportedException
- IfArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int)
is false for oid.java.sql.SQLException
-
toSingleDimensionBinaryRepresentation
final byte[] toSingleDimensionBinaryRepresentation(BaseConnection connection, A array) throws java.sql.SQLException, java.sql.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:
java.sql.SQLFeatureNotSupportedException
- IfArrayEncoding.AbstractArrayEncoder.supportBinaryRepresentation(int)
is false for oid.java.sql.SQLException
-
write
protected abstract void write(A array, byte[] bytes, int offset)
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.
-
-