## nom.tam.fits
Class BinaryTable

    java.lang.Object
      nom.tam.fits.Data
          nom.tam.fits.BinaryTable

public class BinaryTable
extends Data

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

Field Summary
`(package private) Vector` `columns` The columns of data in the binary table.
`(package private) int[][]` `dimens` The dimensions of each column.
`(package private) byte[]` `hashArea` This is the area in which variable length column data lives.
`(package private) int` `hashPtr` Pointer to the next available byte in the hashArea.
`(package private) Object[]` `modelRow` An example of the structure of a row
`(package private) int[]` `sizes` The sizes of each column (in number of entries per row)
`(package private) ColumnTable` `table` Where the data is actually stored.

Fields inherited from class nom.tam.fits.Data
`dataArray`

Constructor Summary
`BinaryTable()` Create a null binary table data segment.
`BinaryTable(Header myHeader)` Create a binary table from given header information.
`BinaryTable(Object[][] data)` Create a binary table from existing data in row order.

Method Summary
`void` `addColumn(Object[] o)` Add a column to the end of a table.
`void` `addFlattenedColumn(Object o, int[] dims)` Add a column where the data is already flattened.
`void` `addRow(Object[] o)` Add a row at the end of the table.
`Column` `addVarData(Object[] data)` Add a variable length column to the data.
`protected void` `expandHashArea(int need)` This routine makes sure the hash area is large enough to fill a given request.
`Class[]` `getBases()`
`Object[]` `getColumn(int col)` Get a given column
`int[][]` `getDimens()`
`Object` `getElement(int i, int j)` Get a particular element from the table.
`Object` `getFlattenedColumn(int col)` Get a column in flattened format.
`int` `getHeapSize()`
`int` `getNcol()` Get the number of columns in the table.
`int` `getNrow()` Get the number of rows in the table
`Object[]` `getRow(int row)` Get a given row
`int[]` `getSizes()`
`int` `getTrueSize()` Get the size of the data in the HDU sans padding.
`char[]` `getTypes()`
`Object` `getVarData(int col, Class baseClass, boolean complex)` Get the data from a variable length column as a two-d primitive array.
`void` `read(BufferedDataInputStream i)` Read a data array into the current object and if needed position to the beginning of the next FITS block.
`protected void` `readTrueData(BufferedDataInputStream i)` Read in the actual data portion.
`void` `setColumn(int col, Object[] xcol)` Replace a column in the table.
`void` `setElement(int i, int j, Object o)` Replace a single element within the table.
`void` `setFlattenedColumn(int col, Object data)` Set a column with the data already flattened.
`void` `setRow(int row, Object[] data)` Replace a row in the table.
`protected int` `useModelRow(Object[] model, int nrow)` Use an example row to determine what the table should look like.
`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(BufferedDataOutputStream os)` Write the data -- including any buffering needed
`protected void` `writeTrueData(BufferedDataOutputStream o)` Write the data including any hash data.

Methods inherited from class nom.tam.fits.Data
`getData, getPaddedSize, getPadding`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### hashArea

    byte[] hashArea

  This is the area in which variable length column data lives.

### hashPtr

    int hashPtr

  Pointer to the next available byte in the hashArea.

### columns

    Vector columns

  The columns of data in the binary table.

### sizes

    int[] sizes

  The sizes of each column (in number of entries per row)

### dimens

    int[][] dimens

  The dimensions of each column.

### modelRow

    Object[] modelRow

  An example of the structure of a row

### table

    ColumnTable table

  Where the data is actually stored.

Constructor Detail

### BinaryTable

    public BinaryTable()
                throws FitsException

  Create a null binary table data segment.

### BinaryTable

    public BinaryTable(Header myHeader)
                throws FitsException

  Create a binary table from given header information.

### BinaryTable

    public BinaryTable(Object[][] data)
                throws FitsException

  Create a binary table from existing data in row order.

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

Method Detail

### useModelRow

    protected int useModelRow(Object[] model,
                              int nrow)

  Use an example row to determine what the table should look like.

  Parameters:
    `model` - An example of a row. Each element of model should have the structure of the corresponding element of the row.
    `nrow` - The number of rows in the table.
  Returns:
    The size of the table in bytes.

### getRow

    public Object[] getRow(int row)
                    throws FitsException

  Get a given row

  Parameters:
    `row` - The index of the row to be returned.
  Returns:
    A row of data.
  Throws:
    `FitsException`

### setRow

    public void setRow(int row,
                       Object[] data)
                throws FitsException

  Replace a row in the table.

  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,
                          Object[] xcol)
                   throws FitsException

  Replace a column in the table.

  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,
                                   Object data)
                            throws FitsException

  Set a column with the data already 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 Object[] getColumn(int col)
                       throws FitsException

  Get a given column

  Parameters:
    `col` - The index of the column.
  Throws:
    `FitsException`

### getFlattenedColumn

    public 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 Object getElement(int i,
                             int j)
                      throws FitsException

  Get a particular element from the table.

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

### addRow

    public void addRow(Object[] o)
                throws FitsException

  Add a row at the end of the table.

  Parameters:
    `o` - An array of objects instantiating the data. These should have the same structure as any existing rows.
  Throws:
    `FitsException`

### addColumn

    public void addColumn(Object[] o)
                   throws FitsException

  Add a column to the end of a table.

  Parameters:
    `o` - An array of identically structured objects with the same number of elements as other columns in the table.
  Throws:
    `FitsException`

### addFlattenedColumn

    public void addFlattenedColumn(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.
  Throws:
    `FitsException`

### getNrow

    public int getNrow()

  Get the number of rows in the table

### getNcol

    public int getNcol()

  Get the number of columns in the table.

### 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,
                           Object o)
                    throws FitsException

  Replace a single element within the table.

  Parameters:
    `i` - The row of the data.
    `j` - The column of the data.
    `o` - The replacement data.
  Throws:
    `FitsException`

### expandHashArea

    protected void expandHashArea(int need)

  This routine makes sure the hash area is large enough to fill a given request. If not it reallocates the hash area, and copies the old data into the new area.

  Parameters:
    `need` - The number of bytes needed for the current hash area request.

### writeTrueData

    protected void writeTrueData(BufferedDataOutputStream o)
                          throws FitsException

  Write the data including any hash data.

  Overrides:
    `writeTrueData` in class `Data`
  Parameters:
    `o` - The output stream.
  Throws:
    `FitsException`

### read

    public void read(BufferedDataInputStream i)
              throws FitsException

  Description copied from class: `Data`
  Read a data array into the current object and if needed position to the beginning of the next FITS block.

  Overrides:
    `read` in class `Data`
  Parameters:
    `i` - The input data stream
  Throws:
    `FitsException`

### readTrueData

    protected void readTrueData(BufferedDataInputStream i)
                         throws FitsException

  Description copied from class: `Data`
  Read in the actual data portion. This method needs to be overriden for ASCII tables and for binary tables with variable length data.

  Overrides:
    `readTrueData` in class `Data`
  Parameters:
    `i` - The input stream.
  Throws:
    `FitsException`

### getTrueSize

    public int getTrueSize()

  Get the size of the data in the HDU sans padding.

  Overrides:
    `getTrueSize` in class `Data`

### addVarData

    public Column addVarData(Object[] data)
                      throws FitsException

  Add a variable length column to the data.

  Parameters:
    `data` - The data comprising the variable length column. This should be a two dimensional primitive array (3D for complex data). Note that it is declared as a one dimensional object array to make access convenient. Any 2-d array can be cast to a 1-d array of objects.
  Returns:
    A column describing the variable format data. This column can then be added to the table using other functions.
  Throws:
    `FitsException`

### getVarData

    public Object getVarData(int col,
                             Class baseClass,
                             boolean complex)
                      throws FitsException

  Get the data from a variable length column as a two-d primitive array.

  Parameters:
    `col` - The index of the column to be returned.
    `baseClass` - The base class of the array. It should be one of the primitive types, e.g, Integer.TYPE.
  Throws:
    `FitsException`

### write

    public void write(BufferedDataOutputStream os)
               throws FitsException

  Description copied from class: `Data`
  Write the data -- including any buffering needed

  Overrides:
    `write` in class `Data`
  Parameters:
    `os` - The output stream on which to write the data.
  Throws:
    `FitsException`

### getHeapSize

    public int getHeapSize()

### getDimens

    public int[][] getDimens()

### getBases

    public Class[] getBases()

### getTypes

    public char[] getTypes()

### getSizes

    public int[] getSizes()