org.apache.commons.codec
Class StringEncoderComparator

java.lang.Object
  |
  +--org.apache.commons.codec.StringEncoderComparator
All Implemented Interfaces:
java.util.Comparator

public class StringEncoderComparator
extends java.lang.Object
implements java.util.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:
$Revision: 1.1 $ $Date: 2003/04/25 17:50:56 $
Author:
Tim O'Brien

Constructor Summary
StringEncoderComparator()
          A no-arg, do-nothing constructor
StringEncoderComparator(StringEncoder en)
          Use the provided soundex algorithm.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compare 2 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

StringEncoderComparator

public StringEncoderComparator()
A no-arg, do-nothing constructor


StringEncoderComparator

public StringEncoderComparator(StringEncoder en)
Use the provided soundex algorithm.

Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compare 2 strings based not on the strings themselves, but on an encoding of the two strings using the StringEncoder this Comparator was created with.

Specified by:
compare in interface java.util.Comparator


Copyright © 2002-2003 Apache Software Foundation. All Rights Reserved.