# Class StarResultSet

java.lang.Object
uk.ac.starlink.table.jdbc.StarResultSet

public class StarResultSet extends Object
Wraps the `ResultSet` class to provide the functions which are required to provide `StarTable` functionality.

Since:
  23 Jul 2007
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`StarResultSet(ResultSet rset)`
Constructs a StarResultSet with default type mapping behaviour.
`StarResultSet(ResultSet rset, TypeMapper typeMapper)`
Constructs a StarResultSet with given type mapping behaviour.

## Method Summary

Modifier and Type
Method
Description
`RowSequence`
`createRowSequence()`
Returns a sequential RowSequence based on this object.
`Object`
`getCell(int icol)`
Returns the object at a given column in the current row of this result set in a form suitable for use as the content of a StarTable cell.
`List<ValueInfo>`
`getColumnAuxDataInfos()`
Returns an ordered list of `ValueInfo` objects representing the auxilliary metadata returned by this object's ColumnInfo objects.
`ColumnInfo[]`
`getColumnInfos()`
Returns the array of column metadata objects corresponding to the columns in this result set.
`ResultSet`
`getResultSet()`
Returns the result set on which this table is based.
`Object[]`
`getRow()`
Returns the current row of this result set in a form suitable for use as the content of a StarTable.
`long`
`getRowCount()`
Lazily counts the number of rows in this result set, if it has random access.
`boolean`
`isRandom()`
Indicates whether this result set can be used for random access.
`void`
`setRowIndex(long lrow)`
Sets the row index from which subsequent `getCell(int)` and `getRow()` calls will read.

### Methods inherited from class Object

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

## Constructor Details

### StarResultSet

public StarResultSet(ResultSet rset) throws SQLException
Constructs a StarResultSet with default type mapping behaviour.

Parameters:
  `rset` - result set
Throws:
  `SQLException`

### StarResultSet

public StarResultSet(ResultSet rset, TypeMapper typeMapper) throws SQLException
Constructs a StarResultSet with given type mapping behaviour.

Parameters:
  `rset` - result set
  `typeMapper` - handles conversion of JDBC types to cell types
Throws:
  `SQLException`

## Method Details

### getResultSet

public ResultSet getResultSet()
Returns the result set on which this table is based.

Returns:
  result set

### getColumnInfos

public ColumnInfo[] getColumnInfos()
Returns the array of column metadata objects corresponding to the columns in this result set.

Returns:
  column info array (not a copy)

### isRandom

public boolean isRandom()
Indicates whether this result set can be used for random access.

Returns:
  true iff random access is possible

### getRowCount

public long getRowCount()
Lazily counts the number of rows in this result set, if it has random access. Otherwise, returns -1 (unknown), since a count may be very expensive. If the count cannot be calculated for a random access table for some reason, zero is returned and a warning is logged.

Returns:
  row count

### getColumnAuxDataInfos

public List<ValueInfo> getColumnAuxDataInfos()
Returns an ordered list of `ValueInfo` objects representing the auxilliary metadata returned by this object's ColumnInfo objects.

Returns:
  an unmodifiable ordered set of known metadata keys
See Also:
  - `StarTable.getColumnAuxDataInfos()`

### setRowIndex

public void setRowIndex(long lrow) throws IOException
Sets the row index from which subsequent `getCell(int)` and `getRow()` calls will read. Callers may need to worry about synchronization.

Parameters:
  `lrow` - row index (0-based)
Throws:
  `UnsupportedOperationException` - for non-random result sets
  `IOException`

### getCell

public Object getCell(int icol) throws IOException
Returns the object at a given column in the current row of this result set in a form suitable for use as the content of a StarTable cell. Callers may need to worry about synchronization.

Parameters:
  `icol` - the column to use (first column is 0)
Returns:
  the cell value
Throws:
  `IOException`

### getRow

public Object[] getRow() throws IOException
Returns the current row of this result set in a form suitable for use as the content of a StarTable. Callers may need to worry about synchronization.

Returns:
  array of cell values in current row
Throws:
  `IOException`

### createRowSequence

public RowSequence createRowSequence() throws IOException
Returns a sequential RowSequence based on this object. This assumes that the cursor is currently at the beginning of the result set - no checking is performed here.

Returns:
  row sequence
Throws:
  `IOException`