Interface StructReader (6.49.0)

public interface StructReader

A base interface for reading the fields of a STRUCT. The Cloud Spanner yields StructReader instances as one of the subclasses ResultSet or Struct, most commonly as the result of a read or query operation. At any point in time, a StructReader provides access to a single tuple of data comprising multiple typed columns. Each column may have a NULL or non-NULL value; in both cases, columns always have a type.

Column values are accessed using the getTypeName() methods; a set of methods exists for each Java type that a column may be read as, and depending on the type of the column, only a subset of those methods will be appropriate. For example, #getString(int) and #getString(String) exist for reading columns of type Type#string(); attempting to call those methods for columns of other types will result in an IllegalStateException. The getTypeName() methods should only be called for non-NULL values, otherwise a NullPointerException is raised; #isNull(int)/#isNull(String) can be used to test for NULL-ness if necessary.

All methods for accessing a column have overloads that accept an int column index and a String column name. Column indices are zero-based. The column name overloads will fail with IllegalArgumentException if the column name does not appear exactly once in this instance's #getType(). The int overloads are typically more efficient than their String counterparts.

StructReader itself does not define whether the implementing type is mutable or immutable. For example, ResultSet is a mutable implementation of StructReader, where the StructReader methods provide access to the row that the result set is currently positioned over and ResultSet#next() changes that view to the next row, whereas Struct is an immutable implementation of StructReader.

Methods

getBigDecimal(int columnIndex)

public abstract BigDecimal getBigDecimal(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
BigDecimal

the value of a non-NULL column with type Type#numeric().

getBigDecimal(String columnName)

public abstract BigDecimal getBigDecimal(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
BigDecimal

the value of a non-NULL column with type Type#numeric().

getBigDecimalList(int columnIndex)

public abstract List<BigDecimal> getBigDecimalList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<BigDecimal>

the value of a non-NULL column with type Type.array(Type.numeric()) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getBigDecimalList(String columnName)

public abstract List<BigDecimal> getBigDecimalList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<BigDecimal>

the value of a non-NULL column with type Type.array(Type.numeric()) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getBoolean(int columnIndex)

public abstract boolean getBoolean(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
boolean

the value of a non-NULL column with type Type#bool().

getBoolean(String columnName)

public abstract boolean getBoolean(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
boolean

the value of a non-NULL column with type Type#bool().

getBooleanArray(int columnIndex)

public abstract boolean[] getBooleanArray(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
boolean[]

the value of a non-NULL column with type Type.array(Type.bool()).

getBooleanArray(String columnName)

public abstract boolean[] getBooleanArray(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
boolean[]

the value of a non-NULL column with type Type.array(Type.bool()).

getBooleanList(int columnIndex)

public abstract List<Boolean> getBooleanList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<Boolean>

the value of a non-NULL column with type Type.array(Type.bool()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getBooleanList(String columnName)

public abstract List<Boolean> getBooleanList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<Boolean>

the value of a non-NULL column with type Type.array(Type.bool()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getBytes(int columnIndex)

public abstract ByteArray getBytes(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
com.google.cloud.ByteArray

the value of a non-NULL column with type Type#bytes().

getBytes(String columnName)

public abstract ByteArray getBytes(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
com.google.cloud.ByteArray

the value of a non-NULL column with type Type#bytes().

getBytesList(int columnIndex)

public abstract List<ByteArray> getBytesList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<com.google.cloud.ByteArray>

the value of a non-NULL column with type Type.array(Type.bytes()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getBytesList(String columnName)

public abstract List<ByteArray> getBytesList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<com.google.cloud.ByteArray>

the value of a non-NULL column with type Type.array(Type.bytes()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getColumnCount()

public abstract int getColumnCount()
Returns
TypeDescription
int

the number of columns in the underlying data. This includes any columns with NULL values.

getColumnIndex(String columnName)

public abstract int getColumnIndex(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
int

the index of the column named columnName.

getColumnType(int columnIndex)

public abstract Type getColumnType(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
Type

the type of a column.

getColumnType(String columnName)

public abstract Type getColumnType(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
Type

the type of a column.

getDate(int columnIndex)

public abstract Date getDate(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
com.google.cloud.Date

the value of a non-NULL column with type Type#date().

getDate(String columnName)

public abstract Date getDate(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
com.google.cloud.Date

the value of a non-NULL column with type Type#date().

getDateList(int columnIndex)

public abstract List<Date> getDateList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<com.google.cloud.Date>

the value of a non-NULL column with type Type.array(Type.date()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getDateList(String columnName)

public abstract List<Date> getDateList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<com.google.cloud.Date>

the value of a non-NULL column with type Type.array(Type.date()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getDouble(int columnIndex)

public abstract double getDouble(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
double

the value of a non-NULL column with type Type#float64().

getDouble(String columnName)

public abstract double getDouble(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
double

the value of a non-NULL column with type Type#float64().

getDoubleArray(int columnIndex)

public abstract double[] getDoubleArray(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
double[]

the value of a non-NULL column with type Type.array(Type.float64()).

getDoubleArray(String columnName)

public abstract double[] getDoubleArray(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
double[]

the value of a non-NULL column with type Type.array(Type.float64()).

getDoubleList(int columnIndex)

public abstract List<Double> getDoubleList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<Double>

the value of a non-NULL column with type Type.array(Type.float64()) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getDoubleList(String columnName)

public abstract List<Double> getDoubleList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<Double>

the value of a non-NULL column with type Type.array(Type.float64()) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getJson(int columnIndex)

public default String getJson(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
String

the value of a non-NULL column with type Type#json().

getJson(String columnName)

public default String getJson(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
String

the value of a non-NULL column with type Type#json().

getJsonList(int columnIndex)

public default List<String> getJsonList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<String>

the value of a non-NULL column with type Type.array(Type.json()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getJsonList(String columnName)

public default List<String> getJsonList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<String>

the value of a non-NULL column with type Type.array(Type.json()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getLong(int columnIndex)

public abstract long getLong(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
long

the value of a non-NULL column with type Type#int64().

getLong(String columnName)

public abstract long getLong(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
long

the value of a non-NULL column with type Type#int64().

getLongArray(int columnIndex)

public abstract long[] getLongArray(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
long[]

the value of a non-NULL column with type Type.array(Type.int64()).

getLongArray(String columnName)

public abstract long[] getLongArray(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
long[]

the value of a non-NULL column with type Type.array(Type.int64()).

getLongList(int columnIndex)

public abstract List<Long> getLongList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<Long>

the value of a non-NULL column with type Type.array(Type.int64()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getLongList(String columnName)

public abstract List<Long> getLongList(String columnName)
Parameter
NameDescription
columnNameString
Returns
TypeDescription
List<Long>

the value of a non-NULL column with type Type.array(Type.int64()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getPgJsonb(int columnIndex)

public default String getPgJsonb(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
String

the value of a non-NULL column with type Type#pgJsonb().

getPgJsonb(String columnName)

public default String getPgJsonb(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
String

the value of a non-NULL column with type Type#pgJsonb().

getPgJsonbList(int columnIndex)

public default List<String> getPgJsonbList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<String>

the value of a non-NULL column with type Type.array(Type.pgJsonb()) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getPgJsonbList(String columnName)

public default List<String> getPgJsonbList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<String>

the value of a non-NULL column with type Type.array(Type.pgJsonb()) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getString(int columnIndex)

public abstract String getString(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
String

the value of a non-NULL column with type Type#string().

getString(String columnName)

public abstract String getString(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
String

the value of a non-NULL column with type Type#string().

getStringList(int columnIndex)

public abstract List<String> getStringList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<String>

the value of a non-NULL column with type Type.array(Type.string()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getStringList(String columnName)

public abstract List<String> getStringList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<String>

the value of a non-NULL column with type Type.array(Type.string()). The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getStructList(int columnIndex)

public abstract List<Struct> getStructList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<Struct>

the value of a non-NULL column with type Type.array(Type.struct(...)) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getStructList(String columnName)

public abstract List<Struct> getStructList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<Struct>

the value of a non-NULL column with type Type.array(Type.struct(...)) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getTimestamp(int columnIndex)

public abstract Timestamp getTimestamp(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
com.google.cloud.Timestamp

the value of a non-NULL column with type Type#timestamp().

getTimestamp(String columnName)

public abstract Timestamp getTimestamp(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
com.google.cloud.Timestamp

the value of a non-NULL column with type Type#timestamp().

getTimestampList(int columnIndex)

public abstract List<Timestamp> getTimestampList(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
List<com.google.cloud.Timestamp>

the value of a non-NULL column with type Type.array(Type.timestamp()) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getTimestampList(String columnName)

public abstract List<Timestamp> getTimestampList(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
List<com.google.cloud.Timestamp>

the value of a non-NULL column with type Type.array(Type.timestamp()) The list returned by this method is lazily constructed. Create a copy of it if you intend to access each element in the list multiple times.

getType()

public abstract Type getType()
Returns
TypeDescription
Type

the type of the underlying data. This will always be a STRUCT type, with fields corresponding to the data's columns. For the result of a read or query, this will always match the columns passed to the read() call or named in the query text, in order.

getValue(int columnIndex)

public default Value getValue(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
Value

the value of a nullable column as a Value.

getValue(String columnName)

public default Value getValue(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
Value

the value of a nullable column as a Value.

isNull(int columnIndex)

public abstract boolean isNull(int columnIndex)
Parameter
NameDescription
columnIndexint

index of the column

Returns
TypeDescription
boolean

true if a column contains a NULL value.

isNull(String columnName)

public abstract boolean isNull(String columnName)
Parameter
NameDescription
columnNameString

name of the column

Returns
TypeDescription
boolean

true if a column contains a NULL value.