Package com.google.cloud.spanner
Class AbstractStructReader
java.lang.Object
com.google.cloud.spanner.AbstractStructReader
- All Implemented Interfaces:
StructReader
- Direct Known Subclasses:
Struct
Base class for assisting
StructReader
implementations.
This class implements the majority of the StructReader
interface, leaving subclasses
to implement core data access via the getTypeNameInternal()
methods.
AbstractStructReader
guarantees that these will only be called for non-NULL
columns of a
type appropriate for the method.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkNonNull
(int columnIndex, Object columnNameForError) getBigDecimal
(int columnIndex) getBigDecimal
(String columnName) protected abstract BigDecimal
getBigDecimalInternal
(int columnIndex) getBigDecimalList
(int columnIndex) getBigDecimalList
(String columnName) protected abstract List<BigDecimal>
getBigDecimalListInternal
(int columnIndex) boolean
getBoolean
(int columnIndex) boolean
getBoolean
(String columnName) boolean[]
getBooleanArray
(int columnIndex) boolean[]
getBooleanArray
(String columnName) protected abstract boolean[]
getBooleanArrayInternal
(int columnIndex) protected abstract boolean
getBooleanInternal
(int columnIndex) getBooleanList
(int columnIndex) getBooleanList
(String columnName) getBooleanListInternal
(int columnIndex) com.google.cloud.ByteArray
getBytes
(int columnIndex) com.google.cloud.ByteArray
protected abstract com.google.cloud.ByteArray
getBytesInternal
(int columnIndex) List<com.google.cloud.ByteArray>
getBytesList
(int columnIndex) List<com.google.cloud.ByteArray>
getBytesList
(String columnName) protected abstract List<com.google.cloud.ByteArray>
getBytesListInternal
(int columnIndex) int
int
getColumnIndex
(String columnName) getColumnType
(int columnIndex) getColumnType
(String columnName) com.google.cloud.Date
getDate
(int columnIndex) com.google.cloud.Date
protected abstract com.google.cloud.Date
getDateInternal
(int columnIndex) List<com.google.cloud.Date>
getDateList
(int columnIndex) List<com.google.cloud.Date>
getDateList
(String columnName) protected abstract List<com.google.cloud.Date>
getDateListInternal
(int columnIndex) double
getDouble
(int columnIndex) double
double[]
getDoubleArray
(int columnIndex) double[]
getDoubleArray
(String columnName) protected abstract double[]
getDoubleArrayInternal
(int columnIndex) protected abstract double
getDoubleInternal
(int columnIndex) getDoubleList
(int columnIndex) getDoubleList
(String columnName) getDoubleListInternal
(int columnIndex) getJson
(int columnIndex) protected String
getJsonInternal
(int columnIndex) getJsonList
(int columnIndex) getJsonList
(String columnName) getJsonListInternal
(int columnIndex) long
getLong
(int columnIndex) long
long[]
getLongArray
(int columnIndex) long[]
getLongArray
(String columnName) protected abstract long[]
getLongArrayInternal
(int columnIndex) protected abstract long
getLongInternal
(int columnIndex) getLongList
(int columnIndex) getLongList
(String columnName) getLongListInternal
(int columnIndex) getPgJsonb
(int columnIndex) getPgJsonb
(String columnName) protected String
getPgJsonbInternal
(int columnIndex) getPgJsonbList
(int columnIndex) getPgJsonbList
(String columnName) getPgJsonbListInternal
(int columnIndex) getString
(int columnIndex) protected abstract String
getStringInternal
(int columnIndex) getStringList
(int columnIndex) getStringList
(String columnName) getStringListInternal
(int columnIndex) getStructList
(int columnIndex) getStructList
(String columnName) getStructListInternal
(int columnIndex) com.google.cloud.Timestamp
getTimestamp
(int columnIndex) com.google.cloud.Timestamp
getTimestamp
(String columnName) protected abstract com.google.cloud.Timestamp
getTimestampInternal
(int columnIndex) List<com.google.cloud.Timestamp>
getTimestampList
(int columnIndex) List<com.google.cloud.Timestamp>
getTimestampList
(String columnName) protected abstract List<com.google.cloud.Timestamp>
getTimestampListInternal
(int columnIndex) getValue
(int columnIndex) protected Value
getValueInternal
(int columnIndex) boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.cloud.spanner.StructReader
getType, isNull
-
Constructor Details
-
AbstractStructReader
public AbstractStructReader()
-
-
Method Details
-
getBooleanInternal
protected abstract boolean getBooleanInternal(int columnIndex) -
getLongInternal
protected abstract long getLongInternal(int columnIndex) -
getDoubleInternal
protected abstract double getDoubleInternal(int columnIndex) -
getBigDecimalInternal
-
getStringInternal
-
getJsonInternal
-
getPgJsonbInternal
-
getBytesInternal
protected abstract com.google.cloud.ByteArray getBytesInternal(int columnIndex) -
getTimestampInternal
protected abstract com.google.cloud.Timestamp getTimestampInternal(int columnIndex) -
getDateInternal
protected abstract com.google.cloud.Date getDateInternal(int columnIndex) -
getValueInternal
-
getBooleanArrayInternal
protected abstract boolean[] getBooleanArrayInternal(int columnIndex) -
getBooleanListInternal
-
getLongArrayInternal
protected abstract long[] getLongArrayInternal(int columnIndex) -
getLongListInternal
-
getDoubleArrayInternal
protected abstract double[] getDoubleArrayInternal(int columnIndex) -
getDoubleListInternal
-
getBigDecimalListInternal
-
getStringListInternal
-
getJsonListInternal
-
getPgJsonbListInternal
-
getBytesListInternal
-
getTimestampListInternal
-
getDateListInternal
-
getStructListInternal
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceStructReader
- Returns:
- the number of columns in the underlying data. This includes any columns with
NULL
values.
-
getColumnType
- Specified by:
getColumnType
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the type of a column.
-
getColumnType
- Specified by:
getColumnType
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the type of a column.
-
isNull
- Specified by:
isNull
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
true
if a column contains aNULL
value.
-
getBoolean
public boolean getBoolean(int columnIndex) - Specified by:
getBoolean
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.bool()
.
-
getBoolean
- Specified by:
getBoolean
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.bool()
.
-
getLong
public long getLong(int columnIndex) - Specified by:
getLong
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.int64()
.
-
getLong
- Specified by:
getLong
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.int64()
.
-
getDouble
public double getDouble(int columnIndex) - Specified by:
getDouble
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.float64()
.
-
getDouble
- Specified by:
getDouble
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.float64()
.
-
getBigDecimal
- Specified by:
getBigDecimal
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.numeric()
.
-
getBigDecimal
- Specified by:
getBigDecimal
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.numeric()
.
-
getString
- Specified by:
getString
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.string()
.
-
getString
- Specified by:
getString
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.string()
.
-
getJson
- Specified by:
getJson
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.json()
.
-
getJson
- Specified by:
getJson
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.json()
.
-
getPgJsonb
- Specified by:
getPgJsonb
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.pgJsonb()
.
-
getPgJsonb
- Specified by:
getPgJsonb
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.pgJsonb()
.
-
getBytes
public com.google.cloud.ByteArray getBytes(int columnIndex) - Specified by:
getBytes
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.bytes()
.
-
getBytes
- Specified by:
getBytes
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.bytes()
.
-
getTimestamp
public com.google.cloud.Timestamp getTimestamp(int columnIndex) - Specified by:
getTimestamp
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.timestamp()
.
-
getTimestamp
- Specified by:
getTimestamp
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.timestamp()
.
-
getDate
public com.google.cloud.Date getDate(int columnIndex) - Specified by:
getDate
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.date()
.
-
getDate
- Specified by:
getDate
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.date()
.
-
getValue
- Specified by:
getValue
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a nullable column as a
Value
.
-
getValue
- Specified by:
getValue
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a nullable column as a
Value
.
-
getBooleanArray
public boolean[] getBooleanArray(int columnIndex) - Specified by:
getBooleanArray
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.array(Type.bool())
.
-
getBooleanArray
- Specified by:
getBooleanArray
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.array(Type.bool())
.
-
getBooleanList
- Specified by:
getBooleanList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getBooleanList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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:
getLongArray
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.array(Type.int64())
.
-
getLongArray
- Specified by:
getLongArray
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.array(Type.int64())
.
-
getLongList
- Specified by:
getLongList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getLongList
in interfaceStructReader
- Returns:
- the value of a non-
NULL
column 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
public double[] getDoubleArray(int columnIndex) - Specified by:
getDoubleArray
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.array(Type.float64())
.
-
getDoubleArray
- Specified by:
getDoubleArray
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.array(Type.float64())
.
-
getDoubleList
- Specified by:
getDoubleList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getDoubleList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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:
getBigDecimalList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getBigDecimalList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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:
getStringList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getStringList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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:
getJsonList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getJsonList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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:
getPgJsonbList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getPgJsonbList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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:
getBytesList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getBytesList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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:
getTimestampList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getTimestampList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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:
getDateList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getDateList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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
- Specified by:
getStructList
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column 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:
getStructList
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column 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.
-
getColumnIndex
- Specified by:
getColumnIndex
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the index of the column named
columnName
.
-
checkNonNull
-