com.sciapp.filter
Class StringFilter

java.lang.Object
  extended by com.sciapp.filter.StringFilter
All Implemented Interfaces:
Filter

public class StringFilter
extends Object
implements Filter

A string filter. This filter has three operation modes: EQUALS, CONTAINS and BEGINS_WITH. Also, it can be case sensitive/insensitive.


Field Summary
static int BEGINS_WITH
          The mode that tests if a string begins with the supplied object.
protected  boolean caseSensitive
          boolean denoting case sensitivity.
static int CONTAINS
          The mode that tests if a string is contained in the supplied object.
static int EQUALS
          The mode that tests for equality of the supplied object.
protected  int mode
          The current filter mode.
protected  String[] options
          The options presented to the user.
protected  String pattern
          The filter expression.
 
Constructor Summary
StringFilter()
          Constructs a StringFilter with a default CONTAINS operation mode.
 
Method Summary
 boolean accept(Object value)
          Matches a specified object against the current filter.
 boolean accept(String expression)
          Matches the String expression against the current filter.
 String[] getDescriptions()
          Returns a string array representing the filter options presented to the user.
 int getMode()
          Returns the current filter operation mode.
 Object getPattern()
          Returns the object used as the filter pattern.
 boolean isCaseSensitive()
          Determines if this string filter is case sensitive.
 void setCaseSensitive(boolean caseSensitive)
          Sets the case sensitivity of this string filter.
 void setMode(int mode)
          Sets the operation mode of the filter.
 void setPattern(Object exp)
          Defines an abstract object to be used as the filter pattern.
 void setPattern(String pattern)
          Sets the filter pattern as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALS

public static final int EQUALS
The mode that tests for equality of the supplied object.

See Also:
Constant Field Values

CONTAINS

public static final int CONTAINS
The mode that tests if a string is contained in the supplied object.

See Also:
Constant Field Values

BEGINS_WITH

public static final int BEGINS_WITH
The mode that tests if a string begins with the supplied object.

See Also:
Constant Field Values

mode

protected int mode
The current filter mode.


caseSensitive

protected boolean caseSensitive
boolean denoting case sensitivity.


pattern

protected String pattern
The filter expression.


options

protected String[] options
The options presented to the user.

Constructor Detail

StringFilter

public StringFilter()
Constructs a StringFilter with a default CONTAINS operation mode.

Method Detail

accept

public boolean accept(Object value)
Matches a specified object against the current filter.

Specified by:
accept in interface Filter
Parameters:
value - the object we want to match
Returns:
true if the object matched

accept

public boolean accept(String expression)
Matches the String expression against the current filter.

Parameters:
expression - the string to match
Returns:
true if the string matched

getDescriptions

public String[] getDescriptions()
Returns a string array representing the filter options presented to the user. The index of each element in this array corresponds to the operation mode of the filter.

Specified by:
getDescriptions in interface Filter
Returns:
the filter options.

getMode

public int getMode()
Returns the current filter operation mode.

Specified by:
getMode in interface Filter
Returns:
the mode the filter is in.

getPattern

public Object getPattern()
Returns the object used as the filter pattern.

Specified by:
getPattern in interface Filter
Returns:
the current filter pattern

isCaseSensitive

public boolean isCaseSensitive()
Determines if this string filter is case sensitive.

Returns:
true if the filter is case sensitive.

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Sets the case sensitivity of this string filter.

Parameters:
caseSensitive - the case sensitivity

setMode

public void setMode(int mode)
Sets the operation mode of the filter.

Specified by:
setMode in interface Filter
Parameters:
mode - the operation mode

setPattern

public void setPattern(Object exp)
Defines an abstract object to be used as the filter pattern.

Specified by:
setPattern in interface Filter
Parameters:
exp - the filter pattern

setPattern

public void setPattern(String pattern)
Sets the filter pattern as a String.

Parameters:
pattern - the filter pattern