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
<T>getProtoEnum(int columnIndex, Function<Integer,ProtocolMessageEnum> method)
public default T <T>getProtoEnum(int columnIndex, Function<Integer,ProtocolMessageEnum> method)
To get the proto enum of type T
from Struct.
Parameters | |
---|---|
Name | Description |
columnIndex | int Index of the column. |
method | Function<Integer,ProtocolMessageEnum> A function that takes enum integer constant as argument and returns the enum. Use method @code{forNumber} from generated enum class (eg: MyProtoEnum::forNumber). @see forNumber |
Returns | |
---|---|
Type | Description |
T | The value of a non- |
<T>getProtoEnum(String columnName, Function<Integer,ProtocolMessageEnum> method)
public default T <T>getProtoEnum(String columnName, Function<Integer,ProtocolMessageEnum> method)
To get the proto enum of type T
from Struct.
Parameters | |
---|---|
Name | Description |
columnName | String Name of the column. |
method | Function<Integer,ProtocolMessageEnum> A function that takes enum integer constant as argument and returns the enum. Use method @code{forNumber} from generated enum class (eg: MyProtoEnum::forNumber). @see forNumber |
Returns | |
---|---|
Type | Description |
T | The value of a non- |
<T>getProtoEnumList(int columnIndex, Function<Integer,ProtocolMessageEnum> method)
public default List<T> <T>getProtoEnumList(int columnIndex, Function<Integer,ProtocolMessageEnum> method)
To get the proto enum of type T
from Struct.
Parameters | |
---|---|
Name | Description |
columnIndex | int Index of the column. |
method | Function<Integer,ProtocolMessageEnum> A function that takes enum integer constant as argument and returns the enum. Use method @code{forNumber} from generated enum class (eg: MyProtoEnum::forNumber). @see forNumber |
Returns | |
---|---|
Type | Description |
List<T> | The value of a non- |
<T>getProtoEnumList(String columnName, Function<Integer,ProtocolMessageEnum> method)
public default List<T> <T>getProtoEnumList(String columnName, Function<Integer,ProtocolMessageEnum> method)
To get the proto enum list of type T
from Struct.
Parameters | |
---|---|
Name | Description |
columnName | String Name of the column. |
method | Function<Integer,ProtocolMessageEnum> A function that takes enum integer constant as argument and returns the enum. Use method @code{forNumber} from generated enum class (eg: MyProtoEnum::forNumber). @see forNumber |
Returns | |
---|---|
Type | Description |
List<T> | The value of a non- |
<T>getProtoMessage(int columnIndex, T message)
public default T <T>getProtoMessage(int columnIndex, T message)
To get the proto message of generic type T
from Struct.
Parameters | |
---|---|
Name | Description |
columnIndex | int Index of the column. |
message | T Proto message object. Message can't be null as it's internally used to find the type of proto. Use @code{MyProtoClass.getDefaultInstance()}. @see getDefaultInstance() |
Returns | |
---|---|
Type | Description |
T | The value of a non- |
<T>getProtoMessage(String columnName, T message)
public default T <T>getProtoMessage(String columnName, T message)
To get the proto message of type T
from Struct.
Parameters | |
---|---|
Name | Description |
columnName | String Name of the column. |
message | T Proto message object. Message can't be null as it's internally used to find the type of proto. Use @code{MyProtoClass.getDefaultInstance()}. @see getDefaultInstance() |
Returns | |
---|---|
Type | Description |
T | The value of a non- |
<T>getProtoMessageList(int columnIndex, T message)
public default List<T> <T>getProtoMessageList(int columnIndex, T message)
To get the proto message of generic type T
from Struct.
Parameters | |
---|---|
Name | Description |
columnIndex | int Index of the column. |
message | T Proto message object. Message can't be null as it's internally used to find the type of proto. Use @code{MyProtoClass.getDefaultInstance()}. @see getDefaultInstance() |
Returns | |
---|---|
Type | Description |
List<T> | The value of a non- |
<T>getProtoMessageList(String columnName, T message)
public default List<T> <T>getProtoMessageList(String columnName, T message)
To get the proto message of type T
from Struct.
Parameters | |
---|---|
Name | Description |
columnName | String Name of the column. |
message | T Proto message object. Message can't be null as it's internally used to find the type of proto. Use @code{MyProtoClass.getDefaultInstance()}. @see getDefaultInstance() |
Returns | |
---|---|
Type | Description |
List<T> | The value of a non- |
getBigDecimal(int columnIndex)
public abstract BigDecimal getBigDecimal(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
BigDecimal | the value of a non- |
getBigDecimal(String columnName)
public abstract BigDecimal getBigDecimal(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
BigDecimal | the value of a non- |
getBigDecimalList(int columnIndex)
public abstract List<BigDecimal> getBigDecimalList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<BigDecimal> | the value of a non- |
getBigDecimalList(String columnName)
public abstract List<BigDecimal> getBigDecimalList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<BigDecimal> | the value of a non- |
getBoolean(int columnIndex)
public abstract boolean getBoolean(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
boolean | the value of a non- |
getBoolean(String columnName)
public abstract boolean getBoolean(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
boolean | the value of a non- |
getBooleanArray(int columnIndex)
public abstract boolean[] getBooleanArray(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
boolean[] | the value of a non- |
getBooleanArray(String columnName)
public abstract boolean[] getBooleanArray(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
boolean[] | the value of a non- |
getBooleanList(int columnIndex)
public abstract List<Boolean> getBooleanList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<Boolean> | the value of a non- |
getBooleanList(String columnName)
public abstract List<Boolean> getBooleanList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<Boolean> | the value of a non- |
getBytes(int columnIndex)
public abstract ByteArray getBytes(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
com.google.cloud.ByteArray | the value of a non- |
getBytes(String columnName)
public abstract ByteArray getBytes(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
com.google.cloud.ByteArray | the value of a non- |
getBytesList(int columnIndex)
public abstract List<ByteArray> getBytesList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<com.google.cloud.ByteArray> | the value of a non- |
getBytesList(String columnName)
public abstract List<ByteArray> getBytesList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<com.google.cloud.ByteArray> | the value of a non- |
getColumnCount()
public abstract int getColumnCount()
Returns | |
---|---|
Type | Description |
int | the number of columns in the underlying data. This includes any columns with |
getColumnIndex(String columnName)
public abstract int getColumnIndex(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
int | the index of the column named |
getColumnType(int columnIndex)
public abstract Type getColumnType(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
Type | the type of a column. |
getColumnType(String columnName)
public abstract Type getColumnType(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
Type | the type of a column. |
getDate(int columnIndex)
public abstract Date getDate(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
com.google.cloud.Date | the value of a non- |
getDate(String columnName)
public abstract Date getDate(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
com.google.cloud.Date | the value of a non- |
getDateList(int columnIndex)
public abstract List<Date> getDateList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<com.google.cloud.Date> | the value of a non- |
getDateList(String columnName)
public abstract List<Date> getDateList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<com.google.cloud.Date> | the value of a non- |
getDouble(int columnIndex)
public abstract double getDouble(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
double | the value of a non- |
getDouble(String columnName)
public abstract double getDouble(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
double | the value of a non- |
getDoubleArray(int columnIndex)
public abstract double[] getDoubleArray(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
double[] | the value of a non- |
getDoubleArray(String columnName)
public abstract double[] getDoubleArray(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
double[] | the value of a non- |
getDoubleList(int columnIndex)
public abstract List<Double> getDoubleList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<Double> | the value of a non- |
getDoubleList(String columnName)
public abstract List<Double> getDoubleList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<Double> | the value of a non- |
getFloat(int columnIndex)
public default float getFloat(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
float | the value of a non- |
getFloat(String columnName)
public default float getFloat(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
float | the value of a non- |
getFloatArray(int columnIndex)
public default float[] getFloatArray(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
float[] | the value of a non- |
getFloatArray(String columnName)
public default float[] getFloatArray(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
float[] | the value of a non- |
getFloatList(int columnIndex)
public default List<Float> getFloatList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<Float> | the value of a non- |
getFloatList(String columnName)
public abstract List<Float> getFloatList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<Float> | the value of a non- |
getJson(int columnIndex)
public default String getJson(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
String | the value of a non- |
getJson(String columnName)
public default String getJson(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
String | the value of a non- |
getJsonList(int columnIndex)
public default List<String> getJsonList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<String> | the value of a non- |
getJsonList(String columnName)
public default List<String> getJsonList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<String> | the value of a non- |
getLong(int columnIndex)
public abstract long getLong(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
long | the value of a non- |
getLong(String columnName)
public abstract long getLong(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
long | the value of a non- |
getLongArray(int columnIndex)
public abstract long[] getLongArray(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
long[] | the value of a non- |
getLongArray(String columnName)
public abstract long[] getLongArray(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
long[] | the value of a non- |
getLongList(int columnIndex)
public abstract List<Long> getLongList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<Long> | the value of a non- |
getLongList(String columnName)
public abstract List<Long> getLongList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String |
Returns | |
---|---|
Type | Description |
List<Long> | the value of a non- |
getPgJsonb(int columnIndex)
public default String getPgJsonb(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
String | the value of a non- |
getPgJsonb(String columnName)
public default String getPgJsonb(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
String | the value of a non- |
getPgJsonbList(int columnIndex)
public default List<String> getPgJsonbList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<String> | the value of a non- |
getPgJsonbList(String columnName)
public default List<String> getPgJsonbList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<String> | the value of a non- |
getString(int columnIndex)
public abstract String getString(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
String | the value of a non- |
getString(String columnName)
public abstract String getString(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
String | the value of a non- |
getStringList(int columnIndex)
public abstract List<String> getStringList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<String> | the value of a non- |
getStringList(String columnName)
public abstract List<String> getStringList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<String> | the value of a non- |
getStructList(int columnIndex)
public abstract List<Struct> getStructList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<Struct> | the value of a non- |
getStructList(String columnName)
public abstract List<Struct> getStructList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<Struct> | the value of a non- |
getTimestamp(int columnIndex)
public abstract Timestamp getTimestamp(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
com.google.cloud.Timestamp | the value of a non- |
getTimestamp(String columnName)
public abstract Timestamp getTimestamp(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
com.google.cloud.Timestamp | the value of a non- |
getTimestampList(int columnIndex)
public abstract List<Timestamp> getTimestampList(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
List<com.google.cloud.Timestamp> | the value of a non- |
getTimestampList(String columnName)
public abstract List<Timestamp> getTimestampList(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
List<com.google.cloud.Timestamp> | the value of a non- |
getType()
public abstract Type getType()
Returns | |
---|---|
Type | Description |
Type | the type of the underlying data. This will always be a |
getValue(int columnIndex)
public default Value getValue(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
Value | the value of a nullable column as a Value. |
getValue(String columnName)
public default Value getValue(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
Value | the value of a nullable column as a Value. |
isNull(int columnIndex)
public abstract boolean isNull(int columnIndex)
Parameter | |
---|---|
Name | Description |
columnIndex | int index of the column |
Returns | |
---|---|
Type | Description |
boolean |
|
isNull(String columnName)
public abstract boolean isNull(String columnName)
Parameter | |
---|---|
Name | Description |
columnName | String name of the column |
Returns | |
---|---|
Type | Description |
boolean |
|