Mp3dings 
20100427

net.sourceforge.mp3dings.filter
Class NumericFilter

java.lang.Object
  extended by net.sourceforge.mp3dings.utils.Bean
      extended by net.sourceforge.mp3dings.filter.FilterBean
          extended by net.sourceforge.mp3dings.filter.NumericFilter
All Implemented Interfaces:
Serializable, Filter

public class NumericFilter
extends FilterBean
implements Serializable

A filter that accepts or rejects a numeric value depending on whether this value is inside or outside a given numeric range.

Version:
$Revision: 13 $ ($Date: 2007-07-27 11:52:39 +0200 (Fr, 27 Jul 2007) $)
Author:
Moritz Ringler
See Also:
Serialized Form

Field Summary
static boolean EXCLUDE
           
static boolean INCLUDE
           
 
Fields inherited from class net.sourceforge.mp3dings.utils.Bean
L_NO_ID, NO_ID, PROPERTY_ID, PROPERTY_NAME
 
Constructor Summary
NumericFilter()
          Default constructor.
NumericFilter(int lbound, int ubound, boolean incl)
          Constructs a new NumericFilter for the given field, with the given bounds and the given inclusion behaviour.
 
Method Summary
 boolean equals(Object o)
           
 Object filter(Object val)
          Compares val to the filter bounds if val is a number.
 int[] getBounds()
          Queries the bounds of this filter.
 boolean getInclude()
          Returns whether this filter currently accepts or rejects numbers inside the given numeric range.
 int getLowerBound()
           
 int getUpperBound()
           
 int hashCode()
           
static Bean load(Preferences pref, String key)
           
 void setBounds(int lbound, int ubound)
          Sets the filter bounds.
 void setInclude(boolean incl)
          Sets whether this filter accepts (INCLUDE) or rejects (EXCLUDE) numbers inside the given numeric range.
 void setLowerBound(int lowerBound)
           
 void setUpperBound(int upperBound)
           
 
Methods inherited from class net.sourceforge.mp3dings.utils.Bean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getConstraints, getId, getName, getPropertyChangeListeners, getPropertyChangeListeners, isSavable, load, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCLUDE

public static final boolean INCLUDE
See Also:
setInclude(boolean), Constant Field Values

EXCLUDE

public static final boolean EXCLUDE
See Also:
setInclude(boolean), Constant Field Values
Constructor Detail

NumericFilter

public NumericFilter()
Default constructor. Same as NumericFilter(Integer.MIN_VALUE, Integer.MAX_VALUE, 1)

See Also:
NumericFilter(int, int, boolean)

NumericFilter

public NumericFilter(int lbound,
                     int ubound,
                     boolean incl)
Constructs a new NumericFilter for the given field, with the given bounds and the given inclusion behaviour.

Parameters:
lbound - Lower bound.
ubound - Upper bound.
incl - Sets whether this filter accepts or rejects numbers in the open range (lbound, ubound).
See Also:
setBounds(int, int), setInclude(boolean)
Method Detail

load

public static Bean load(Preferences pref,
                        String key)

setBounds

public void setBounds(int lbound,
                      int ubound)
Sets the filter bounds. The filter range will be the open range (lbound;ubound). Use Double.NEGATIVE_INFINITY and Double.POSITIVE_INFINITY where appropriate.

Parameters:
lbound - Lower bound.
ubound - Upper bound.
See Also:
getBounds()

getBounds

public int[] getBounds()
Queries the bounds of this filter.

Returns:
An array that has the lower bound at index 0 and the upper bound at index 1;
See Also:
setBounds(int, int)

filter

public Object filter(Object val)
Compares val to the filter bounds if val is a number.

Specified by:
filter in interface Filter
Specified by:
filter in class FilterBean
Parameters:
val - the value to filter
Returns:
null if val is numeric and NOT inside the filter bounds, otherwise the unchanged object val is returned.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

setLowerBound

public void setLowerBound(int lowerBound)

getLowerBound

public int getLowerBound()

setUpperBound

public void setUpperBound(int upperBound)

getUpperBound

public int getUpperBound()

getInclude

public boolean getInclude()
Returns whether this filter currently accepts or rejects numbers inside the given numeric range.

Returns:
incl one of INCLUDE and EXCLUDE
See Also:
setInclude(boolean)

setInclude

public void setInclude(boolean incl)
Sets whether this filter accepts (INCLUDE) or rejects (EXCLUDE) numbers inside the given numeric range.

Parameters:
incl - one of INCLUDE and EXCLUDE
See Also:
getInclude()

Mp3dings 
20100427