nom.tam.fits
Class BinaryTable

java.lang.Object
  extended by nom.tam.fits.Data
      extended by nom.tam.fits.BinaryTable
All Implemented Interfaces:
FitsElement, TableData

public class BinaryTable
extends Data
implements TableData

This class defines the methods for accessing FITS binary table data.


Field Summary
 
Fields inherited from class nom.tam.fits.Data
dataSize, fileOffset, input
 
Constructor Summary
BinaryTable()
          Create a null binary table data segment.
BinaryTable(ColumnTable tab)
          Create a binary table from an existing ColumnTable
BinaryTable(Header myHeader)
          Create a binary table from given header information.
BinaryTable(java.lang.Object[] o)
          Create a binary table from existing data in column order.
BinaryTable(java.lang.Object[][] data)
          Create a binary table from existing data in row order.
 
Method Summary
 int addColumn(java.lang.Object o)
          Add a column to the end of a table.
 int addFlattenedColumn(java.lang.Object o, int[] dims)
          Add a column where the data is already flattened.
 int addRow(java.lang.Object[] o)
          Add a row at the end of the table.
 void deleteColumns(int start, int len)
          Delete a set of columns.
 void deleteRows(int row, int len)
          Delete rows from a table.
 void fillHeader(Header h)
          Update a FITS header to reflect the current state of the data.
 java.lang.Class[] getBases()
           
 java.lang.Object getColumn(int col)
          Get a given column
 java.lang.Object getData()
          Return the data array object.
 int[][] getDimens()
           
 java.lang.Object getElement(int i, int j)
          Get a particular element from the table.
 java.lang.Object[] getFlatColumns()
           
 java.lang.Object getFlattenedColumn(int col)
          Get a column in flattened format.
 int getHeapOffset()
          What is the offset to the heap
 int getHeapSize()
          What is the size of the heap -- including the offset from the end of the table data.
 int getNCols()
          Get the number of columns in the table.
 int getNRows()
          Get the number of rows in the table
 java.lang.Object getRawElement(int i, int j)
          Get a particular element from the table but do no processing of this element (e.g., dimension conversion or extraction of variable length array elements/)
 java.lang.Object[] getRow(int row)
          Get a given row
 int[] getSizes()
           
static int[] getTDims(java.lang.String tdims)
          Parse the TDIMS value.
 int getTrueSize()
          Get the size of the data in the HDU sans padding.
 char[] getTypes()
           
 void read(ArrayDataInput i)
          Read the data -- or defer reading on random access
protected  void readTrueData(ArrayDataInput i)
          Read table, heap and padding
 void setColumn(int col, java.lang.Object xcol)
          Replace a column in the table.
 void setElement(int i, int j, java.lang.Object o)
          Replace a single element within the table.
 void setFlattenedColumn(int col, java.lang.Object data)
          Set a column with the data aleady flattened.
 void setRow(int row, java.lang.Object[] data)
          Replace a row in the table.
 void updateAfterDelete(int oldNcol, Header hdr)
          Update the header after a deletion.
protected  boolean validColumn(int j)
          Check if the column number is valid.
protected  boolean validRow(int i)
          Check to see if this is a valid row.
 void write(ArrayDataOutput os)
          Write the table, heap and padding
 
Methods inherited from class nom.tam.fits.Data
getFileOffset, getKernel, getSize, rewrite, rewriteable, setFileOffset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryTable

public BinaryTable()
            throws FitsException
Create a null binary table data segment.

Throws:
FitsException

BinaryTable

public BinaryTable(Header myHeader)
            throws FitsException
Create a binary table from given header information.

Parameters:
header - A header describing what the binary table should look like.
Throws:
FitsException

BinaryTable

public BinaryTable(java.lang.Object[][] data)
            throws FitsException
Create a binary table from existing data in row order.

Parameters:
data - The data used to initialize the binary table.
Throws:
FitsException

BinaryTable

public BinaryTable(java.lang.Object[] o)
            throws FitsException
Create a binary table from existing data in column order.

Throws:
FitsException

BinaryTable

public BinaryTable(ColumnTable tab)
Create a binary table from an existing ColumnTable

Method Detail

getTDims

public static int[] getTDims(java.lang.String tdims)
Parse the TDIMS value. If the TDIMS value cannot be deciphered a one-d array with the size given in arrsiz is returned.

Parameters:
tdims - The value of the TDIMSn card.
arraySize - The size field found on the TFORMn card.
Returns:
An int array of the desired dimensions. Note that the order of the tdims is the inverse of the order in the TDIMS key.

fillHeader

public void fillHeader(Header h)
                throws FitsException
Update a FITS header to reflect the current state of the data.

Throws:
FitsException

getRow

public java.lang.Object[] getRow(int row)
                          throws FitsException
Get a given row

Specified by:
getRow in interface TableData
Parameters:
row - The index of the row to be returned.
Returns:
A row of data.
Throws:
FitsException

setRow

public void setRow(int row,
                   java.lang.Object[] data)
            throws FitsException
Replace a row in the table.

Specified by:
setRow in interface TableData
Parameters:
row - The index of the row to be replaced.
data - The new values for the row.
Throws:
FitsException - Thrown if the new row cannot match the existing data.

setColumn

public void setColumn(int col,
                      java.lang.Object xcol)
               throws FitsException
Replace a column in the table.

Specified by:
setColumn in interface TableData
Parameters:
col - The index of the column to be replaced.
xcol - The new data for the column
Throws:
FitsException - Thrown if the data does not match the current column description.

setFlattenedColumn

public void setFlattenedColumn(int col,
                               java.lang.Object data)
                        throws FitsException
Set a column with the data aleady flattened.

Parameters:
col - The index of the column to be replaced.
data - The new data array. This should be a one-d primitive array.
Throws:
FitsException - Thrown if the type of length of the replacement data differs from the original.

getColumn

public java.lang.Object getColumn(int col)
                           throws FitsException
Get a given column

Specified by:
getColumn in interface TableData
Parameters:
col - The index of the column.
Throws:
FitsException

getFlattenedColumn

public java.lang.Object getFlattenedColumn(int col)
                                    throws FitsException
Get a column in flattened format. For large tables getting a column in standard format can be inefficient because a separate object is needed for each row. Leaving the data in flattened format means that only a single object is created.

Parameters:
col -
Throws:
FitsException

getElement

public java.lang.Object getElement(int i,
                                   int j)
                            throws FitsException
Get a particular element from the table.

Specified by:
getElement in interface TableData
Parameters:
i - The row of the element.
j - The column of the element.
Throws:
FitsException

getRawElement

public java.lang.Object getRawElement(int i,
                                      int j)
                               throws FitsException
Get a particular element from the table but do no processing of this element (e.g., dimension conversion or extraction of variable length array elements/)

Parameters:
i - The row of the element.
j - The column of the element.
Throws:
FitsException

addRow

public int addRow(java.lang.Object[] o)
           throws FitsException
Add a row at the end of the table. Given the way the table is structured this will normally not be very efficient.

Specified by:
addRow in interface TableData
Parameters:
o - An array of elements to be added. Each element of o should be an array of primitives or a String.
Throws:
FitsException

deleteRows

public void deleteRows(int row,
                       int len)
                throws FitsException
Delete rows from a table.

Specified by:
deleteRows in interface TableData
Parameters:
row - The 0-indexed start of the rows to be deleted.
len - The number of rows to be deleted.
Throws:
FitsException

addColumn

public int addColumn(java.lang.Object o)
              throws FitsException
Add a column to the end of a table.

Specified by:
addColumn in interface TableData
Parameters:
o - An array of identically structured objects with the same number of elements as other columns in the table.
Throws:
FitsException

addFlattenedColumn

public int addFlattenedColumn(java.lang.Object o,
                              int[] dims)
                       throws FitsException
Add a column where the data is already flattened.

Parameters:
o - The new column data. This should be a one-dimensional primitive array.
dims - The dimensions of one row of the column.
Throws:
FitsException

getNRows

public int getNRows()
Get the number of rows in the table

Specified by:
getNRows in interface TableData

getNCols

public int getNCols()
Get the number of columns in the table.

Specified by:
getNCols in interface TableData

validRow

protected boolean validRow(int i)
Check to see if this is a valid row.

Parameters:
i - The Java index (first=0) of the row to check.

validColumn

protected boolean validColumn(int j)
Check if the column number is valid.

Parameters:
j - The Java index (first=0) of the column to check.

setElement

public void setElement(int i,
                       int j,
                       java.lang.Object o)
                throws FitsException
Replace a single element within the table.

Specified by:
setElement in interface TableData
Parameters:
i - The row of the data.
j - The column of the data.
o - The replacement data.
Throws:
FitsException

read

public void read(ArrayDataInput i)
          throws FitsException
Read the data -- or defer reading on random access

Specified by:
read in interface FitsElement
Specified by:
read in class Data
Parameters:
i - The input data stream
Throws:
FitsException

readTrueData

protected void readTrueData(ArrayDataInput i)
                     throws FitsException
Read table, heap and padding

Throws:
FitsException

getTrueSize

public int getTrueSize()
Get the size of the data in the HDU sans padding.


write

public void write(ArrayDataOutput os)
           throws FitsException
Write the table, heap and padding

Specified by:
write in interface FitsElement
Specified by:
write in class Data
Parameters:
os - The output stream on which to write the data.
Throws:
FitsException

getData

public java.lang.Object getData()
                         throws FitsException
Description copied from class: Data
Return the data array object.

Specified by:
getData in class Data
Throws:
FitsException

getDimens

public int[][] getDimens()

getBases

public java.lang.Class[] getBases()

getTypes

public char[] getTypes()

getFlatColumns

public java.lang.Object[] getFlatColumns()

getSizes

public int[] getSizes()

getHeapSize

public int getHeapSize()
What is the size of the heap -- including the offset from the end of the table data.


getHeapOffset

public int getHeapOffset()
What is the offset to the heap


deleteColumns

public void deleteColumns(int start,
                          int len)
                   throws FitsException
Delete a set of columns. Note that this does not fix the header, so users should normally call the routine in TableHDU.

Specified by:
deleteColumns in interface TableData
Throws:
FitsException

updateAfterDelete

public void updateAfterDelete(int oldNcol,
                              Header hdr)
                       throws FitsException
Update the header after a deletion.

Specified by:
updateAfterDelete in interface TableData
Throws:
FitsException