Package org.postgresql.jdbc
Class ArrayEncoding
java.lang.Object
org.postgresql.jdbc.ArrayEncoding
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 ClassesModifier and TypeClassDescriptionprivate static class
Base class to implementArrayEncoding.ArrayEncoder
and provide multi-dimensional support.(package private) static interface
private static class
Base support for primitive arrays.private static class
ArrayEncoding.NumberArrayEncoder<N extends Number>
Base class to provide support forNumber
based arrays.private static final class
Wraps anArrayEncoding.AbstractArrayEncoder
implementation and provides support for 2 or more dimensions using recursion.private static final class
Wraps anArrayEncoding.AbstractArrayEncoder
implementation and provides optimized support for 2 dimensions. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map
<Class, ArrayEncoding.AbstractArrayEncoder> private static final ArrayEncoding.AbstractArrayEncoder
<boolean[]> private static final ArrayEncoding.AbstractArrayEncoder
<Boolean[]> private static final ArrayEncoding.AbstractArrayEncoder
<byte[][]> private static final ArrayEncoding.AbstractArrayEncoder
<double[]> private static final ArrayEncoding.AbstractArrayEncoder
<Double[]> private static final ArrayEncoding.AbstractArrayEncoder
<float[]> private static final ArrayEncoding.AbstractArrayEncoder
<Float[]> private static final ArrayEncoding.AbstractArrayEncoder
<int[]> private static final ArrayEncoding.AbstractArrayEncoder
<Integer[]> private static final ArrayEncoding.AbstractArrayEncoder
<long[]> private static final ArrayEncoding.AbstractArrayEncoder
<Long[]> private static final ArrayEncoding.AbstractArrayEncoder
<Object[]> private static final ArrayEncoding.AbstractArrayEncoder
<short[]> private static final ArrayEncoding.AbstractArrayEncoder
<Short[]> private static final ArrayEncoding.AbstractArrayEncoder
<String[]> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <A> ArrayEncoding.ArrayEncoder
<A> getArrayEncoder
(A array) Returns support for encoding array.
-
Field Details
-
LONG_ARRAY
-
LONG_OBJ_ARRAY
-
INT_ARRAY
-
INT_OBJ_ARRAY
-
SHORT_ARRAY
-
SHORT_OBJ_ARRAY
-
DOUBLE_ARRAY
-
DOUBLE_OBJ_ARRAY
-
FLOAT_ARRAY
-
FLOAT_OBJ_ARRAY
-
BOOLEAN_ARRAY
-
BOOLEAN_OBJ_ARRAY
-
STRING_ARRAY
-
BYTEA_ARRAY
-
OBJECT_ARRAY
-
ARRAY_CLASS_TO_ENCODER
-
-
Constructor Details
-
ArrayEncoding
ArrayEncoding()
-
-
Method Details
-
getArrayEncoder
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:
-