comp202.fall2007.a5.comparator
Class ComparatorFactory

Object
  extended by comp202.fall2007.a5.comparator.ComparatorFactory

public class ComparatorFactory
extends Object

A ComparatorFactory creates SongComparator objects that define certain orders on Songs based on their attributes.


Field Summary
static SongComparator ASCENDING_ALBUM_COMPARATOR
          A SongComparator which defines an order based on the album title attributes of Songs.
static SongComparator ASCENDING_ALBUM_DISC_TRACK_COMPARATOR
          A SongComparator which defines an order equivalent to applying ASCENDING_ALBUM_COMPARATOR, ASCENDING_DISC_COMPARATOR, and ASCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until all three have been tried without one of them determining that one Song occurs before or after another.
static SongComparator ASCENDING_ARTIST_ALBUM_DISC_TRACK_COMPARATOR
          A SongComparator which defines an order equivalent to applying ASCENDING_ARTIST_COMPARATOR, ASCENDING_ALBUM_COMPARATOR, ASCENDING_DISC_COMPARATOR, and ASCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until all four have been tried without one of them determining that one Song occurs before or after another.
static SongComparator ASCENDING_ARTIST_COMPARATOR
          A SongComparator which defines an order based on the artist name attributes of Songs.
static SongComparator ASCENDING_DISC_COMPARATOR
          A SongComparator which defines an order based on the disc number attributes of Songs.
static SongComparator ASCENDING_DISC_TRACK_COMPARATOR
          A SongComparator which defines an order equivalent to applying ASCENDING_DISC_COMPARATOR and ASCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until both have been tried without one of them determining that one Song occurs before or after another.
static SongComparator ASCENDING_LENGTH_COMPARATOR
          A SongComparator which defines an order based on the length attributes of Songs.
static SongComparator ASCENDING_PATH_COMPARATOR
          A SongComparator which defines an order based on the path attributes of Song.
static SongComparator ASCENDING_TITLE_COMPARATOR
          A SongComparator which defines an order based on the track title attributes of Songs.
static SongComparator ASCENDING_TRACK_COMPARATOR
          A SongComparator which defines an order based on the track number attributes of Songs.
static SongComparator DESCENDING_ALBUM_COMPARATOR
          A SongComparator which defines an order based on the album title attributes of Songs.
static SongComparator DESCENDING_ALBUM_DISC_TRACK_COMPARATOR
          A SongComparator which defines an order equivalent to applying DESCENDING_ALBUM_COMPARATOR, DESCENDING_DISC_COMPARATOR, and DESCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until all three have been tried without one of them determining that one Song occurs before or after another.
static SongComparator DESCENDING_ARTIST_ALBUM_DISC_TRACK_COMPARATOR
          A SongComparator which defines an order equivalent to applying DESCENDING_ARTIST_COMPARATOR, DESCENDING_ALBUM_COMPARATOR, DESCENDING_DISC_COMPARATOR, and DESCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until all four have been tried without one of them determining that one Song occurs before or after another.
static SongComparator DESCENDING_ARTIST_COMPARATOR
          A SongComparator which defines an order based on the artist name attributes of Songs.
static SongComparator DESCENDING_DISC_COMPARATOR
          A SongComparator which defines an order based on the disc number attributes of Songs.
static SongComparator DESCENDING_DISC_TRACK_COMPARATOR
          A SongComparator which defines an order equivalent to applying DESCENDING_DISC_COMPARATOR and DESCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until both have been tried without one of them determining that one Song occurs before or after another.
static SongComparator DESCENDING_LENGTH_COMPARATOR
          A SongComparator which defines an order based on the length attributes of Songs.
static SongComparator DESCENDING_PATH_COMPARATOR
          A SongComparator which defines an order based on the path attributes of Songs.
static SongComparator DESCENDING_TITLE_COMPARATOR
          A SongComparator which defines an order based on the track title attributes of Songs.
static SongComparator DESCENDING_TRACK_COMPARATOR
          A SongComparator which defines an order based on the track number attributes of Songs.
 
Constructor Summary
ComparatorFactory()
          Creates a new ComparatorFactory.
 
Method Summary
 SongComparator createMultiComparator(java.util.ArrayList<SongComparator> subComparators)
           Creates a new SongComparator which defines an order that is the combination of the individual SongComparators in the specified ArrayList.
 SongComparator createMultiComparator(SongComparator[] subComparators)
           Creates a new SongComparator which defines an order that is the combination of the individual SongComparators in the specified array.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASCENDING_ARTIST_COMPARATOR

public static final SongComparator ASCENDING_ARTIST_COMPARATOR
A SongComparator which defines an order based on the artist name attributes of Songs. In this order, a Song is defined to appear before another if the value of its artist name attribute appears lexicographically before the value of the artist name attribute of the other Song, using a case-insensitive comparison.


DESCENDING_ARTIST_COMPARATOR

public static final SongComparator DESCENDING_ARTIST_COMPARATOR
A SongComparator which defines an order based on the artist name attributes of Songs. In this order, a Song is defined to appear before another if the value of its artist name attribute appears lexicographically after the value of the artist name attribute of the other Song, using a case-insensitive comparison.


ASCENDING_ALBUM_COMPARATOR

public static final SongComparator ASCENDING_ALBUM_COMPARATOR
A SongComparator which defines an order based on the album title attributes of Songs. In this order, a Song is defined to appear before another if the value of its album title attribute appears lexicographically before the value of the album title attribute of the other Song, using a case-insensitive comparison.


DESCENDING_ALBUM_COMPARATOR

public static final SongComparator DESCENDING_ALBUM_COMPARATOR
A SongComparator which defines an order based on the album title attributes of Songs. In this order, a Song is defined to appear before another if the value of its album title attribute appears lexicographically after the value of the album title attribute of the other Song, using a case-insensitive comparison.


ASCENDING_DISC_COMPARATOR

public static final SongComparator ASCENDING_DISC_COMPARATOR
A SongComparator which defines an order based on the disc number attributes of Songs. In this order, a Song is defined to appear before another if the value of its disc number attribute is less than the value of the disc number attribute of the other Song.


DESCENDING_DISC_COMPARATOR

public static final SongComparator DESCENDING_DISC_COMPARATOR
A SongComparator which defines an order based on the disc number attributes of Songs. In this order, a Song is defined to appear before another if the value of its disc number attribute is greater than the value of the disc number attribute of the other Song.


ASCENDING_TRACK_COMPARATOR

public static final SongComparator ASCENDING_TRACK_COMPARATOR
A SongComparator which defines an order based on the track number attributes of Songs. In this order, a Song is defined to appear before another if the value of its track number attribute is less than the value of the track number attribute of the other Song.


DESCENDING_TRACK_COMPARATOR

public static final SongComparator DESCENDING_TRACK_COMPARATOR
A SongComparator which defines an order based on the track number attributes of Songs. In this order, a Song is defined to appear before another if the value of its track number attribute is greater than the value of the track number attribute of the other Song.


ASCENDING_PATH_COMPARATOR

public static final SongComparator ASCENDING_PATH_COMPARATOR
A SongComparator which defines an order based on the path attributes of Song. In this order, a Song is defined to appear before another if the path of the file containing the corresponding audio track appears before the path of the file containing the audio track corresponding of the other Song, using the natural order defined by the compareTo() method of the File class.


DESCENDING_PATH_COMPARATOR

public static final SongComparator DESCENDING_PATH_COMPARATOR
A SongComparator which defines an order based on the path attributes of Songs. In this order, a Song is defined to appear before another if the path of the file containing the corresponding audio track appears after the path of the file containing the audio track corresponding to the other Song, using the natural order defined by the compareTo() method of the File class.


ASCENDING_TITLE_COMPARATOR

public static final SongComparator ASCENDING_TITLE_COMPARATOR
A SongComparator which defines an order based on the track title attributes of Songs. In this order, a Song is defined to appear before another if the value of its track title attribute appears lexicographically before the value of the track title attribute of the other Song, using a case-insensitive comparison.


DESCENDING_TITLE_COMPARATOR

public static final SongComparator DESCENDING_TITLE_COMPARATOR
A SongComparator which defines an order based on the track title attributes of Songs. In this order, a Song is defined to appear before another if the value of its track title attribute appears lexicographically after the value of the track title attribute of the other Song, using a case-insensitive comparison.


ASCENDING_LENGTH_COMPARATOR

public static final SongComparator ASCENDING_LENGTH_COMPARATOR
A SongComparator which defines an order based on the length attributes of Songs. In this order, a Song is defined to appear before another if the value of its length attribute is less than the value of the length attribute of the other Song.


DESCENDING_LENGTH_COMPARATOR

public static final SongComparator DESCENDING_LENGTH_COMPARATOR
A SongComparator which defines an order based on the length attributes of Songs. In this order, a Song is defined to appear before another if the value of its length attribute is greater than the value of the length attribute of the other Song.


ASCENDING_DISC_TRACK_COMPARATOR

public static final SongComparator ASCENDING_DISC_TRACK_COMPARATOR
A SongComparator which defines an order equivalent to applying ASCENDING_DISC_COMPARATOR and ASCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until both have been tried without one of them determining that one Song occurs before or after another.


DESCENDING_DISC_TRACK_COMPARATOR

public static final SongComparator DESCENDING_DISC_TRACK_COMPARATOR
A SongComparator which defines an order equivalent to applying DESCENDING_DISC_COMPARATOR and DESCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until both have been tried without one of them determining that one Song occurs before or after another.


ASCENDING_ALBUM_DISC_TRACK_COMPARATOR

public static final SongComparator ASCENDING_ALBUM_DISC_TRACK_COMPARATOR
A SongComparator which defines an order equivalent to applying ASCENDING_ALBUM_COMPARATOR, ASCENDING_DISC_COMPARATOR, and ASCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until all three have been tried without one of them determining that one Song occurs before or after another.


DESCENDING_ALBUM_DISC_TRACK_COMPARATOR

public static final SongComparator DESCENDING_ALBUM_DISC_TRACK_COMPARATOR
A SongComparator which defines an order equivalent to applying DESCENDING_ALBUM_COMPARATOR, DESCENDING_DISC_COMPARATOR, and DESCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until all three have been tried without one of them determining that one Song occurs before or after another.


ASCENDING_ARTIST_ALBUM_DISC_TRACK_COMPARATOR

public static final SongComparator ASCENDING_ARTIST_ALBUM_DISC_TRACK_COMPARATOR
A SongComparator which defines an order equivalent to applying ASCENDING_ARTIST_COMPARATOR, ASCENDING_ALBUM_COMPARATOR, ASCENDING_DISC_COMPARATOR, and ASCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until all four have been tried without one of them determining that one Song occurs before or after another.


DESCENDING_ARTIST_ALBUM_DISC_TRACK_COMPARATOR

public static final SongComparator DESCENDING_ARTIST_ALBUM_DISC_TRACK_COMPARATOR
A SongComparator which defines an order equivalent to applying DESCENDING_ARTIST_COMPARATOR, DESCENDING_ALBUM_COMPARATOR, DESCENDING_DISC_COMPARATOR, and DESCENDING_TRACK_COMPARATOR, in that order, until one of them determines that a Song occurs before or after the other, or until all four have been tried without one of them determining that one Song occurs before or after another.

Constructor Detail

ComparatorFactory

public ComparatorFactory()
Creates a new ComparatorFactory.

Method Detail

createMultiComparator

public SongComparator createMultiComparator(java.util.ArrayList<SongComparator> subComparators)

Creates a new SongComparator which defines an order that is the combination of the individual SongComparators in the specified ArrayList.

The order defined by the returned SongComparator is determined by applying the SongComparators in the specified ArrayList, in the order in which they appear in the specified ArrayList. This process is repeated until one of the SongComparators determines that a Song occurs before or after the other in the order it defines, or until all the SongComparator in the specified ArrayList have been tried without one determining that one of the Songs occurs before or after the other in the orders they define.

null elements contained in the specified ArrayList are not included in the new SongComparator. Subsequent changes to the specified ArrayList do not affect the SongComparator returned by this method.

Parameters:
subComparators - An ArrayList containing the individual SongComparators which are to be part of the returned SongComparator.
Returns:
A SongComparator which is the combination of the SongComparators in subComparators.
Throws:
NullPointerException - if subComparators is null.

createMultiComparator

public SongComparator createMultiComparator(SongComparator[] subComparators)

Creates a new SongComparator which defines an order that is the combination of the individual SongComparators in the specified array.

The order defined by the returned is determined by applying the SongComparators in the specified array, in the order in which they appear in the specified array. This process is repeated until one of the SongComparators determines that a Song occurs before or after the other in the order it defines, or until all the SongComparator in the specified array have been tried without one determining that one of the Songs occurs before or after the other in the orders they define.

null elements contained in the specified array are not included in the new SongComparator. Subsequent changes to the specified array do not affect the SongComparator returned by this method.

Parameters:
subComparators - An array containing the individual SongComparators which are to be part of the returned SongComparator.
Returns:
A SongComparator which is the combination of the SongComparator in subComparators.
Throws:
NullPointerException - if subComparators is null.