kiwi.util
Class StringComparator
java.lang.Object
|
+--kiwi.util.StringComparator
- All Implemented Interfaces:
- Comparator
- public class StringComparator
- extends java.lang.Object
- implements Comparator
A string comparator. This class compares the string representations of
two objects.
- Author:
- Mark Lindner, PING Software Group
Constructor Summary |
StringComparator()
Construct a new case-sensitive StringComparator . |
StringComparator(boolean caseSensitive)
Construct a new StringComparator . |
Method Summary |
int |
compare(java.lang.Object a,
java.lang.Object b)
Compare the string representations of two objects. |
boolean |
isCaseSensitive()
Determine if this comparator is case-sensitive. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
caseSensitive
private boolean caseSensitive
StringComparator
public StringComparator()
- Construct a new case-sensitive
StringComparator
.
StringComparator
public StringComparator(boolean caseSensitive)
- Construct a new
StringComparator
.
- Parameters:
caseSensitive
- A flag specifying whether comparisons will be
case-sensitive.
isCaseSensitive
public boolean isCaseSensitive()
- Determine if this comparator is case-sensitive.
- Returns:
- true if the comparator is case-sensitive, and false
otherwise.
compare
public int compare(java.lang.Object a,
java.lang.Object b)
- Compare the string representations of two objects. A
toString()
is performed on both objects, and then the
resulting strings are compared using the compareTo()
method
of the String
class.
- Specified by:
compare
in interface Comparator
- Parameters:
a
- The first object.b
- The second object.- Returns:
- 0 if the objects are equal, -1 if a is less than
b, and 1 if a is greater than b.