org.knime.core.data.container
Class TableSpecReplacerTable

java.lang.Object
  extended by org.knime.core.data.container.TableSpecReplacerTable
All Implemented Interfaces:
Iterable<DataRow>, DataTable, BufferedDataTable.KnowsRowCountTable

public final class TableSpecReplacerTable
extends Object
implements BufferedDataTable.KnowsRowCountTable

Table that only replaces the data table spec of an underlying table. This class is not intended for subclassing or to be used in a node model implementation. Instead, use the methods provided through the execution context.

Author:
Bernd Wiswedel, University of Konstanz
See Also:
ExecutionContext.createSpecReplacerTable( BufferedDataTable, DataTableSpec)

Constructor Summary
TableSpecReplacerTable(BufferedDataTable table, DataTableSpec newSpec)
          Creates new table.
 
Method Summary
 void clear()
          Do not call this method! It's used internally.
 void ensureOpen()
          Implementation of BufferedDataTable.ensureOpen().
 DataTableSpec getDataTableSpec()
          Returns the DataTableSpec object of this table which gives information about the structure of this data table.
 BufferedDataTable[] getReferenceTables()
          Get handle to reference table in an array of length 1.
 int getRowCount()
          Row count of the table.
 CloseableRowIterator iterator()
          Overridden to narrow return type to closeable iterator.
static TableSpecReplacerTable load(NodeSettingsRO s, DataTableSpec newSpec, Map<Integer,BufferedDataTable> tblRep)
          Restores table from a file that has been written using KNIME 1.2.0 or later.
static TableSpecReplacerTable load11x(File f, NodeSettingsRO s, Map<Integer,BufferedDataTable> tblRep)
          Restores table from a file that has been written using KNIME 1.1.x or before.
 void putIntoTableRepository(HashMap<Integer,ContainerTable> rep)
          Does nothing.
 void removeFromTableRepository(HashMap<Integer,ContainerTable> rep)
          Does nothing.
 void saveToFile(File f, NodeSettingsWO s, ExecutionMonitor exec)
          Save the table to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableSpecReplacerTable

public TableSpecReplacerTable(BufferedDataTable table,
                              DataTableSpec newSpec)
Creates new table. Not intended to be used directly for node implementations.

Parameters:
table - The reference table.
newSpec - Its new spec.
Throws:
IllegalArgumentException - If the spec doesn't match the data (number of columns)
Method Detail

saveToFile

public void saveToFile(File f,
                       NodeSettingsWO s,
                       ExecutionMonitor exec)
                throws IOException,
                       CanceledExecutionException
Save the table to a file.

Specified by:
saveToFile in interface BufferedDataTable.KnowsRowCountTable
Parameters:
f - To write to.
s - To add meta information to.
exec - For progress/cancel.
Throws:
IOException - If writing fails.
CanceledExecutionException - If canceled.

putIntoTableRepository

public void putIntoTableRepository(HashMap<Integer,ContainerTable> rep)
Does nothing. Put this table into the global table repository. Called when execution finished.

Specified by:
putIntoTableRepository in interface BufferedDataTable.KnowsRowCountTable
Parameters:
rep - The workflow table repository.

removeFromTableRepository

public void removeFromTableRepository(HashMap<Integer,ContainerTable> rep)
Does nothing. Remove this table from global table repository. Called when node is reset.

Specified by:
removeFromTableRepository in interface BufferedDataTable.KnowsRowCountTable
Parameters:
rep - The workflow table repository.

load11x

public static TableSpecReplacerTable load11x(File f,
                                             NodeSettingsRO s,
                                             Map<Integer,BufferedDataTable> tblRep)
                                      throws IOException,
                                             InvalidSettingsException
Restores table from a file that has been written using KNIME 1.1.x or before. Not intended to be used by node implementations.

Parameters:
f - The file to read from.
s - The settings to get meta information from.
tblRep - The table repository
Returns:
The resulting table.
Throws:
IOException - If reading the file fails.
InvalidSettingsException - If reading the settings fails.

load

public static TableSpecReplacerTable load(NodeSettingsRO s,
                                          DataTableSpec newSpec,
                                          Map<Integer,BufferedDataTable> tblRep)
                                   throws InvalidSettingsException
Restores table from a file that has been written using KNIME 1.2.0 or later. Not intended to be used by node implementations.

Parameters:
s - The settings to get meta information from.
newSpec - The new table spec.
tblRep - The table repository
Returns:
The resulting table.
Throws:
InvalidSettingsException - If reading the settings fails.

clear

public void clear()
Do not call this method! It's used internally. Clears any allocated temporary files. The table won't be used anymore.

Specified by:
clear in interface BufferedDataTable.KnowsRowCountTable

ensureOpen

public void ensureOpen()
Implementation of BufferedDataTable.ensureOpen().

Specified by:
ensureOpen in interface BufferedDataTable.KnowsRowCountTable

getDataTableSpec

public DataTableSpec getDataTableSpec()
Returns the DataTableSpec object of this table which gives information about the structure of this data table.

Specified by:
getDataTableSpec in interface DataTable
Returns:
the DataTableSpec of this table

iterator

public CloseableRowIterator iterator()
Overridden to narrow return type to closeable iterator. Returns a row iterator which returns each row one-by-one from the table.

Specified by:
iterator in interface Iterable<DataRow>
Specified by:
iterator in interface DataTable
Specified by:
iterator in interface BufferedDataTable.KnowsRowCountTable
Returns:
row iterator
See Also:
DataRow

getRowCount

public int getRowCount()
Row count of the table.

Specified by:
getRowCount in interface BufferedDataTable.KnowsRowCountTable
Returns:
The row count.

getReferenceTables

public BufferedDataTable[] getReferenceTables()
Get handle to reference table in an array of length 1.

Specified by:
getReferenceTables in interface BufferedDataTable.KnowsRowCountTable
Returns:
Reference to that table.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.