|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sciapp.comparators.StringComparator
public class StringComparator
This class compares two strings lexicographically.
The case sensitivity can be controlled with setCaseSensitive(boolean)
.
Field Summary | |
---|---|
protected boolean |
caseSensitive
a boolean flag indicating the case-sensitivity of the String comparator. |
Constructor Summary | |
---|---|
StringComparator()
Creates a case-insensitive String comparator. |
|
StringComparator(boolean caseSensitivity)
Creates a String comparator. |
Method Summary | |
---|---|
int |
compare(Object o1,
Object o2)
Compares its two arguments for order as defined by compare of the
Comparator interface. |
boolean |
isCaseSensitive()
Determines if this comparator is case sensitive. |
void |
setCaseSensitive(boolean caseSensitivity)
Sets the case sensitivity of this string comparator. |
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 |
Field Detail |
---|
protected boolean caseSensitive
Constructor Detail |
---|
public StringComparator()
public StringComparator(boolean caseSensitivity)
The case sensitivity is determined by the caseSensitivity parameter.
caseSensitivity
- the case sensitivity of the comparator.Method Detail |
---|
public int compare(Object o1, Object o2)
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
compareTo
or compareToIgnoreCase
of the String class.
compare
in interface Comparator
o1
- the first object to be compared.o2
- the second object to be compared.
o1
is less than, equal to, or greater than o2
.public boolean isCaseSensitive()
public void setCaseSensitive(boolean caseSensitivity)
caseSensitivity
- the case sensitivity
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |