TissueInfo API 20130530171129

edu.mssm.crover.tables
Interface Table

All Known Implementing Classes:
ArrayTable

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 schemas. 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 relational 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 relational DBMS could be developed.

The purpose of this interface was primarily 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(String identifier, 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, Object value)
          Appends a value of type Object to this column.
 Table 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).
 Table copy(RowFilter filter)
           
 Table copy(RowFilter rowFilter, ColumnFilter columnFilter)
           
 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.
 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(String identifier)
          Returns the column index associated with this identifier.
 int getColumnNumber()
          Returns the number of columns of this table.
 ArrayTable.ColumnDescription getColumnValues(int i)
           
 double[] getDoubles(String columnId)
          Get the doubles for a particular column id.
 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.
 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.
 String[] getStrings(String columnId)
          Get the strings for a particular column id.
 Class<?> getType(int column)
          Returns the type of the column which index is passed as argument.
 Object getValue(int column, Table.RowIterator row)
          Returns the value stored in this position as an Object, when appropriate.
 void incrementRowNumber()
           
 boolean isColumn(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, String value)
          Append a value passed as a String.
 boolean permutateColumns(String columnName, int newColumnPosition)
          Permutate the position of columns.
 void processRows(RowProcessor myRowProcessor)
           
 void removeColumn(int columnIndex)
          Removes a column from this table.
 void removeColumn(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 setValue(int columnIndex, Table.RowIterator ri, boolean value)
           
 void setValue(int columnIndex, Table.RowIterator ri, char value)
           
 void setValue(int columnIndex, Table.RowIterator ri, double value)
           
 void setValue(int columnIndex, Table.RowIterator ri, float value)
           
 void setValue(int columnIndex, Table.RowIterator ri, int value)
           
 void setValue(int columnIndex, Table.RowIterator ri, long value)
           
 String toString(Table source)
           
 String toString(Table source, boolean printData)
          Returns a text representation of the table source.
 Table transpose(DefineColumnFromRow columnHelper)
           
 

Method Detail

incrementRowNumber

void incrementRowNumber()

copy

Table copy()
           throws TypeMismatchException,
                  InvalidColumnException
Throws:
TypeMismatchException
InvalidColumnException

copy

Table copy(RowFilter filter)
           throws TypeMismatchException,
                  InvalidColumnException
Throws:
TypeMismatchException
InvalidColumnException

copy

Table copy(RowFilter rowFilter,
           ColumnFilter columnFilter)
           throws TypeMismatchException,
                  InvalidColumnException
Throws:
TypeMismatchException
InvalidColumnException

getColumnValues

ArrayTable.ColumnDescription getColumnValues(int i)

setValue

void setValue(int columnIndex,
              Table.RowIterator ri,
              int value)

setValue

void setValue(int columnIndex,
              Table.RowIterator ri,
              long value)

setValue

void setValue(int columnIndex,
              Table.RowIterator ri,
              boolean value)

setValue

void setValue(int columnIndex,
              Table.RowIterator ri,
              float value)

setValue

void setValue(int columnIndex,
              Table.RowIterator ri,
              double value)

setValue

void setValue(int columnIndex,
              Table.RowIterator ri,
              char value)

processRows

void processRows(RowProcessor myRowProcessor)
                 throws TypeMismatchException,
                        InvalidColumnException
Throws:
TypeMismatchException
InvalidColumnException

transpose

Table transpose(DefineColumnFromRow columnHelper)
                throws InvalidColumnException,
                       TypeMismatchException,
                       ColumnTypeException
Throws:
InvalidColumnException
TypeMismatchException
ColumnTypeException

permutateColumns

boolean permutateColumns(String columnName,
                         int newColumnPosition)
                         throws InvalidColumnException
Permutate the position of columns. The named column will be moved to position.

Parameters:
columnName - The name of the column to move
newColumnPosition - the position to place the column
Returns:
True if a permutation was necessary. False otherwise.
Throws:
InvalidColumnException - if the column name or position is not valid

getStrings

String[] getStrings(String columnId)
                    throws InvalidColumnException
Get the strings for a particular column id.

Parameters:
columnId - The column id to get the strings for
Returns:
an array of strings
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).

getDoubles

double[] getDoubles(String columnId)
                    throws InvalidColumnException
Get the doubles for a particular column id.

Parameters:
columnId - The column id to get the values for
Returns:
an array of doubles
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).

getColumnNumber

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

Returns:
the number of columns in this table

getRowNumber

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

Returns:
the number of rows in this table

getIdentifier

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


getColumnIndex

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

Throws:
InvalidColumnException

getType

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
Returns the value stored in this position as an int, when appropriate.

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

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,
                  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

String elementToString(int column,
                       Table.RowIterator row)

parseAppend

void parseAppend(int column,
                 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(String identifier,
              Class type)
Adds a new column to this table.

Parameters:
identifier - The name of the new column
type - The type of the new column
Returns:
The index of this column.

isColumn

boolean isColumn(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(String identifier)
                  throws InvalidColumnException
Removes a column from this table.

Parameters:
identifier - The identifer for the column to remove
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).

removeColumn

void removeColumn(int columnIndex)
Removes a column from this table.

Parameters:
columnIndex - Index of the column to remove.

getDoubleValue

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

Throws:
TypeMismatchException - Thrown when the element is not a double.

getBooleanValue

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

Throws:
TypeMismatchException - Thrown when the element is not a boolean.

appendDoubleValue

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

Throws:
TypeMismatchException

toString

String toString(Table source)

toString

String toString(Table source,
                boolean printData)
Returns a text representation of the 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.


TissueInfo API 20130530171129

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