# Class WrapperDataStoreFactory

java.lang.Object
uk.ac.starlink.ttools.plot2.data.WrapperDataStoreFactory

All Implemented Interfaces:
  `DataStoreFactory`

public abstract class WrapperDataStoreFactory extends Object implements DataStoreFactory
DataStoreFactory implementation which allows decoration of the tables used to obtain the data, by providing a custom wrapper for their RowSequence objects.

The implementation is fairly ticklish, since various of the objects that we want to wrap have not only to behave (mostly) like the unwrapped objects to which they delegate, but also to be equal to them (`Equality`). It works by wrapping each DataSpec in a custom wrapper object any time it is presented to the underlying base DataStoreFactory, either by the methods of this DataStoreFactory implementation or by methods invoked on DataStore objects it dispenses. These wrapper objects obey the equality constraints.

Since:
  8 Nov 2013
Author:
  Mark Taylor

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`WrapperDataStoreFactory(DataStoreFactory baseFact)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected abstract uk.ac.starlink.table.RowAccess`
`createRowAccess(uk.ac.starlink.table.StarTable table)`
Creates a row access from a given table.
`protected abstract uk.ac.starlink.table.RowSequence`
`createRowSequence(uk.ac.starlink.table.StarTable table)`
Creates a row sequence from a given table.
`protected abstract uk.ac.starlink.table.RowSplittable`
`createRowSplittable(uk.ac.starlink.table.StarTable table)`
Creates a row splittable from a given table.
`DataStore`
`readDataStore(DataSpec[] dataSpecs, DataStore prevStore)`
Generates a DataStore capable of supplying the data for a given list of DataSpec objects.

### Methods inherited from class Object

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

## Constructor Details

### WrapperDataStoreFactory

protected WrapperDataStoreFactory(DataStoreFactory baseFact)
Constructor.

Parameters:
  `baseFact` - base implementation that actually acquires the data

## Method Details

### readDataStore

public DataStore readDataStore(DataSpec[] dataSpecs, DataStore prevStore) throws IOException, InterruptedException
Description copied from interface: `DataStoreFactory`
Generates a DataStore capable of supplying the data for a given list of DataSpec objects. The `prevStore` argument may optionally supply the result of a previous invocation of this method. The implementation may choose to make use of the internal state of such an instance for efficiency, for instance by re-using data that has already been read.

Since the bulk data is managed by the DataStore object, care should be taken about what happens to the DataStore objects supplied to and returned from this method. In particular, code both invoking and implementing this method should usually make sure not to keep a reference to the `prevStore` argument.

This method may perform the actual reading, and therefore take time. It is not intended to be invoked on the event dispatch thread.

Specified by:
  `readDataStore` in interface `DataStoreFactory`
Parameters:
  `dataSpecs` - data specifications; some elements may be null
  `prevStore` - previously obtained DataStore, or null
Returns:
  new data store
Throws:
  `IOException`
  `InterruptedException`

### createRowSequence

protected abstract uk.ac.starlink.table.RowSequence createRowSequence(uk.ac.starlink.table.StarTable table) throws IOException
Creates a row sequence from a given table.

The obvious implementation is `table.getRowSequence()`, but implementations may decorate that instance to provide useful functionality.

Parameters:
  `table` - table providing data
Returns:
  row sequence which will be used to acquire table data
Throws:
  `IOException`

### createRowAccess

protected abstract uk.ac.starlink.table.RowAccess createRowAccess(uk.ac.starlink.table.StarTable table) throws IOException
Creates a row access from a given table.

The obvious implementation is `table.getRowAccess()`, but implementations may decorate that instance to provide useful functionality.

Parameters:
  `table` - table providing data
Returns:
  row access which will be used to acquire table data
Throws:
  `IOException`

### createRowSplittable

protected abstract uk.ac.starlink.table.RowSplittable createRowSplittable(uk.ac.starlink.table.StarTable table) throws IOException
Creates a row splittable from a given table.

The obvious implementation is `table.getRowSplittable()`, but implementations may decorate that instance to provide useful functionality.

Parameters:
  `table` - table providing data
Returns:
  row splittable which will be used to acquire table data
Throws:
  `IOException`