Interface StructReader

  • All Known Subinterfaces:
    AsyncResultSet, ResultSet
    All Known Implementing Classes:
    AbstractStructReader, ForwardingAsyncResultSet, ForwardingResultSet, ForwardingStructReader, Struct

    public interface StructReader
    A base interface for reading the fields of a STRUCT. The Cloud Spanner yields StructReader instances as one of the subclasses ResultSet or Struct, most commonly as the result of a read or query operation. At any point in time, a StructReader provides access to a single tuple of data comprising multiple typed columns. Each column may have a NULL or non-NULL value; 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) and getString(String) exist for reading columns of type Type.string(); attempting to call those methods for columns of other types will result in an IllegalStateException. The getTypeName() methods should only be called for non-NULL values, otherwise a NullPointerException is raised; isNull(int)/isNull(String) can be used to test for NULL-ness if necessary.

    All methods for accessing a column have overloads that accept an int column index and a String column name. Column indices are zero-based. The column name overloads will fail with IllegalArgumentException if the column name does not appear exactly once in this instance's getType(). The int overloads are typically more efficient than their String counterparts.

    StructReader itself does not define whether the implementing type is mutable or immutable. For example, ResultSet is a mutable implementation of StructReader, where the StructReader methods provide access to the row that the result set is currently positioned over and ResultSet.next() changes that view to the next row, whereas Struct is an immutable implementation of StructReader.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      BigDecimal getBigDecimal​(int columnIndex)
      Returns the value of a non-NULL column with type Type.numeric().
      BigDecimal getBigDecimal​(String columnName)
      Returns the value of a non-NULL column with type Type.numeric().
      List<BigDecimal> getBigDecimalList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.numeric()) The list returned by this method is lazily constructed.
      List<BigDecimal> getBigDecimalList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.numeric()) The list returned by this method is lazily constructed.
      boolean getBoolean​(int columnIndex)
      Returns the value of a non-NULL column with type Type.bool().
      boolean getBoolean​(String columnName)
      Returns the value of a non-NULL column with type Type.bool().
      boolean[] getBooleanArray​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.bool()).
      boolean[] getBooleanArray​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.bool()).
      List<Boolean> getBooleanList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.bool()).
      List<Boolean> getBooleanList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.bool()).
      com.google.cloud.ByteArray getBytes​(int columnIndex)
      Returns the value of a non-NULL column with type Type.bytes().
      com.google.cloud.ByteArray getBytes​(String columnName)
      Returns the value of a non-NULL column with type Type.bytes().
      List<com.google.cloud.ByteArray> getBytesList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.bytes()).
      List<com.google.cloud.ByteArray> getBytesList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.bytes()).
      int getColumnCount()
      Returns the number of columns in the underlying data.
      int getColumnIndex​(String columnName)
      Returns the index of the column named columnName.
      Type getColumnType​(int columnIndex)
      Returns the type of a column.
      Type getColumnType​(String columnName)
      Returns the type of a column.
      com.google.cloud.Date getDate​(int columnIndex)
      Returns the value of a non-NULL column with type Type.date().
      com.google.cloud.Date getDate​(String columnName)
      Returns the value of a non-NULL column with type Type.date().
      List<com.google.cloud.Date> getDateList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.date()).
      List<com.google.cloud.Date> getDateList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.date()).
      double getDouble​(int columnIndex)
      Returns the value of a non-NULL column with type Type.float64().
      double getDouble​(String columnName)
      Returns the value of a non-NULL column with type Type.float64().
      double[] getDoubleArray​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.float64()).
      double[] getDoubleArray​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.float64()).
      List<Double> getDoubleList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.float64()) The list returned by this method is lazily constructed.
      List<Double> getDoubleList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.float64()) The list returned by this method is lazily constructed.
      default String getJson​(int columnIndex)
      Returns the value of a non-NULL column with type Type.json().
      default String getJson​(String columnName)
      Returns the value of a non-NULL column with type Type.json().
      default List<String> getJsonList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.json()).
      default List<String> getJsonList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.json()).
      long getLong​(int columnIndex)
      Returns the value of a non-NULL column with type Type.int64().
      long getLong​(String columnName)
      Returns the value of a non-NULL column with type Type.int64().
      long[] getLongArray​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.int64()).
      long[] getLongArray​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.int64()).
      List<Long> getLongList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.int64()).
      List<Long> getLongList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.int64()).
      default String getPgJsonb​(int columnIndex)
      Returns the value of a non-NULL column with type Type.pgJsonb().
      default String getPgJsonb​(String columnName)
      Returns the value of a non-NULL column with type Type.pgJsonb().
      default List<String> getPgJsonbList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.pgJsonb()) The list returned by this method is lazily constructed.
      default List<String> getPgJsonbList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.pgJsonb()) The list returned by this method is lazily constructed.
      String getString​(int columnIndex)
      Returns the value of a non-NULL column with type Type.string().
      String getString​(String columnName)
      Returns the value of a non-NULL column with type Type.string().
      List<String> getStringList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.string()).
      List<String> getStringList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.string()).
      List<Struct> getStructList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.array(Type.struct(...)) The list returned by this method is lazily constructed.
      List<Struct> getStructList​(String columnName)
      Returns the value of a non-NULL column with type Type.array(Type.struct(...)) The list returned by this method is lazily constructed.
      com.google.cloud.Timestamp getTimestamp​(int columnIndex)
      Returns the value of a non-NULL column with type Type.timestamp().
      com.google.cloud.Timestamp getTimestamp​(String columnName)
      Returns the value of a non-NULL column with type Type.timestamp().
      List<com.google.cloud.Timestamp> getTimestampList​(int columnIndex)
      Returns the value of a non-NULL column with type Type.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-NULL column with type Type.array(Type.timestamp()) The list returned by this method is lazily constructed.
      Type getType()
      Returns the type of the underlying data.
      default Value getValue​(int columnIndex)
      Returns the value of a nullable column as a Value.
      default Value getValue​(String columnName)
      Returns the value of a nullable column as a Value.
      boolean isNull​(int columnIndex)
      Returns true if a column contains a NULL value.
      boolean isNull​(String columnName)
      Returns true if a column contains a NULL value.
    • Method Detail

      • getType

        Type getType()
        Returns the type of the underlying data. This will always be a STRUCT type, with fields corresponding to the data's columns. For the result of a read or query, this will always match the columns passed to the read() 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 with NULL values.
      • getColumnType

        Type getColumnType​(int columnIndex)
        Returns the type of a column.
      • getColumnType

        Type getColumnType​(String columnName)
        Returns the type of a column.
      • isNull

        boolean isNull​(int columnIndex)
        Returns true if a column contains a NULL value.
      • isNull

        boolean isNull​(String columnName)
        Returns true if a column contains a NULL value.
      • getBoolean

        boolean getBoolean​(int columnIndex)
        Returns the value of a non-NULL column with type Type.bool().
      • getBoolean

        boolean getBoolean​(String columnName)
        Returns the value of a non-NULL column with type Type.bool().
      • getLong

        long getLong​(int columnIndex)
        Returns the value of a non-NULL column with type Type.int64().
      • getLong

        long getLong​(String columnName)
        Returns the value of a non-NULL column with type Type.int64().
      • getDouble

        double getDouble​(int columnIndex)
        Returns the value of a non-NULL column with type Type.float64().
      • getDouble

        double getDouble​(String columnName)
        Returns the value of a non-NULL column with type Type.float64().
      • getBigDecimal

        BigDecimal getBigDecimal​(int columnIndex)
        Returns the value of a non-NULL column with type Type.numeric().
      • getString

        String getString​(int columnIndex)
        Returns the value of a non-NULL column with type Type.string().
      • getJson

        default String getJson​(int columnIndex)
        Returns the value of a non-NULL column with type Type.json().
      • getJson

        default String getJson​(String columnName)
        Returns the value of a non-NULL column with type Type.json().
      • getPgJsonb

        default String getPgJsonb​(int columnIndex)
        Returns the value of a non-NULL column with type Type.pgJsonb().
      • getBytes

        com.google.cloud.ByteArray getBytes​(int columnIndex)
        Returns the value of a non-NULL column with type Type.bytes().
      • getBytes

        com.google.cloud.ByteArray getBytes​(String columnName)
        Returns the value of a non-NULL column with type Type.bytes().
      • getTimestamp

        com.google.cloud.Timestamp getTimestamp​(int columnIndex)
        Returns the value of a non-NULL column with type Type.timestamp().
      • getTimestamp

        com.google.cloud.Timestamp getTimestamp​(String columnName)
        Returns the value of a non-NULL column with type Type.timestamp().
      • getDate

        com.google.cloud.Date getDate​(int columnIndex)
        Returns the value of a non-NULL column with type Type.date().
      • getDate

        com.google.cloud.Date getDate​(String columnName)
        Returns the value of a non-NULL column with type Type.date().
      • getValue

        default Value getValue​(int columnIndex)
        Returns the value of a nullable column as a Value.
      • getValue

        default Value getValue​(String columnName)
        Returns the value of a nullable column as a Value.
      • getBooleanArray

        boolean[] getBooleanArray​(int columnIndex)
        Returns the value of a non-NULL column with type Type.array(Type.bool()).
        Throws:
        NullPointerException - if any element of the array value is NULL. If the array may contain NULL values, use getBooleanList(int) instead.
      • getBooleanArray

        boolean[] getBooleanArray​(String columnName)
        Returns the value of a non-NULL column with type Type.array(Type.bool()).
        Throws:
        NullPointerException - if any element of the array value is NULL. If the array may contain NULL values, use getBooleanList(String) instead.
      • getBooleanList

        List<Boolean> getBooleanList​(int columnIndex)
        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

        List<Boolean> getBooleanList​(String columnName)
        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

        long[] getLongArray​(int columnIndex)
        Returns the value of a non-NULL column with type Type.array(Type.int64()).
        Throws:
        NullPointerException - if any element of the array value is NULL. If the array may contain NULL values, use getLongList(int) instead.
      • getLongArray

        long[] getLongArray​(String columnName)
        Returns the value of a non-NULL column with type Type.array(Type.int64()).
        Throws:
        NullPointerException - if any element of the array value is NULL. If the array may contain NULL values, use getLongList(String) instead.
      • getLongList

        List<Long> getLongList​(int columnIndex)
        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

        List<Long> getLongList​(String columnName)
        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

        double[] getDoubleArray​(int columnIndex)
        Returns the value of a non-NULL column with type Type.array(Type.float64()).
        Throws:
        NullPointerException - if any element of the array value is NULL. If the array may contain NULL values, use getDoubleList(int) instead.
      • getDoubleArray

        double[] getDoubleArray​(String columnName)
        Returns the value of a non-NULL column with type Type.array(Type.float64()).
        Throws:
        NullPointerException - if any element of the array value is NULL. If the array may contain NULL values, use getDoubleList(String) instead.
      • getDoubleList

        List<Double> getDoubleList​(int columnIndex)
        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

        List<Double> getDoubleList​(String columnName)
        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

        List<BigDecimal> getBigDecimalList​(int columnIndex)
        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

        List<BigDecimal> getBigDecimalList​(String columnName)
        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

        List<String> getStringList​(int columnIndex)
        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

        List<String> getStringList​(String columnName)
        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

        default List<String> getJsonList​(int columnIndex)
        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

        default List<String> getJsonList​(String columnName)
        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

        default List<String> getPgJsonbList​(int columnIndex)
        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

        default List<String> getPgJsonbList​(String columnName)
        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

        List<com.google.cloud.ByteArray> getBytesList​(int columnIndex)
        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

        List<com.google.cloud.ByteArray> getBytesList​(String columnName)
        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

        List<com.google.cloud.Timestamp> getTimestampList​(int columnIndex)
        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

        List<com.google.cloud.Timestamp> getTimestampList​(String columnName)
        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

        List<com.google.cloud.Date> getDateList​(int columnIndex)
        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

        List<com.google.cloud.Date> getDateList​(String columnName)
        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

        List<Struct> getStructList​(int columnIndex)
        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

        List<Struct> getStructList​(String columnName)
        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.