nom.tam.fits
Class TableHDU

java.lang.Object
  extended by nom.tam.fits.BasicHDU
      extended by nom.tam.fits.TableHDU
All Implemented Interfaces:
FitsElement
Direct Known Subclasses:
AsciiTableHDU, BinaryTableHDU

public abstract class TableHDU
extends BasicHDU

This class allows FITS binary and ASCII tables to be accessed via a common interface. Bug Fix: 3/28/01 to findColumn.


Field Summary
 
Fields inherited from class nom.tam.fits.BasicHDU
BITPIX_BYTE, BITPIX_DOUBLE, BITPIX_FLOAT, BITPIX_INT, BITPIX_LONG, BITPIX_SHORT, isPrimary, myData, myHeader
 
Method Summary
abstract  int addColumn(java.lang.Object data)
          Add a column to the table.
 int addRow(java.lang.Object[] newRow)
          Add a row to the end of the table.
abstract  java.lang.String[] columnKeyStems()
          Get the stems of the keywords that are associated with table columns.
 void deleteColumnsIndexOne(int column, int len)
          Delete a set of columns from a table.
 void deleteColumnsIndexOne(int column, int len, java.lang.String[] fields)
          Delete a set of columns from a table.
 void deleteColumnsIndexZero(int column, int len)
          Delete a set of columns from a table.
 void deleteColumnsIndexZero(int column, int len, java.lang.String[] fields)
          Delete a set of columns from a table.
 void deleteRows(int row)
          Remove all rows from the table starting at some specific index from the table.
 void deleteRows(int firstRow, int nRow)
          Remove a number of adjacent rows from the table.
 int findColumn(java.lang.String colName)
          Find the 0-based column index corresponding to a particular column name.
 java.lang.Object getColumn(int col)
          Get a specific column from the table using 0-based column indexing.
 java.lang.Object getColumn(java.lang.String colName)
          Get a specific column of the table where the column name is specified using the TTYPEn keywords in the header.
 java.lang.String getColumnFormat(int index)
          Get the FITS type of a column in the table.
 java.lang.String getColumnMeta(int index, java.lang.String type)
          Convenience method for getting column data.
 java.lang.String getColumnName(int index)
          Get the name of a column in the table.
 java.lang.Object[] getColumns()
          Get all of the columns of the table.
 java.lang.Object getElement(int row, int col)
          Get a specific element of the table using 0-based indices.
 int getNCols()
          Get the number of columns for this table
 int getNRows()
          Get the number of rows for this table
 java.lang.Object[] getRow(int row)
          Get a specific row of the table
 void setColumn(int col, java.lang.Object newCol)
          Update a column within a table.
 void setColumn(java.lang.String colName, java.lang.Object newCol)
          Update a column within a table.
 void setColumnMeta(int index, java.lang.String key, boolean value, java.lang.String comment, boolean after)
           
 void setColumnMeta(int index, java.lang.String key, double value, java.lang.String comment, boolean after)
           
 void setColumnMeta(int index, java.lang.String key, long value, java.lang.String comment, boolean after)
           
 void setColumnMeta(int index, java.lang.String key, java.lang.String value, java.lang.String comment)
           
 void setColumnMeta(int index, java.lang.String key, java.lang.String value, java.lang.String comment, boolean after)
          Specify column metadata for a given column in a way that allows all of the column metadata for a given column to be organized together.
 void setColumnName(int index, java.lang.String name, java.lang.String comment)
           
 void setCurrentColumn(int col)
          Set the cursor in the header to point after the metadata for the specified column
 void setCurrentColumn(int col, boolean after)
          Set the cursor in the header to point either before the TFORM value or after the column metadat
 void setElement(int row, int col, java.lang.Object element)
          Update a single element within the table.
 void setRow(int row, java.lang.Object[] newRow)
          Update a row within a table.
 
Methods inherited from class nom.tam.fits.BasicHDU
addValue, addValue, addValue, addValue, getAuthor, getAxes, getBitPix, getBlankValue, getBScale, getBUnit, getBZero, getCreationDate, getData, getDummyHDU, getEpoch, getEquinox, getFileOffset, getGroupCount, getHeader, getInstrument, getKernel, getMaximumValue, getMinimumValue, getObject, getObservationDate, getObserver, getOrigin, getParameterCount, getReference, getSize, getTelescope, getTrimmedString, info, isHeader, read, readData, reset, rewrite, rewriteable, skipData, skipData, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRow

public java.lang.Object[] getRow(int row)
                          throws FitsException
Get a specific row of the table

Throws:
FitsException

getColumn

public java.lang.Object getColumn(java.lang.String colName)
                           throws FitsException
Get a specific column of the table where the column name is specified using the TTYPEn keywords in the header.

Parameters:
colName - The name of the column to be extracted.
Throws:
FitsException

getColumn

public java.lang.Object getColumn(int col)
                           throws FitsException
Get a specific column from the table using 0-based column indexing.

Throws:
FitsException

getColumns

public java.lang.Object[] getColumns()
                              throws FitsException
Get all of the columns of the table.

Throws:
FitsException

getElement

public java.lang.Object getElement(int row,
                                   int col)
                            throws FitsException
Get a specific element of the table using 0-based indices.

Throws:
FitsException

setRow

public void setRow(int row,
                   java.lang.Object[] newRow)
            throws FitsException
Update a row within a table.

Throws:
FitsException

setColumn

public void setColumn(java.lang.String colName,
                      java.lang.Object newCol)
               throws FitsException
Update a column within a table. The new column should have the same format as the column being replaced.

Throws:
FitsException

setColumn

public void setColumn(int col,
                      java.lang.Object newCol)
               throws FitsException
Update a column within a table. The new column should have the same format ast the column being replaced.

Throws:
FitsException

setElement

public void setElement(int row,
                       int col,
                       java.lang.Object element)
                throws FitsException
Update a single element within the table.

Throws:
FitsException

addRow

public int addRow(java.lang.Object[] newRow)
           throws FitsException
Add a row to the end of the table. If this is the first row, then this will add appropriate columns for each of the entries.

Throws:
FitsException

findColumn

public int findColumn(java.lang.String colName)
Find the 0-based column index corresponding to a particular column name.


addColumn

public abstract int addColumn(java.lang.Object data)
                       throws FitsException
Add a column to the table.

Throws:
FitsException

getNCols

public int getNCols()
Get the number of columns for this table

Returns:
The number of columns in the table.

getNRows

public int getNRows()
Get the number of rows for this table

Returns:
The number of rows in the table.

getColumnName

public java.lang.String getColumnName(int index)
Get the name of a column in the table.

Parameters:
index - The 0-based column index.
Returns:
The column name.
Throws:
FitsException - if an invalid index was requested.

setColumnName

public void setColumnName(int index,
                          java.lang.String name,
                          java.lang.String comment)
                   throws FitsException
Throws:
FitsException

setColumnMeta

public void setColumnMeta(int index,
                          java.lang.String key,
                          java.lang.String value,
                          java.lang.String comment,
                          boolean after)
                   throws FitsException
Specify column metadata for a given column in a way that allows all of the column metadata for a given column to be organized together.

Parameters:
index - The 0-based index of the column
key - The column key. I.e., the keyword will be key+(index+1)
value - The value to be placed in the header.
comment - The comment for the header
after - Should the header card be after the current column metadata block (true), or immediately before the TFORM card (false).
Throws:
FitsException

getColumnMeta

public java.lang.String getColumnMeta(int index,
                                      java.lang.String type)
Convenience method for getting column data. Note that this works only for metadata that returns a string value. This is equivalent to getStringValue(type+index);


setColumnMeta

public void setColumnMeta(int index,
                          java.lang.String key,
                          java.lang.String value,
                          java.lang.String comment)
                   throws FitsException
Throws:
FitsException

setColumnMeta

public void setColumnMeta(int index,
                          java.lang.String key,
                          long value,
                          java.lang.String comment,
                          boolean after)
                   throws FitsException
Throws:
FitsException

setColumnMeta

public void setColumnMeta(int index,
                          java.lang.String key,
                          double value,
                          java.lang.String comment,
                          boolean after)
                   throws FitsException
Throws:
FitsException

setColumnMeta

public void setColumnMeta(int index,
                          java.lang.String key,
                          boolean value,
                          java.lang.String comment,
                          boolean after)
                   throws FitsException
Throws:
FitsException

getColumnFormat

public java.lang.String getColumnFormat(int index)
                                 throws FitsException
Get the FITS type of a column in the table.

Parameters:
index - The 0-based index of the column.
Returns:
The FITS type.
Throws:
FitsException - if an invalid index was requested.

setCurrentColumn

public void setCurrentColumn(int col)
Set the cursor in the header to point after the metadata for the specified column

Parameters:
col - The 0-based index of the column

setCurrentColumn

public void setCurrentColumn(int col,
                             boolean after)
Set the cursor in the header to point either before the TFORM value or after the column metadat

Parameters:
col - The 0-based index of the column
after - True if the cursor should be placed after the existing column metadata or false if the cursor is to be placed before the TFORM value. If no corresponding TFORM is found, the cursoe will be placed at the end of current header.

deleteRows

public void deleteRows(int row)
                throws FitsException
Remove all rows from the table starting at some specific index from the table. Inspired by a routine by R. Mathar but re-implemented using the DataTable and changes to AsciiTable so that it can be done easily for both Binary and ASCII tables.

Parameters:
row - the (0-based) index of the first row to be deleted.
Throws:
FitsExcpetion - if an error occurs.
FitsException

deleteRows

public void deleteRows(int firstRow,
                       int nRow)
                throws FitsException
Remove a number of adjacent rows from the table. This routine was inspired by code by R.Mathar but re-implemented using changes in the ColumnTable class abd AsciiTable so that we can do it for all FITS tables.

Parameters:
firstRow - the (0-based) index of the first row to be deleted. This is zero-based indexing: 0<=firstrow< number of rows.
nRow - the total number of rows to be deleted.
Throws:
FitsException - If an error occurs in the deletion.

deleteColumnsIndexOne

public void deleteColumnsIndexOne(int column,
                                  int len)
                           throws FitsException
Delete a set of columns from a table.

Throws:
FitsException

deleteColumnsIndexZero

public void deleteColumnsIndexZero(int column,
                                   int len)
                            throws FitsException
Delete a set of columns from a table.

Throws:
FitsException

deleteColumnsIndexOne

public void deleteColumnsIndexOne(int column,
                                  int len,
                                  java.lang.String[] fields)
                           throws FitsException
Delete a set of columns from a table.

Parameters:
column - The one-indexed start column.
len - The number of columns to delete.
fields - Stems for the header fields to be removed for the table.
Throws:
FitsException

deleteColumnsIndexZero

public void deleteColumnsIndexZero(int column,
                                   int len,
                                   java.lang.String[] fields)
                            throws FitsException
Delete a set of columns from a table.

Parameters:
column - The zero-indexed start column.
len - The number of columns to delete.
fields - Stems for the header fields to be removed for the table.
Throws:
FitsException

columnKeyStems

public abstract java.lang.String[] columnKeyStems()
Get the stems of the keywords that are associated with table columns. Users can supplement this with their own and call the appropriate deleteColumns fields.