/[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.50 by mark, Tue Aug 13 20:51:07 2002 UTC revision 1.51 by ericb, Mon Sep 16 13:31:08 2002 UTC
# Line 738  public final class String implements Ser Line 738  public final class String implements Ser
738    
739    /**    /**
740     * Compares this String and another String (case insensitive). This     * Compares this String and another String (case insensitive). This
741     * comparison is <em>different</em> from equalsIgnoreCase, in that it uses     * comparison is <em>similar</em> to equalsIgnoreCase, in that it ignores
742     * <code>this.toUpperCase().toLowerCase()     * locale and multi-characater capitalization, and compares characters
743     *    .compareTo(s.toUpperCase().toLowerCase())</code>, which can perform     * after performing
744     * multi-character capitalization expansions. However, this is still     * <code>Character.toLowerCase(Character.toUpperCase(c))</code> on each
745     * unsatisfactory for certain locales, in which case you should use     * character of the string. This is unsatisfactory for locale-based
746     * {@link java.text.Collator}.     * comparison, in which case you should use {@link java.text.Collator}.
747     *     *
748     * @param s the string to compare against     * @param s the string to compare against
749     * @return the comparison     * @return the comparison
# Line 752  public final class String implements Ser Line 752  public final class String implements Ser
752     */     */
753    public int compareToIgnoreCase(String s)    public int compareToIgnoreCase(String s)
754    {    {
755      return toUpperCase().toLowerCase().compareTo(s.toUpperCase()      int i = Math.min(count, s.count);
756                                                   .toLowerCase());      int x = offset;
757        int y = s.offset;
758        while (--i >= 0)
759          {
760            int result = Character.toLowerCase(Character.toUpperCase(value[x++]))
761              - Character.toLowerCase(Character.toUpperCase(s.value[y++]));
762            if (result != 0)
763              return result;
764          }
765        return count - s.count;
766    }    }
767    
768    /**    /**

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

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