comp202.fall2007.a5.filter
Class NumberMatchType

Object
  extended by comp202.fall2007.a5.filter.NumberMatchType

public abstract class NumberMatchType
extends Object

A NumberMatchType object defines a way to determine whether two integer values match. It is used mostly by SongFilters who define conditions based on numeric attributes of Songs, such as the track number or length, to determine whether a Song matches the conditions they define.


Field Summary
static NumberMatchType AT_LEAST
          Implements number matching as a comparison for inequality where the value of the first argument is greater than or equal to the value of the second argument.
static NumberMatchType AT_MOST
          Implements number matching as a comparison for inequality where the value of the first argument is less than or equal to the value of the second argument.
static NumberMatchType EQUAL
          Implements number matching as a comparison for equality.
 
Method Summary
abstract  boolean match(int left, int right)
           Determines whether the first specified integer value matches the second specified integer value according to the matching algorithm implemented by this NumberMatchType.
 String toString()
           Returns a String representation of this NumberMatchType which describes the type of matching it represents.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AT_LEAST

public static final NumberMatchType AT_LEAST
Implements number matching as a comparison for inequality where the value of the first argument is greater than or equal to the value of the second argument. It is used in the construction of SongFilters to indicate that this matching type should be used by the new SongFilter. In other words, if a SongFilter that defines a condition based on a numeric attribute of Songs uses this NumberMatchType, it accepts the Song if the value of the Song's attribute is greater than or equal to the filter value.


AT_MOST

public static final NumberMatchType AT_MOST
Implements number matching as a comparison for inequality where the value of the first argument is less than or equal to the value of the second argument. It is used in the construction of SongFilters to indicate that this matching type should be used by the new SongFilter. In other words, if a SongFilter that defines a condition based on a numeric attribute of Songs uses this NumberMatchType, it accepts the Song if the value of the Song's attribute is less than or equal to the filter value.


EQUAL

public static final NumberMatchType EQUAL
Implements number matching as a comparison for equality. It is used in the construction of SongFilters to indicate that this matching type should be used by the new SongFilter. In other words, if a SongFilter that defines a condition based on a numeric attribute of Songs uses this NumberMatchType, it accepts the Song if the value of the Song's attribute is equal to the filter value.

Method Detail

toString

public String toString()

Returns a String representation of this NumberMatchType which describes the type of matching it represents.

Overrides:
toString in class Object
Returns:
A String representation of this NumberMatchType.

match

public abstract boolean match(int left,
                              int right)

Determines whether the first specified integer value matches the second specified integer value according to the matching algorithm implemented by this NumberMatchType.

This method is called internally by methods defined in the SongFilter class, and does not need to be called by classes which use SongFilters.

Parameters:
left - The first integer value
right - The second integer value
Returns:
true if left matches right according to the type of matching algorithm implemented by this NumberMatchType, false otherwise.