edu.mssm.crover.tables
Class OrderedTable

java.lang.Object
  |
  +--edu.mssm.crover.tables.OrderedTable
All Implemented Interfaces:
Table

public class OrderedTable
extends java.lang.Object
implements Table


Nested Class Summary
 class OrderedTable.OrderedRowIterator
           
 
Nested classes inherited from class edu.mssm.crover.tables.Table
 
Constructor Summary
OrderedTable(Table source, Table.RowIterator[] order)
           
 
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 char 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)
          Table are write once data storage.
 void appendObject(int column, java.lang.Object value)
          Appends a value of type Object to this column.
 void copy(int source_column, Table.RowIterator isource, 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 isource, 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.
 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 a char, 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.
 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 setSortColumn(java.lang.String identifier)
           
 java.lang.String toString()
           
 java.lang.String toString(Table source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrderedTable

public OrderedTable(Table source,
                    Table.RowIterator[] order)
Method Detail

setSortColumn

public void setSortColumn(java.lang.String identifier)

getColumnNumber

public int getColumnNumber()
Returns the number of columns of this table.

Specified by:
getColumnNumber in interface Table

getRowNumber

public int getRowNumber()
Returns the number of row of this table.

Specified by:
getRowNumber in interface Table

getIdentifier

public java.lang.String getIdentifier(int column)
Returns the identifier associated with this column index.

Specified by:
getIdentifier in interface Table

getColumnIndex

public int getColumnIndex(java.lang.String identifier)
                   throws InvalidColumnException
Returns the column index associated with this identifier.

Specified by:
getColumnIndex in interface Table
InvalidColumnException

getType

public java.lang.Class getType(int column)
Returns the type of the column which index is passed as argument.

Specified by:
getType in interface Table

firstRow

public Table.RowIterator firstRow()
Returns an iterator that reference the first instance of this table.

Specified by:
firstRow in interface Table

lastRow

public Table.RowIterator lastRow()
Returns an iterator that reference the last instance of this table.

Specified by:
lastRow in interface Table

getIntValue

public int getIntValue(int column,
                       Table.RowIterator row)
                throws TypeMismatchException,
                       InvalidColumnException
Returns the value stored in this position as an int, when appropriate.

Specified by:
getIntValue in interface Table
Throws:
TypeMismatchException - 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).

getValue

public java.lang.Object getValue(int column,
                                 Table.RowIterator row)
                          throws TypeMismatchException,
                                 InvalidColumnException
Returns the value stored in this position as an Object, when appropriate.

Specified by:
getValue in interface Table
Throws:
TypeMismatchException - 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).

getFloatValue

public float getFloatValue(int column,
                           Table.RowIterator row)
                    throws TypeMismatchException,
                           InvalidColumnException
Returns the value stored in this position as a float, when appropriate.

Specified by:
getFloatValue in interface Table
Throws:
TypeMismatchException - 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).

getCharValue

public char getCharValue(int column,
                         Table.RowIterator row)
                  throws TypeMismatchException,
                         InvalidColumnException
Description copied from interface: Table
Returns the value stored in this position as a char, when appropriate.

Specified by:
getCharValue in interface Table
Throws:
InvalidColumnException - Thrown when the specified index does not identify a column of this table (negative indices and indices greater than getColumnNumber() throw this exception).
TypeMismatchException - Thrown when the element is not a char

getBooleanValue

public boolean getBooleanValue(int column,
                               Table.RowIterator row)
                        throws TypeMismatchException,
                               InvalidColumnException
Description copied from interface: Table
Returns the value stored in this position as an boolean, when appropriate.

Specified by:
getBooleanValue in interface Table
Throws:
InvalidColumnException - Thrown when the specified index does not identify a column of this table (negative indices and indices greater than getColumnNumber() throw this exception).
TypeMismatchException - Thrown when the element is not a boolean.

appendIntValue

public void appendIntValue(int column,
                           int value)
                    throws TypeMismatchException
Table are write once data storage. At least at the moment.

Specified by:
appendIntValue in interface Table
Throws:
TypeMismatchException - Thrown when the column exists but its type is incompatible with an int.

appendBooleanValue

public void appendBooleanValue(int column,
                               boolean value)
                        throws TypeMismatchException
Description copied from interface: Table
Appends a char value to the specified column.

Specified by:
appendBooleanValue in interface Table
TypeMismatchException

appendCharValue

public void appendCharValue(int column,
                            char value)
                     throws TypeMismatchException
Description copied from interface: Table
Appends a char value to the specified column.

Specified by:
appendCharValue in interface Table
TypeMismatchException

appendObject

public void appendObject(int column,
                         java.lang.Object value)
                  throws TypeMismatchException
Appends a value of type Object to this column.

Specified by:
appendObject in interface Table
Throws:
TypeMismatchException - Thrown when the column exist s but its type is incompatible with an Object.

appendFloatValue

public void appendFloatValue(int column,
                             float value)
                      throws TypeMismatchException
Appends a float value to the specified column.

Specified by:
appendFloatValue in interface Table
TypeMismatchException

elementToString

public java.lang.String elementToString(int column,
                                        Table.RowIterator row)
Specified by:
elementToString in interface Table

parseAppend

public void parseAppend(int column,
                        java.lang.String value)
                 throws ColumnTypeException
Append a value passed as a String. This operation imply parsing the value from its String representation. This is supported for the following types: int, float, boolean, String, and for any object type when a StringAppender has been provided when the column has been created.

Specified by:
parseAppend in interface Table
ColumnTypeException
See Also:
StringAppender

addColumn

public int addColumn(java.lang.String identifier,
                     java.lang.Class type)
              throws InvalidColumnException
Adds a new column to this table.

Specified by:
addColumn in interface Table
Throws:
InvalidColumnException - Thrown when the column name is already in use in this table.

isColumn

public boolean isColumn(java.lang.String identifier)
Returns true when the identifier designate a column of this column.

Specified by:
isColumn in interface Table

copy

public void copy(Table sourceTable,
                 int source_column,
                 Table.RowIterator isource,
                 Table destTable,
                 int dest_column,
                 Table.RowIterator dest)
Copy the value at position sourceTable(column, source) to the position destTable(column, dest). The previous value, (column, dest), is overridden.

Specified by:
copy in interface Table

copy

public void copy(int source_column,
                 Table.RowIterator isource,
                 int dest_column,
                 Table.RowIterator dest)
Copy the value at position (column, source) to the position (column, dest). The previous value, (column, dest), is overridden. The operation is performed on this table.

Specified by:
copy in interface Table

reserve

public void reserve(int column,
                    int numElements)
Reserve the space for numElements in the given column. Required before copying the elements from a different table.

Specified by:
reserve in interface Table

removeColumn

public void removeColumn(java.lang.String identifier)
                  throws InvalidColumnException
Removes a column from this table.

Specified by:
removeColumn in interface Table
Throws:
InvalidColumnException - Thrown when the column name is not used in this table. The instances stored in this column are dropped.

getDoubleValue

public double getDoubleValue(int column,
                             Table.RowIterator row)
                      throws TypeMismatchException,
                             InvalidColumnException
Returns the value stored in this position as an double, when appropriate.

Specified by:
getDoubleValue in interface Table
Throws:
TypeMismatchException - 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).

appendDoubleValue

public void appendDoubleValue(int column,
                              double value)
                       throws TypeMismatchException
Appends a double value to the specified column.

Specified by:
appendDoubleValue in interface Table
TypeMismatchException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(Table source)
Specified by:
toString in interface Table

defineColumnsFrom

public void defineColumnsFrom(Table t)
Description copied from interface: Table
Defines the columns of this table from the columns in source. For each column of the source table, a new column is added to this Table.

Specified by:
defineColumnsFrom in interface Table
Parameters:
t - Source for the column definition.

removeLastRow

public void removeLastRow()
Description copied from interface: Table
Removes the last appended row from each column of this table.

Specified by:
removeLastRow in interface Table


Copyright @ 2003 Mount Sinai School of Medicine. All Rights Reserved.