The
The example below demonstrates how a default value for a nominal column is found if no settings are available:
configure
method has two responsibilities:
- check incoming data table specs and validate settings against them, if necessary, and
- based on the incoming data table specs create the resulting output specs
ColumnRearranger
is used, typically a private method is used to create it. Then the configure method would look like:
Example #1:
protected
DataTableSpec[] configure(final
DataTableSpec[] inSpecs)throws
InvalidSettingsException { ColumnRearranger c = createColumnRearranger(inSpecs[INPORT]);return new
DataTableSpec[]{c.createSpec()}; }
Example #2:
protected
DataTableSpec[] configure(throws
InvalidSettingsException { // check spec with selected column DataColumnSpec columnSpec = inSpecs[DATA_INPORT].getColumnSpec(m_classifyColumn);if
(columnSpec ==null
|| !columnSpec.getType().isCompatible(NominalValue.class
)) { // if no useful column is selected guess one // get the first useful one starting at the end of the tablefor
(int
i = inSpecs[DATA_INPORT].getNumColumns() - 1; i >= 0; i--) {if
(inSpecs[DATA_INPORT].getColumnSpec(i).getType() .isCompatible(NominalValue.class
)) { m_classifyColumn = inSpecs[DATA_INPORT].getColumnSpec(i).getName();break
; }throw new
InvalidSettingsException("Table contains no nominal" + " attribute for classification."); } }return new
DataTableSpec[]{}; }