|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--edu.mssm.crover.tables.ArrayTable
Array-based implementation of the Table interface. The array is reallocated each time a need to grow the allocated space is encountered. That is not so smart as this is reasonable only for small tables: at reallocation time, twice the storage space of a column is used during the copy.
| Nested Class Summary | |
class |
ArrayTable.ColumnDescription
Holds and describe a column of this table. |
class |
ArrayTable.RowIterator
|
| Nested classes inherited from class edu.mssm.crover.tables.Table |
|
| Field Summary | |
protected int |
chunk
|
protected int |
INITIAL_LENGTH
|
| Constructor Summary | |
ArrayTable()
|
|
| Method Summary | |
int |
addColumn(java.lang.String identifier,
java.lang.Class type)
Adds a new column to this table. |
void |
appendBooleanValue(int column,
boolean value)
Appends a boolean value to the specified column. |
void |
appendCharValue(int column,
char value)
Appends a char value to the specified column. |
void |
appendDoubleValue(int column,
double value)
Appends a double value to the specified column. |
void |
appendFloatValue(int column,
float value)
Appends a float value to the specified column. |
void |
appendIntValue(int column,
int value)
Appends an int value to the specified column. |
void |
appendObject(int column,
java.lang.Object value)
Appends a Object value to the specified column. |
void |
checkSize(int column)
Check wether the internal storage needs to be expanded, performs the required reallocation when it does. |
void |
clean()
Cleans this column. |
void |
copy(int source_column,
Table.RowIterator source,
int dest_column,
Table.RowIterator dest)
Copy the value at position (column, source) to the position (column, dest). |
void |
copy(Table sourceTable,
int source_column,
Table.RowIterator source,
Table destTable,
int dest_column,
Table.RowIterator dest)
Copy the value at position sourceTable(column, source) to the position destTable(column, dest). |
void |
defineColumnsFrom(Table t)
Defines the columns of this table from the columns in source. |
java.lang.String |
elementToString(int column,
Table.RowIterator row)
|
Table.RowIterator |
firstRow()
Returns an iterator that reference the first instance of this table. |
protected void |
fixRowNumber(int coloumn_row_number)
Enforce the number of row of the table to be at least equal to the provided number of element of the column. |
boolean |
getBooleanValue(int column,
Table.RowIterator row)
Returns the value stored in this position as an boolean, when appropriate. |
char |
getCharValue(int column,
Table.RowIterator row)
Returns the value stored in this position as an int, when appropriate. |
int |
getColumnIndex(java.lang.String identifier)
Returns the column index associated with this identifier. |
int |
getColumnNumber()
Returns the number of columns of this table. |
double |
getDoubleValue(int column,
Table.RowIterator row)
Returns the value stored in this position as an double, when appropriate. |
float |
getFloatValue(int column,
Table.RowIterator row)
Returns the value stored in this position as a float, when appropriate. |
java.lang.String |
getIdentifier(int column)
Returns the identifier associated with this column index. |
int |
getIntValue(int column,
Table.RowIterator row)
Returns the value stored in this position as an int, when appropriate. |
int |
getRowNumber()
Returns the number of row of this table. |
java.lang.Class |
getType(int column)
Returns the type of the column which index is passed as argument. |
java.lang.Object |
getValue(int column,
Table.RowIterator row)
Returns the value stored in this position as an Object, when appropriate. |
boolean |
isColumn(java.lang.String identifier)
Returns true when the identifier designate a column of this column. |
Table.RowIterator |
lastRow()
Returns an iterator that reference the last instance of this table. |
static void |
main(java.lang.String[] args)
|
void |
parseAppend(int column,
java.lang.String value)
Append a value passed as a String. |
void |
removeColumn(java.lang.String identifier)
Removes a column from this table. |
void |
removeLastRow()
Removes the last appended row from each column of this table. |
void |
reserve(int column,
int numElements)
Reserve the space for numElements in the given column. |
void |
setChunk(int more)
Set the number of element of a column to expand the size with when the available space is saturated for this column. |
void |
setInitialSize(int init)
The amount of element initially available for each column before a reallocation is required. |
java.lang.String |
toString()
|
java.lang.String |
toString(Table source)
Returns a text representation of the table source. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected int chunk
protected int INITIAL_LENGTH
| Constructor Detail |
public ArrayTable()
| Method Detail |
public void clean()
public final void copy(Table sourceTable,
int source_column,
Table.RowIterator source,
Table destTable,
int dest_column,
Table.RowIterator dest)
copy in interface Table
public final void copy(int source_column,
Table.RowIterator source,
int dest_column,
Table.RowIterator dest)
copy in interface Table
public void reserve(int column,
int numElements)
reserve in interface Table
public int addColumn(java.lang.String identifier,
java.lang.Class type)
throws InvalidColumnException
addColumn in interface TableInvalidColumnException - Thrown when the column name is already in use in this table.
public void removeColumn(java.lang.String identifier)
throws InvalidColumnException
removeColumn in interface TableInvalidColumnException - Thrown when the column name is not used in this table.
The instances stored in this column are dropped.public boolean isColumn(java.lang.String identifier)
isColumn in interface Tableprotected void fixRowNumber(int coloumn_row_number)
public int getColumnNumber()
getColumnNumber in interface Tablepublic int getRowNumber()
getRowNumber in interface Tablepublic java.lang.String getIdentifier(int column)
getIdentifier in interface Table
public int getColumnIndex(java.lang.String identifier)
throws InvalidColumnException
getColumnIndex in interface TableInvalidColumnExceptionpublic java.lang.Class getType(int column)
getType in interface Tablepublic Table.RowIterator firstRow()
firstRow in interface Tablepublic Table.RowIterator lastRow()
lastRow in interface Table
public int getIntValue(int column,
Table.RowIterator row)
throws TypeMismatchException,
InvalidColumnException
getIntValue in interface TableTypeMismatchException - Thrown when the element is not an integer.
InvalidColumnException - Thrown when the specified index does not
identify a column of this table (negative indices and indices greater than getColumnNumber() throw this exception).
public char getCharValue(int column,
Table.RowIterator row)
throws TypeMismatchException,
InvalidColumnException
getCharValue in interface TableTypeMismatchException - Thrown when the element is not an integer.
InvalidColumnException - Thrown when the specified index does not
identify a column of this table (negative indices and indices greater than getColumnNumber() throw this exception).
public boolean getBooleanValue(int column,
Table.RowIterator row)
throws TypeMismatchException,
InvalidColumnException
getBooleanValue in interface TableTypeMismatchException - Thrown when the element is not a boolean.
InvalidColumnException - Thrown when the specified index does not
identify a column of this table (negative indices and indices greater than getColumnNumber() throw this exception).
public double getDoubleValue(int column,
Table.RowIterator row)
throws TypeMismatchException,
InvalidColumnException
getDoubleValue in interface TableTypeMismatchException - Thrown when the element is not a double.
InvalidColumnException - Thrown when the specified index does not
identify a column of this table (negative indices and indices greater than getColumnNumber() throw this exception).
public void appendIntValue(int column,
int value)
throws TypeMismatchException
appendIntValue in interface TableTypeMismatchException - Thrown when the column exists
but its type is incompatible with an int.
public void appendBooleanValue(int column,
boolean value)
throws TypeMismatchException
appendBooleanValue in interface TableTypeMismatchException
public void appendCharValue(int column,
char value)
throws TypeMismatchException
appendCharValue in interface TableTypeMismatchException
public void appendObject(int column,
java.lang.Object value)
throws TypeMismatchException
appendObject in interface TableTypeMismatchException - Thrown when the column exist s
but its type is incompatible with an Object.
public void appendFloatValue(int column,
float value)
throws TypeMismatchException
appendFloatValue in interface TableTypeMismatchException
public void appendDoubleValue(int column,
double value)
throws TypeMismatchException
appendDoubleValue in interface TableTypeMismatchException
public void parseAppend(int column,
java.lang.String value)
throws ColumnTypeException
parseAppend in interface TableColumnTypeExceptionStringAppenderpublic void setChunk(int more)
public void setInitialSize(int init)
public final void checkSize(int column)
public java.lang.Object getValue(int column,
Table.RowIterator row)
throws TypeMismatchException,
InvalidColumnException
getValue in interface TableTypeMismatchException - Thrown when the element is not a subclass of Object
InvalidColumnException - Thrown when the specified index does not
identify a column of this table (negative indices and indices greater than getColumnNumber() throw this exception).
public float getFloatValue(int column,
Table.RowIterator row)
throws TypeMismatchException,
InvalidColumnException
getFloatValue in interface TableTypeMismatchException - Thrown when the element is not a float.
InvalidColumnException - Thrown when the specified index does not identify a column of this table (negative
indices and indices greater than getColumnNumber() throw this exception).
public java.lang.String elementToString(int column,
Table.RowIterator row)
elementToString in interface Tablepublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(Table source)
toString in interface Tablepublic static void main(java.lang.String[] args)
public void defineColumnsFrom(Table t)
defineColumnsFrom in interface Tablet - Source for the column definition.public void removeLastRow()
removeLastRow in interface Table
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||