# Class WrapperRowAccess

java.lang.Object
uk.ac.starlink.table.WrapperRowAccess

All Implemented Interfaces:
  `Closeable, AutoCloseable, RowAccess, RowData`

public class WrapperRowAccess extends Object implements RowAccess
RowAccess which wraps another RowAccess. This class acts as a wrapper around an existing 'base' RowSequence object; all its methods are implemented by forwarding them to the corresponding methods of that base sequence.

This class is provided so that it can be extended by subclasses which modify the view of the base sequence in useful ways.

Since:
  24 Jul 2020
Author:
  Mark Taylor (Starlink)
See Also:
  - `WrapperStarTable`

## Constructor Summary

Constructors
Constructor
Description
`WrapperRowAccess(RowAccess baseAcc)`
Constructs a new RowAccess based on a given one.
`WrapperRowAccess(RowAccess baseAcc, RowData data)`
Constructs a new RowAccess based on a given one but with a supplied data access implementation.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Closes this reader.
`Object`
`getCell(int icol)`
Returns the contents of a given cell at the current row.
`Object[]`
`getRow()`
Returns the contents of all the cells at the current row.
`void`
`setRowIndex(long irow)`
Sets the row index to which subsequent data accesses will refer.
`String`
`toString()`
Returns an indication of the wrapper structure of this object.

### Methods inherited from class Object

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

## Constructor Details

### WrapperRowAccess

public WrapperRowAccess(RowAccess baseAcc)
Constructs a new RowAccess based on a given one.

Parameters:
  `baseAcc` - the base row access

### WrapperRowAccess

public WrapperRowAccess(RowAccess baseAcc, RowData data)
Constructs a new RowAccess based on a given one but with a supplied data access implementation.

Parameters:
  `baseAcc` - the base row access
  `data` - RowData object whose methods will be used to implement the getCell and getRow methods

## Method Details

### setRowIndex

public void setRowIndex(long irow) throws IOException
Description copied from interface: `RowAccess`
Sets the row index to which subsequent data accesses will refer.

This method must be called before the first invocation of `RowAccess.getCell(int)`/`RowAccess.getRow()`, otherwise behaviour is undefined (but implementations will likely throw an unchecked exception on subsequent getCell/getRow calls). The effect of setting the value to an out of range value is undefined; it may throw an exception here, or during subsequent calls, or behave otherwise.

Specified by:
  `setRowIndex` in interface `RowAccess`
Parameters:
  `irow` - row index
Throws:
  `IOException`

### getCell

public Object getCell(int icol) throws IOException
Description copied from interface: `RowAccess`
Returns the contents of a given cell at the current row.

Behaviour is undefined if the row index has not been set, or has been set to a value for which no table row exists; however implementations are encouraged to throw suitable `RuntimeException` in this case.

Specified by:
  `getCell` in interface `RowAccess`
Specified by:
  `getCell` in interface `RowData`
Parameters:
  `icol` - column index
Returns:
  contents of given column at current row
Throws:
  `IOException` - if there's a problem reading the value

### getRow

public Object[] getRow() throws IOException
Description copied from interface: `RowAccess`
Returns the contents of all the cells at the current row.

Note the returned object may be reused between invocations,

Behaviour is undefined if the row index has not been set, or has been set to a value for which no table row exists; however implementations are encouraged to throw a suitable `RuntimeException` in this case.

Specified by:
  `getRow` in interface `RowAccess`
Specified by:
  `getRow` in interface `RowData`
Returns:
  array with one element for each column in the table
Throws:
  `IOException`

### close

public void close() throws IOException
Description copied from interface: `RowAccess`
Closes this reader. The effect of calling any of the other methods following a close is undefined.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `RowAccess`
Throws:
  `IOException`

### toString

public String toString()
Returns an indication of the wrapper structure of this object.

Overrides:
  `toString` in class `Object`
Returns:
  string representation