uk.ac.starlink.table.jdbc

## Class RandomResultSetStarTable

- java.lang.Object
- - uk.ac.starlink.table.AbstractStarTable
  - - uk.ac.starlink.table.RandomStarTable
    - - uk.ac.starlink.table.jdbc.RandomResultSetStarTable

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, StarTable

      public class RandomResultSetStarTable
      extends RandomStarTable

  StarTable implementation based on a random-access `ResultSet`. Such results sets have a `type` of `ResultSet.TYPE_SCROLL_*` and are generally produced from by using a Statement which has been constructed using corresponding type. This implementation is thread-safe.
  Since:
    23 Jul 2007

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RandomResultSetStarTable(java.sql.ResultSet rset)` Constructor.
    `RandomResultSetStarTable(StarResultSet srset)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` The `AbstractStarTable` implementation of this method does nothing.
    `java.lang.Object` | `getCell(long lrow, int icol)` Implementations of this method must be safe for concurrent calls from multiple threads.
    `java.util.List<ValueInfo>` | `getColumnAuxDataInfos()` Goes through the table columns (`ColumnInfo` objects) and picks out all the AuxData items which exist, generalising where necessary and returning a union of them in alphabetical order by name.
    `int` | `getColumnCount()` Returns the number of columns in this table.
    `ColumnInfo` | `getColumnInfo(int icol)` Returns the object describing the data in a given column.
    `java.sql.ResultSet` | `getResultSet()` Returns the result set on which this table is built.
    `java.lang.Object[]` | `getRow(long lrow)` The `AbstractStarTable` implementation of this method constructs a row by repeated invocation of `AbstractStarTable.getCell(long, int)`.
    `long` | `getRowCount()` Implementations must supply a non-negative return value.

    - ### Methods inherited from class uk.ac.starlink.table.RandomStarTable

      `getRowAccess, getRowSequence, isRandom`

    - ### Methods inherited from class uk.ac.starlink.table.AbstractStarTable

      `checkedLongToInt, getName, getParameters, getRowSplittable, getURL, setName, setParameters, setURL`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface uk.ac.starlink.table.StarTable

      `getParameterByName, setParameter`

- - ### Constructor Detail

    - #### RandomResultSetStarTable

          public RandomResultSetStarTable(java.sql.ResultSet rset)
                                   throws java.sql.SQLException

      Constructor.
      Parameters:
        `rset` - result set containing data
      Throws:
        `java.lang.IllegalArgumentException` - if `rset` is not random access
        `java.sql.SQLException`

    - #### RandomResultSetStarTable

          public RandomResultSetStarTable(StarResultSet srset)

      Constructor.
      Parameters:
        `srset` - result set containing data
      Throws:
        `java.lang.IllegalArgumentException` - if `srset` is not random access

  - ### Method Detail

    - #### getResultSet

          public java.sql.ResultSet getResultSet()

      Returns the result set on which this table is built.
      Returns:
        result set

    - #### getColumnCount

          public int getColumnCount()

      Description copied from interface: `StarTable`
      Returns the number of columns in this table.
      Specified by:
        `getColumnCount` in interface `StarTable`
      Specified by:
        `getColumnCount` in class `AbstractStarTable`
      Returns:
        the number of columns

    - #### getColumnInfo

          public ColumnInfo getColumnInfo(int icol)

      Description copied from interface: `StarTable`
      Returns the object describing the data in a given column.
      Specified by:
        `getColumnInfo` in interface `StarTable`
      Specified by:
        `getColumnInfo` in class `AbstractStarTable`
      Parameters:
        `icol` - the column for which header information is required
      Returns:
        a ValueInfo object for column `icol`

    - #### getRowCount

          public long getRowCount()

      Description copied from class: `RandomStarTable`
      Implementations must supply a non-negative return value.
      Specified by:
        `getRowCount` in interface `StarTable`
      Specified by:
        `getRowCount` in class `RandomStarTable`
      Returns:
        the number of rows in the table

    - #### getColumnAuxDataInfos

          public java.util.List<ValueInfo> getColumnAuxDataInfos()

      Description copied from class: `AbstractStarTable`
      Goes through the table columns (`ColumnInfo` objects) and picks out all the AuxData items which exist, generalising where necessary and returning a union of them in alphabetical order by name. Subclasses should override this if they can do better, for instance providing an order for the keys.
      Specified by:
        `getColumnAuxDataInfos` in interface `StarTable`
      Overrides:
        `getColumnAuxDataInfos` in class `AbstractStarTable`
      Returns:
        a list of all the auxiliary metadata `ValueInfo` items which in fact crop up in column metadata
      See Also:
        `DefaultValueInfo.getAuxData()`

    - #### getCell

          public java.lang.Object getCell(long lrow,
                                          int icol)
                                   throws java.io.IOException

      Description copied from class: `RandomStarTable`
      Implementations of this method must be safe for concurrent calls from multiple threads.
      Specified by:
        `getCell` in interface `StarTable`
      Specified by:
        `getCell` in class `RandomStarTable`
      Parameters:
        `lrow` - the index of the cell's row
        `icol` - the index of the cell's column
      Returns:
        the contents of this cell
      Throws:
        `java.io.IOException` - if there is an error reading the data

    - #### getRow

          public java.lang.Object[] getRow(long lrow)
                                    throws java.io.IOException

      Description copied from class: `AbstractStarTable`
      The `AbstractStarTable` implementation of this method constructs a row by repeated invocation of `AbstractStarTable.getCell(long, int)`.
      Specified by:
        `getRow` in interface `StarTable`
      Overrides:
        `getRow` in class `AbstractStarTable`
      Parameters:
        `lrow` - the index of the row to retrieve
      Returns:
        an array of the objects in each cell in row `irow`
      Throws:
        `java.io.IOException` - if there is an error reading the data

    - #### close

          public void close()
                     throws java.io.IOException

      Description copied from class: `AbstractStarTable`
      The `AbstractStarTable` implementation of this method does nothing.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `StarTable`
      Overrides:
        `close` in class `AbstractStarTable`
      Throws:
        `java.io.IOException`