org.apache.commons.codec
Class StringEncoderComparator
java.lang.Object
org.apache.commons.codec.StringEncoderComparator
- All Implemented Interfaces:
- Comparator
- public class StringEncoderComparator
- extends Object
- implements Comparator
String are comparable, and this comparator allows
you to configure it with an instance of a class
which implements the StringEncoder. This comparator
is used to sort Strings by an encoding shceme 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.
- Version:
- $Id: StringEncoderComparator.java,v 1.9 2003/11/13 06:50:35 ggregory Exp $
- Author:
- Tim O'Brien, Gary Gregory
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 |
stringEncoder
private StringEncoder stringEncoder
- Internal encoder instance.
StringEncoderComparator
public StringEncoderComparator()
- Constructs a new instance.
StringEncoderComparator
public StringEncoderComparator(StringEncoder en)
- Constructs a new instance with the given soundex algorithm.
compare
public 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.
If an
EncoderException
is encountered, return 0
.
- Specified by:
compare
in interface Comparator
- See Also:
Comparable
${component.name} version 1.2 - Copyright © 2003 - Apache Software Foundation