org.knime.base.node.preproc.rename
Class RenameColumnSetting

java.lang.Object
  extended by org.knime.base.node.preproc.rename.RenameColumnSetting

final class RenameColumnSetting
extends Object

Helper class that combines settings as to what should be happen with one column. That is one object of this class is responsible for only one column!

Author:
Bernd Wiswedel, University of Konstanz

Field Summary
static String CFG_NEW_COLNAME
          Config identifier for the new column name (if any).
static String CFG_NEW_COLTYPE
          Config identifier for the index of the new type.
static String CFG_OLD_COLNAME
          Config identifier for the original column name, used for sanity check.
 
Constructor Summary
RenameColumnSetting(DataColumnSpec column)
          Constructor being used in the NodeModel's configure method (for validation) and in the NodeDialog (DataTableSpec used to init default values like possible types).
RenameColumnSetting(String name)
          Inits a settings object for a given column.
 
Method Summary
(package private)  DataColumnSpec configure(DataColumnSpec inSpec)
          Called by configure in NodeModel to compute the new column spec.
(package private) static Set<Class<? extends DataValue>> constructPossibleTypes(DataType type)
          Construct a set with all types a given type can be cast to.
(package private) static RenameColumnSetting createFrom(NodeSettingsRO settings)
          Factory method used in NodeModel#validate and #loadSettingsFrom.
(package private)  String getName()
           
(package private)  String getNewColumnName()
          The name of the new column, if any.
(package private)  int getNewValueClassIndex()
          The index of the type to cast the column to.
(package private)  Class<? extends DataValue>[] getPossibleValueClasses()
          Result may be null when the first constructor was used (based on a column name only).
(package private)  void loadSettingsFrom(NodeSettingsRO settings)
          Loads settings from a settings object.
(package private)  void saveSettingsTo(NodeSettingsWO settings)
          Save the current settings to a config.
(package private)  void setNewColumnName(String newColumnName)
          Sets a new column name or null.
(package private)  void setNewValueClassIndex(int newType)
          Set new type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CFG_OLD_COLNAME

public static final String CFG_OLD_COLNAME
Config identifier for the original column name, used for sanity check.

See Also:
Constant Field Values

CFG_NEW_COLNAME

public static final String CFG_NEW_COLNAME
Config identifier for the new column name (if any).

See Also:
Constant Field Values

CFG_NEW_COLTYPE

public static final String CFG_NEW_COLTYPE
Config identifier for the index of the new type. The index is calculated on the order of the compatible types in constructPossibleTypes(DataType)

See Also:
Constant Field Values
Constructor Detail

RenameColumnSetting

RenameColumnSetting(String name)
Inits a settings object for a given column. This constructor is used in the NodeModel' load and validate method (no DataTableSpec availabe).

Parameters:
name - the column to get settings (e.g. compatible types) from
Throws:
NullPointerException - if argument is null

RenameColumnSetting

RenameColumnSetting(DataColumnSpec column)
Constructor being used in the NodeModel's configure method (for validation) and in the NodeDialog (DataTableSpec used to init default values like possible types).

Parameters:
column - the column spec form which to get values
Method Detail

getNewColumnName

String getNewColumnName()
The name of the new column, if any. May be null when no new name was set.

Returns:
the newColumnName

setNewColumnName

void setNewColumnName(String newColumnName)
Sets a new column name or null.

Parameters:
newColumnName - the newColumnName to set

getNewValueClassIndex

int getNewValueClassIndex()
The index of the type to cast the column to.

Returns:
the newType

setNewValueClassIndex

void setNewValueClassIndex(int newType)
Set new type.

Parameters:
newType - the newType to set

getName

String getName()
Returns:
the old name

getPossibleValueClasses

Class<? extends DataValue>[] getPossibleValueClasses()
Result may be null when the first constructor was used (based on a column name only).

Returns:
the possibleTypes

loadSettingsFrom

void loadSettingsFrom(NodeSettingsRO settings)
Loads settings from a settings object.

Parameters:
settings - to load from

saveSettingsTo

void saveSettingsTo(NodeSettingsWO settings)
Save the current settings to a config.

Parameters:
settings - to save to

configure

DataColumnSpec configure(DataColumnSpec inSpec)
                   throws InvalidSettingsException
Called by configure in NodeModel to compute the new column spec.

Parameters:
inSpec - the original input spec (names must match)
Returns:
the new column spec
Throws:
InvalidSettingsException - if that fails

createFrom

static RenameColumnSetting createFrom(NodeSettingsRO settings)
                               throws InvalidSettingsException
Factory method used in NodeModel#validate and #loadSettingsFrom.

Parameters:
settings - to load from
Returns:
a new object of this class with the settings
Throws:
InvalidSettingsException - if that fails

constructPossibleTypes

static Set<Class<? extends DataValue>> constructPossibleTypes(DataType type)
Construct a set with all types a given type can be cast to. It also contains always StringValue.class.

Parameters:
type - the type for which to determine all possible types
Returns:
a set containing all compatible types, including type


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.