org.knime.core.node
Class ExtensionTable

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

public abstract class ExtensionTable
extends Object
implements BufferedDataTable.KnowsRowCountTable

Base class for custom buffered data table types. In addition to the contract defined by BufferedDataTable.KnowsRowCountTable, ExtensionTables must define a constructor that accepts a single argument of type ExtensionTable.LoadContext.


Nested Class Summary
static class ExtensionTable.LoadContext
          Various parameters needed for loading an extension table.
 
Constructor Summary
protected ExtensionTable()
          Default constructor; to be used to create a new table (as opposed to loading an existing table).
protected ExtensionTable(ExtensionTable.LoadContext context)
          Constructor to be used when loading an existing table.
 
Method Summary
protected  BufferedDataTable create(ExecutionContext exec)
          Create the actual buffered data table.
protected  JComponent[] getViews(BufferedDataTable owner)
          Overwrite this method to provide a custom viewer.
(package private) static ExtensionTable loadExtensionTable(ReferencedFile fileRef, DataTableSpec spec, NodeSettingsRO s, Map<Integer,BufferedDataTable> tblRep, ExecutionMonitor exec)
          Load the extension, used internally from BufferedDataTable.
 void saveToFile(File f, NodeSettingsWO settings, ExecutionMonitor exec)
          Save the table to a file.
protected abstract  void saveToFileOverwrite(File f, NodeSettingsWO settings, ExecutionMonitor exec)
          Saves this extension table to the argument file.
protected static ExtensionTable unwrap(BufferedDataTable table)
          Provides a way to return the underlying extension table if the BufferedDataTable is an extension table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.knime.core.node.BufferedDataTable.KnowsRowCountTable
clear, ensureOpen, getReferenceTables, getRowCount, iterator, putIntoTableRepository, removeFromTableRepository
 
Methods inherited from interface org.knime.core.data.DataTable
getDataTableSpec
 

Constructor Detail

ExtensionTable

protected ExtensionTable()
Default constructor; to be used to create a new table (as opposed to loading an existing table).


ExtensionTable

protected ExtensionTable(ExtensionTable.LoadContext context)
                  throws IOException,
                         CanceledExecutionException,
                         InvalidSettingsException
Constructor to be used when loading an existing table. Subclasses must define a constructor of the same signature.

Parameters:
context - various parameters needed for loading
Throws:
InvalidSettingsException - If settings are invalid
IOException - If reading fails
CanceledExecutionException - If canceled
Method Detail

create

protected final BufferedDataTable create(ExecutionContext exec)
Create the actual buffered data table.

Parameters:
exec - The context, used to set ownership on table.
Returns:
a newly created buffered data table

getViews

protected JComponent[] getViews(BufferedDataTable owner)
Overwrite this method to provide a custom viewer. It will use the default viewer (BufferedDataTableViewer) if the implementation returns null (default) or an empty list. Extensions may provide custom features such as searching.

Parameters:
owner - the owner of this delegate
Returns:
an array of views for the port object, each displayed as a tab in the out port view. Null or empty list to rely on the default view.

unwrap

protected static ExtensionTable unwrap(BufferedDataTable table)
Provides a way to return the underlying extension table if the BufferedDataTable is an extension table. Also (recursively) unwraps WrappedTables in case they are wrapping an extension table.

Parameters:
table - the table to unwrap
Returns:
the underlying extension table or null if this is not an extension table

saveToFile

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

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

saveToFileOverwrite

protected abstract void saveToFileOverwrite(File f,
                                            NodeSettingsWO settings,
                                            ExecutionMonitor exec)
                                     throws IOException,
                                            CanceledExecutionException
Saves this extension table to the argument file.

Parameters:
f - To write to.
settings - The (derived) settings object (empty).
exec - Execution monitor for cancelation, progress.
Throws:
IOException - If that fails.
CanceledExecutionException - if canceled.

loadExtensionTable

static ExtensionTable loadExtensionTable(ReferencedFile fileRef,
                                         DataTableSpec spec,
                                         NodeSettingsRO s,
                                         Map<Integer,BufferedDataTable> tblRep,
                                         ExecutionMonitor exec)
                                  throws InvalidSettingsException,
                                         IOException,
                                         CanceledExecutionException
Load the extension, used internally from BufferedDataTable.

Parameters:
fileRef - To load from, it's a referenced file so that implementations can delay the reading to when it's necessary.
spec - The table specification.
s - The settings object
tblRep - The global table map.
exec - Progress monitor.
Returns:
the loaded table
Throws:
InvalidSettingsException - If settings are invalid
IOException - If reading fails
CanceledExecutionException - If canceled


Copyright, 2003 - 2012. 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.