Package org.postgresql.jdbc
Class PgArray
java.lang.Object
org.postgresql.jdbc.PgArray
- All Implemented Interfaces:
Array
Array is used collect one column of query result data.
Read a field of type Array into either a natively-typed Java array object or a ResultSet. Accessor methods provide the ability to capture array slices.
Other than the constructor all methods are direct implementations of those specified for java.sql.Array. Please refer to the javadoc for java.sql.Array for detailed descriptions of the functionality and parameters of the methods of this class.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayDecoding.PgArrayList
Value of field asArrayDecoding.PgArrayList
.protected BaseConnection
A database connection.protected byte[]
protected String
Field value as String.private final ResourceLock
private final int
The OID of this field. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
PgArray
(BaseConnection connection, int oid) PgArray
(BaseConnection connection, int oid, byte[] fieldBytes) Create a new Array.PgArray
(BaseConnection connection, int oid, String fieldString) Create a new Array. -
Method Summary
Modifier and TypeMethodDescriptionprivate Object
buildArray
(ArrayDecoding.PgArrayList input, int index, int count) ConvertArrayList
to array.private ArrayDecoding.PgArrayList
buildArrayList
(String fieldString) BuildArrayList
from field's string input.private int
calcRemainingDataLength
(byte[] fieldBytes, int[] dims, int pos, int elementOid, int thisDimension) static void
void
free()
getArray()
getArray
(long index, int count) getArrayImpl
(long index, int count, Map<String, Class<?>> map) getArrayImpl
(Map<String, Class<?>> map) int
private BaseConnection
getResultSet
(long index, int count) getResultSet
(long index, int count, Map<String, Class<?>> map) getResultSet
(Map<String, Class<?>> map) getResultSetImpl
(long index, int count, Map<String, Class<?>> map) getResultSetImpl
(Map<String, Class<?>> map) boolean
isBinary()
private Object
readBinaryArray
(byte[] fieldBytes, int index, int count) private ResultSet
readBinaryResultSet
(byte[] fieldBytes, int index, int count) private int
storeValues
(byte[] fieldBytes, List<Tuple> rows, Field[] fields, int elementOid, int[] dims, int pos, int thisDimension, int index) byte[]
toBytes()
toString()
private String
Convert array list to PG String representation (e.g.
-
Field Details
-
connection
A database connection. -
oid
private final int oidThe OID of this field. -
fieldString
Field value as String. -
arrayList
Value of field asArrayDecoding.PgArrayList
. Will be initialized only once withinbuildArrayList(String)
. -
fieldBytes
protected byte[] fieldBytes -
lock
-
-
Constructor Details
-
PgArray
- Throws:
SQLException
-
PgArray
Create a new Array.- Parameters:
connection
- a database connectionoid
- the oid of the array datatypefieldString
- the array data in string form- Throws:
SQLException
- if something wrong happens
-
PgArray
Create a new Array.- Parameters:
connection
- a database connectionoid
- the oid of the array datatypefieldBytes
- the array data in byte form- Throws:
SQLException
- if something wrong happens
-
-
Method Details
-
getConnection
-
getArray
- Specified by:
getArray
in interfaceArray
- Throws:
SQLException
-
getArray
- Specified by:
getArray
in interfaceArray
- Throws:
SQLException
-
getArrayImpl
- Throws:
SQLException
-
getArray
- Specified by:
getArray
in interfaceArray
- Throws:
SQLException
-
getArray
- Specified by:
getArray
in interfaceArray
- Throws:
SQLException
-
getArrayImpl
- Throws:
SQLException
-
readBinaryArray
- Throws:
SQLException
-
readBinaryResultSet
- Throws:
SQLException
-
storeValues
private int storeValues(byte[] fieldBytes, List<Tuple> rows, Field[] fields, int elementOid, int[] dims, int pos, int thisDimension, int index) throws SQLException - Throws:
SQLException
-
calcRemainingDataLength
private int calcRemainingDataLength(byte[] fieldBytes, int[] dims, int pos, int elementOid, int thisDimension) -
buildArrayList
BuildArrayList
from field's string input. As a result of this methodarrayList
is build. Method can be called many times in order to make sure that array list is ready to use, howeverarrayList
will be set only once during first call.- Throws:
SQLException
-
buildArray
private Object buildArray(ArrayDecoding.PgArrayList input, int index, int count) throws SQLException ConvertArrayList
to array.- Parameters:
input
- list to be converted into array- Throws:
SQLException
-
getBaseType
- Specified by:
getBaseType
in interfaceArray
- Throws:
SQLException
-
getBaseTypeName
- Specified by:
getBaseTypeName
in interfaceArray
- Throws:
SQLException
-
getResultSet
- Specified by:
getResultSet
in interfaceArray
- Throws:
SQLException
-
getResultSet
- Specified by:
getResultSet
in interfaceArray
- Throws:
SQLException
-
getResultSet
- Specified by:
getResultSet
in interfaceArray
- Throws:
SQLException
-
getResultSet
- Specified by:
getResultSet
in interfaceArray
- Throws:
SQLException
-
getResultSetImpl
- Throws:
SQLException
-
getResultSetImpl
public ResultSet getResultSetImpl(long index, int count, Map<String, Class<?>> map) throws SQLException- Throws:
SQLException
-
toString
-
toString
Convert array list to PG String representation (e.g. {0,1,2}).- Throws:
SQLException
-
escapeArrayElement
-
isBinary
public boolean isBinary() -
toBytes
public byte[] toBytes() -
free
- Specified by:
free
in interfaceArray
- Throws:
SQLException
-