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)
ParameterName | Description |
columnIndex | int
|
ReturnsgetBigDecimal(String columnName)
public abstract BigDecimal getBigDecimal(String columnName)
ParameterName | Description |
columnName | String
|
ReturnsgetBigDecimalList(int columnIndex)
public abstract List<BigDecimal> getBigDecimalList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.numeric())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetBigDecimalList(String columnName)
public abstract List<BigDecimal> getBigDecimalList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.numeric())
.
ParameterName | Description |
columnName | String
|
ReturnsgetBoolean(int columnIndex)
public abstract boolean getBoolean(int columnIndex)
Returns the value of a non-NULL
column with type Type#bool().
ParameterName | Description |
columnIndex | int
|
ReturnsgetBoolean(String columnName)
public abstract boolean getBoolean(String columnName)
Returns the value of a non-NULL
column with type Type#bool().
ParameterName | Description |
columnName | String
|
ReturnsgetBooleanArray(int columnIndex)
public abstract boolean[] getBooleanArray(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.bool())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetBooleanArray(String columnName)
public abstract boolean[] getBooleanArray(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.bool())
.
ParameterName | Description |
columnName | String
|
ReturnsgetBooleanList(int columnIndex)
public abstract List<Boolean> getBooleanList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.bool())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetBooleanList(String columnName)
public abstract List<Boolean> getBooleanList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.bool())
.
ParameterName | Description |
columnName | String
|
ReturnsgetBytes(int columnIndex)
public abstract ByteArray getBytes(int columnIndex)
Returns the value of a non-NULL
column with type Type#bytes().
ParameterName | Description |
columnIndex | int
|
ReturnsType | Description |
com.google.cloud.ByteArray | |
getBytes(String columnName)
public abstract ByteArray getBytes(String columnName)
Returns the value of a non-NULL
column with type Type#bytes().
ParameterName | Description |
columnName | String
|
ReturnsType | Description |
com.google.cloud.ByteArray | |
getBytesList(int columnIndex)
public abstract List<ByteArray> getBytesList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.bytes())
.
ParameterName | Description |
columnIndex | int
|
ReturnsType | Description |
List<com.google.cloud.ByteArray> | |
getBytesList(String columnName)
public abstract List<ByteArray> getBytesList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.bytes())
.
ParameterName | Description |
columnName | String
|
ReturnsType | Description |
List<com.google.cloud.ByteArray> | |
getColumnCount()
public abstract int getColumnCount()
Returns the number of columns in the underlying data. This includes any columns with NULL
values.
ReturnsgetColumnIndex(String columnName)
public abstract int getColumnIndex(String columnName)
Returns the index of the column named columnName
.
ParameterName | Description |
columnName | String
|
ReturnsgetColumnType(int columnIndex)
public abstract Type getColumnType(int columnIndex)
Returns the type of a column.
ParameterName | Description |
columnIndex | int
|
ReturnsgetColumnType(String columnName)
public abstract Type getColumnType(String columnName)
Returns the type of a column.
ParameterName | Description |
columnName | String
|
ReturnsgetDate(int columnIndex)
public abstract Date getDate(int columnIndex)
Returns the value of a non-NULL
column with type Type#date().
ParameterName | Description |
columnIndex | int
|
ReturnsType | Description |
com.google.cloud.Date | |
getDate(String columnName)
public abstract Date getDate(String columnName)
Returns the value of a non-NULL
column with type Type#date().
ParameterName | Description |
columnName | String
|
ReturnsType | Description |
com.google.cloud.Date | |
getDateList(int columnIndex)
public abstract List<Date> getDateList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.date())
.
ParameterName | Description |
columnIndex | int
|
ReturnsType | Description |
List<com.google.cloud.Date> | |
getDateList(String columnName)
public abstract List<Date> getDateList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.date())
.
ParameterName | Description |
columnName | String
|
ReturnsType | Description |
List<com.google.cloud.Date> | |
getDouble(int columnIndex)
public abstract double getDouble(int columnIndex)
ParameterName | Description |
columnIndex | int
|
ReturnsgetDouble(String columnName)
public abstract double getDouble(String columnName)
ParameterName | Description |
columnName | String
|
ReturnsgetDoubleArray(int columnIndex)
public abstract double[] getDoubleArray(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.float64())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetDoubleArray(String columnName)
public abstract double[] getDoubleArray(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.float64())
.
ParameterName | Description |
columnName | String
|
ReturnsgetDoubleList(int columnIndex)
public abstract List<Double> getDoubleList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.float64())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetDoubleList(String columnName)
public abstract List<Double> getDoubleList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.float64())
.
ParameterName | Description |
columnName | String
|
ReturnsgetJson(int columnIndex)
public default String getJson(int columnIndex)
ParameterName | Description |
columnIndex | int
|
ReturnsgetJson(String columnName)
public default String getJson(String columnName)
ParameterName | Description |
columnName | String
|
ReturnsgetJsonList(int columnIndex)
public default List<String> getJsonList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.string())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetJsonList(String columnName)
public default List<String> getJsonList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.string())
.
ParameterName | Description |
columnName | String
|
ReturnsgetLong(int columnIndex)
public abstract long getLong(int columnIndex)
Returns the value of a non-NULL
column with type Type#int64().
ParameterName | Description |
columnIndex | int
|
ReturnsgetLong(String columnName)
public abstract long getLong(String columnName)
Returns the value of a non-NULL
column with type Type#int64().
ParameterName | Description |
columnName | String
|
ReturnsgetLongArray(int columnIndex)
public abstract long[] getLongArray(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.int64())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetLongArray(String columnName)
public abstract long[] getLongArray(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.int64())
.
ParameterName | Description |
columnName | String
|
ReturnsgetLongList(int columnIndex)
public abstract List<Long> getLongList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.int64())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetLongList(String columnName)
public abstract List<Long> getLongList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.int64())
.
ParameterName | Description |
columnName | String
|
ReturnsgetString(int columnIndex)
public abstract String getString(int columnIndex)
ParameterName | Description |
columnIndex | int
|
ReturnsgetString(String columnName)
public abstract String getString(String columnName)
ParameterName | Description |
columnName | String
|
ReturnsgetStringList(int columnIndex)
public abstract List<String> getStringList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.string())
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetStringList(String columnName)
public abstract List<String> getStringList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.string())
.
ParameterName | Description |
columnName | String
|
ReturnsgetStructList(int columnIndex)
public abstract List<Struct> getStructList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.struct(...))
.
ParameterName | Description |
columnIndex | int
|
ReturnsgetStructList(String columnName)
public abstract List<Struct> getStructList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.struct(...))
.
ParameterName | Description |
columnName | String
|
ReturnsgetTimestamp(int columnIndex)
public abstract Timestamp getTimestamp(int columnIndex)
ParameterName | Description |
columnIndex | int
|
ReturnsType | Description |
com.google.cloud.Timestamp | |
getTimestamp(String columnName)
public abstract Timestamp getTimestamp(String columnName)
ParameterName | Description |
columnName | String
|
ReturnsType | Description |
com.google.cloud.Timestamp | |
getTimestampList(int columnIndex)
public abstract List<Timestamp> getTimestampList(int columnIndex)
Returns the value of a non-NULL
column with type Type.array(Type.timestamp())
.
ParameterName | Description |
columnIndex | int
|
ReturnsType | Description |
List<com.google.cloud.Timestamp> | |
getTimestampList(String columnName)
public abstract List<Timestamp> getTimestampList(String columnName)
Returns the value of a non-NULL
column with type Type.array(Type.timestamp())
.
ParameterName | Description |
columnName | String
|
ReturnsType | Description |
List<com.google.cloud.Timestamp> | |
getType()
public abstract Type getType()
Returns 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.
ReturnsgetValue(int columnIndex)
public default Value getValue(int columnIndex)
Returns the value of a nullable column as a Value.
ParameterName | Description |
columnIndex | int
|
ReturnsgetValue(String columnName)
public default Value getValue(String columnName)
Returns the value of a nullable column as a Value.
ParameterName | Description |
columnName | String
|
ReturnsisNull(int columnIndex)
public abstract boolean isNull(int columnIndex)
Returns true
if a column contains a NULL
value.
ParameterName | Description |
columnIndex | int
|
ReturnsisNull(String columnName)
public abstract boolean isNull(String columnName)
Returns true
if a column contains a NULL
value.
ParameterName | Description |
columnName | String
|
Returns