com.sciapp.filter
Class NumericFilter

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

public class NumericFilter
extends Object
implements Filter

A general numeric filter. This filter is suitable for all Number objects, although the actual filtering uses only int values.

If the filter pattern is not a number, then this filter will match all objects.


Field Summary
static int EQUAL_TO
          The mode that tests if a number is equal to another.
static int LESS_EQUAL_TO
          The mode that tests if a number is less than or equal to another.
static int LESS_THAN
          The mode that tests if a number is less than another.
protected  int mode
          The current filtering mode.
static int MORE_EQUAL_TO
          The mode that tests if a number more or equal to another.
static int MORE_THAN
          The mode that tests if a number is more than another.
protected  String[] options
          The options presented to the user.
protected  int value
          The filter pattern as an integer value.
 
Constructor Summary
NumericFilter()
          Constructs a NumericFilter with an EQUAL_TO operation mode.
 
Method Summary
 boolean accept(int i)
          Matches the integer value i against the current filter.
 boolean accept(Object value)
          Matches a specified object 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. This object is always an Integer, regardless of what object we used in setPattern.
 void setMode(int mode)
          Sets the operation mode of the filter.
 void setPattern(int i)
          Sets the filter pattern to i.
 void setPattern(Object pattern)
          Defines an abstract object to be used as the filter pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LESS_THAN

public static final int LESS_THAN
The mode that tests if a number is less than another.

See Also:
Constant Field Values

LESS_EQUAL_TO

public static final int LESS_EQUAL_TO
The mode that tests if a number is less than or equal to another.

See Also:
Constant Field Values

EQUAL_TO

public static final int EQUAL_TO
The mode that tests if a number is equal to another.

See Also:
Constant Field Values

MORE_EQUAL_TO

public static final int MORE_EQUAL_TO
The mode that tests if a number more or equal to another.

See Also:
Constant Field Values

MORE_THAN

public static final int MORE_THAN
The mode that tests if a number is more than another.

See Also:
Constant Field Values

value

protected int value
The filter pattern as an integer value.


mode

protected int mode
The current filtering mode.


options

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

Constructor Detail

NumericFilter

public NumericFilter()
Constructs a NumericFilter with an EQUAL_TO operation mode.

Method Detail

accept

public boolean accept(int i)
Matches the integer value i against the current filter.

Parameters:
i - the integer to match
Returns:
true if the value matched

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

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.

This object is always an Integer, regardless of what object we used in setPattern.

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

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(int i)
Sets the filter pattern to i.

Parameters:
i - an integer value used as the filter pattern.

setPattern

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

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