@Override public int compareString(String a, String b, boolean ignoreCase) { if (ignoreCase) { // this is locale sensitive a = a.toUpperCase(); b = b.toUpperCase(); } int comp; if (collationKeys != null) { CollationKey aKey = getKey(a); CollationKey bKey = getKey(b); comp = aKey.compareTo(bKey); } else { comp = collator.compare(a, b); } return comp; }
@Override public int compareString(String a, String b, boolean ignoreCase) { if (ignoreCase) { // this is locale sensitive a = a.toUpperCase(); b = b.toUpperCase(); } int comp; if (collationKeys != null) { CollationKey aKey = getKey(a); CollationKey bKey = getKey(b); comp = aKey.compareTo(bKey); } else { comp = collator.compare(a, b); } return comp; }
result = n1String.compareTo(n2String);
result = n1String.compareTo(n2String);
class Person implements Comparable<Person> { private static final Collator collator = Collator.getInstance(Locale.ITALY); private final String lastname; private final CollationKey key; Person(String lastname) { this.lastname = lastname; this.key = collator.getCollationKey(lastname); } public int compareTo(Person person) { return key.compareTo(person.key); } }
@Override public int compareTo(UserSitemapNode otherNode) { return collationKey.compareTo(otherNode.collationKey); }
public int compareTo(Object o) { if (o instanceof CollationMatchKey) { return key.compareTo(((CollationMatchKey) o).key); } else { throw new ClassCastException(); } }
public int compareTo(Object o) { if (o instanceof CollationMatchKey) { return key.compareTo(((CollationMatchKey) o).key); } else { throw new ClassCastException(); } }
/** {@inheritDoc} */ public int compareTo(Object o) { if (!(o instanceof TextComparable)) { throw new IllegalArgumentException("o must be instance of" + TextComparable.class); } TextComparable oc = (TextComparable)o; return key.compareTo(oc.key); }
/** * {@inheritDoc} */ @Override public int compareTo(GenericCollationKey<T> o) { return collationKey.compareTo(o.getCollationKey()); }
@Override public int compare(File o1, File o2) { CollationKey key1 = collator.getCollationKey(o1.getAbsolutePath()); CollationKey key2 = collator.getCollationKey(o2.getAbsolutePath()); return key1.compareTo(key2); } }
@Override public int compare(Path o1, Path o2) { CollationKey key1 = collator.getCollationKey(o1.toString()); CollationKey key2 = collator.getCollationKey(o2.toString()); return key1.compareTo(key2); } }
public int compare(String o1, String o2) { if (o1 == o2) { return 0; } else if (o2 == null) { return 1; } else if (o1 == null) { return -1; } return getCollationKey(o1).compareTo(getCollationKey(o2)); }
@Override public int compare(UserSitemapNode o1, UserSitemapNode o2) { return o1.getCollationKey() .compareTo(o2.getCollationKey()); }
@Override public int compare(UserSitemapNode o1, UserSitemapNode o2) { return o2.getCollationKey() .compareTo(o1.getCollationKey()); }
@Override public int compare(String o1, String o2) { CollationKey key1 = collator.getCollationKey(o1); CollationKey key2 = collator.getCollationKey(o2); return key1.compareTo(key2); } }
@Override public int compare(String o1, String o2) { if (o1 == o2) { return 0; } else if (o2 == null) { return 1; } else if (o1 == null) { return -1; } return getCollationKey(o1).compareTo(getCollationKey(o2)); }
/** * Compares two strings with a collator, also looking to see if the the strings * are impacted by jdk bugs. may not avoid all jdk bugs in tests. * see https://bugs.openjdk.java.net/browse/JDK-8071862 */ @SuppressForbidden(reason = "dodges JDK-8071862") public static int collate(Collator collator, String s1, String s2) { int v1 = collator.compare(s1, s2); int v2 = collator.getCollationKey(s1).compareTo(collator.getCollationKey(s2)); // if collation keys don't really respect collation order, things are screwed. assumeTrue("hit JDK collator bug", Integer.signum(v1) == Integer.signum(v2)); return v1; } }
public int compare(Node o1, Node o2) { if (o1.getName().equals(TOPNODE)) { return -1; } if (o2.getName().equals(TOPNODE)) { return 1; } CollationKey key1 = toKey(o1); CollationKey key2 = toKey(o2); return key1.compareTo(key2); }
public int compare(Node o1, Node o2) { if (o1.getName().equals(TOPNODE)) { return -1; } if (o2.getName().equals(TOPNODE)) { return 1; } CollationKey key1 = toKey(o1); CollationKey key2 = toKey(o2); return key1.compareTo(key2); }