Holger's
Java API

com.antelmann.util.table
Class SimpleTableRowFilter

java.lang.Object
  extended by com.antelmann.util.table.SimpleTableRowFilter
All Implemented Interfaces:
Filter<TableRow>

public class SimpleTableRowFilter
extends Object
implements Filter<TableRow>

implements a simple filter based on a search string searchPattern.

Since:
6. Oktober 2006, 12:27
Author:
Holger Antelmann
See Also:
FilteredTableModel

Field Summary
 
Fields inherited from interface com.antelmann.util.Filter
EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER
 
Constructor Summary
SimpleTableRowFilter(boolean multiWordSearchOption)
           
SimpleTableRowFilter(Integer... columnsToCheck)
           
SimpleTableRowFilter(String pattern, boolean multiWordSearchOption, Integer... columnsToCheck)
           
SimpleTableRowFilter(String pattern, Integer... columnsToCheck)
          checks for the searchPattern in the given columns (if no column is specified, all columns are checked)
 
Method Summary
 boolean accept(TableRow row)
          returns true only if the given entry is accepted by this filter
protected  boolean containsPattern(Object value, String pattern)
          uses the embedded PatternExtractor and then looks for the pattern to be present
protected  boolean containsPattern(TableRow row, String pattern)
           
 int[] getColumnsToCheck()
          returns a newly created copy of the embedded array
 String getPattern()
           
 PatternExtractor<Object,String> getPatternExtractor()
          returns the PatternExtractor used to generate a String value from a table cell value when searching for a pattern.
 boolean isIgnoreCase()
          true by default
 boolean isMultiWordSearchOption()
           
 void setIgnoreCase(boolean ignoreCase)
           
 void setMultiWordSearchOption(boolean multiWordSearchOption)
           
 void setPattern(String pattern)
           
 void setPatternExtractor(PatternExtractor<Object,String> pe)
          allows to customize the way a String is extracted from a value in a model when searching for a pattern
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTableRowFilter

public SimpleTableRowFilter(Integer... columnsToCheck)

SimpleTableRowFilter

public SimpleTableRowFilter(String pattern,
                            Integer... columnsToCheck)
checks for the searchPattern in the given columns (if no column is specified, all columns are checked)


SimpleTableRowFilter

public SimpleTableRowFilter(boolean multiWordSearchOption)

SimpleTableRowFilter

public SimpleTableRowFilter(String pattern,
                            boolean multiWordSearchOption,
                            Integer... columnsToCheck)
Method Detail

getPattern

public String getPattern()

setPattern

public void setPattern(String pattern)

isIgnoreCase

public boolean isIgnoreCase()
true by default


setIgnoreCase

public void setIgnoreCase(boolean ignoreCase)

getPatternExtractor

public PatternExtractor<Object,String> getPatternExtractor()
returns the PatternExtractor used to generate a String value from a table cell value when searching for a pattern. By default, a special extractor is used that simply either returns null or the toString() value of a value.


setPatternExtractor

public void setPatternExtractor(PatternExtractor<Object,String> pe)
allows to customize the way a String is extracted from a value in a model when searching for a pattern


isMultiWordSearchOption

public boolean isMultiWordSearchOption()

setMultiWordSearchOption

public void setMultiWordSearchOption(boolean multiWordSearchOption)

getColumnsToCheck

public int[] getColumnsToCheck()
returns a newly created copy of the embedded array


accept

public boolean accept(TableRow row)
Description copied from interface: Filter
returns true only if the given entry is accepted by this filter

Specified by:
accept in interface Filter<TableRow>

containsPattern

protected boolean containsPattern(TableRow row,
                                  String pattern)

containsPattern

protected boolean containsPattern(Object value,
                                  String pattern)
uses the embedded PatternExtractor and then looks for the pattern to be present

See Also:
setPatternExtractor(PatternExtractor), Strings.containsIgnoreCase(String, String)


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads