|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.codec.StringEncoderComparator
public class StringEncoderComparator
Strings are comparable, and this comparator allows you to configure it with an instance of a class which implements StringEncoder. This comparator is used to sort Strings by an encoding scheme such as Soundex, Metaphone, etc. This class can come in handy if one need to sort Strings by an encoded form of a name such as Soundex.
Constructor Summary | |
---|---|
StringEncoderComparator()
Deprecated. as creating without a StringEncoder will lead to a broken NullPointerException creating comparator. |
|
StringEncoderComparator(StringEncoder stringEncoder)
Constructs a new instance with the given algorithm. |
Method Summary | |
---|---|
int |
compare(Object o1,
Object o2)
Compares two strings based not on the strings themselves, but on an encoding of the two strings using the StringEncoder this Comparator was created with. |
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 |
---|
public StringEncoderComparator()
public StringEncoderComparator(StringEncoder stringEncoder)
stringEncoder
- the StringEncoder used for comparisons.Method Detail |
---|
public int compare(Object o1, Object o2)
EncoderException
is encountered, return 0
.
compare
in interface Comparator
o1
- the object to compareo2
- the object to compare to
Comparable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |