public class ColumnTable extends java.lang.Object implements DataTable
| Constructor and Description |
|---|
ColumnTable(java.lang.Object[] arrays,
int[] sizes)
Create the object after checking consistency.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addColumn(java.lang.Object newColumn,
int size)
Add a column
|
protected void |
addPointer(java.lang.Object data) |
void |
addRow(java.lang.Object[] row)
Add a row to the table.
|
protected void |
checkArrayConsistency(java.lang.Object[] arrays,
int[] sizes)
Check that the columns and sizes are consistent.
|
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.
|
java.lang.Class[] |
getBases()
Get the base classes of the columns.
|
java.lang.Object |
getColumn(int col)
Get a particular column.
|
java.lang.Object[] |
getColumns()
Get the actual data arrays
|
java.lang.Object |
getElement(int row,
int col)
Get a element of the table.
|
int |
getNCols()
Get the number of columns in the table.
|
int |
getNRows()
Get the number of rows in the table.
|
protected void |
getNumberOfRows()
Calculate the number of rows to read/write at a time.
|
java.lang.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.
|
int |
read(ArrayDataInput is)
Read a table.
|
void |
setColumn(int col,
java.lang.Object newColumn)
Set the values in a particular column.
|
void |
setElement(int row,
int col,
java.lang.Object x)
Modify an element of the table.
|
void |
setRow(int row,
java.lang.Object x)
Modify a row of data.
|
protected void |
setup(java.lang.Object[] arrays,
int[] sizes)
Actually perform the initialization.
|
int |
write(ArrayDataOutput os)
Write a table.
|
public ColumnTable(java.lang.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 columnTableExceptionprotected void setup(java.lang.Object[] arrays,
int[] sizes)
throws TableException
TableExceptionpublic int getNRows()
public int getNCols()
public java.lang.Object getColumn(int col)
public void setColumn(int col,
java.lang.Object newColumn)
throws TableException
setColumn in interface DataTablecol - 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 addColumn(java.lang.Object newColumn,
int size)
throws TableException
TableExceptionpublic void addRow(java.lang.Object[] row)
throws TableException
TableExceptionpublic java.lang.Object getElement(int row,
int col)
getElement in interface DataTablerow - The row desired.col - The column desired.public void setElement(int row,
int col,
java.lang.Object x)
throws TableException
setElement in interface DataTablerow - 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 java.lang.Object getRow(int row)
public void setRow(int row,
java.lang.Object x)
throws TableException
setRow in interface DataTablerow - 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)TableExceptionprotected void checkArrayConsistency(java.lang.Object[] arrays,
int[] sizes)
throws TableException
arrays - The arrays defining the columns.sizes - The number of elements in each row for the column.TableExceptionprotected void getNumberOfRows()
protected void initializePointers()
protected void addPointer(java.lang.Object data)
throws TableException
TableExceptionpublic int read(ArrayDataInput is) throws java.io.IOException
is - The input stream to read from.java.io.IOExceptionpublic int write(ArrayDataOutput os) throws java.io.IOException
os - the output stream to write to.java.io.IOExceptionpublic java.lang.Class[] getBases()
public char[] getTypes()
public java.lang.Object[] getColumns()
public int[] getSizes()
public void deleteRow(int row)
throws TableException
row - The row (0-indexed) to be deleted.TableExceptionpublic 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 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.