Refine search
@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 void setStringValue(String value) { bytes.bytes = collator.getCollationKey(value).toByteArray(); bytes.offset = 0; bytes.length = bytes.bytes.length; } }
k.m_namespaceContext); n1String = k.m_col.getCollationKey(r1.str()); n2String = k.m_col.getCollationKey(r2.str()); result = n1String.compareTo(n2String); String tempN1 = n1String.getSourceString().toLowerCase(); String tempN2 = n2String.getSourceString().toLowerCase();
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); } }
private static byte[] getCollationKeyInBytes(String name) { if (mColl == null) { mColl = Collator.getInstance(); mColl.setStrength(Collator.PRIMARY); } return mColl.getCollationKey(name).toByteArray(); }
/** * 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; } }
DefaultMutableTreeNode sortedNode = new DefaultMutableTreeNode(); Collator collator = Collator.getInstance(locale); CollationKey[] keys = new CollationKey[size]; String string = MergeHelpUtilities.getNodeName((DefaultMutableTreeNode)node.getChildAt(i)); debug("String , i:"+string+" , "+i); keys[i] = collator.getCollationKey(string); DefaultMutableTreeNode child = MergeHelpUtilities.getChildWithName(node,keys[i].getSourceString()); if (child != null) { sortedNode.add(child);
long termStringsByteSize = 0; for (Map.Entry<CollationKey, Integer> entry: termIndex.entrySet()) { String term = entry.getKey().getSourceString(); terms[entry.getValue()] = term; termStringsByteSize += term.getBytes(DEFAULT_CHARSET).length; int sortPos = 0; for (i = 0; i < n; i++) { if (i == 0 || collatorInsensitive.compare(terms[insensitive[i - 1]], terms[insensitive[i]]) != 0) {
@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 compareTo(UserSitemapNode otherNode) { return collationKey.compareTo(otherNode.collationKey); }
rhsBytes = ((CollationKeyICU) other).bytes; } else { rhsBytes = other.toByteArray();
@Override public int compareTo(CollationKey target) { return COMPARATOR.compare(toByteArray(), toBytes(target.getSourceString())); }
@Override public int compare(File o1, File o2) { CollationKey key1 = collator.getCollationKey(o1.getAbsolutePath()); CollationKey key2 = collator.getCollationKey(o2.getAbsolutePath()); return key1.compareTo(key2); } }
/** * <p>Compare this CollationKey to another CollationKey. The * collation rules of the Collator that created this key are * applied.</p> * * <p><strong>Note:</strong> Comparison between CollationKeys * created by different Collators might return incorrect * results. See class documentation.</p> * * @param target target CollationKey * @return an integer value. If the value is less than zero this CollationKey * is less than than target, if the value is zero they are equal, and * if the value is greater than zero this CollationKey is greater * than target. * @exception NullPointerException is thrown if argument is null. * @see Collator#compare(String, String) * @stable ICU 2.8 */ public int compareTo(CollationKey target) { return key.compareTo(target.key); }
/** * Return the source string that this CollationKey represents. * @return source string that this CollationKey represents * @stable ICU 2.8 */ public String getSourceString() { return key.getSourceString(); }
@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; }
k.m_namespaceContext); n1String = k.m_col.getCollationKey(r1.str()); n2String = k.m_col.getCollationKey(r2.str()); result = n1String.compareTo(n2String); String tempN1 = n1String.getSourceString().toLowerCase(); String tempN2 = n2String.getSourceString().toLowerCase();
@Override public BytesRef getBytesRef() { final BytesRef ref = this.builder.get(); ref.bytes = collator.getCollationKey(toString()).toByteArray(); ref.offset = 0; ref.length = ref.bytes.length; return ref; }
@Override public int compare(Path o1, Path o2) { CollationKey key1 = collator.getCollationKey(o1.toString()); CollationKey key2 = collator.getCollationKey(o2.toString()); return key1.compareTo(key2); } }