comp202.fall2007.a5.filter
Class StringMatchType

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

public abstract class StringMatchType
extends Object

A StringMatchType object defines a way to determine whether two Strings match. It is used mostly by SongFilters who define conditions based on text attributes of Songs, such as the artist name or album title, to determine whether a Song matches the conditions they define.


Field Summary
static StringMatchType CONTAINS
           Implements String matching as substring.
static StringMatchType EQUALS
           Implements String matching as comparison for equality.
 
Method Summary
abstract  boolean match(String left, String right, boolean ignorecase)
           Determines whether the first specified String matches the second specified String according to the matching algorithm implemented by this StringMatchType.
 String toString()
           Returns a String representation of this StringMatchType 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

EQUALS

public static final StringMatchType EQUALS

Implements String matching as comparison for equality. Used in the construction of SongFilters to indicate that equality matching should be used by a SongFilter. In other words, if a SongFilter that defines a condition based on a text attribute of Songs uses this StringMatchType, it accepts the Song if the value of the Song's attribute is equal to the filter value.


CONTAINS

public static final StringMatchType CONTAINS

Implements String matching as substring. Used in the construction of SongFilters to indicate that substring matching should be used by a SongFilter. In other words, if a SongFilter that defines a condition based on a text attribute of Songs uses this StringMatchType, it accepts the Song if the value of the Song's attribute contains the filter value as a substring.

Method Detail

toString

public String toString()

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

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

match

public abstract boolean match(String left,
                              String right,
                              boolean ignorecase)

Determines whether the first specified String matches the second specified String according to the matching algorithm implemented by this StringMatchType.

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 String
right - The second String
ignorecase - true if the alphabetic case of letters should be ignored when deciding whether left and right match, false otherwise.
Returns:
true if left matches right according to the type of matching algorithm implemented by this StringMatchType, false otherwise.