sdsu.compare
Class ReverseOrderComparer

java.lang.Object
  |
  +--sdsu.compare.Comparer
        |
        +--sdsu.compare.ReverseOrderComparer

public class ReverseOrderComparer
extends Comparer

A comparer to reverse the order used by a Comparer. For example, an IntegerComparer will evaluate lessThen( 3, 10 ) as true. A ReverseOrder on an IntegerComparer will evaluate lessThen( 3, 10 ) as false. Useful for reversing the order of a sort list.

Version:
1.0 4 June 1997
Author:
Roger Whitney (whitney@cs.sdsu.edu)
See Also:
Serialized Form

Method Summary
 boolean equals(java.lang.Object leftOperand, java.lang.Object rightOperand)
          Returns true if the leftOperand is equal to the rightOperand.
static Comparer getInstance(Comparer originalOrder)
          Returns a Comparer with order reversed from the Comparer originalOrder.
 boolean greaterThan(java.lang.Object leftOperand, java.lang.Object rightOperand)
          Returns true if the leftOperand is greater than the rightOperand.
 boolean greaterThanOrEqual(java.lang.Object leftOperand, java.lang.Object rightOperand)
          Returns true if the leftOperand is greater than or equal the rightOperand.
 boolean lessThan(java.lang.Object leftOperand, java.lang.Object rightOperand)
          Returns true if the leftOperand is less than the rightOperand.
 boolean lessThanOrEqual(java.lang.Object leftOperand, java.lang.Object rightOperand)
          Returns true if the leftOperand is less than or equal to the rightOperand.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Comparer getInstance(Comparer originalOrder)
Returns a Comparer with order reversed from the Comparer originalOrder. If originalOrder is already aReverseOrder object, the ReversOrder objects are not nested. The Comparer inside of the originalOrder is used directly

lessThan

public final boolean lessThan(java.lang.Object leftOperand,
                              java.lang.Object rightOperand)
                       throws java.lang.ClassCastException
Returns true if the leftOperand is less than the rightOperand.
Throws:
java.lang.ClassCastException - If operand objects are not proper type. ClassCastException is a RuntimeException, so compiler does not force you to catch this exception.
Overrides:
lessThan in class Comparer

greaterThan

public final boolean greaterThan(java.lang.Object leftOperand,
                                 java.lang.Object rightOperand)
                          throws java.lang.ClassCastException
Returns true if the leftOperand is greater than the rightOperand.
Throws:
java.lang.ClassCastException - If operand objects are not proper type. ClassCastException is a RuntimeException, so compiler does not force you to catch this exception.
Overrides:
greaterThan in class Comparer

equals

public final boolean equals(java.lang.Object leftOperand,
                            java.lang.Object rightOperand)
                     throws java.lang.ClassCastException
Returns true if the leftOperand is equal to the rightOperand.
Throws:
java.lang.ClassCastException - If operand objects are not proper type. ClassCastException is a RuntimeException, so compiler does not force you to catch this exception.
Overrides:
equals in class Comparer

lessThanOrEqual

public final boolean lessThanOrEqual(java.lang.Object leftOperand,
                                     java.lang.Object rightOperand)
                              throws java.lang.ClassCastException
Returns true if the leftOperand is less than or equal to the rightOperand.
Throws:
java.lang.ClassCastException - If operand objects are not proper type. ClassCastException is a RuntimeException, so compiler does not force you to catch this exception.
Overrides:
lessThanOrEqual in class Comparer

greaterThanOrEqual

public final boolean greaterThanOrEqual(java.lang.Object leftOperand,
                                        java.lang.Object rightOperand)
                                 throws java.lang.ClassCastException
Returns true if the leftOperand is greater than or equal the rightOperand.
Throws:
java.lang.ClassCastException - If operand objects are not proper type. ClassCastException is a RuntimeException, so compiler does not force you to catch this exception.
Overrides:
greaterThanOrEqual in class Comparer