public class ColumnTable<T> extends Object implements DataTable
Constructor and Description |
---|
ColumnTable(Object[] arrays,
int[] sizes)
Create the object after checking consistency.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(Object newColumn,
int size)
Add a column .
|
protected void |
addPointer(Object data)
Add a pointer in the pointer lists.
|
void |
addRow(Object[] row)
Add a row to the table.
|
protected void |
checkArrayConsistency(Object[] newArrays,
int[] newSizes)
Check that the columns and sizes are consistent.
|
ColumnTable<T> |
copy() |
int |
deleteColumns(int start,
int len)
Delete a contiguous set of columns from the table.
|
void |
deleteRow(int row)
Delete a row from the table.
|
void |
deleteRows(int row,
int length)
Delete a contiguous set of rows from the table.
|
Class<?>[] |
getBases()
Get the base classes of the columns.
|
Object |
getColumn(int col)
Get a particular column.
|
Object[] |
getColumns() |
Object |
getElement(int row,
int col)
Get a element of the table.
|
T |
getExtraState() |
int |
getNCols()
Get the number of columns in the table.
|
int |
getNRows()
Get the number of rows in the table.
|
Object |
getRow(int row)
Get a row of data.
|
int[] |
getSizes() |
char[] |
getTypes()
Get the characters describing the base classes of the columns.
|
protected void |
initializePointers()
Set the pointer arrays for the eight primitive types to point to the
appropriate elements of arrays.
|
void |
read(ArrayDataInput is)
Read a table.
|
void |
setColumn(int col,
Object newColumn)
Set the values in a particular column.
|
void |
setElement(int row,
int col,
Object x)
Modify an element of the table.
|
void |
setExtraState(T opaque)
Store additional information that may be needed by the client to
regenerate initial arrays.
|
void |
setRow(int row,
Object x)
Modify a row of data.
|
void |
write(ArrayDataOutput os)
Write a table.
|
public ColumnTable(Object[] arrays, int[] sizes) throws TableException
arrays
- An array of one-d primitive arrays.sizes
- The number of elements in each row for the corresponding
columnTableException
- if the structure of the columns is not consistentpublic void addColumn(Object newColumn, int size) throws TableException
newColumn
- the column to add.size
- size for the columnTableException
- if the structure of the new column does not fit the structure
of the rows/columnsprotected void addPointer(Object data) throws TableException
data
- data pointer to addTableException
- if the structure of the specified array does not fit the
structure of the rows/columnspublic void addRow(Object[] row) throws TableException
row
- the row to addTableException
- if the structure of the specified array does not fit the
structure of the rows/columnsprotected void checkArrayConsistency(Object[] newArrays, int[] newSizes) throws TableException
newArrays
- The arrays defining the columns.newSizes
- The number of elements in each row for the column.TableException
- if the table was inconsistentpublic ColumnTable<T> copy() throws TableException
TableException
public int deleteColumns(int start, int len) throws TableException
start
- The first column (0-indexed) to be deleted.len
- The number of columns to be deleted.TableException
- if the request goes outside the boundaries of the table or if
the length is negative.public void deleteRow(int row) throws TableException
row
- The row (0-indexed) to be deleted.TableException
- if the request goes outside the boundaries of the table or if
the length is negative.public void deleteRows(int row, int length) throws TableException
row
- The row (0-indexed) to be deleted.length
- The number of rows to be deleted.TableException
- if the request goes outside the boundaries of the table or if
the length is negative.public Class<?>[] getBases()
public Object getColumn(int col)
public Object[] getColumns()
public Object getElement(int row, int col)
getElement
in interface DataTable
row
- The row desired.col
- The column desired.public T getExtraState()
public int getNCols()
public int getNRows()
public Object getRow(int row)
public int[] getSizes()
public char[] getTypes()
protected void initializePointers()
public void read(ArrayDataInput is) throws IOException
is
- The input stream to read from.IOException
- if the reading failedpublic void setColumn(int col, Object newColumn) throws TableException
setColumn
in interface DataTable
col
- The column to modify.newColumn
- The new column data. This should be a primitive array.TableException
- Thrown when the new data is not commenserable with
information in the table.public void setElement(int row, int col, Object x) throws TableException
setElement
in interface DataTable
row
- The row containing the element.col
- The column containing the element.x
- The new datum. This should be 1-d primitive array.TableException
- Thrown when the new data is not of the same type as the
data it replaces.public void setExtraState(T opaque)
opaque
- the extra state to set.public void setRow(int row, Object x) throws TableException
setRow
in interface DataTable
row
- The row to be modified.x
- The data to be modified. This should be an array of objects.
It is described as an Object here since other table
implementations may use other methods to store the data (e.g., @see
nom.tam.util.ColumnTable)TableException
public void write(ArrayDataOutput os) throws IOException
os
- the output stream to write to.IOException
- if the write operation failedCopyright © 1996–2016 nom-tam-fits. All rights reserved.