public class PgArray
extends java.lang.Object
implements java.sql.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.
ResultSet.getArray(int)| Modifier and Type | Class and Description |
|---|---|
private static class |
PgArray.PgArrayList
Array list implementation specific for storing PG array elements.
|
| Modifier and Type | Field and Description |
|---|---|
protected PgArray.PgArrayList |
arrayList
Value of field as
PgArray.PgArrayList. |
protected BaseConnection |
connection
A database connection.
|
protected byte[] |
fieldBytes |
protected java.lang.String |
fieldString
Field value as String.
|
private int |
oid
The OID of this field.
|
private boolean |
useObjects
Whether Object[] should be used instead primitive arrays.
|
| Modifier | Constructor and Description |
|---|---|
private |
PgArray(BaseConnection connection,
int oid) |
|
PgArray(BaseConnection connection,
int oid,
byte[] fieldBytes)
Create a new Array.
|
|
PgArray(BaseConnection connection,
int oid,
java.lang.String fieldString)
Create a new Array.
|
| Modifier and Type | Method and Description |
|---|---|
private java.lang.Object |
buildArray(PgArray.PgArrayList input,
int index,
int count)
Convert
ArrayList to array. |
private void |
buildArrayList()
Build
ArrayList from field's string input. |
private int |
calcRemainingDataLength(int[] dims,
int pos,
int elementOid,
int thisDimension) |
private java.lang.Class<?> |
elementOidToClass(int oid) |
static void |
escapeArrayElement(java.lang.StringBuilder b,
java.lang.String s) |
void |
free() |
java.lang.Object |
getArray() |
java.lang.Object |
getArray(long index,
int count) |
java.lang.Object |
getArray(long index,
int count,
java.util.Map<java.lang.String,java.lang.Class<?>> map) |
java.lang.Object |
getArray(java.util.Map<java.lang.String,java.lang.Class<?>> map) |
java.lang.Object |
getArrayImpl(long index,
int count,
java.util.Map<java.lang.String,java.lang.Class<?>> map) |
java.lang.Object |
getArrayImpl(java.util.Map<java.lang.String,java.lang.Class<?>> map) |
int |
getBaseType() |
java.lang.String |
getBaseTypeName() |
java.sql.ResultSet |
getResultSet() |
java.sql.ResultSet |
getResultSet(long index,
int count) |
java.sql.ResultSet |
getResultSet(long index,
int count,
java.util.Map<java.lang.String,java.lang.Class<?>> map) |
java.sql.ResultSet |
getResultSet(java.util.Map<java.lang.String,java.lang.Class<?>> map) |
java.sql.ResultSet |
getResultSetImpl(long index,
int count,
java.util.Map<java.lang.String,java.lang.Class<?>> map) |
java.sql.ResultSet |
getResultSetImpl(java.util.Map<java.lang.String,java.lang.Class<?>> map) |
boolean |
isBinary() |
private java.lang.Object |
readBinaryArray(int index,
int count) |
private java.sql.ResultSet |
readBinaryResultSet(int index,
int count) |
private int |
storeValues(java.util.List<Tuple> rows,
Field[] fields,
int elementOid,
int[] dims,
int pos,
int thisDimension,
int index) |
private int |
storeValues(java.lang.Object[] arr,
int elementOid,
int[] dims,
int pos,
int thisDimension,
int index) |
byte[] |
toBytes() |
java.lang.String |
toString() |
private java.lang.String |
toString(PgArray.PgArrayList list)
Convert array list to PG String representation (e.g.
|
protected BaseConnection connection
private int oid
protected java.lang.String fieldString
private final boolean useObjects
true if
BaseConnection#haveMinimumCompatibleVersion(String) returns true for
argument "8.3".protected PgArray.PgArrayList arrayList
PgArray.PgArrayList. Will be initialized only once within
buildArrayList().protected byte[] fieldBytes
private PgArray(BaseConnection connection, int oid) throws java.sql.SQLException
java.sql.SQLExceptionpublic PgArray(BaseConnection connection, int oid, java.lang.String fieldString) throws java.sql.SQLException
connection - a database connectionoid - the oid of the array datatypefieldString - the array data in string formjava.sql.SQLException - if something wrong happenspublic PgArray(BaseConnection connection, int oid, byte[] fieldBytes) throws java.sql.SQLException
connection - a database connectionoid - the oid of the array datatypefieldBytes - the array data in byte formjava.sql.SQLException - if something wrong happenspublic java.lang.Object getArray()
throws java.sql.SQLException
getArray in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.lang.Object getArray(long index,
int count)
throws java.sql.SQLException
getArray in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.lang.Object getArrayImpl(java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.Object getArray(java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
getArray in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.lang.Object getArray(long index,
int count,
java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
getArray in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.lang.Object getArrayImpl(long index,
int count,
java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
java.sql.SQLExceptionprivate java.lang.Object readBinaryArray(int index,
int count)
throws java.sql.SQLException
java.sql.SQLExceptionprivate int storeValues(java.lang.Object[] arr,
int elementOid,
int[] dims,
int pos,
int thisDimension,
int index)
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLExceptionjava.io.IOExceptionprivate java.sql.ResultSet readBinaryResultSet(int index,
int count)
throws java.sql.SQLException
java.sql.SQLExceptionprivate int storeValues(java.util.List<Tuple> rows, Field[] fields, int elementOid, int[] dims, int pos, int thisDimension, int index) throws java.sql.SQLException
java.sql.SQLExceptionprivate int calcRemainingDataLength(int[] dims,
int pos,
int elementOid,
int thisDimension)
private java.lang.Class<?> elementOidToClass(int oid)
throws java.sql.SQLException
java.sql.SQLExceptionprivate void buildArrayList()
throws java.sql.SQLException
ArrayList from field's string input. As a result of this method
arrayList is build. Method can be called many times in order to make sure that array
list is ready to use, however arrayList will be set only once during first call.java.sql.SQLExceptionprivate java.lang.Object buildArray(PgArray.PgArrayList input, int index, int count) throws java.sql.SQLException
ArrayList to array.input - list to be converted into arrayjava.sql.SQLExceptionpublic int getBaseType()
throws java.sql.SQLException
getBaseType in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.lang.String getBaseTypeName()
throws java.sql.SQLException
getBaseTypeName in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.sql.ResultSet getResultSet()
throws java.sql.SQLException
getResultSet in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.sql.ResultSet getResultSet(long index,
int count)
throws java.sql.SQLException
getResultSet in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.sql.ResultSet getResultSet(java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
getResultSet in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.sql.ResultSet getResultSet(long index,
int count,
java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
getResultSet in interface java.sql.Arrayjava.sql.SQLExceptionpublic java.sql.ResultSet getResultSetImpl(java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.ResultSet getResultSetImpl(long index,
int count,
java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String toString()
toString in class java.lang.Objectprivate java.lang.String toString(PgArray.PgArrayList list) throws java.sql.SQLException
java.sql.SQLExceptionpublic static void escapeArrayElement(java.lang.StringBuilder b,
java.lang.String s)
public boolean isBinary()
public byte[] toBytes()
public void free()
throws java.sql.SQLException
free in interface java.sql.Arrayjava.sql.SQLException