uk.ac.starlink.table

## Class RandomStarTable

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

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, StarTable
  Direct Known Subclasses:
    BeanStarTable, ColumnStarTable, ConstantStarTable, RandomResultSetStarTable, RowListStarTable

      public abstract class RandomStarTable
      extends AbstractStarTable

  Implements a StarTable based on row and cell accessor methods that are random access and thread-safe.

  The `isRandom` method always returns true, and the `getRowSequence` method is implemented using the table's (abstract) `getCell` and `getRow` methods, which must be safe for concurrent use from multiple threads. This implementation is only suitable where table data access is naturally thread-safe; in cases where synchronization or some other potentially expensive mechanism is used to secure thread-safety of `getCell`, it is better to use a different implementation with a better `getRowSequence` implementation.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RandomStarTable()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract java.lang.Object` | `getCell(long irow, int icol)` Implementations of this method must be safe for concurrent calls from multiple threads.
    `RowAccess` | `getRowAccess()` Returns a `RowAccess` object based on the random data access methods of this table.
    `abstract long` | `getRowCount()` Implementations must supply a non-negative return value.
    `RowSequence` | `getRowSequence()` Returns a `RowSequence` object based on the random data access methods of this table.
    `boolean` | `isRandom()` Returns true.

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

      `checkedLongToInt, close, getColumnAuxDataInfos, getColumnCount, getColumnInfo, getName, getParameters, getRow, 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

    - #### RandomStarTable

          public RandomStarTable()

  - ### Method Detail

    - #### isRandom

          public boolean isRandom()

      Returns true.
      Specified by:
        `isRandom` in interface `StarTable`
      Overrides:
        `isRandom` in class `AbstractStarTable`
      Returns:
        true

    - #### getRowSequence

          public RowSequence getRowSequence()

      Returns a `RowSequence` object based on the random data access methods of this table.
      Specified by:
        `getRowSequence` in interface `StarTable`
      Specified by:
        `getRowSequence` in class `AbstractStarTable`
      Returns:
        a row iterator

    - #### getRowAccess

          public RowAccess getRowAccess()

      Returns a `RowAccess` object based on the random data access methods of this table.
      Specified by:
        `getRowAccess` in interface `StarTable`
      Overrides:
        `getRowAccess` in class `AbstractStarTable`
      Returns:
        a row access

    - #### getRowCount

          public abstract long getRowCount()

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

    - #### getCell

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

      Implementations of this method must be safe for concurrent calls from multiple threads.
      Specified by:
        `getCell` in interface `StarTable`
      Overrides:
        `getCell` in class `AbstractStarTable`
      Parameters:
        `irow` - 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