nom.tam.fits
Class AsciiTable

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

public class AsciiTable
extends Data
implements TableData

An ASCII table.


Field Summary
 
Fields inherited from class nom.tam.fits.Data
dataSize, fileOffset, input
 
Constructor Summary
AsciiTable()
          Create an empty ASCII table
AsciiTable(Header hdr)
          Create an ASCII table given a header
 
Method Summary
 int addColumn(java.lang.Object newCol)
          Add a row to the table.
 int addColumn(java.lang.Object newCol, int length)
          This version of addColumn allows the user to override the default length associated with each column type.
 int addRow(java.lang.Object[] newRow)
          Add a row to the FITS table.
 void deleteColumns(int start, int len)
          Delete columns from the table.
 void deleteRows(int start, int len)
          Delete rows from a FITS table
 void fillHeader(Header hdr)
          Fill in a header with information that points to this data.
 java.lang.Object getColumn(int col)
          Get a column of data
 java.lang.Object getData()
          Get the ASCII table information.
 java.lang.Object getElement(int row, int col)
          Get a single element as a one-d array.
 int getNCols()
          Get the number of columns in the table
 int getNRows()
          Get the number of rows in the table
 java.lang.Object[] getRow(int row)
          Get a row.
 int getRowLen()
          Get the number of bytes in a row
protected  int getTrueSize()
          Return the size of the data section
 boolean isNull(int row, int col)
          See if an element is null.
 void read(ArrayDataInput str)
          Read in an ASCII table.
 void setColumn(int col, java.lang.Object newData)
          Replace a column with new data.
 void setElement(int row, int col, java.lang.Object newData)
          Modify an element in the table
 void setNull(int row, int col, boolean flag)
          Mark (or unmark) an element as null.
 void setRow(int row, java.lang.Object[] newData)
          Modify a row in the table
 void updateAfterDelete(int oldNCol, Header hdr)
          This is called after we delete columns.
 void write(ArrayDataOutput str)
          Write the data to an output stream.
 
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

AsciiTable

public AsciiTable(Header hdr)
           throws FitsException
Create an ASCII table given a header

Throws:
FitsException

AsciiTable

public AsciiTable()
Create an empty ASCII table

Method Detail

read

public void read(ArrayDataInput str)
          throws FitsException
Read in an ASCII table. Reading is deferred if we are reading from a random access device

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

getData

public java.lang.Object getData()
                         throws FitsException
Get the ASCII table information. This will actually do the read if it had previously been deferred

Specified by:
getData in class Data
Throws:
FitsException

getColumn

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

Specified by:
getColumn in interface TableData
Throws:
FitsException

getRow

public java.lang.Object[] getRow(int row)
                          throws FitsException
Get a row. If the data has not yet been read just read this row.

Specified by:
getRow in interface TableData
Throws:
FitsException

getElement

public java.lang.Object getElement(int row,
                                   int col)
                            throws FitsException
Get a single element as a one-d array. We return String's as arrays for consistency though they could be returned as a scalar.

Specified by:
getElement in interface TableData
Throws:
FitsException

write

public void write(ArrayDataOutput str)
           throws FitsException
Write the data to an output stream.

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

setColumn

public void setColumn(int col,
                      java.lang.Object newData)
               throws FitsException
Replace a column with new data.

Specified by:
setColumn in interface TableData
Throws:
FitsException

setRow

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

Specified by:
setRow in interface TableData
Throws:
FitsException

setElement

public void setElement(int row,
                       int col,
                       java.lang.Object newData)
                throws FitsException
Modify an element in the table

Specified by:
setElement in interface TableData
Throws:
FitsException

setNull

public void setNull(int row,
                    int col,
                    boolean flag)
Mark (or unmark) an element as null. Note that if this FITS file is latter written out, a TNULL keyword needs to be defined in the corresponding header. This routine does not add an element for String columns.


isNull

public boolean isNull(int row,
                      int col)
See if an element is null.


addColumn

public int addColumn(java.lang.Object newCol)
              throws FitsException
Add a row to the table. Users should be cautious of calling this routine directly rather than the corresponding routine in AsciiTableHDU since this routine knows nothing of the FITS header modifications required.

Specified by:
addColumn in interface TableData
Throws:
FitsException

addColumn

public int addColumn(java.lang.Object newCol,
                     int length)
              throws FitsException
This version of addColumn allows the user to override the default length associated with each column type.

Throws:
FitsException

addRow

public int addRow(java.lang.Object[] newRow)
           throws FitsException
Add a row to the FITS table.

Specified by:
addRow in interface TableData
Throws:
FitsException

deleteRows

public void deleteRows(int start,
                       int len)
                throws FitsException
Delete rows from a FITS table

Specified by:
deleteRows in interface TableData
Throws:
FitsException

getTrueSize

protected int getTrueSize()
Return the size of the data section


fillHeader

public void fillHeader(Header hdr)
Fill in a header with information that points to this data.


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

getRowLen

public int getRowLen()
Get the number of bytes in a row


deleteColumns

public void deleteColumns(int start,
                          int len)
                   throws FitsException
Delete columns from the table.

Specified by:
deleteColumns in interface TableData
Throws:
FitsException

updateAfterDelete

public void updateAfterDelete(int oldNCol,
                              Header hdr)
                       throws FitsException
This is called after we delete columns. The HDU doesn't know how to update the TBCOL entries.

Specified by:
updateAfterDelete in interface TableData
Throws:
FitsException