< prev index next >

## src/java.base/share/classes/java/lang/String.java

Print this page

    1219                                    : StringUTF16.compareTo(v1, v2);
    1220         }
    1221         return coder == LATIN1 ? StringLatin1.compareToUTF16(v1, v2)
    1222                                : StringUTF16.compareToLatin1(v1, v2);
    1223      }
    1224
    1225     /**
    1226      * A Comparator that orders {@code String} objects as by
    1227      * {@link #compareToIgnoreCase(String) compareToIgnoreCase}.
    1228      * This comparator is serializable.
    1229      * <p>
    1230      * Note that this Comparator does <em>not</em> take locale into account,
    1231      * and will result in an unsatisfactory ordering for certain locales.
    1232      * The {@link java.text.Collator} class provides locale-sensitive comparison.
    1233      *
    1234      * @see     java.text.Collator
    1235      * @since   1.2
    1236      */
    1237     public static final Comparator<String> CASE_INSENSITIVE_ORDER
    1238                                          = new CaseInsensitiveComparator();

    1239     private static class CaseInsensitiveComparator
    1240             implements Comparator<String>, java.io.Serializable {
    1241         // use serialVersionUID from JDK 1.2.2 for interoperability
    1242         @java.io.Serial
    1243         private static final long serialVersionUID = 8575799808933029326L;
    1244
    1245         public int compare(String s1, String s2) {
    1246             byte v1[] = s1.value;
    1247             byte v2[] = s2.value;
    1248             byte coder = s1.coder();
    1249             if (coder == s2.coder()) {
    1250                 return coder == LATIN1 ? StringLatin1.compareToCI(v1, v2)
    1251                                        : StringUTF16.compareToCI(v1, v2);
    1252             }
    1253             return coder == LATIN1 ? StringLatin1.compareToCI_UTF16(v1, v2)
    1254                                    : StringUTF16.compareToCI_Latin1(v1, v2);
    1255         }
    1256
    1257         /** Replaces the de-serialized object. */
    1258         @java.io.Serial
    1219                                    : StringUTF16.compareTo(v1, v2);
    1220         }
    1221         return coder == LATIN1 ? StringLatin1.compareToUTF16(v1, v2)
    1222                                : StringUTF16.compareToLatin1(v1, v2);
    1223      }
    1224
    1225     /**
    1226      * A Comparator that orders {@code String} objects as by
    1227      * {@link #compareToIgnoreCase(String) compareToIgnoreCase}.
    1228      * This comparator is serializable.
    1229      * <p>
    1230      * Note that this Comparator does <em>not</em> take locale into account,
    1231      * and will result in an unsatisfactory ordering for certain locales.
    1232      * The {@link java.text.Collator} class provides locale-sensitive comparison.
    1233      *
    1234      * @see     java.text.Collator
    1235      * @since   1.2
    1236      */
    1237     public static final Comparator<String> CASE_INSENSITIVE_ORDER
    1238                                          = new CaseInsensitiveComparator();
    1239
    1240     /**
    1241      * CaseInsensitiveComparator for Strings.
    1242      */
    1243     private static class CaseInsensitiveComparator
    1244             implements Comparator<String>, java.io.Serializable {
    1245         // use serialVersionUID from JDK 1.2.2 for interoperability
    1246         @java.io.Serial
    1247         private static final long serialVersionUID = 8575799808933029326L;
    1248
    1249         public int compare(String s1, String s2) {
    1250             byte v1[] = s1.value;
    1251             byte v2[] = s2.value;
    1252             byte coder = s1.coder();
    1253             if (coder == s2.coder()) {
    1254                 return coder == LATIN1 ? StringLatin1.compareToCI(v1, v2)
    1255                                        : StringUTF16.compareToCI(v1, v2);
    1256             }
    1257             return coder == LATIN1 ? StringLatin1.compareToCI_UTF16(v1, v2)
    1258                                    : StringUTF16.compareToCI_Latin1(v1, v2);
    1259         }
    1260
    1261         /** Replaces the de-serialized object. */
    1262         @java.io.Serial

< prev index next >