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 |
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 |
/** |
/** |