net.rim.device.api.util
Class StringComparator

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

public class StringComparator
extends Object
implements Comparator

A basic Comparator implementation to compare String instances either case-sensitively or case-insensitively.

Since:
BlackBerry API 4.5.0

Method Summary
 int compare(Object o1, Object o2)
          Compares the two strings lexicographically using the desired case-sensitivity.
static StringComparator getInstance(boolean ignoreCase)
          Returns an instance of a StringComparator with the desired case sensitivity.
 
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
 



Method Detail

getInstance

public static final StringComparator getInstance(boolean ignoreCase)
Returns an instance of a StringComparator with the desired case sensitivity.

Parameters:
ignoreCase - Whether or not the StringComparator should be case-insensitive.
Returns:
The desired StringComparator instance.
Since:
BlackBerry API 4.5.0

compare

public int compare(Object o1,
                   Object o2)
Compares the two strings lexicographically using the desired case-sensitivity.

Specified by:
compare in interface Comparator
Parameters:
o1 - First string to compare
o2 - Second string to compare
Returns:
0 if the two strings are equal, less than zero if o1 is less than o2, greater than zero if o1 is greater than o2.
Throws:
NullPointerException - if either o1 or o2 is null
ClassCastException - if the run-time type of either o1 or o2 is not String
Since:
BlackBerry API 4.5.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal