com.sciapp.filter
Class StringFilter

java.lang.Object
  extended by com.sciapp.filter.Filter
      extended by com.sciapp.filter.StringFilter

public class StringFilter
extends Filter

A string filter.

This filter has three modes: EQUALS, CONTAINS, BEGINS_WITH and ENDS_WITH. It can alsobe 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 ENDS_WITH
          The mode that tests if a string ends with the supplied object.
static int EQUALS
          The mode that tests for equality of the supplied object.
protected  int mode
          The current filter mode.
protected  boolean negate
          boolean indicating whether the string filter returns the negative of the result of each mode.
protected  String pattern
          The filter expression.
 
Fields inherited from class com.sciapp.filter.Filter
acceptNull
 
Constructor Summary
StringFilter()
          Constructs a StringFilter with a default CONTAINS mode and no negation.
 
Method Summary
 boolean accept(Object value)
          Decides whether to accept the value supplied.
 boolean accept(String expression)
          Matches the String expression against the current filter.
 Object getFilterPattern()
          Returns the object used as the filter pattern.
 int getMode()
          Returns the mode of this StringFilter.
 String getPattern()
          Returns the filter expression.
 boolean isCaseSensitive()
          Determines if this string filter is case sensitive.
 boolean isNegate()
          Determines the negation behaviour of the filter.
 void setCaseSensitive(boolean caseSensitive)
          Sets the case sensitivity of this string filter.
 void setFilterPattern(Object filter)
          Sets an object as the filter pattern.
 void setMode(int mode)
          Sets the mode of this StringFilter to mode.
 void setNegate(boolean negate)
          Sets the negation behaviour of the filter.
 void setPattern(String pattern)
          Sets the filter expression.
 
Methods inherited from class com.sciapp.filter.Filter
getAcceptNull, setAcceptNull
 
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

ENDS_WITH

public static final int ENDS_WITH
The mode that tests if a string ends 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.


negate

protected boolean negate
boolean indicating whether the string filter returns the negative of the result of each mode.

Constructor Detail

StringFilter

public StringFilter()
Constructs a StringFilter with a default CONTAINS mode and no negation.

Method Detail

accept

public boolean accept(Object value)
Decides whether to accept the value supplied.

Specified by:
accept in class Filter
Parameters:
value - the object we want to decide if it will be filtered or not.
Returns:
true if the object matched and should not be filtered out, false otherwise.

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

getFilterPattern

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

Specified by:
getFilterPattern in class Filter
Returns:
the object that is currently set as the filter pattern.

getMode

public int getMode()
Returns the mode of this StringFilter. It can either be EQUALS, CONTAINS or BEGINS_WITH.

Returns:
the mode of this string filter.

getPattern

public String getPattern()
Returns the filter expression.

Returns:
the filter expression.

isCaseSensitive

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

Returns:
true if the filter is case sensitive.

isNegate

public boolean isNegate()
Determines the negation behaviour of the filter.

Returns:
true if the filter will negate the result.

setCaseSensitive

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

Parameters:
caseSensitive - the case sensitivity

setFilterPattern

public void setFilterPattern(Object filter)
Sets an object as the filter pattern. Subclasses should provide an implementation that will probably first cast filter to the appropriate object.

Specified by:
setFilterPattern in class Filter
Parameters:
filter - the object to set as the filter pattern

setMode

public void setMode(int mode)
Sets the mode of this StringFilter to mode. It can either be EQUALS, CONTAINS, BEGINS_WITH or ENDS_WITH.

Parameters:
mode - the mode of this string filter.

setNegate

public void setNegate(boolean negate)
Sets the negation behaviour of the filter. If the supplied boolean value is true, the filter will return the negative of the result for each mode.

Parameters:
negate - true if the filter will negate the result, false otherwise.

setPattern

public void setPattern(String pattern)
Sets the filter expression.

Parameters:
pattern - the filter expression.