edu.mssm.crover.tables
Interface Table

All Known Implementing Classes:
ArrayTable, OrderedTable

public interface Table

Table data storage representation. This interface is designed to provide a fast access to the element of the table while allowing to deal with tables of flexible shemas. This seems a bit antithetic at first, and is translated in a number of function getXValue that return the element of a given type. This design allow to store the instances of the table as elementary types, which saves memory, and enable to pass each element directly to the client without wrapping each value in an object. The Schema/Data dissociation is mirroring the classical relationnal database data model. Implementations of this interface are free to store the data the way they prefer. We provide a memory resident array based implementation called ArrayTable for casual task (small table dimensions). Implementations for relationnal DBMS could be developped. The purpose of this interface was primilarily to propose a way to hold a Mineset (SGI data mining tool) table in memory for post-processing.


Nested Class Summary
static interface Table.RowIterator
           
 
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 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.
 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)
           
 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.
 java.lang.String toString(Table source)
           
 

Method Detail

getColumnNumber

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


getRowNumber

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


getIdentifier

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


getColumnIndex

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

Throws:
InvalidColumnException

getType

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


firstRow

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


lastRow

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


getCharValue

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

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

getIntValue

int getIntValue(int column,
                Table.RowIterator row)
                throws TypeMismatchException,
                       InvalidColumnException
Throws:
TypeMismatchException
InvalidColumnException

getValue

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

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

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

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).

appendIntValue

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

Throws:
TypeMismatchException - Thrown when the column exists but its type is incompatible with an int.

appendCharValue

void appendCharValue(int column,
                     char value)
                     throws TypeMismatchException
Appends a char value to the specified column.

Throws:
TypeMismatchException

appendBooleanValue

void appendBooleanValue(int column,
                        boolean value)
                        throws TypeMismatchException
Appends a char value to the specified column.

Throws:
TypeMismatchException

appendObject

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

Throws:
TypeMismatchException - Thrown when the column exist s but its type is incompatible with an Object.

appendFloatValue

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

Throws:
TypeMismatchException

elementToString

java.lang.String elementToString(int column,
                                 Table.RowIterator row)

parseAppend

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.

Throws:
ColumnTypeException
See Also:
StringAppender

addColumn

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

Throws:
InvalidColumnException - Thrown when the column name is already in use in this table.

isColumn

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


copy

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). The previous value, (column, dest), is overridden.


copy

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). The previous value, (column, dest), is overridden. The operation is performed on this table.


reserve

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


removeColumn

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

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

getDoubleValue

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

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).

getBooleanValue

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

Throws:
TypeMismatchException - 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).

appendDoubleValue

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

Throws:
TypeMismatchException

toString

java.lang.String toString(Table source)

defineColumnsFrom

void defineColumnsFrom(Table t)
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.

Parameters:
t - Source for the column definition.

removeLastRow

void removeLastRow()
Removes the last appended row from each column of this table.



Copyright © 2003-2013 Institute for Computational Biomedicine, All Rights Reserved.