org.knime.base.node.preproc.filter.row.rowfilter
Class RangeRowFilter

java.lang.Object
  extended by org.knime.base.node.preproc.filter.row.rowfilter.RowFilter
      extended by org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter
          extended by org.knime.base.node.preproc.filter.row.rowfilter.RangeRowFilter
All Implemented Interfaces:
Cloneable

public class RangeRowFilter
extends AttrValueRowFilter

Filters rows based on the value of a cell in a certain column. It includes (or excludes) rows if their cell value is in a certain range. The type of the column is not checked and not restricted to numerical types - the result of a string range check (for example) might not be as expected though. The filter uses the comparator provided by the column (see DataValueComparator).

NOTE: Before the filter instance is applied it must be configured to find the column index to the specified column name and to set the appropriate comparator.

Author:
ohl, University of Konstanz

Constructor Summary
RangeRowFilter()
          Don't use created filter without loading settings before.
RangeRowFilter(String colName, boolean include, DataCell lowerBound, DataCell upperBound)
          Creates a filter that compares the value of a data cell in the specified column with the specified range.
 
Method Summary
 DataTableSpec configure(DataTableSpec inSpec)
          Called when a new DataTableSpec is available.
 DataCell getLowerBound()
           
 DataCell getUpperBound()
           
 void loadSettingsFrom(NodeSettingsRO cfg)
          Load your internal settings from the configuration object.
 boolean matches(DataRow row, int rowIndex)
          Return true if the specified row matches the criteria set in the filter.
protected  void saveSettings(NodeSettingsWO cfg)
          Do not call this function - rather call RowFilter.saveSettingsTo(NodeSettingsWO).
 String toString()
          
 
Methods inherited from class org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter
getColIdx, getColName, getInclude
 
Methods inherited from class org.knime.base.node.preproc.filter.row.rowfilter.RowFilter
clone, saveSettingsTo
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RangeRowFilter

public RangeRowFilter(String colName,
                      boolean include,
                      DataCell lowerBound,
                      DataCell upperBound)
Creates a filter that compares the value of a data cell in the specified column with the specified range. If the value is in that range the row is included (or excluded, depending on the corresponding flag). It is possible to set only one bound of the range, an open interval is assumed then (an exception will fly, if no bound is set though).

NOTE: This filter must be configured before it can be applied (there, the index of the selected column is determined and the comparator is retrieved from the column. The comparator is used to do the range checking).

Parameters:
colName - the column name of the cell to match
include - if true, matching rows are included, if false, they are excluded.
lowerBound - the lower bound of the range the value will be checked against. Could be null (if the upper bound is not null) which indicates that there is no lower bound for the range.
upperBound - the upper bound of the range the value will be checked against. Could be null (if the lower bound is not null) which indicates that there is no upper bound for the range.
See Also:
configure(DataTableSpec)

RangeRowFilter

RangeRowFilter()
Don't use created filter without loading settings before.

Method Detail

configure

public DataTableSpec configure(DataTableSpec inSpec)
                        throws InvalidSettingsException
Called when a new DataTableSpec is available. The filters can grab whatever they need from that new config (e.g. a comparator), should do some error checking (e.g. col number against number of columns) - throw an InvalidSettingsException if settings are invalid, and can return a new table spec according to their settings - if they can. If a filter cannot tell how it would modify the spec, it should return null. (Returned table specs are not used right now anyway.)

Overrides:
configure in class AttrValueRowFilter
Parameters:
inSpec - the new spec propagated into the row filter node. Could be null or empty!
Returns:
a new table spec, if you can
Throws:
InvalidSettingsException - if the settings in the row filter are not compatible with the table spec coming in

loadSettingsFrom

public void loadSettingsFrom(NodeSettingsRO cfg)
                      throws InvalidSettingsException
Load your internal settings from the configuration object. Throw an exception if the config is invalid/incorrect/inconsistent.

Overrides:
loadSettingsFrom in class AttrValueRowFilter
Parameters:
cfg - the object holding the settings to load
Throws:
InvalidSettingsException - if cfg contains invalid/incorrect/inconsistent settings

saveSettings

protected void saveSettings(NodeSettingsWO cfg)
Do not call this function - rather call RowFilter.saveSettingsTo(NodeSettingsWO). This is just a helper function for RowFilter.saveSettingsTo(NodeSettingsWO). Row filters implement this and do the work usually done in RowFilter.saveSettingsTo(NodeSettingsWO). The passed config is prepared in a way that the factory will be able to recreate this object from it.

Overrides:
saveSettings in class AttrValueRowFilter
Parameters:
cfg - object to add the current internal settings to

matches

public boolean matches(DataRow row,
                       int rowIndex)
                throws EndOfTableException,
                       IncludeFromNowOn
Return true if the specified row matches the criteria set in the filter. Can throw a EndOfTableException if the filter can tell that no more rows of the table will be able to fulfill the criteria.

Specified by:
matches in class RowFilter
Parameters:
row - the row to test
rowIndex - the row index of the passed row in the original table
Returns:
true if the row matches the criteria set in the filter, false if not
Throws:
EndOfTableException - if there is no chance that any of the rows coming (including the current rowIndex) will fulfill the criteria, thus no further row in the original table will be a match to this filter. (In general this is hard to tell, but a row number filter can certainly use it.) If the exception is received the row filter table iterator will flag an end of table.
IncludeFromNowOn - if the current and all following rows from now on are to be included into the result table

getLowerBound

public DataCell getLowerBound()
Returns:
the lowerBound

getUpperBound

public DataCell getUpperBound()
Returns:
the upperBound

toString

public String toString()

Overrides:
toString in class Object


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.