Interface StructReader
-
- All Known Subinterfaces:
AsyncResultSet,ResultSet
- All Known Implementing Classes:
AbstractStructReader,ForwardingAsyncResultSet,ForwardingResultSet,ForwardingStructReader,Struct
public interface StructReaderA base interface for reading the fields of aSTRUCT. The Cloud Spanner yieldsStructReaderinstances as one of the subclassesResultSetorStruct, most commonly as the result of a read or query operation. At any point in time, aStructReaderprovides access to a single tuple of data comprising multiple typed columns. Each column may have aNULLor non-NULLvalue; 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)andgetString(String)exist for reading columns of typeType.string(); attempting to call those methods for columns of other types will result in anIllegalStateException. ThegetTypeName()methods should only be called for non-NULLvalues, otherwise aNullPointerExceptionis raised;isNull(int)/isNull(String)can be used to test forNULL-ness if necessary.All methods for accessing a column have overloads that accept an
intcolumn index and aStringcolumn name. Column indices are zero-based. The column name overloads will fail withIllegalArgumentExceptionif the column name does not appear exactly once in this instance'sgetType(). Theintoverloads are typically more efficient than theirStringcounterparts.StructReaderitself does not define whether the implementing type is mutable or immutable. For example,ResultSetis a mutable implementation ofStructReader, where theStructReadermethods provide access to the row that the result set is currently positioned over andResultSet.next()changes that view to the next row, whereasStructis an immutable implementation ofStructReader.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description BigDecimalgetBigDecimal(int columnIndex)Returns the value of a non-NULLcolumn with typeType.numeric().BigDecimalgetBigDecimal(String columnName)Returns the value of a non-NULLcolumn with typeType.numeric().List<BigDecimal>getBigDecimalList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.numeric())The list returned by this method is lazily constructed.List<BigDecimal>getBigDecimalList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.numeric())The list returned by this method is lazily constructed.booleangetBoolean(int columnIndex)Returns the value of a non-NULLcolumn with typeType.bool().booleangetBoolean(String columnName)Returns the value of a non-NULLcolumn with typeType.bool().boolean[]getBooleanArray(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.bool()).boolean[]getBooleanArray(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.bool()).List<Boolean>getBooleanList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.bool()).List<Boolean>getBooleanList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.bool()).com.google.cloud.ByteArraygetBytes(int columnIndex)Returns the value of a non-NULLcolumn with typeType.bytes().com.google.cloud.ByteArraygetBytes(String columnName)Returns the value of a non-NULLcolumn with typeType.bytes().List<com.google.cloud.ByteArray>getBytesList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.bytes()).List<com.google.cloud.ByteArray>getBytesList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.bytes()).intgetColumnCount()Returns the number of columns in the underlying data.intgetColumnIndex(String columnName)Returns the index of the column namedcolumnName.TypegetColumnType(int columnIndex)Returns the type of a column.TypegetColumnType(String columnName)Returns the type of a column.com.google.cloud.DategetDate(int columnIndex)Returns the value of a non-NULLcolumn with typeType.date().com.google.cloud.DategetDate(String columnName)Returns the value of a non-NULLcolumn with typeType.date().List<com.google.cloud.Date>getDateList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.date()).List<com.google.cloud.Date>getDateList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.date()).doublegetDouble(int columnIndex)Returns the value of a non-NULLcolumn with typeType.float64().doublegetDouble(String columnName)Returns the value of a non-NULLcolumn with typeType.float64().double[]getDoubleArray(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.float64()).double[]getDoubleArray(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.float64()).List<Double>getDoubleList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.float64())The list returned by this method is lazily constructed.List<Double>getDoubleList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.float64())The list returned by this method is lazily constructed.default StringgetJson(int columnIndex)Returns the value of a non-NULLcolumn with typeType.json().default StringgetJson(String columnName)Returns the value of a non-NULLcolumn with typeType.json().default List<String>getJsonList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.json()).default List<String>getJsonList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.json()).longgetLong(int columnIndex)Returns the value of a non-NULLcolumn with typeType.int64().longgetLong(String columnName)Returns the value of a non-NULLcolumn with typeType.int64().long[]getLongArray(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.int64()).long[]getLongArray(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.int64()).List<Long>getLongList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.int64()).List<Long>getLongList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.int64()).default StringgetPgJsonb(int columnIndex)Returns the value of a non-NULLcolumn with typeType.pgJsonb().default StringgetPgJsonb(String columnName)Returns the value of a non-NULLcolumn with typeType.pgJsonb().default List<String>getPgJsonbList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.pgJsonb())The list returned by this method is lazily constructed.default List<String>getPgJsonbList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.pgJsonb())The list returned by this method is lazily constructed.StringgetString(int columnIndex)Returns the value of a non-NULLcolumn with typeType.string().StringgetString(String columnName)Returns the value of a non-NULLcolumn with typeType.string().List<String>getStringList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.string()).List<String>getStringList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.string()).List<Struct>getStructList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.struct(...))The list returned by this method is lazily constructed.List<Struct>getStructList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.struct(...))The list returned by this method is lazily constructed.com.google.cloud.TimestampgetTimestamp(int columnIndex)Returns the value of a non-NULLcolumn with typeType.timestamp().com.google.cloud.TimestampgetTimestamp(String columnName)Returns the value of a non-NULLcolumn with typeType.timestamp().List<com.google.cloud.Timestamp>getTimestampList(int columnIndex)Returns the value of a non-NULLcolumn with typeType.array(Type.timestamp())The list returned by this method is lazily constructed.List<com.google.cloud.Timestamp>getTimestampList(String columnName)Returns the value of a non-NULLcolumn with typeType.array(Type.timestamp())The list returned by this method is lazily constructed.TypegetType()Returns the type of the underlying data.default ValuegetValue(int columnIndex)Returns the value of a nullable column as aValue.default ValuegetValue(String columnName)Returns the value of a nullable column as aValue.booleanisNull(int columnIndex)Returnstrueif a column contains aNULLvalue.booleanisNull(String columnName)Returnstrueif a column contains aNULLvalue.
-
-
-
Method Detail
-
getType
Type getType()
Returns the type of the underlying data. This will always be aSTRUCTtype, with fields corresponding to the data's columns. For the result of a read or query, this will always match the columns passed to theread()call or named in the query text, in order.
-
getColumnCount
int getColumnCount()
Returns the number of columns in the underlying data. This includes any columns withNULLvalues.
-
getColumnIndex
int getColumnIndex(String columnName)
Returns the index of the column namedcolumnName.- Throws:
IllegalArgumentException- if there is not exactly one element oftype().structFields()withType.StructField.getName()equal tocolumnName
-
getColumnType
Type getColumnType(int columnIndex)
Returns the type of a column.
-
isNull
boolean isNull(int columnIndex)
Returnstrueif a column contains aNULLvalue.
-
isNull
boolean isNull(String columnName)
Returnstrueif a column contains aNULLvalue.
-
getBoolean
boolean getBoolean(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.bool().
-
getBoolean
boolean getBoolean(String columnName)
Returns the value of a non-NULLcolumn with typeType.bool().
-
getLong
long getLong(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.int64().
-
getLong
long getLong(String columnName)
Returns the value of a non-NULLcolumn with typeType.int64().
-
getDouble
double getDouble(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.float64().
-
getDouble
double getDouble(String columnName)
Returns the value of a non-NULLcolumn with typeType.float64().
-
getBigDecimal
BigDecimal getBigDecimal(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.numeric().
-
getBigDecimal
BigDecimal getBigDecimal(String columnName)
Returns the value of a non-NULLcolumn with typeType.numeric().
-
getString
String getString(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.string().
-
getString
String getString(String columnName)
Returns the value of a non-NULLcolumn with typeType.string().
-
getJson
default String getJson(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.json().
-
getJson
default String getJson(String columnName)
Returns the value of a non-NULLcolumn with typeType.json().
-
getPgJsonb
default String getPgJsonb(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.pgJsonb().
-
getPgJsonb
default String getPgJsonb(String columnName)
Returns the value of a non-NULLcolumn with typeType.pgJsonb().
-
getBytes
com.google.cloud.ByteArray getBytes(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.bytes().
-
getBytes
com.google.cloud.ByteArray getBytes(String columnName)
Returns the value of a non-NULLcolumn with typeType.bytes().
-
getTimestamp
com.google.cloud.Timestamp getTimestamp(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.timestamp().
-
getTimestamp
com.google.cloud.Timestamp getTimestamp(String columnName)
Returns the value of a non-NULLcolumn with typeType.timestamp().
-
getDate
com.google.cloud.Date getDate(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.date().
-
getDate
com.google.cloud.Date getDate(String columnName)
Returns the value of a non-NULLcolumn with typeType.date().
-
getValue
default Value getValue(int columnIndex)
Returns the value of a nullable column as aValue.
-
getValue
default Value getValue(String columnName)
Returns the value of a nullable column as aValue.
-
getBooleanArray
boolean[] getBooleanArray(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.array(Type.bool()).- Throws:
NullPointerException- if any element of the array value isNULL. If the array may containNULLvalues, usegetBooleanList(int)instead.
-
getBooleanArray
boolean[] getBooleanArray(String columnName)
Returns the value of a non-NULLcolumn with typeType.array(Type.bool()).- Throws:
NullPointerException- if any element of the array value isNULL. If the array may containNULLvalues, usegetBooleanList(String)instead.
-
getBooleanList
List<Boolean> getBooleanList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
List<Boolean> getBooleanList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getLongArray
long[] getLongArray(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.array(Type.int64()).- Throws:
NullPointerException- if any element of the array value isNULL. If the array may containNULLvalues, usegetLongList(int)instead.
-
getLongArray
long[] getLongArray(String columnName)
Returns the value of a non-NULLcolumn with typeType.array(Type.int64()).- Throws:
NullPointerException- if any element of the array value isNULL. If the array may containNULLvalues, usegetLongList(String)instead.
-
getLongList
List<Long> getLongList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
List<Long> getLongList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getDoubleArray
double[] getDoubleArray(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.array(Type.float64()).- Throws:
NullPointerException- if any element of the array value isNULL. If the array may containNULLvalues, usegetDoubleList(int)instead.
-
getDoubleArray
double[] getDoubleArray(String columnName)
Returns the value of a non-NULLcolumn with typeType.array(Type.float64()).- Throws:
NullPointerException- if any element of the array value isNULL. If the array may containNULLvalues, usegetDoubleList(String)instead.
-
getDoubleList
List<Double> getDoubleList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
List<Double> getDoubleList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getBigDecimalList
List<BigDecimal> getBigDecimalList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
List<BigDecimal> getBigDecimalList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getStringList
List<String> getStringList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
List<String> getStringList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getJsonList
default List<String> getJsonList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
default List<String> getJsonList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getPgJsonbList
default List<String> getPgJsonbList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
default List<String> getPgJsonbList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getBytesList
List<com.google.cloud.ByteArray> getBytesList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
List<com.google.cloud.ByteArray> getBytesList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getTimestampList
List<com.google.cloud.Timestamp> getTimestampList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
List<com.google.cloud.Timestamp> getTimestampList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getDateList
List<com.google.cloud.Date> getDateList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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
List<com.google.cloud.Date> getDateList(String columnName)
Returns the value of a non-NULLcolumn with typeType.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.
-
getStructList
List<Struct> getStructList(int columnIndex)
Returns the value of a non-NULLcolumn with typeType.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.
-
-