Interface TableData
- All Known Implementing Classes:
AbstractTableData
,AsciiTable
,BinaryTable
,CompressedImageData
,CompressedTableData
Interface for accessing binary and ASCII table data.
Note, that this interface is the big sister DataTable
, with nearly identical method signstures.
But there are differences too, such as the type of argument of setting row data, and when and what excpetions are
thrown. This one also has includes additional methods for table manipulation. Overall it would have been a more
prudent design to consolidate the two interfaces but this is what we have so we stick to it. However, mabe this is
something an upcoming major release may address...
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
Add a column to the table, without updating the header of an encompassing HDU.int
Add a row at the end of the table without updating the header of an encompassing HDU.default int
addRowEntries
(Object... entries) LikeaddRow(Object[])
, but with a vararg list of row entries.void
deleteColumns
(int col, int len) Removes a set of consecutive columns from this table, without updating assocu=iated the header information for the columns that were removed.void
deleteRows
(int row, int len) Removes a set of consecutive rows from this table without updating any associated header information for an encompassing HDU.getColumn
(int col) Returns the data for a particular column in as an array of elements.getElement
(int row, int col) Returns the data element in this table.int
getNCols()
Returns the number of columns contained in this table.int
getNRows()
Returns the number of columns contained in this table.Object[]
getRow
(int row) Returns an array of elements in a particualr table row.void
Sets new data for a table column.void
setElement
(int row, int col, Object element) Sets new data element in this table.void
Sets new data for a table row.default void
setRowEntries
(int row, Object... entries) LikesetRow(int, Object[])
but with vararg list of entries.void
updateAfterDelete
(int oldNcol, Header hdr) Deprecated.It is not entirely foolproof for keeping the header in sync -- it is better to (re)wrap tables in a new HDU after column deletions, and then edit the new header as necessary to incorporate custom entries.
-
Method Details
-
addColumn
Add a column to the table, without updating the header of an encompassing HDU. You should not use this method on tables already in an HDU, since it will not update the HDUs headers. Instead you can either useTableHDU.addColumn(Object)
or else create a new HDU for the table once the editing is copmleted -- adding or migrating any custom header entries as necessary after.- Parameters:
newCol
- the new column information. it should be either a primitive array, in which each element stores a scalar value for every row, or else anObject[]
where type of all of the constituents is identical. Multidimensional data should have the same layout in each row, but varied length one-dimensional arrays are OK. The arrat's length must match the number of rows already contained in the table, unless the table is still empty.- Returns:
- the number of columns in the adapted table
- Throws:
FitsException
- if the operation failed- See Also:
-
addRow
Add a row at the end of the table without updating the header of an encompassing HDU. You should not use this method on tables already in an HDU, since it will not update the HDUs headers. Instead you can useTableHDU.addRow(Object[])
or else create a new HDU for the table once the editing is completed -- adding or migrating any custom header entries as necessary after.- Parameters:
newRow
- An array of elements to be added. Each element of o should be an array of primitives or a String.- Returns:
- the number of rows in the adapted table
- Throws:
FitsException
- if the operation failed- See Also:
-
addRowEntries
LikeaddRow(Object[])
, but with a vararg list of row entries.- Parameters:
entries
- A vararg list of elements to be added. Each element of o should be an array of primitives or a String.- Returns:
- the number of rows in the adapted table
- Throws:
FitsException
- if the operation failed- See Also:
-
deleteColumns
Removes a set of consecutive columns from this table, without updating assocu=iated the header information for the columns that were removed. You should not use this method on tables already in an HDU, since it will not update the HDUs headers. Instead you should always create a new HDU for the table after editing, adding or migrating any custom header entries as necessary after.- Parameters:
col
- the 0-based index of the first column to removelen
- the number of subsequent columns to remove- Throws:
FitsException
- if the table could not be modified- See Also:
-
deleteRows
Removes a set of consecutive rows from this table without updating any associated header information for an encompassing HDU. You should not use this method on tables already in an HDU, since it will not update the HDUs headers. Instead you should always create a new HDU for the table after editing, adding or migrating any custom header entries as necessary after.- Parameters:
row
- the 0-based index of the first row to removelen
- the number of subsequent rows to remove- Throws:
FitsException
- if the table could not be modified- See Also:
-
getColumn
Returns the data for a particular column in as an array of elements. See
addColumn(Object)
for more information about the format of data elements in general.- Parameters:
col
- The 0-based column index.- Returns:
- an array of primitives (for scalar columns), or else an
Object[]
array, or possiblynull
- Throws:
FitsException
- if the table could not be accessed- See Also:
-
getElement
Returns the data element in this table. Elements are always stored as arrays even when scalar types. Thus a single
double
value will be returned as adouble[1]
. For most column types the storage type of the array matches that of their native Java type, but there are exceptions:- Character arrays in FITS are stored as
byte[]
orshort[]
, depending on theFitsFactory.setUseUnicodeChars(boolean)
setting, not unicode Javachar[]
. Therefore, this call will returnbyte[]
orshort[]
, the same as for a byte or 16-bit integer array. As a result if a new table is created with the returned data, the new table column will change its FITS column type fromA
toB
orI
. - Complex values in FITS are stored as
float[2]
ordouble[2]
, not as aComplexValue
type. Therefore, this call will returnfloat[]
ordouble[]
, the same as for a float array. As a result if a new table is created with the returned data, the new table column will change it's FITS column type fromC
toF
, or fromM
toD
,.
- Parameters:
row
- the 0-based row index of the elementcol
- the 0-based column index of the element- Returns:
- A primitive array containing the data for the the specified (row, col) entry in the table.
- Throws:
FitsException
- if the table could not be accessed- See Also:
- Character arrays in FITS are stored as
-
getNCols
int getNCols()Returns the number of columns contained in this table.- Returns:
- the current number of columns in the table.
- See Also:
-
getNRows
int getNRows()Returns the number of columns contained in this table.- Returns:
- the current number of columns in the table.
- See Also:
-
getRow
Returns an array of elements in a particualr table row. SeegetElement(int, int)
for more information about the format of each element in the row.- Parameters:
row
- the 0-based row index- Returns:
- an object containing the row data (for all column) of the specified row, or possubly
null
. SeegetElement(int, int)
for more information about the format of each element in the row. - Throws:
FitsException
- if the table could not be accessed- See Also:
-
setColumn
Sets new data for a table column. SeeaddColumn(Object)
for more information on the column data format.- Parameters:
col
- the 0-based column indexnewCol
- an object containing the new column data (for all rows) of the specified column. SeegetColumn(int)
for more information on the column data format.- Throws:
FitsException
- if the table could not be modified- See Also:
-
setElement
Sets new data element in this table. SeegetElement(int, int)
for more information about the format of elements.- Parameters:
row
- the 0-based row index of the elementcol
- the 0-based column index of the elementelement
- the new element at the specified table location as a primitive array.- Throws:
FitsException
- if the table could not be modified- See Also:
-
setRow
Sets new data for a table row. SeegetElement(int, int)
for more information about the format of elements.- Parameters:
row
- the 0-based row indexnewRow
- an object containing the row data (for all column) of the specified row. SeegetElement(int, int)
for more information about the format of each element in the row.- Throws:
FitsException
- if the table could not be modified- See Also:
-
setRowEntries
LikesetRow(int, Object[])
but with vararg list of entries.- Parameters:
row
- the 0-based row indexentries
- an object containing the row data (for all column) of the specified row. SeegetElement(int, int)
for more information about the format of each element in the row.- Throws:
FitsException
- if the table could not be modified- See Also:
-
updateAfterDelete
Deprecated.It is not entirely foolproof for keeping the header in sync -- it is better to (re)wrap tables in a new HDU after column deletions, and then edit the new header as necessary to incorporate custom entries. May be removed from the API in the future.Updates the table dimensions in the header following deletion. Whoever callsdeleteColumns(int, int)
on this table should call this method after the deletion(s), at least once after all desired column deletions have been processed).- Parameters:
oldNcol
- The number of columns in the table before the first call todeleteColumns(int, int)
.hdr
- The table header- Throws:
FitsException
- if the header could not be updated
-