comp202.fall2007.a5.comparator
Class SongComparator

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

public abstract class SongComparator
extends Object

A SongComparator object defines an order on Songs. This order is total; that is, it is defined for any pair of Songs. However, it is possible that this order is not strict; that is, it is possible that for certain pairs of Songs, neither Song appears before or after the other. This situation occurs when the order defined by a SongComparator is based on some attributes of Songs, and the two Songs in the pair have equal values for these attributes.


Constructor Summary
SongComparator()
          Creates a new SongComparator.
 
Method Summary
abstract  int compareTo(Song left, Song right)
           Compares the two specified Songs and determines whether or not one occurs before the other in the order defined by this SongComparator.
abstract  String toString()
          Returns a String representation of this SongComparator, which describes the order it defines.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SongComparator

public SongComparator()
Creates a new SongComparator.

Method Detail

compareTo

public abstract int compareTo(Song left,
                              Song right)

Compares the two specified Songs and determines whether or not one occurs before the other in the order defined by this SongComparator.

If the first specified Song occurs before the second specified Song in the order defined by this SongComparator, this method returns a negative number. If the second specified Song occurs before the first specified Song in the order defined by this SongComparator, this method returns a positive number. If neither of the specified Song appears before the other in the order defined by this SongComparator, this method returns 0.

Parameters:
left - A Song.
right - Another Song.
Returns:
A negative number, 0, or a positive number if left occurs before, neither before nor after, or after right, respectively.

toString

public abstract String toString()
Returns a String representation of this SongComparator, which describes the order it defines.

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