Package org.postgresql.jdbc
Class ArrayEncoding.NumberArrayEncoder<N extends java.lang.Number>
- java.lang.Object
-
- org.postgresql.jdbc.ArrayEncoding.AbstractArrayEncoder<N[]>
-
- org.postgresql.jdbc.ArrayEncoding.NumberArrayEncoder<N>
-
- Type Parameters:
N- The base type of array.
- All Implemented Interfaces:
ArrayEncoding.ArrayEncoder<N[]>
- Enclosing class:
- ArrayEncoding
private abstract static class ArrayEncoding.NumberArrayEncoder<N extends java.lang.Number> extends ArrayEncoding.AbstractArrayEncoder<N[]>
Base class to provide support forNumberbased arrays.
-
-
Field Summary
Fields Modifier and Type Field Description private intfieldSize-
Fields inherited from class org.postgresql.jdbc.ArrayEncoding.AbstractArrayEncoder
arrayOid
-
-
Constructor Summary
Constructors Constructor Description NumberArrayEncoder(int fieldSize, int oid, int arrayOid)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidappendArray(java.lang.StringBuilder sb, char delim, N[] array)AppendStringrepresentation of array to sb.(package private) intcountNulls(N[] array)Counts the number ofnullelements in array.byte[]toBinaryRepresentation(BaseConnection connection, N[] array, int oid)Creates binary representation of the array.(package private) byte[]toSingleDimensionBinaryRepresentation(BaseConnection connection, N[] array)Createsbyte[]of just the raw data (no metadata).protected abstract voidwrite(N number, byte[] bytes, int offset)Write single value (number) to bytes beginning at offset.private byte[]writeBytes(N[] array, int nullCount, int offset)-
Methods inherited from class org.postgresql.jdbc.ArrayEncoding.AbstractArrayEncoder
getDefaultArrayTypeOid, getTypeOID, supportBinaryRepresentation, toArrayString
-
-
-
-
Method Detail
-
countNulls
final int countNulls(N[] array)
Counts the number ofnullelements in array.- Overrides:
countNullsin classArrayEncoding.AbstractArrayEncoder<N extends java.lang.Number[]>- Parameters:
array- The array to countnullelements in.- Returns:
- The number of
nullelements in array.
-
toBinaryRepresentation
public final byte[] toBinaryRepresentation(BaseConnection connection, N[] 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 containnullelements.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, N[] array) throws java.sql.SQLException, java.sql.SQLFeatureNotSupportedException
Createsbyte[]of just the raw data (no metadata).- Specified by:
toSingleDimensionBinaryRepresentationin classArrayEncoding.AbstractArrayEncoder<N extends java.lang.Number[]>- 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:
java.sql.SQLFeatureNotSupportedException- IfArrayEncoding.AbstractArrayEncoder.supportBinaryRepresentation(int)is false for oid.java.sql.SQLException
-
writeBytes
private byte[] writeBytes(N[] array, int nullCount, int offset)
-
write
protected abstract void write(N number, byte[] bytes, int offset)
Write single value (number) to bytes beginning at offset.- Parameters:
number- The value to write to bytes. This will never benull.bytes- Thebyte[]to write to.offset- The offset into bytes to write the number value.
-
appendArray
public final void appendArray(java.lang.StringBuilder sb, char delim, N[] array)AppendStringrepresentation of array to sb.- Parameters:
sb- TheStringBuilderto append to.delim- The delimiter between elements.array- The array to represent. Will not benull, but may containnullelements.
-
-