comp202.fall2007.a5.filter
Class FilterFactory

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

public class FilterFactory
extends Object

A FilterFactory provides methods to create SongFilters that define various conditions based on the attributes of Songs, or on the conditions defined by other SongFilters.


Constructor Summary
FilterFactory()
          Creates a new FilterFactory.
 
Method Summary
 SongFilter createAlbumFilter(String albumTitle, StringMatchType matchType)
           Creates a new SongFilter which accepts all Songs whose album attribute matches the specified String, using a match type defined by the specified StringMatchType.
 SongFilter createAndFilter(java.util.ArrayList<SongFilter> subFilters)
           Creates a new SongFilter object which accepts a given Song if and only if all SongFilters in the specified ArrayList accept the given Song.
 SongFilter createAndFilter(SongFilter[] subFilters)
           Creates a new SongFilter object which accepts a given Song if and only if all SongFilters in the specified array accept the given Song.
 SongFilter createArtistFilter(String artistName, StringMatchType matchType)
           Creates a new SongFilter which accepts all Songs whose artist attribute matches the specified String, using a match type defined by the specified StringMatchType.
 SongFilter createDiscFilter(int discNumber, NumberMatchType matchType)
           Creates a new SongFilter which accepts all Songs whose disc attribute matches the specified integer, using a match type defined by the specified NumberMatchType.
 SongFilter createEverythingFilter()
           Creates a new SongFilter which accepts every Song.
 SongFilter createLengthFilter(int length, NumberMatchType matchType)
           Creates a new SongFilter which accepts all Songs whose length attribute matches the specified String, using a match type defined by the specified NumberMatchType.
 SongFilter createNotFilter(SongFilter subFilter)
           Creates a new SongFilter which is the negation of the specified SongFilter; that is, if the specified SongFilter accepts a Song, the returned SongFilter rejects it, and vice-versa.
 SongFilter createNothingFilter()
           Creates a new SongFilter which rejects every Song.
 SongFilter createOrFilter(java.util.ArrayList<SongFilter> subFilters)
           Creates a new SongFilter object which accepts a given Song if and only if at least one of the SongFilters in the specified ArrayList accepts the given Song.
 SongFilter createOrFilter(SongFilter[] subFilters)
           Creates a new SongFilter object which accepts a given Song if and only if at least one of the SongFilters in the specified array accepts the given Song.
 SongFilter createPathFilter(java.io.File songPath)
           Creates a new SongFilter which accepts all Songs whose path attribute is equal to the specified File, as defined by the equality of File objects.
 SongFilter createTitleFilter(String songTitle, StringMatchType matchType)
           Creates a new SongFilter which accepts all Songs whose title attribute matches the specified String, using a match type defined by the specified StringMatchType.
 SongFilter createTrackFilter(int trackNumber, NumberMatchType matchType)
           Creates a new SongFilter which accepts all Songs whose track number attribute matches the specified integer, using a match type defined by the specified NumberMatchType.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterFactory

public FilterFactory()
Creates a new FilterFactory.

Method Detail

createAlbumFilter

public SongFilter createAlbumFilter(String albumTitle,
                                    StringMatchType matchType)

Creates a new SongFilter which accepts all Songs whose album attribute matches the specified String, using a match type defined by the specified StringMatchType.

Parameters:
albumTitle - The album title used in the condition defined by the returned SongFilter.
matchType - The type of comparison used by the returned SongFilter to determine whether a Song's album attribute matches albumTitle. The comparison is case-INsensitive.
Returns:
A new SongFilter which accepts all Songs whose album attribute matches albumTitle, according to the type of comparison defined by matchType.

createArtistFilter

public SongFilter createArtistFilter(String artistName,
                                     StringMatchType matchType)

Creates a new SongFilter which accepts all Songs whose artist attribute matches the specified String, using a match type defined by the specified StringMatchType.

Parameters:
artistName - The artist name used in the condition defined by the returned SongFilter.
matchType - The type of comparison used by the returned SongFilter to determine whether a Song's artist attribute matches artistTitle. The comparison is case-INsensitive.
Returns:
A new SongFilter which accepts all Songs whose artist attribute matches albumTitle, according to the type of comparison defined by matchType.

createTitleFilter

public SongFilter createTitleFilter(String songTitle,
                                    StringMatchType matchType)

Creates a new SongFilter which accepts all Songs whose title attribute matches the specified String, using a match type defined by the specified StringMatchType.

Parameters:
songTitle - The song title used in the condition defined by the returned SongFilter.
matchType - The type of comparison used by the returned SongFilter to determine whether a Song's title attribute matches artistTitle. The comparison is case-INsensitive.
Returns:
A new SongFilter which accepts all Songs whose title attribute matches albumTitle, according to the type of comparison defined by matchType.

createPathFilter

public SongFilter createPathFilter(java.io.File songPath)

Creates a new SongFilter which accepts all Songs whose path attribute is equal to the specified File, as defined by the equality of File objects.

Parameters:
songPath - The path used in the condition defined by the returned SongFilter.
Returns:
A new SongFilter which accepts all Songs whose path attribute is equal to songPath.

createLengthFilter

public SongFilter createLengthFilter(int length,
                                     NumberMatchType matchType)

Creates a new SongFilter which accepts all Songs whose length attribute matches the specified String, using a match type defined by the specified NumberMatchType.

Parameters:
length - The length value used in the condition defined by the returned SongFilter.
matchType - The type of comparison used by the returned SongFilter to determine whether a Song's length matches length.
Returns:
A new SongFilter which accepts all Songs whose length attribute matches length, according to the type of comparison defined by matchType.

createDiscFilter

public SongFilter createDiscFilter(int discNumber,
                                   NumberMatchType matchType)

Creates a new SongFilter which accepts all Songs whose disc attribute matches the specified integer, using a match type defined by the specified NumberMatchType.

Parameters:
discNumber - The disc number used in the condition defined by the returned SongFilter.
matchType - The type of comparison used by the returned SongFilter to determine whether a Song's disc number matches discNumber.
Returns:
A new SongFilter which accepts all Songs whose disc number attribute matches discNumber, according to the type of comparison defined by matchType.

createTrackFilter

public SongFilter createTrackFilter(int trackNumber,
                                    NumberMatchType matchType)

Creates a new SongFilter which accepts all Songs whose track number attribute matches the specified integer, using a match type defined by the specified NumberMatchType.

Parameters:
trackNumber - The track number used in the condition defined by the returned SongFilter.
matchType - The type of comparison used by the returned SongFilter to determine whether a Song's track number matches discNumber.
Returns:
A new SongFilter which accepts all Songs whose track number attribute matches trackNumber, according to the type of comparison defined by matchType.

createEverythingFilter

public SongFilter createEverythingFilter()

Creates a new SongFilter which accepts every Song. That is, the returned SongFilter's accept() method always returns true.

Returns:
A new SongFilter which accepts every Song.

createNothingFilter

public SongFilter createNothingFilter()

Creates a new SongFilter which rejects every Song. That is, the returned SongFilter's accept() method always returns false.

Returns:
A new SongFilter which rejects every Song.

createAndFilter

public SongFilter createAndFilter(java.util.ArrayList<SongFilter> subFilters)

Creates a new SongFilter object which accepts a given Song if and only if all SongFilters in the specified ArrayList accept the given Song.

Subsequent changes to the specified ArrayList do not affect the state of the SongFilter that this method creates and returns.

Parameters:
subFilters - An ArrayList of SongFilters; to be accepted by the newly-created SongFilter, a Song must be accepted by all SongFilters in this ArrayList.
Returns:
A new SongFilter which accepts a given Song if and only if all SongFilters in subFilters accept the given Song.

createAndFilter

public SongFilter createAndFilter(SongFilter[] subFilters)

Creates a new SongFilter object which accepts a given Song if and only if all SongFilters in the specified array accept the given Song.

Subsequent changes to the specified array do not affect the state of the SongFilter that this method creates and returns.

Parameters:
subFilters - An array of SongFilters; to be accepted by the newly-created SongFilter, a Song must be accepted by all SongFilters in this array.
Returns:
A new SongFilter which accepts a given Song if and only if all SongFilters in subFilters accept the given Song.

createOrFilter

public SongFilter createOrFilter(java.util.ArrayList<SongFilter> subFilters)

Creates a new SongFilter object which accepts a given Song if and only if at least one of the SongFilters in the specified ArrayList accepts the given Song.

Subsequent changes to the specified ArrayList do not affect the state of the SongFilter that this method creates and returns.

Parameters:
subFilters - An ArrayList of SongFilters; to be accepted by the newly-created SongFilter, a Song must be accepted by at least one SongFilter in this ArrayList.
Returns:
A new SongFilter which accepts a given Song if and only if at least one SongFilter in subFilters accepts the given Song.

createOrFilter

public SongFilter createOrFilter(SongFilter[] subFilters)

Creates a new SongFilter object which accepts a given Song if and only if at least one of the SongFilters in the specified array accepts the given Song.

Subsequent changes to the specified array do not affect the state of the SongFilter that this method creates and returns.

Parameters:
subFilters - An array of SongFilters; to be accepted by the newly-created SongFilter, a Song must be accepted by at least one SongFilters in this array.
Returns:
A new SongFilter which accepts a given Song if and only if at least one SongFilter in subFilters accepts the given Song.

createNotFilter

public SongFilter createNotFilter(SongFilter subFilter)

Creates a new SongFilter which is the negation of the specified SongFilter; that is, if the specified SongFilter accepts a Song, the returned SongFilter rejects it, and vice-versa.

Parameters:
subFilter - A SongFilter.
Returns:
A new SongFilter which accepts all Songs rejected by subFilter, and vice-versa.