/[classpath]/classpath/java/lang/String.java
ViewVC logotype

Diff of /classpath/java/lang/String.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33 by jewel, Sun Aug 5 01:40:04 2001 UTC revision 1.34 by ericb, Sat Sep 8 03:55:38 2001 UTC
# Line 38  import java.io.*; Line 38  import java.io.*;
38   * Compliant with JDK 1.1.   * Compliant with JDK 1.1.
39   *   *
40   * @author Paul N. Fisher   * @author Paul N. Fisher
41     * @author Eric Blake <ebb9@email.byu.edu>
42   * @since JDK1.0   * @since JDK1.0
43   */   */
44  public final class String implements Comparable, CharSequence, Serializable {  public final class String implements Comparable, CharSequence, Serializable {
# Line 79  public final class String implements Com Line 80  public final class String implements Com
80    private int cachedHashCode;    private int cachedHashCode;
81    
82    /**    /**
83       * An implementation for {@link CASE_INSENSITIVE_ORDER}.
84       * This must be {@link Serializable}.
85       */
86      private static final class CaseInsensitiveComparator
87        implements Comparator, Serializable
88      {
89        /**
90         * The default private constructor generates unnecessary overhead
91         */
92        CaseInsensitiveComparator() {}
93    
94        /**
95         * Compares to Strings, using
96         * <code>String.compareToIgnoreCase(String)</code>.
97         *
98         * @param o1 the first string
99         * @param o2 the second string
100         * @return &lt; 0, 0, or &gt; 0 depending on the case-insensitive
101         *         comparison of the two strings.
102         * @throws NullPointerException if either argument is null
103         * @throws ClassCastException if either argument is not a String
104         * @see #compareToIgnoreCase(String)
105         */
106        public int compare(Object o1, Object o2)
107        {
108          return ((String) o1).compareToIgnoreCase((String) o2);
109        }
110      }
111    
112      /**
113     * A Comparator that uses <code>String.compareToIgnoreCase(String)</code>.     * A Comparator that uses <code>String.compareToIgnoreCase(String)</code>.
114       * This comparator is {@link Serializable}.
115     *     *
116     * @since 1.2     * @since 1.2
117     */     */
118    public static final Comparator CASE_INSENSITIVE_ORDER    public static final Comparator CASE_INSENSITIVE_ORDER
119        = new Comparator() {      = new CaseInsensitiveComparator();
               public int compare(Object o1, Object o2) {  
                   return ((String)o1).compareToIgnoreCase((String)o2);  
               }  
           };  
120    
121    /**    /**
122     * Creates an empty String (length 0)     * Creates an empty String (length 0)

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26