Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.comparators
Class CaseInsensitiveStringComparator

java.lang.Object
  extended by com.citra.comparators.CaseInsensitiveStringComparator
All Implemented Interfaces:
Serializable, Comparator

public class CaseInsensitiveStringComparator
extends Object
implements Comparator, Serializable

This class compares two strings lexicographically, ignoring case differences.

The more general StringComparator can also be used, which allows the changing of case sensitivity at runtime.

See Also:
Serialized Form

Constructor Summary
CaseInsensitiveStringComparator()
           
 
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
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

CaseInsensitiveStringComparator

public CaseInsensitiveStringComparator()
Method Detail

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.

Copyright © 2011 Citra Technologies. All Rights Reserved.