diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ChangeLog.usermap | 1 | ||||
-rw-r--r-- | java/lang/String.java | 38 |
3 files changed, 39 insertions, 5 deletions
@@ -1,3 +1,8 @@ +2001-09-07 Eric Blake <ebb9@email.byu.edu> + + * java/lang/String.java (CASE_INSENSITIVE_ORDER): implements + Serializable + 2001-09-07 C. Brian Jones <cbj@gnu.org> * native/cni: added for CNI native files * native/common: added for common JNI/CNI files diff --git a/ChangeLog.usermap b/ChangeLog.usermap index 5c70c30f9..a9e2ae3a8 100644 --- a/ChangeLog.usermap +++ b/ChangeLog.usermap @@ -13,3 +13,4 @@ mark:'Mark Wielaard <mark@klomp.org>' tromey:'Tom Tromey <tromey@cygnus.com>' green:'Anthony Green <green@redhat.com>' warrenl:'Warren Levy <warrenl@cygnus.com>' +ericb:'Eric Blake <ebb9@email.byu.edu>' diff --git a/java/lang/String.java b/java/lang/String.java index 039f39cf3..045c082d3 100644 --- a/java/lang/String.java +++ b/java/lang/String.java @@ -38,6 +38,7 @@ import java.io.*; * Compliant with JDK 1.1. * * @author Paul N. Fisher + * @author Eric Blake <ebb9@email.byu.edu> * @since JDK1.0 */ public final class String implements Comparable, CharSequence, Serializable { @@ -79,16 +80,43 @@ public final class String implements Comparable, CharSequence, Serializable { private int cachedHashCode; /** + * An implementation for {@link CASE_INSENSITIVE_ORDER}. + * This must be {@link Serializable}. + */ + private static final class CaseInsensitiveComparator + implements Comparator, Serializable + { + /** + * The default private constructor generates unnecessary overhead + */ + CaseInsensitiveComparator() {} + + /** + * Compares to Strings, using + * <code>String.compareToIgnoreCase(String)</code>. + * + * @param o1 the first string + * @param o2 the second string + * @return < 0, 0, or > 0 depending on the case-insensitive + * comparison of the two strings. + * @throws NullPointerException if either argument is null + * @throws ClassCastException if either argument is not a String + * @see #compareToIgnoreCase(String) + */ + public int compare(Object o1, Object o2) + { + return ((String) o1).compareToIgnoreCase((String) o2); + } + } + + /** * A Comparator that uses <code>String.compareToIgnoreCase(String)</code>. + * This comparator is {@link Serializable}. * * @since 1.2 */ public static final Comparator CASE_INSENSITIVE_ORDER - = new Comparator() { - public int compare(Object o1, Object o2) { - return ((String)o1).compareToIgnoreCase((String)o2); - } - }; + = new CaseInsensitiveComparator(); /** * Creates an empty String (length 0) |