org.knime.base.node.preproc.cellsplit
Class CellSplitterCellFactory

java.lang.Object
  extended by org.knime.base.node.preproc.cellsplit.CellSplitterCellFactory
All Implemented Interfaces:
CellFactory

 class CellSplitterCellFactory
extends Object
implements CellFactory

Creates the data cells for the new columns of the cell splitter.

Author:
ohl, University of Konstanz

Constructor Summary
CellSplitterCellFactory(DataTableSpec inSpec, CellSplitterSettings settings)
          Constructor.
 
Method Summary
(package private) static CellSplitterSettings createNewColumnTypes(BufferedDataTable table, CellSplitterUserSettings userSettings, ExecutionContext exec)
          Analyzes the values in the user selected column and tries to figure out how many columns are needed to hold the splitted values and of which type the new resulting column have to be.
 DataCell[] getCells(DataRow row)
          Get the new cells for a given row.
 DataColumnSpec[] getColumnSpecs()
          The column specs for the cells that are generated in the getCells() method.
 void setProgress(int curRowNr, int rowCount, RowKey lastKey, ExecutionMonitor exec)
          This method is called when a row has been processed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellSplitterCellFactory

public CellSplitterCellFactory(DataTableSpec inSpec,
                               CellSplitterSettings settings)
Constructor.

Parameters:
inSpec - the spec from the underlying input table
settings - the settings object containing the user settings.
Method Detail

getCells

public DataCell[] getCells(DataRow row)
Get the new cells for a given row. These cells are incorporated into the existing row. The way it is done is defined through the ColumnRearranger using this object.

Specified by:
getCells in interface CellFactory
Parameters:
row - The row of interest.
Returns:
The new cells to that row.

getColumnSpecs

public DataColumnSpec[] getColumnSpecs()
The column specs for the cells that are generated in the getCells() method. This method is only called once, there is no need to cache the return value. The length of the returned array must match the length of the array returned by the getCells(DataRow) method and also the types must match, i.e. the type of the respective DataColumnSpec must be of the same type or a super type of the cell as returned by getCells(DataRow).

Specified by:
getColumnSpecs in interface CellFactory
Returns:
The specs to the newly created cells.

setProgress

public void setProgress(int curRowNr,
                        int rowCount,
                        RowKey lastKey,
                        ExecutionMonitor exec)
This method is called when a row has been processed. It allows the implementor to set progress in the execution monitor and also some meaningful progress message.

Note, you don't need to check exec.checkCanceled() in the implementation as this is done in the calling class.

Specified by:
setProgress in interface CellFactory
Parameters:
curRowNr - The number of the row just processed
rowCount - The total number of rows.
lastKey - The row's key.
exec - The execution monitor to report progress to.

createNewColumnTypes

static CellSplitterSettings createNewColumnTypes(BufferedDataTable table,
                                                 CellSplitterUserSettings userSettings,
                                                 ExecutionContext exec)
                                          throws CanceledExecutionException
Analyzes the values in the user selected column and tries to figure out how many columns are needed to hold the splitted values and of which type the new resulting column have to be.
If the "guess" flag in the settings object is NOT set, it returns the column number entered by the user and string type for all columns. Otherwise it runs once through the entire table, splits the value of the selected column, stores the maximum number of parts received, and tries to convert each part into an int (first), then into a double, and if both fails it sets string type for the corresponding column.

Parameters:
table - the table with the column to examine (can be null, if no type guessing is required)
userSettings - user settings
exec - the execution context to set progress and check for cancel (can be null)
Returns:
a settings object containing the same settings as the ones passed in and in addition the type (and number) of each column to add
Throws:
CanceledExecutionException - if user cancels


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.