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

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.StringCompareRowFilter
All Implemented Interfaces:
Cloneable

public class StringCompareRowFilter
extends AttrValueRowFilter

Filters rows based on the string representation of the value in a certain column. The type of the column is not checked and not restricted to the type of StringValue. The filter uses the String representation of the value (by calling DataCell.toString())

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

Author:
ohl, University of Konstanz

Field Summary
static String CFGKEY_PATTERN
           
 
Constructor Summary
StringCompareRowFilter()
          Don't use created filter without loading settings before.
StringCompareRowFilter(String strPattern, String colName, boolean include, boolean caseSensitive, boolean hasWildcards, boolean isRegExpr)
          Creates a row filter that compares the string representation of the cell in the specified column with the given string pattern.
 
Method Summary
 boolean getCaseSensitive()
           
 boolean getHasWildcards()
           
 boolean getIsRegExpr()
           
 String getPattern()
           
 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
configure, 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
 

Field Detail

CFGKEY_PATTERN

public static final String CFGKEY_PATTERN
See Also:
Constant Field Values
Constructor Detail

StringCompareRowFilter

public StringCompareRowFilter(String strPattern,
                              String colName,
                              boolean include,
                              boolean caseSensitive,
                              boolean hasWildcards,
                              boolean isRegExpr)
Creates a row filter that compares the string representation of the cell in the specified column with the given string pattern. Matching rows are included or excluded, depending on the corresponding argument. The pattern will either be matched exactly, or case insensitive, or may contain wildcards. A wildcard is the asterisk (*) matching any number (including zero) of any character, and the question mark (?) matching any (but exactly one) character. Cells with missing values never match!

Parameters:
strPattern - the pattern that is matched against the string representation of the data cell
colName - the column name of the cell to match
include - if true, matching rows are included, if false, they are excluded.
caseSensitive - if true a case sensitive match is performed, otherwise characters of different case match, too.
hasWildcards - if true, '*' and '?' is interpreted as wildcard matching any character sequence or any character respectively. If false, '*' and '?' are treated as regular characters and match '*' and '?' in the value.
isRegExpr - if true, the pattern argument is treated as regular expression. Can't be true when the hasWildcard argument is true

StringCompareRowFilter

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

Method Detail

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

getCaseSensitive

public boolean getCaseSensitive()
Returns:
the caseSensitive

getHasWildcards

public boolean getHasWildcards()
Returns:
the hasWildcards

getIsRegExpr

public boolean getIsRegExpr()
Returns:
the isRegExpr

getPattern

public String getPattern()
Returns:
the pattern

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.