public class BinaryTable extends AbstractTableData
Modifier and Type | Class and Description |
---|---|
protected static class |
BinaryTable.ColumnDesc
Collect all of the information we are using to describe a column into a
single object.
|
protected static class |
BinaryTable.SaveState
Opaque state to pass to ColumnTable
|
dataSize, fileOffset, input
Constructor and Description |
---|
BinaryTable()
Create a null binary table data segment.
|
BinaryTable(ColumnTable<?> tabIn)
Create a binary table from an existing ColumnTable
|
BinaryTable(Header myHeader)
Create a binary table from given header information.
|
BinaryTable(Object[] o)
Create a binary table from existing data in column order.
|
BinaryTable(Object[][] data)
Create a binary table from existing data in row order.
|
Modifier and Type | Method and Description |
---|---|
int |
addColumn(Object o)
Add a column to the table without any associated header information.
|
int |
addFlattenedColumn(Object o,
int[] dims)
Add a column where the data is already flattened.
|
int |
addRow(Object[] o)
Add a row at the end of the table.
|
protected ColumnTable<BinaryTable.SaveState> |
createColumnTable(Object[] arrCol,
int[] sizes) |
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.
|
Class<?>[] |
getBases() |
Object |
getColumn(int col)
Get a given column
|
ColumnTable<BinaryTable.SaveState> |
getData() |
int[][] |
getDimens() |
Object |
getElement(int i,
int j)
Get a particular element from the table.
|
Object[] |
getFlatColumns() |
Object |
getFlattenedColumn(int col) |
int |
getHeapOffset() |
int |
getHeapSize() |
Object[] |
getModelRow() |
int |
getNCols()
Get the number of columns in the table.
|
int |
getNRows()
Get the number of rows in the table
|
Object |
getRawElement(int i,
int j) |
Object[] |
getRow(int row)
Get a given row
|
int[] |
getSizes() |
static int[] |
getTDims(String tdims)
Parse the TDIMS value.
|
long |
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 |
readHeap(ArrayDataInput input)
Read the heap which contains the data for variable length arrays.
|
protected void |
readTrueData(ArrayDataInput i)
Read table, heap and padding
|
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.
|
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.
|
getFileOffset, getKernel, getSize, reset, rewrite, rewriteable, setFileOffset
public BinaryTable()
public BinaryTable(ColumnTable<?> tabIn)
tabIn
- the column table to create the binary table frompublic BinaryTable(Header myHeader) throws FitsException
myHeader
- A header describing what the binary table should look like.FitsException
- if the specified header is not usable for a binary tablepublic BinaryTable(Object[] o) throws FitsException
o
- array of columnsFitsException
- if the data for the columns could not be used as coulumnspublic BinaryTable(Object[][] data) throws FitsException
data
- The data used to initialize the binary table.FitsException
- if the data could not be converted to a binary tablepublic static int[] getTDims(String tdims)
tdims
- The value of the TDIMSn card.public int addColumn(Object o) throws FitsException
TableData
o
- the new column information. the newCol should be an Object[]
where type of all of the constituents is identical. The length
of data should match the other columns. Note: It is
valid for data to be a 2 or higher dimensionality primitive
array. In this case the column index is the first (in Java
speak) index of the array. E.g., if called with
int[30][20][10], the number of rows in the table should be 30
and this column will have elements which are 2-d integer
arrays with TDIM = (10,20).FitsException
- if the operation failedpublic int addFlattenedColumn(Object o, int[] dims) throws FitsException
o
- The new column data. This should be a one-dimensional
primitive array.dims
- The dimensions of one row of the column.FitsException
- if the array could not be flattenedpublic int addRow(Object[] o) throws FitsException
TableData
o
- An array of elements to be added. Each element of o should be
an array of primitives or a String.FitsException
- if the operation failedprotected ColumnTable<BinaryTable.SaveState> createColumnTable(Object[] arrCol, int[] sizes) throws TableException
TableException
public void deleteColumns(int start, int len) throws FitsException
FitsException
public void deleteRows(int row, int len) throws FitsException
row
- The 0-indexed start of the rows to be deleted.len
- The number of rows to be deleted. * @throws FitsException if
the operation failedFitsException
public void fillHeader(Header h) throws FitsException
h
- header to fill with the data from the current data objectFitsException
- if the operation failspublic Class<?>[] getBases()
public Object getColumn(int col) throws FitsException
col
- The index of the column. * @throws FitsException if the
operation failedFitsException
public ColumnTable<BinaryTable.SaveState> getData() throws FitsException
getData
in class Data
FitsException
- if the data could not be gathered .public int[][] getDimens()
public Object getElement(int i, int j) throws FitsException
i
- The row of the element.j
- The column of the element. * @throws FitsException if the
operation failedFitsException
public Object[] getFlatColumns()
public Object getFlattenedColumn(int col) throws FitsException
col
- the column to flattenFitsException
- if the column could not be flattenedpublic int getHeapOffset()
public int getHeapSize()
public Object[] getModelRow()
public int getNCols()
public int getNRows()
public Object getRawElement(int i, int j) throws FitsException
i
- The row of the element.j
- The column of the element.FitsException
- if the operation failedpublic Object[] getRow(int row) throws FitsException
row
- The index of the row to be returned.FitsException
public int[] getSizes()
public long getTrueSize()
public char[] getTypes()
public void read(ArrayDataInput i) throws FitsException
read
in interface FitsElement
read
in class Data
i
- The input data streamFitsException
- if the read was unsuccessful.protected void readHeap(ArrayDataInput input) throws FitsException
input
- stream to read from.FitsException
- if the heap could not be read from the streamprotected void readTrueData(ArrayDataInput i) throws FitsException
i
- the stream to read the data from.FitsException
- if the reading failedpublic void setColumn(int col, Object xcol) throws FitsException
col
- The index of the column to be replaced.xcol
- The new data for the columnFitsException
- Thrown if the data does not match the current column
description.public void setElement(int i, int j, Object o) throws FitsException
i
- The row of the data.j
- The column of the data.o
- The replacement data. * @throws FitsException if the operation
failedFitsException
public void setFlattenedColumn(int col, Object data) throws FitsException
col
- The index of the column to be replaced.data
- The new data array. This should be a one-d primitive array.FitsException
- Thrown if the type of length of the replacement data differs
from the original.public void setRow(int row, Object[] data) throws FitsException
row
- The index of the row to be replaced.data
- The new values for the row.FitsException
- Thrown if the new row cannot match the existing data.public void updateAfterDelete(int oldNcol, Header hdr) throws FitsException
FitsException
protected boolean validColumn(int j)
j
- The Java index (first=0) of the column to check.true
if the column is validprotected boolean validRow(int i)
i
- The Java index (first=0) of the row to check.true
if the row is validpublic void write(ArrayDataOutput os) throws FitsException
write
in interface FitsElement
write
in class Data
os
- The output stream on which to write the data.FitsException
- if the write was unsuccessful.Copyright © 1996–2016 nom-tam-fits. All rights reserved.