Package org.postgresql.jdbc
Class ArrayEncoding
- java.lang.Object
-
- org.postgresql.jdbc.ArrayEncoding
-
final class ArrayEncoding extends java.lang.Object
Utility for using arrays in requests.Binary format:
- 4 bytes with number of dimensions
- 4 bytes, boolean indicating nulls present or not
- 4 bytes type oid
- 8 bytes describing the length of each dimension (repeated for each dimension)
- 4 bytes for length
- 4 bytes for lower bound on length to check for overflow (it appears this value can always be 0)
- data in depth first element order corresponding number and length of dimensions
- 4 bytes describing length of element,
0xFFFFFFFF
(-1
) meansnull
- binary representation of element (iff not
null
).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ArrayEncoding.AbstractArrayEncoder<A>
Base class to implementArrayEncoding.ArrayEncoder
and provide multi-dimensional support.static interface
ArrayEncoding.ArrayEncoder<A>
private static class
ArrayEncoding.FixedSizePrimitiveArrayEncoder<A>
Base support for primitive arrays.private static class
ArrayEncoding.NumberArrayEncoder<N extends java.lang.Number>
Base class to provide support forNumber
based arrays.private static class
ArrayEncoding.RecursiveArrayEncoder
Wraps anArrayEncoding.AbstractArrayEncoder
implementation and provides support for 2 or more dimensions using recursion.private static class
ArrayEncoding.TwoDimensionPrimitiveArrayEncoder<A>
Wraps anArrayEncoding.AbstractArrayEncoder
implementation and provides optimized support for 2 dimensions.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ArrayEncoding()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <A> ArrayEncoding.ArrayEncoder<A>
getArrayEncoder(A array)
Returns support for encoding array.
-
-
-
Field Detail
-
LONG_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<long[]> LONG_ARRAY
-
LONG_OBJ_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<java.lang.Long[]> LONG_OBJ_ARRAY
-
INT_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<int[]> INT_ARRAY
-
INT_OBJ_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<java.lang.Integer[]> INT_OBJ_ARRAY
-
SHORT_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<short[]> SHORT_ARRAY
-
SHORT_OBJ_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<java.lang.Short[]> SHORT_OBJ_ARRAY
-
DOUBLE_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<double[]> DOUBLE_ARRAY
-
DOUBLE_OBJ_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<java.lang.Double[]> DOUBLE_OBJ_ARRAY
-
FLOAT_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<float[]> FLOAT_ARRAY
-
FLOAT_OBJ_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<java.lang.Float[]> FLOAT_OBJ_ARRAY
-
BOOLEAN_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<boolean[]> BOOLEAN_ARRAY
-
BOOLEAN_OBJ_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<java.lang.Boolean[]> BOOLEAN_OBJ_ARRAY
-
STRING_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<java.lang.String[]> STRING_ARRAY
-
BYTEA_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<byte[][]> BYTEA_ARRAY
-
OBJECT_ARRAY
private static final ArrayEncoding.AbstractArrayEncoder<java.lang.Object[]> OBJECT_ARRAY
-
ARRAY_CLASS_TO_ENCODER
private static final java.util.Map<java.lang.Class,ArrayEncoding.AbstractArrayEncoder> ARRAY_CLASS_TO_ENCODER
-
-
Method Detail
-
getArrayEncoder
public static <A> ArrayEncoding.ArrayEncoder<A> getArrayEncoder(A array) throws PSQLException
Returns support for encoding array.- Parameters:
array
- The array to encode. Must not benull
.- Returns:
- An instance capable of encoding array as a
String
at minimum. Some types may support binary encoding. - Throws:
PSQLException
- if array is not a supported type.- See Also:
ArrayEncoding.ArrayEncoder.supportBinaryRepresentation(int)
-
-