N
- The base type of array.private abstract static class ArrayEncoding.NumberArrayEncoder<N extends java.lang.Number> extends ArrayEncoding.AbstractArrayEncoder<N[]>
Number
based arrays.Modifier and Type | Field and Description |
---|---|
private int |
fieldSize |
arrayOid
Constructor and Description |
---|
NumberArrayEncoder(int fieldSize,
int oid,
int arrayOid) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
appendArray(java.lang.StringBuilder sb,
char delim,
N[] array)
Append
String representation of array to sb. |
(package private) int |
countNulls(N[] array)
Counts the number of
null elements in array. |
byte[] |
toBinaryRepresentation(BaseConnection connection,
N[] array,
int oid)
Creates binary representation of the array.
|
(package private) byte[] |
toSingleDimensionBinaryRepresentation(BaseConnection connection,
N[] array)
Creates
byte[] of just the raw data (no metadata). |
protected abstract void |
write(N number,
byte[] bytes,
int offset)
Write single value (number) to bytes beginning at
offset.
|
private byte[] |
writeBytes(N[] array,
int nullCount,
int offset) |
getDefaultArrayTypeOid, getTypeOID, supportBinaryRepresentation, toArrayString
NumberArrayEncoder(int fieldSize, int oid, int arrayOid)
fieldSize
- The fixed size to represent each value in binary.oid
- The base type oid.arrayOid
- The array type oid.final int countNulls(N[] array)
null
elements in array.countNulls
in class ArrayEncoding.AbstractArrayEncoder<N extends java.lang.Number[]>
array
- The array to count null
elements in.null
elements in array.public final byte[] toBinaryRepresentation(BaseConnection connection, N[] array, int oid) throws java.sql.SQLException, java.sql.SQLFeatureNotSupportedException
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 be null
, but may
contain null
elements.oid
- The array type oid to use. Calls to
ArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int)
must have returned
true
.java.sql.SQLFeatureNotSupportedException
- If ArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int)
is false for
oid.java.sql.SQLException
final byte[] toSingleDimensionBinaryRepresentation(BaseConnection connection, N[] array) throws java.sql.SQLException, java.sql.SQLFeatureNotSupportedException
byte[]
of just the raw data (no metadata).toSingleDimensionBinaryRepresentation
in class ArrayEncoding.AbstractArrayEncoder<N extends java.lang.Number[]>
connection
- The connection the binary representation will be used on.array
- The array to create binary representation of. Will not be
null
, but may contain null
elements.byte[]
of just the raw data (no metadata).java.sql.SQLFeatureNotSupportedException
- If ArrayEncoding.AbstractArrayEncoder.supportBinaryRepresentation(int)
is false for
oid.java.sql.SQLException
private byte[] writeBytes(N[] array, int nullCount, int offset)
protected abstract void write(N number, byte[] bytes, int offset)
number
- The value to write to bytes. This will never be null
.bytes
- The byte[]
to write to.offset
- The offset into bytes to write the number value.final void appendArray(java.lang.StringBuilder sb, char delim, N[] array)
String
representation of array to sb.appendArray
in class ArrayEncoding.AbstractArrayEncoder<N extends java.lang.Number[]>
sb
- The StringBuilder
to append to.delim
- The delimiter between elements.array
- The array to represent. Will not be null
, but may contain
null
elements.