Package org.postgresql.jdbc

# Class PgArray

java.lang.Object
org.postgresql.jdbc.PgArray

All Implemented Interfaces:
  `Array`

public class PgArray extends Object implements 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:
  - `ResultSet.getArray(int)`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected @Nullable org.postgresql.jdbc.ArrayDecoding.PgArrayList`
`arrayList`
Value of field as `ArrayDecoding.PgArrayList`.
`protected @Nullable BaseConnection`
`connection`
A database connection.
`protected byte @Nullable []`
`fieldBytes`
`protected @Nullable String`
`fieldString`
Field value as String.

## Constructor Summary

Constructors
Constructor
Description
`PgArray(BaseConnection connection, int oid, byte @Nullable [] fieldBytes)`
Create a new Array.
`PgArray(BaseConnection connection, int oid, @Nullable String fieldString)`
Create a new Array.

## Method Summary

Modifier and Type
Method
Description
`static void`
`escapeArrayElement(StringBuilder b, String s)`
`void`
`free()`
`Object`
`getArray()`
`Object`
`getArray(long index, int count)`
`Object`
`getArray(long index, int count, @Nullable Map<String,Class<?>> map)`
`Object`
`getArray(Map<String,Class<?>> map)`
`@Nullable Object`
`getArrayImpl(long index, int count, @Nullable Map<String,Class<?>> map)`
`Object`
`getArrayImpl(Map<String,Class<?>> map)`
`int`
`getBaseType()`
`String`
`getBaseTypeName()`
`ResultSet`
`getResultSet()`
`ResultSet`
`getResultSet(long index, int count)`
`ResultSet`
`getResultSet(long index, int count, @Nullable Map<String,Class<?>> map)`
`ResultSet`
`getResultSet(@Nullable Map<String,Class<?>> map)`
`ResultSet`
`getResultSetImpl(long index, int count, @Nullable Map<String,Class<?>> map)`
`ResultSet`
`getResultSetImpl(@Nullable Map<String,Class<?>> map)`
`boolean`
`isBinary()`
`byte @Nullable []`
`toBytes()`
`@Nullable String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### connection

protected @Nullable BaseConnection connection
A database connection.

### fieldString

protected @Nullable String fieldString
Field value as String.

### arrayList

protected @Nullable org.postgresql.jdbc.ArrayDecoding.PgArrayList arrayList
Value of field as `ArrayDecoding.PgArrayList`. Will be initialized only once within `buildArrayList(String)`.

### fieldBytes

protected byte @Nullable [] fieldBytes

## Constructor Details

### PgArray

public PgArray(BaseConnection connection, int oid, @Nullable String fieldString) throws SQLException
Create a new Array.

Parameters:
  `connection` - a database connection
  `oid` - the oid of the array datatype
  `fieldString` - the array data in string form
Throws:
  `SQLException` - if something wrong happens

### PgArray

public PgArray(BaseConnection connection, int oid, byte @Nullable [] fieldBytes) throws SQLException
Create a new Array.

Parameters:
  `connection` - a database connection
  `oid` - the oid of the array datatype
  `fieldBytes` - the array data in byte form
Throws:
  `SQLException` - if something wrong happens

## Method Details

### getArray

public Object getArray() throws SQLException

Specified by:
  `getArray` in interface `Array`
Throws:
  `SQLException`

### getArray

public Object getArray(long index, int count) throws SQLException

Specified by:
  `getArray` in interface `Array`
Throws:
  `SQLException`

### getArrayImpl

public Object getArrayImpl(Map<String,Class<?>> map) throws SQLException

Throws:
  `SQLException`

### getArray

public Object getArray(Map<String,Class<?>> map) throws SQLException

Specified by:
  `getArray` in interface `Array`
Throws:
  `SQLException`

### getArray

public Object getArray(long index, int count, @Nullable Map<String,Class<?>> map) throws SQLException

Specified by:
  `getArray` in interface `Array`
Throws:
  `SQLException`

### getArrayImpl

public @Nullable Object getArrayImpl(long index, int count, @Nullable Map<String,Class<?>> map) throws SQLException

Throws:
  `SQLException`

### getBaseType

public int getBaseType() throws SQLException

Specified by:
  `getBaseType` in interface `Array`
Throws:
  `SQLException`

### getBaseTypeName

public String getBaseTypeName() throws SQLException

Specified by:
  `getBaseTypeName` in interface `Array`
Throws:
  `SQLException`

### getResultSet

public ResultSet getResultSet() throws SQLException

Specified by:
  `getResultSet` in interface `Array`
Throws:
  `SQLException`

### getResultSet

public ResultSet getResultSet(long index, int count) throws SQLException

Specified by:
  `getResultSet` in interface `Array`
Throws:
  `SQLException`

### getResultSet

public ResultSet getResultSet(@Nullable Map<String,Class<?>> map) throws SQLException

Specified by:
  `getResultSet` in interface `Array`
Throws:
  `SQLException`

### getResultSet

public ResultSet getResultSet(long index, int count, @Nullable Map<String,Class<?>> map) throws SQLException

Specified by:
  `getResultSet` in interface `Array`
Throws:
  `SQLException`

### getResultSetImpl

public ResultSet getResultSetImpl(@Nullable Map<String,Class<?>> map) throws SQLException

Throws:
  `SQLException`

### getResultSetImpl

public ResultSet getResultSetImpl(long index, int count, @Nullable Map<String,Class<?>> map) throws SQLException

Throws:
  `SQLException`

### toString

public @Nullable String toString()

Overrides:
  `toString` in class `Object`

### escapeArrayElement

public static void escapeArrayElement(StringBuilder b, String s)

### isBinary

public boolean isBinary()

### toBytes

public byte @Nullable [] toBytes()

### free

public void free() throws SQLException

Specified by:
  `free` in interface `Array`
Throws:
  `SQLException`