Package com.google.cloud.spanner
Class AbstractStructReader
- java.lang.Object
-
- com.google.cloud.spanner.AbstractStructReader
-
- All Implemented Interfaces:
StructReader
- Direct Known Subclasses:
Struct
public abstract class AbstractStructReader extends Object implements StructReader
Base class for assistingStructReader
implementations.This class implements the majority of the
StructReader
interface, leaving subclasses to implement core data access via thegetTypeNameInternal()
methods.AbstractStructReader
guarantees that these will only be called for non-NULL
columns of a type appropriate for the method.
-
-
Constructor Summary
Constructors Constructor Description AbstractStructReader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkNonNull(int columnIndex, Object columnNameForError)
BigDecimal
getBigDecimal(int columnIndex)
BigDecimal
getBigDecimal(String columnName)
protected abstract BigDecimal
getBigDecimalInternal(int columnIndex)
List<BigDecimal>
getBigDecimalList(int columnIndex)
List<BigDecimal>
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)
List<Boolean>
getBooleanList(int columnIndex)
List<Boolean>
getBooleanList(String columnName)
protected abstract List<Boolean>
getBooleanListInternal(int columnIndex)
com.google.cloud.ByteArray
getBytes(int columnIndex)
com.google.cloud.ByteArray
getBytes(String columnName)
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
getColumnCount()
int
getColumnIndex(String columnName)
Type
getColumnType(int columnIndex)
Type
getColumnType(String columnName)
com.google.cloud.Date
getDate(int columnIndex)
com.google.cloud.Date
getDate(String columnName)
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
getDouble(String columnName)
double[]
getDoubleArray(int columnIndex)
double[]
getDoubleArray(String columnName)
protected abstract double[]
getDoubleArrayInternal(int columnIndex)
protected abstract double
getDoubleInternal(int columnIndex)
List<Double>
getDoubleList(int columnIndex)
List<Double>
getDoubleList(String columnName)
protected abstract List<Double>
getDoubleListInternal(int columnIndex)
String
getJson(int columnIndex)
String
getJson(String columnName)
protected String
getJsonInternal(int columnIndex)
List<String>
getJsonList(int columnIndex)
List<String>
getJsonList(String columnName)
protected List<String>
getJsonListInternal(int columnIndex)
long
getLong(int columnIndex)
long
getLong(String columnName)
long[]
getLongArray(int columnIndex)
long[]
getLongArray(String columnName)
protected abstract long[]
getLongArrayInternal(int columnIndex)
protected abstract long
getLongInternal(int columnIndex)
List<Long>
getLongList(int columnIndex)
List<Long>
getLongList(String columnName)
protected abstract List<Long>
getLongListInternal(int columnIndex)
String
getPgJsonb(int columnIndex)
String
getPgJsonb(String columnName)
protected String
getPgJsonbInternal(int columnIndex)
List<String>
getPgJsonbList(int columnIndex)
List<String>
getPgJsonbList(String columnName)
protected List<String>
getPgJsonbListInternal(int columnIndex)
String
getString(int columnIndex)
String
getString(String columnName)
protected abstract String
getStringInternal(int columnIndex)
List<String>
getStringList(int columnIndex)
List<String>
getStringList(String columnName)
protected abstract List<String>
getStringListInternal(int columnIndex)
List<Struct>
getStructList(int columnIndex)
List<Struct>
getStructList(String columnName)
protected abstract List<Struct>
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)
Value
getValue(int columnIndex)
Value
getValue(String columnName)
protected Value
getValueInternal(int columnIndex)
boolean
isNull(String columnName)
-
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
-
-
-
-
Method Detail
-
getBooleanInternal
protected abstract boolean getBooleanInternal(int columnIndex)
-
getLongInternal
protected abstract long getLongInternal(int columnIndex)
-
getDoubleInternal
protected abstract double getDoubleInternal(int columnIndex)
-
getBigDecimalInternal
protected abstract BigDecimal getBigDecimalInternal(int columnIndex)
-
getStringInternal
protected abstract String getStringInternal(int columnIndex)
-
getJsonInternal
protected String getJsonInternal(int columnIndex)
-
getPgJsonbInternal
protected String getPgJsonbInternal(int columnIndex)
-
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
protected Value getValueInternal(int columnIndex)
-
getBooleanArrayInternal
protected abstract boolean[] getBooleanArrayInternal(int columnIndex)
-
getLongArrayInternal
protected abstract long[] getLongArrayInternal(int columnIndex)
-
getDoubleArrayInternal
protected abstract double[] getDoubleArrayInternal(int columnIndex)
-
getBigDecimalListInternal
protected abstract List<BigDecimal> getBigDecimalListInternal(int columnIndex)
-
getBytesListInternal
protected abstract List<com.google.cloud.ByteArray> getBytesListInternal(int columnIndex)
-
getTimestampListInternal
protected abstract List<com.google.cloud.Timestamp> getTimestampListInternal(int columnIndex)
-
getDateListInternal
protected abstract List<com.google.cloud.Date> getDateListInternal(int columnIndex)
-
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
public Type getColumnType(int columnIndex)
- Specified by:
getColumnType
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the type of a column.
-
getColumnType
public Type getColumnType(String columnName)
- Specified by:
getColumnType
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the type of a column.
-
isNull
public boolean isNull(String columnName)
- 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
public boolean getBoolean(String columnName)
- 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
public long getLong(String columnName)
- 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
public double getDouble(String columnName)
- Specified by:
getDouble
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.float64()
.
-
getBigDecimal
public BigDecimal getBigDecimal(int columnIndex)
- Specified by:
getBigDecimal
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.numeric()
.
-
getBigDecimal
public BigDecimal getBigDecimal(String columnName)
- Specified by:
getBigDecimal
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.numeric()
.
-
getString
public String getString(int columnIndex)
- Specified by:
getString
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.string()
.
-
getString
public String getString(String columnName)
- Specified by:
getString
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.string()
.
-
getJson
public String getJson(int columnIndex)
- Specified by:
getJson
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.json()
.
-
getJson
public String getJson(String columnName)
- Specified by:
getJson
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.json()
.
-
getPgJsonb
public String getPgJsonb(int columnIndex)
- Specified by:
getPgJsonb
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a non-
NULL
column with typeType.pgJsonb()
.
-
getPgJsonb
public String getPgJsonb(String columnName)
- 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
public com.google.cloud.ByteArray getBytes(String columnName)
- 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
public com.google.cloud.Timestamp getTimestamp(String columnName)
- 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
public com.google.cloud.Date getDate(String columnName)
- Specified by:
getDate
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the value of a non-
NULL
column with typeType.date()
.
-
getValue
public Value getValue(int columnIndex)
- Specified by:
getValue
in interfaceStructReader
- Parameters:
columnIndex
- index of the column- Returns:
- the value of a nullable column as a
Value
.
-
getValue
public Value getValue(String columnName)
- 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
public boolean[] getBooleanArray(String columnName)
- 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
public List<Boolean> getBooleanList(int columnIndex)
- 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
public List<Boolean> getBooleanList(String columnName)
- 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
public long[] getLongArray(String columnName)
- 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
public List<Long> getLongList(int columnIndex)
- 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
public List<Long> getLongList(String columnName)
- 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
public double[] getDoubleArray(String columnName)
- 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
public List<Double> getDoubleList(int columnIndex)
- 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
public List<Double> getDoubleList(String columnName)
- 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
public List<BigDecimal> getBigDecimalList(int columnIndex)
- 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
public List<BigDecimal> getBigDecimalList(String columnName)
- 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
public List<String> getStringList(int columnIndex)
- 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
public List<String> getStringList(String columnName)
- 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
public List<String> getJsonList(int columnIndex)
- 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
public List<String> getJsonList(String columnName)
- 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
public List<String> getPgJsonbList(int columnIndex)
- 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
public List<String> getPgJsonbList(String columnName)
- 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
public List<com.google.cloud.ByteArray> getBytesList(int columnIndex)
- 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
public List<com.google.cloud.ByteArray> getBytesList(String columnName)
- 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
public List<com.google.cloud.Timestamp> getTimestampList(int columnIndex)
- 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
public List<com.google.cloud.Timestamp> getTimestampList(String columnName)
- 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
public List<com.google.cloud.Date> getDateList(int columnIndex)
- 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
public List<com.google.cloud.Date> getDateList(String columnName)
- 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
public List<Struct> getStructList(int columnIndex)
- 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
public List<Struct> getStructList(String columnName)
- 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
public int getColumnIndex(String columnName)
- Specified by:
getColumnIndex
in interfaceStructReader
- Parameters:
columnName
- name of the column- Returns:
- the index of the column named
columnName
.
-
checkNonNull
protected void checkNonNull(int columnIndex, Object columnNameForError)
-
-