Package com.google.cloud.spanner
Class ForwardingStructReader
java.lang.Object
com.google.cloud.spanner.ForwardingStructReader
- All Implemented Interfaces:
StructReader
- Direct Known Subclasses:
ForwardingResultSet
Forwarding implements of StructReader
-
Constructor Summary
ConstructorsConstructorDescriptionForwardingStructReader(StructReader delegate) ForwardingStructReader(com.google.common.base.Supplier<? extends StructReader> delegate) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled before each forwarding call to allow sub classes to do additional state checking.getBigDecimal(int columnIndex) getBigDecimal(String columnName) getBigDecimalList(int columnIndex) getBigDecimalList(String columnName) booleangetBoolean(int columnIndex) booleangetBoolean(String columnName) boolean[]getBooleanArray(int columnIndex) boolean[]getBooleanArray(String columnName) getBooleanList(int columnIndex) getBooleanList(String columnName) com.google.cloud.ByteArraygetBytes(int columnIndex) com.google.cloud.ByteArrayList<com.google.cloud.ByteArray>getBytesList(int columnIndex) List<com.google.cloud.ByteArray>getBytesList(String columnName) intintgetColumnIndex(String columnName) getColumnType(int columnIndex) getColumnType(String columnName) com.google.cloud.DategetDate(int columnIndex) com.google.cloud.DateList<com.google.cloud.Date>getDateList(int columnIndex) List<com.google.cloud.Date>getDateList(String columnName) doublegetDouble(int columnIndex) doubledouble[]getDoubleArray(int columnIndex) double[]getDoubleArray(String columnName) getDoubleList(int columnIndex) getDoubleList(String columnName) floatgetFloat(int columnIndex) floatfloat[]getFloatArray(int columnIndex) float[]getFloatArray(String columnName) getFloatList(int columnIndex) getFloatList(String columnName) getJson(int columnIndex) getJsonList(int columnIndex) getJsonList(String columnName) longgetLong(int columnIndex) longlong[]getLongArray(int columnIndex) long[]getLongArray(String columnName) getLongList(int columnIndex) getLongList(String columnName) getPgJsonb(int columnIndex) getPgJsonb(String columnName) getPgJsonbList(int columnIndex) getPgJsonbList(String columnName) <T extends com.google.protobuf.ProtocolMessageEnum>
TgetProtoEnum(int columnIndex, Function<Integer, com.google.protobuf.ProtocolMessageEnum> method) To get the proto enum of typeTfrom Struct.<T extends com.google.protobuf.ProtocolMessageEnum>
TgetProtoEnum(String columnName, Function<Integer, com.google.protobuf.ProtocolMessageEnum> method) To get the proto enum of typeTfrom Struct.<T extends com.google.protobuf.ProtocolMessageEnum>
List<T>getProtoEnumList(int columnIndex, Function<Integer, com.google.protobuf.ProtocolMessageEnum> method) To get the proto enum of typeTfrom Struct.<T extends com.google.protobuf.ProtocolMessageEnum>
List<T>getProtoEnumList(String columnName, Function<Integer, com.google.protobuf.ProtocolMessageEnum> method) To get the proto enum list of typeTfrom Struct.<T extends com.google.protobuf.AbstractMessage>
TgetProtoMessage(int columnIndex, T message) To get the proto message of generic typeTfrom Struct.<T extends com.google.protobuf.AbstractMessage>
TgetProtoMessage(String columnName, T message) To get the proto message of typeTfrom Struct.<T extends com.google.protobuf.AbstractMessage>
List<T>getProtoMessageList(int columnIndex, T message) To get the proto message of generic typeTfrom Struct.<T extends com.google.protobuf.AbstractMessage>
List<T>getProtoMessageList(String columnName, T message) To get the proto message of typeTfrom Struct.getString(int columnIndex) getStringList(int columnIndex) getStringList(String columnName) getStructList(int columnIndex) getStructList(String columnName) com.google.cloud.TimestampgetTimestamp(int columnIndex) com.google.cloud.TimestampgetTimestamp(String columnName) List<com.google.cloud.Timestamp>getTimestampList(int columnIndex) List<com.google.cloud.Timestamp>getTimestampList(String columnName) getType()getValue(int columnIndex) booleanisNull(int columnIndex) boolean
-
Constructor Details
-
ForwardingStructReader
-
ForwardingStructReader
-
-
Method Details
-
checkValidState
protected void checkValidState()Called before each forwarding call to allow sub classes to do additional state checking. Sub classes should throw anExceptionif the current state is not valid for reading data from thisForwardingStructReader. The default implementation does nothing. -
getType
- Specified by:
getTypein interfaceStructReader- Returns:
- the type of the underlying data. This will always be a
STRUCTtype, 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
public int getColumnCount()- Specified by:
getColumnCountin interfaceStructReader- Returns:
- the number of columns in the underlying data. This includes any columns with
NULLvalues.
-
getColumnIndex
- Specified by:
getColumnIndexin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the index of the column named
columnName.
-
getColumnType
- Specified by:
getColumnTypein interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the type of a column.
-
getColumnType
- Specified by:
getColumnTypein interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the type of a column.
-
isNull
public boolean isNull(int columnIndex) - Specified by:
isNullin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
trueif a column contains aNULLvalue.
-
isNull
- Specified by:
isNullin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
trueif a column contains aNULLvalue.
-
getBoolean
public boolean getBoolean(int columnIndex) - Specified by:
getBooleanin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.bool().
-
getBoolean
- Specified by:
getBooleanin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.bool().
-
getLong
public long getLong(int columnIndex) - Specified by:
getLongin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.int64().
-
getLong
- Specified by:
getLongin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.int64().
-
getFloat
public float getFloat(int columnIndex) - Specified by:
getFloatin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.float32().
-
getFloat
- Specified by:
getFloatin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.float32().
-
getDouble
public double getDouble(int columnIndex) - Specified by:
getDoublein interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.float64().
-
getDouble
- Specified by:
getDoublein interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.float64().
-
getBigDecimal
- Specified by:
getBigDecimalin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.numeric().
-
getBigDecimal
- Specified by:
getBigDecimalin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.numeric().
-
getString
- Specified by:
getStringin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.string().
-
getString
- Specified by:
getStringin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.string().
-
getJson
- Specified by:
getJsonin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.json().
-
getJson
- Specified by:
getJsonin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.json().
-
getPgJsonb
- Specified by:
getPgJsonbin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.pgJsonb().
-
getPgJsonb
- Specified by:
getPgJsonbin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.pgJsonb().
-
getBytes
public com.google.cloud.ByteArray getBytes(int columnIndex) - Specified by:
getBytesin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.bytes().
-
getBytes
- Specified by:
getBytesin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.bytes().
-
getTimestamp
public com.google.cloud.Timestamp getTimestamp(int columnIndex) - Specified by:
getTimestampin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.timestamp().
-
getTimestamp
- Specified by:
getTimestampin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.timestamp().
-
getDate
public com.google.cloud.Date getDate(int columnIndex) - Specified by:
getDatein interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.date().
-
getDate
- Specified by:
getDatein interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.date().
-
getBooleanArray
public boolean[] getBooleanArray(int columnIndex) - Specified by:
getBooleanArrayin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.bool()).
-
getBooleanArray
- Specified by:
getBooleanArrayin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.bool()).
-
getBooleanList
- Specified by:
getBooleanListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getBooleanListin interfaceStructReader- Parameters:
columnName- name of the column- 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
public long[] getLongArray(int columnIndex) - Specified by:
getLongArrayin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.int64()).
-
getLongArray
- Specified by:
getLongArrayin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.int64()).
-
getLongList
- Specified by:
getLongListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getLongListin interfaceStructReader- 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.
-
getFloatArray
public float[] getFloatArray(int columnIndex) - Specified by:
getFloatArrayin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.float32()).
-
getFloatArray
- Specified by:
getFloatArrayin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.float32()).
-
getFloatList
- Specified by:
getFloatListin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.float32())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.
-
getFloatList
- Specified by:
getFloatListin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.float32())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
public double[] getDoubleArray(int columnIndex) - Specified by:
getDoubleArrayin interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.float64()).
-
getDoubleArray
- Specified by:
getDoubleArrayin interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a non-
NULLcolumn with typeType.array(Type.float64()).
-
getDoubleList
- Specified by:
getDoubleListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getDoubleListin interfaceStructReader- Parameters:
columnName- name of the column- 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
- Specified by:
getBigDecimalListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getBigDecimalListin interfaceStructReader- Parameters:
columnName- name of the column- 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
- Specified by:
getStringListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getStringListin interfaceStructReader- Parameters:
columnName- name of the column- 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
- Specified by:
getJsonListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getJsonListin interfaceStructReader- Parameters:
columnName- name of the column- 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
- Specified by:
getPgJsonbListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getPgJsonbListin interfaceStructReader- Parameters:
columnName- name of the column- 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
- Specified by:
getBytesListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getBytesListin interfaceStructReader- Parameters:
columnName- name of the column- 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
- Specified by:
getTimestampListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getTimestampListin interfaceStructReader- Parameters:
columnName- name of the column- 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
- Specified by:
getDateListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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
- Specified by:
getDateListin interfaceStructReader- Parameters:
columnName- name of the column- 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.
-
getProtoMessageList
public <T extends com.google.protobuf.AbstractMessage> List<T> getProtoMessageList(int columnIndex, T message) Description copied from interface:StructReaderTo get the proto message of generic typeTfrom Struct.- Specified by:
getProtoMessageListin interfaceStructReader- Parameters:
columnIndex- Index of the column.message- 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:
- The value of a non-
NULLcolumn with typeType.array(Type.proto(String)).
-
getProtoMessageList
public <T extends com.google.protobuf.AbstractMessage> List<T> getProtoMessageList(String columnName, T message) Description copied from interface:StructReaderTo get the proto message of typeTfrom Struct.- Specified by:
getProtoMessageListin interfaceStructReader- Parameters:
columnName- Name of the column.message- 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:
- The value of a non-
NULLcolumn with typeType.array(Type.proto(String)).
-
getProtoEnumList
public <T extends com.google.protobuf.ProtocolMessageEnum> List<T> getProtoEnumList(int columnIndex, Function<Integer, com.google.protobuf.ProtocolMessageEnum> method) Description copied from interface:StructReaderTo get the proto enum of typeTfrom Struct.- Specified by:
getProtoEnumListin interfaceStructReader- Parameters:
columnIndex- Index of the column.method- 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:
- The value of a non-
NULLcolumn with typeType.array(Type.protoEnum(String)).
-
getProtoEnumList
public <T extends com.google.protobuf.ProtocolMessageEnum> List<T> getProtoEnumList(String columnName, Function<Integer, com.google.protobuf.ProtocolMessageEnum> method) Description copied from interface:StructReaderTo get the proto enum list of typeTfrom Struct.- Specified by:
getProtoEnumListin interfaceStructReader- Parameters:
columnName- Name of the column.method- 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:
- The value of a non-
NULLcolumn with typeType.array(Type.protoEnum(String)).
-
getStructList
- Specified by:
getStructListin interfaceStructReader- Parameters:
columnIndex- index of the column- 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.
-
getStructList
- Specified by:
getStructListin interfaceStructReader- Parameters:
columnName- name of the column- 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.
-
getProtoMessage
public <T extends com.google.protobuf.AbstractMessage> T getProtoMessage(int columnIndex, T message) Description copied from interface:StructReaderTo get the proto message of generic typeTfrom Struct.- Specified by:
getProtoMessagein interfaceStructReader- Parameters:
columnIndex- Index of the column.message- 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:
- The value of a non-
NULLcolumn with typeType.proto(String)()}.
-
getProtoMessage
public <T extends com.google.protobuf.AbstractMessage> T getProtoMessage(String columnName, T message) Description copied from interface:StructReaderTo get the proto message of typeTfrom Struct.- Specified by:
getProtoMessagein interfaceStructReader- Parameters:
columnName- Name of the column.message- 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:
- The value of a non-
NULLcolumn with typeType.proto(String)()}.
-
getProtoEnum
public <T extends com.google.protobuf.ProtocolMessageEnum> T getProtoEnum(int columnIndex, Function<Integer, com.google.protobuf.ProtocolMessageEnum> method) Description copied from interface:StructReaderTo get the proto enum of typeTfrom Struct.- Specified by:
getProtoEnumin interfaceStructReader- Parameters:
columnIndex- Index of the column.method- 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:
- The value of a non-
NULLcolumn with typeType.protoEnum(String)()}.
-
getProtoEnum
public <T extends com.google.protobuf.ProtocolMessageEnum> T getProtoEnum(String columnName, Function<Integer, com.google.protobuf.ProtocolMessageEnum> method) Description copied from interface:StructReaderTo get the proto enum of typeTfrom Struct.- Specified by:
getProtoEnumin interfaceStructReader- Parameters:
columnName- Name of the column.method- 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:
- The value of a non-
NULLcolumn with typeType.protoEnum(String)()}.
-
getValue
- Specified by:
getValuein interfaceStructReader- Parameters:
columnIndex- index of the column- Returns:
- the value of a nullable column as a
Value.
-
getValue
- Specified by:
getValuein interfaceStructReader- Parameters:
columnName- name of the column- Returns:
- the value of a nullable column as a
Value.
-