Class AbstractStructReader

  • All Implemented Interfaces:
    StructReader
    Direct Known Subclasses:
    Struct

    public abstract class AbstractStructReader
    extends Object
    implements StructReader
    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 Detail

      • AbstractStructReader

        public AbstractStructReader()
    • 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)
      • getBooleanListInternal

        protected abstract List<Boolean> getBooleanListInternal​(int columnIndex)
      • getLongArrayInternal

        protected abstract long[] getLongArrayInternal​(int columnIndex)
      • getLongListInternal

        protected abstract List<Long> getLongListInternal​(int columnIndex)
      • getDoubleArrayInternal

        protected abstract double[] getDoubleArrayInternal​(int columnIndex)
      • getDoubleListInternal

        protected abstract List<Double> getDoubleListInternal​(int columnIndex)
      • getBigDecimalListInternal

        protected abstract List<BigDecimal> getBigDecimalListInternal​(int columnIndex)
      • getStringListInternal

        protected abstract List<String> getStringListInternal​(int columnIndex)
      • getJsonListInternal

        protected List<String> getJsonListInternal​(int columnIndex)
      • getPgJsonbListInternal

        protected List<String> getPgJsonbListInternal​(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)
      • getStructListInternal

        protected abstract List<Struct> getStructListInternal​(int columnIndex)
      • getColumnCount

        public int getColumnCount()
        Specified by:
        getColumnCount in interface StructReader
        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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the type of a column.
      • getColumnType

        public Type getColumnType​(String columnName)
        Specified by:
        getColumnType in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the type of a column.
      • isNull

        public boolean isNull​(String columnName)
        Specified by:
        isNull in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        true if a column contains a NULL value.
      • getBoolean

        public boolean getBoolean​(int columnIndex)
        Specified by:
        getBoolean in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.bool().
      • getBoolean

        public boolean getBoolean​(String columnName)
        Specified by:
        getBoolean in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.bool().
      • getLong

        public long getLong​(int columnIndex)
        Specified by:
        getLong in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.int64().
      • getLong

        public long getLong​(String columnName)
        Specified by:
        getLong in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.int64().
      • getDouble

        public double getDouble​(int columnIndex)
        Specified by:
        getDouble in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.float64().
      • getDouble

        public double getDouble​(String columnName)
        Specified by:
        getDouble in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.float64().
      • getString

        public String getString​(int columnIndex)
        Specified by:
        getString in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.string().
      • getJson

        public String getJson​(int columnIndex)
        Specified by:
        getJson in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.json().
      • getJson

        public String getJson​(String columnName)
        Specified by:
        getJson in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.json().
      • getPgJsonb

        public String getPgJsonb​(int columnIndex)
        Specified by:
        getPgJsonb in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.pgJsonb().
      • getBytes

        public com.google.cloud.ByteArray getBytes​(int columnIndex)
        Specified by:
        getBytes in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.bytes().
      • getBytes

        public com.google.cloud.ByteArray getBytes​(String columnName)
        Specified by:
        getBytes in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.bytes().
      • getTimestamp

        public com.google.cloud.Timestamp getTimestamp​(int columnIndex)
        Specified by:
        getTimestamp in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.timestamp().
      • getTimestamp

        public com.google.cloud.Timestamp getTimestamp​(String columnName)
        Specified by:
        getTimestamp in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.timestamp().
      • getDate

        public com.google.cloud.Date getDate​(int columnIndex)
        Specified by:
        getDate in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.date().
      • getDate

        public com.google.cloud.Date getDate​(String columnName)
        Specified by:
        getDate in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.date().
      • getValue

        public Value getValue​(int columnIndex)
        Specified by:
        getValue in interface StructReader
        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 interface StructReader
        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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.array(Type.bool()).
      • getBooleanArray

        public boolean[] getBooleanArray​(String columnName)
        Specified by:
        getBooleanArray in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.array(Type.bool()).
      • getBooleanList

        public List<Boolean> getBooleanList​(int columnIndex)
        Specified by:
        getBooleanList in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.array(Type.int64()).
      • getLongArray

        public long[] getLongArray​(String columnName)
        Specified by:
        getLongArray in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.array(Type.int64()).
      • getLongList

        public List<Long> getLongList​(int columnIndex)
        Specified by:
        getLongList in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.array(Type.float64()).
      • getDoubleArray

        public double[] getDoubleArray​(String columnName)
        Specified by:
        getDoubleArray in interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.array(Type.float64()).
      • getDoubleList

        public List<Double> getDoubleList​(int columnIndex)
        Specified by:
        getDoubleList in interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnIndex - index of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the value of a non-NULL column with type Type.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 interface StructReader
        Parameters:
        columnName - name of the column
        Returns:
        the index of the column named columnName.
      • checkNonNull

        protected void checkNonNull​(int columnIndex,
                                    Object columnNameForError)