public class ColumnTable 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) |
void |
addRow(Object[] row)
Add a row to the table.
|
protected void |
checkArrayConsistency(Object[] arrays,
int[] sizes)
Check that the columns and sizes are consistent.
|
Class[] |
getBases()
Get the base classes of the columns.
|
Object |
getColumn(int col)
Get a particular column.
|
Object[] |
getColumns()
Get the actual data arrays
|
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.
|
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,
Object newColumn)
Set the values in a particular column.
|
void |
setElement(int row,
int col,
Object x)
Modify an element of the table.
|
void |
setRow(int row,
Object x)
Modify a row of data.
|
protected void |
setup(Object[] arrays,
int[] sizes)
Actually perform the initialization.
|
int |
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
protected void setup(Object[] arrays, int[] sizes) throws TableException
TableException
public int getNRows()
public int getNCols()
public Object getColumn(int col)
public 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
informaiton in the table.public void addColumn(Object newColumn, int size) throws TableException
TableException
public void addRow(Object[] row) throws TableException
TableException
public Object getElement(int row, int col)
getElement
in interface DataTable
row
- The row desired.col
- The column desired.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 Object getRow(int row)
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.,TableException
ColumnTable.getColumn.
protected void checkArrayConsistency(Object[] arrays, int[] sizes) throws TableException
arrays
- The arrays defining the columns.sizes
- The number of elements in each row for the column.TableException
protected void getNumberOfRows()
rowSize
- The size of a row in bytes.nrows
- The number of rows in the table.protected void initializePointers()
protected void addPointer(Object data) throws TableException
TableException
public int read(ArrayDataInput is) throws IOException
is
- The input stream to read from.IOException
public int write(ArrayDataOutput os) throws IOException
os
- the output stream to write to.IOException
public Class[] getBases()
public char[] getTypes()
public Object[] getColumns()
public int[] getSizes()
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.