net.rim.device.api.util
Class InvertedOrderComparator

java.lang.Object
  extended by net.rim.device.api.util.InvertedOrderComparator
All Implemented Interfaces:
Comparator

public final class InvertedOrderComparator
extends Object
implements Comparator

Comparator to do inverted total orderings on collections of objects.

Build this comparator with another comparator that does, for example, an ascending order of data. You can then use this class to impose a descending order on the same data.


Constructor Summary
InvertedOrderComparator(Comparator comparator)
          Creates a new InvertedOrderComparator instance.
 
Method Summary
 int compare(Object o1, Object o2)
          Compares two arguments for order.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.rim.device.api.util.Comparator
equals
 



Constructor Detail

InvertedOrderComparator

public InvertedOrderComparator(Comparator comparator)
Creates a new InvertedOrderComparator instance.

Parameters:
comparator - Comparator whose ordering to invert.


Method Detail

compare

public int compare(Object o1,
                   Object o2)
Compares two arguments for order.

This method simply invokes compare(o2,o1) on the Comparator parameter you passed to the constructor.

Specified by:
compare in interface Comparator
Parameters:
o1 - First object to compare.
o2 - Second object to compare.
Returns:
Negative integer if the first object is 'greater than' the second; a positive integer if the second object is 'less than' the second; zero if the two objects are 'equal'.





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.