< prev index next >

src/java.base/share/classes/java/lang/StringUTF16.java

Print this page




 275         int len2 = length(other);
 276         int lim = Math.min(len1, len2);
 277         for (int k = 0; k < lim; k++) {
 278             char c1 = getChar(value, k);
 279             char c2 = getChar(other, k);
 280             if (c1 != c2) {
 281                 c1 = Character.toUpperCase(c1);
 282                 c2 = Character.toUpperCase(c2);
 283                 if (c1 != c2) {
 284                     c1 = Character.toLowerCase(c1);
 285                     c2 = Character.toLowerCase(c2);
 286                     if (c1 != c2) {
 287                         return c1 - c2;
 288                     }
 289                 }
 290             }
 291         }
 292         return len1 - len2;
 293     }
 294 














 295     public static int compareToCI_Latin1(byte[] value, byte[] other) {
 296         int len1 = length(value);
 297         int len2 = StringLatin1.length(other);
 298         int lim = Math.min(len1, len2);
 299         for (int k = 0; k < lim; k++) {
 300             char c1 = getChar(value, k);
 301             char c2 = StringLatin1.getChar(other, k);
 302             if (c1 != c2) {
 303                 c1 = Character.toUpperCase(c1);
 304                 c2 = Character.toUpperCase(c2);
 305                 if (c1 != c2) {
 306                     c1 = Character.toLowerCase(c1);
 307                     c2 = Character.toLowerCase(c2);
 308                     if (c1 != c2) {
 309                         return c1 - c2;
 310                     }
 311                 }
 312             }
 313         }
 314         return len1 - len2;




 275         int len2 = length(other);
 276         int lim = Math.min(len1, len2);
 277         for (int k = 0; k < lim; k++) {
 278             char c1 = getChar(value, k);
 279             char c2 = getChar(other, k);
 280             if (c1 != c2) {
 281                 c1 = Character.toUpperCase(c1);
 282                 c2 = Character.toUpperCase(c2);
 283                 if (c1 != c2) {
 284                     c1 = Character.toLowerCase(c1);
 285                     c2 = Character.toLowerCase(c2);
 286                     if (c1 != c2) {
 287                         return c1 - c2;
 288                     }
 289                 }
 290             }
 291         }
 292         return len1 - len2;
 293     }
 294 
 295     /**
 296      * hashCode consistent with {@link #compareToCI}
 297      */
 298     public static int hashCodeCI(byte[] value) {
 299         int len = length(value);
 300         int h = 0;
 301         for (int k = 0; k < len; k++) {
 302             char cu = (char) CharacterDataLatin1.instance.toUpperCase(getChar(value, k));
 303             char cl = (char) CharacterDataLatin1.instance.toLowerCase(cu);
 304             h = 31 * h + cl;
 305         }
 306         return h;
 307     }
 308 
 309     public static int compareToCI_Latin1(byte[] value, byte[] other) {
 310         int len1 = length(value);
 311         int len2 = StringLatin1.length(other);
 312         int lim = Math.min(len1, len2);
 313         for (int k = 0; k < lim; k++) {
 314             char c1 = getChar(value, k);
 315             char c2 = StringLatin1.getChar(other, k);
 316             if (c1 != c2) {
 317                 c1 = Character.toUpperCase(c1);
 318                 c2 = Character.toUpperCase(c2);
 319                 if (c1 != c2) {
 320                     c1 = Character.toLowerCase(c1);
 321                     c2 = Character.toLowerCase(c2);
 322                     if (c1 != c2) {
 323                         return c1 - c2;
 324                     }
 325                 }
 326             }
 327         }
 328         return len1 - len2;


< prev index next >