uk.ac.starlink.fits
Class BintableStarTable

java.lang.Object
  |
  +--uk.ac.starlink.table.AbstractStarTable
        |
        +--uk.ac.starlink.fits.BintableStarTable
All Implemented Interfaces:
StarTable

public abstract class BintableStarTable
extends AbstractStarTable

An implementation of the StarTable interface which uses a FITS BINTABLE extension. Reading is done into the random access data (possibly a mapped file); the nom.tam.fits classes are not used.

It is safe to read cells from different threads.


Method Summary
 List getColumnAuxDataInfos()
          Goes through the table columns (ColumnInfo objects) and picks out all the AuxData items which exist, generalising where necessary and returning a union of them in alphabetical order by name.
 int getColumnCount()
          Returns the number of columns in this table.
 ColumnInfo getColumnInfo(int icol)
          Returns the object describing the data in a given column.
protected  int[] getColumnOffsets()
          Returns the array of byte offsets from the start of the row at which each column starts.
 long getRowCount()
          Returns the number of rows in this table, if known.
protected  int getRowLength()
          Returns the number of bytes occupied in the data stream by a single row of the table.
static StarTable makeRandomStarTable(Header hdr, RandomAccess rstream)
          Constructs a StarTable from a given random access stream.
 Object readCell(DataInput stream, int icol)
          Reads a cell from a given column from the current position in a stream.
 Object[] readRow(DataInput stream)
          Reads a whole row of the table from the current position in a stream, returning a new Object[] array.
 void readRow(DataInput stream, Object[] row)
          Reads a whole row of the table into an existing array.
static void streamStarTable(Header hdr, DataInput stream, 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, getCell, getName, getParameterByName, getParameters, getRow, getRowSequence, getURL, isRandom, setName, setParameter, setParameters, setURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeRandomStarTable

public static StarTable makeRandomStarTable(Header hdr,
                                            RandomAccess rstream)
                                     throws FitsException
Constructs a StarTable from a given random access stream.

Parameters:
hdr - FITS header descrbing the HDU
rstream - data stream positioned at the start of the data section of the HDU
FitsException

streamStarTable

public static void streamStarTable(Header hdr,
                                   DataInput stream,
                                   TableSink sink)
                            throws FitsException,
                                   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
stream - input stream positioned at the start of the data part of the BINTABLE extension
sink - destination for the table
FitsException
IOException

getRowCount

public long getRowCount()
Description copied from interface: StarTable
Returns the number of rows in this table, if known. If the number of rows cannot be (easily) determined, a value of -1 will be returned.

Specified by:
getRowCount in interface StarTable
Specified by:
getRowCount in class AbstractStarTable
Returns:
the number of rows, or -1

getColumnCount

public int getColumnCount()
Description copied from interface: StarTable
Returns the number of columns in this table.

Specified by:
getColumnCount in interface StarTable
Specified by:
getColumnCount in class AbstractStarTable
Returns:
the number of columns

getColumnInfo

public ColumnInfo getColumnInfo(int icol)
Description copied from interface: StarTable
Returns the object describing the data in a given column.

Specified by:
getColumnInfo in interface StarTable
Specified by:
getColumnInfo in class AbstractStarTable
Parameters:
icol - the column for which header information is required
Returns:
a ValueInfo object for column icol

getColumnAuxDataInfos

public List getColumnAuxDataInfos()
Description copied from class: AbstractStarTable
Goes through the table columns (ColumnInfo objects) and picks out all the AuxData items which exist, generalising where necessary and returning a union of them in alphabetical order by name. Subclasses should override this if they can do better, for instance providing an order for the keys.

Specified by:
getColumnAuxDataInfos in interface StarTable
Overrides:
getColumnAuxDataInfos in class AbstractStarTable
Returns:
a list of all the auxiliary metadata ValueInfo items which in fact crop up in column metadata

readCell

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

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

readRow

public Object[] readRow(DataInput 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
IOException

readRow

public void readRow(DataInput stream,
                    Object[] row)
             throws IOException
Reads a whole row of the table into an existing array.

Parameters:
stream - a stream containing the byte data, positioned to the right place
row - ncol-element array, filled with row data on completion
IOException

getRowLength

protected int 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 int[] 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

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.