com.sciapp.comparators
Class CaseInsensitiveStringComparator
java.lang.Object
com.sciapp.comparators.CaseInsensitiveStringComparator
- All Implemented Interfaces:
- Comparator
public class CaseInsensitiveStringComparator
- extends Object
- implements Comparator
This class compares two strings lexicographically, ignoring case differences.
Method Summary |
int |
compare(Object o1,
Object o2)
Compares its two arguments for order as defined by compare of the
Comparator interface. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CaseInsensitiveStringComparator
public CaseInsensitiveStringComparator()
compare
public int compare(Object o1,
Object o2)
- Compares its two arguments for order as defined by
compare
of the
Comparator
interface. o1
and o2
must be
Strings, otherwise this method throws a ClassCastException.
This method casts both objects to Strings and compares them using
compareToIgnoreCase
of the String class.
- Specified by:
compare
in interface Comparator
- Parameters:
o1
- the first object to be compared.o2
- the second object to be compared.
- Returns:
- a negative integer, zero, or a positive integer as
o1
is greater than, equal to, or less than o2
, ignoring case considerations.