Skip to content

Commit ec225ad

Browse files
author
Timothy O'Brien
committed
The StringEncoderComparator used to call o1.toString(), and
o2.toString() on the parameters supplied to the compare method. There is no need to require that only Strings are passed to the StringEncoderComparator - (actually there is no reason why we couldn't have a generic Encoder comparator. This patch is the first step towards a more generic object, and it allows us to test the exception condition in this compare() method. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/codec/trunk@130206 13f79535-47bb-0310-9956-ffa450edef68
1 parent c76ca5e commit ec225ad

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/java/org/apache/commons/codec/StringEncoderComparator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
*
7171
* @author Tim O'Brien
7272
* @author Gary Gregory
73-
* @version $Id: StringEncoderComparator.java,v 1.6 2003/10/05 21:45:48 tobrien Exp $
73+
* @version $Id: StringEncoderComparator.java,v 1.7 2003/10/12 01:34:06 tobrien Exp $
7474
*/
7575
public class StringEncoderComparator implements Comparator {
7676

@@ -103,8 +103,8 @@ public int compare(Object o1, Object o2) {
103103
int compareCode = 0;
104104

105105
try {
106-
String s1 = stringEncoder.encode(o1.toString());
107-
String s2 = stringEncoder.encode(o2.toString());
106+
Comparable s1 = (Comparable) ((Encoder) stringEncoder).encode(o1);
107+
Comparable s2 = (Comparable) ((Encoder) stringEncoder).encode(o2);
108108
compareCode = s1.compareTo(s2);
109109
}
110110
catch (EncoderException ee) {

0 commit comments

Comments
 (0)