Package uk.ac.starlink.fits

# Class BintableStarTable

java.lang.Object
uk.ac.starlink.table.AbstractStarTable
uk.ac.starlink.fits.BintableStarTable

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `uk.ac.starlink.table.StarTable`

public abstract class BintableStarTable extends uk.ac.starlink.table.AbstractStarTable
An implementation of the StarTable interface which uses a FITS BINTABLE extension.

The implementation varies according to whether random or sequential-only access is provided by the underlying data access. A factory method is provided to create an appropriate instance.

Some instances of this class hang on to file descriptors. If you are in danger of running out of that resource before instances are garbage collected, you can call the `AbstractStarTable.close()` method to release them. Attempting to read data following such a call may result in an exception.

Limited support is provided for the HEALPix-FITS convention; the relevant `HealpixTableInfo` table parameters are added, but any BAD_DATA keyword value is ignored, and the 1024-element array-valued column variant of the format is not understood.

Author:
  Mark Taylor

## Field Summary

Fields
Modifier and Type
Field
Description
`static final uk.ac.starlink.table.ValueInfo`
`LONGOFF_INFO`
Column aux metadata key for stringified longs offset.
`static final uk.ac.starlink.table.ValueInfo`
`TBCOL_INFO`
Column aux metadata key for TBCOLn cards.
`static final uk.ac.starlink.table.ValueInfo`
`TDISP_INFO`
Column aux metadata key for TDISPn cards.
`static final uk.ac.starlink.table.ValueInfo`
`TFORM_INFO`
Column aux metadata key for TFORMn cards.
`static final uk.ac.starlink.table.ValueInfo`
`TNULL_INFO`
Column aux metadata key for TNULLn cards.
`static final uk.ac.starlink.table.ValueInfo`
`TSCAL_INFO`
Column aux metadata key for TSCALn cards.
`static final uk.ac.starlink.table.ValueInfo`
`TZERO_INFO`
Column aux metadata key for TZEROn cards.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`BintableStarTable(FitsHeader hdr, boolean isRandom, WideFits wide)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static BintableStarTable`
`createTable(FitsHeader hdr, InputFactory inputFact, WideFits wide)`
Returns an instance of this class given a data access instance.
`List<uk.ac.starlink.table.ValueInfo>`
`getColumnAuxDataInfos()`
`int`
`getColumnCount()`
`uk.ac.starlink.table.ColumnInfo`
`getColumnInfo(int icol)`
`protected long[]`
`getColumnOffsets()`
Returns the array of byte offsets from the start of the row at which each column starts.
`long`
`getRowCount()`
`protected long`
`getRowLength()`
Returns the number of bytes occupied in the data stream by a single row of the table.
`protected Object`
`readCell(BasicInput stream, int icol)`
Reads a cell from a given column from the current position in a stream.
`protected Object[]`
`readRow(BasicInput stream)`
Reads a whole row of the table from the current position in a stream, returning a new Object[] array.
`static void`
`streamStarTable(FitsHeader hdr, BasicInput input, WideFits wide, uk.ac.starlink.table.TableSink sink)`
Reads a BINTABLE extension from a stream and writes the result to a table sink.

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

`checkedLongToInt, close, getCell, getName, getParameters, getRow, getRowAccess, getRowSequence, getRowSplittable, getURL, isRandom, 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`

## Field Details

### TNULL_INFO

public static final uk.ac.starlink.table.ValueInfo TNULL_INFO
Column aux metadata key for TNULLn cards.

### TSCAL_INFO

public static final uk.ac.starlink.table.ValueInfo TSCAL_INFO
Column aux metadata key for TSCALn cards.

### TZERO_INFO

public static final uk.ac.starlink.table.ValueInfo TZERO_INFO
Column aux metadata key for TZEROn cards.

### TDISP_INFO

public static final uk.ac.starlink.table.ValueInfo TDISP_INFO
Column aux metadata key for TDISPn cards.

### TBCOL_INFO

public static final uk.ac.starlink.table.ValueInfo TBCOL_INFO
Column aux metadata key for TBCOLn cards.

### TFORM_INFO

public static final uk.ac.starlink.table.ValueInfo TFORM_INFO
Column aux metadata key for TFORMn cards.

### LONGOFF_INFO

public static final uk.ac.starlink.table.ValueInfo LONGOFF_INFO
Column aux metadata key for stringified longs offset.

## Constructor Details

### BintableStarTable

protected BintableStarTable(FitsHeader hdr, boolean isRandom, WideFits wide) throws IOException
Constructor.

Parameters:
  `hdr` - FITS header cards
  `isRandom` - true if the data access will be random-access, false for sequential-only
  `wide` - convention for representing extended columns; use null to avoid use of extended columns
Throws:
  `IOException`

## Method Details

### getRowCount

public long getRowCount()

Specified by:
  `getRowCount` in interface `uk.ac.starlink.table.StarTable`
Specified by:
  `getRowCount` in class `uk.ac.starlink.table.AbstractStarTable`

### getColumnCount

public int getColumnCount()

Specified by:
  `getColumnCount` in interface `uk.ac.starlink.table.StarTable`
Specified by:
  `getColumnCount` in class `uk.ac.starlink.table.AbstractStarTable`

### getColumnInfo

public uk.ac.starlink.table.ColumnInfo getColumnInfo(int icol)

Specified by:
  `getColumnInfo` in interface `uk.ac.starlink.table.StarTable`
Specified by:
  `getColumnInfo` in class `uk.ac.starlink.table.AbstractStarTable`

### getColumnAuxDataInfos

public List<uk.ac.starlink.table.ValueInfo> getColumnAuxDataInfos()

Specified by:
  `getColumnAuxDataInfos` in interface `uk.ac.starlink.table.StarTable`
Overrides:
  `getColumnAuxDataInfos` in class `uk.ac.starlink.table.AbstractStarTable`

### readCell

protected Object readCell(BasicInput stream, int icol) throws IOException
Reads a cell from a given column from the current position in a stream.

Parameters:
  `stream` - a stream containing the byte data, positioned to the right place
  `icol` - the column index corresponding to the cell to be read
Throws:
  `IOException`

### readRow

protected Object[] readRow(BasicInput stream) throws IOException
Reads a whole row of the table from the current position in a stream, returning a new Object[] array.

Parameters:
  `stream` - a stream containing the byte data, positioned to the right place
Returns:
  `ncol`-element array of cells for this row
Throws:
  `IOException`

### getRowLength

protected long getRowLength()
Returns the number of bytes occupied in the data stream by a single row of the table. This is equal to the sum of the column offsets array.

Returns:
  row length in bytes

### getColumnOffsets

protected long[] getColumnOffsets()
Returns the array of byte offsets from the start of the row at which each column starts.

Returns:
  `ncol`-element array of byte offsets

### createTable

public static BintableStarTable createTable(FitsHeader hdr, InputFactory inputFact, WideFits wide) throws IOException
Returns an instance of this class given a data access instance.

Parameters:
  `hdr` - FITS header cards
  `inputFact` - factory for access to the data part of the HDU representing a FITS BINTABLE extension
  `wide` - convention for representing extended columns; use null to avoid use of extended columns
Returns:
  StarTable instance; it will be random-access according to whether the input factory is
Throws:
  `IOException`

### streamStarTable

public static void streamStarTable(FitsHeader hdr, BasicInput input, WideFits wide, uk.ac.starlink.table.TableSink sink) throws IOException
Reads a BINTABLE extension from a stream and writes the result to a table sink.

Parameters:
  `hdr` - FITS header object describing the BINTABLE extension
  `input` - input stream positioned at the start of the data part of the BINTABLE extension
  `wide` - convention for representing extended columns; use null to avoid use of extended columns
  `sink` - destination for the table
Throws:
  `IOException`