Java 8 CollationKey - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CollationKey class.

This code example shows how to use the following methods:compareTo
            return diff;
        } 
        // then by name (not really needed, but makes for predictable test cases) 
        CollationKey k1 = collator.getCollationKey(o1.getName());
        CollationKey k2 = collator.getCollationKey(o2.getName());
        return k1.compareTo(k2);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:compareTo
This code example shows how to use the following methods:compareTo
	public void test_compareToLjava_text_CollationKey() { 
		Collator collator = Collator.getInstance();
		collator.setStrength(Collator.PRIMARY);
		CollationKey key1 = collator.getCollationKey("abc");
		CollationKey key2 = collator.getCollationKey("ABC");
		assertEquals("Should be equal", 0, key1.compareTo(key2));
	} 
 
	/** 
	 * @tests java.text.CollationKey#compareTo(java.lang.Object) 
	 */ 
	public void test_compareToLjava_lang_Object() { 
		// Test for method int 
		// java.text.CollationKey.compareTo(java.lang.Object) 
		Collator collator = Collator.getInstance();
		collator.setStrength(Collator.PRIMARY);
		CollationKey key1 = collator.getCollationKey("abc");
		CollationKey key2 = collator.getCollationKey("ABC");
		assertEquals("Should be equal", 0, key1.compareTo(key2));
	} 
5
CodeRank
This code example shows how to use the following methods:compareTo
        else 
        { 
            String s1 = first.toString();
            String s2 = second.toString();
            //result = s1.compareTo(s2); 
            result = m_collator.getCollationKey(s1).compareTo(
                m_collator.getCollationKey(s2));
        } 
 
        // set the result based on ascending/descending 
        if (!m_sortAscending)
        { 
            result = -result;
        } 
 
        return result;
    } 
 
 
    /** 
3
CodeRank
This code example shows how to use the following methods:compareTo
     */ 
    public int compareStrings(String p_A, String p_B)
    { 
        String a = p_A == null ? "" : p_A;
        String b = p_B == null ? "" : p_B;
        return getCollationKey(a).compareTo(getCollationKey(b));
    } 
 
    /** 
     * Gets the locale of this StringComparator. 
     */ 
    public Locale getLocale()
    { 
        return m_locale;
    } 
 
    /** 
     * Extracts the filename part of an MsOffice multipart file: 
     * "(header) en_US/ppt.ppt" --> "en_US/ppt.ppt". 
     */ 
4
CodeRank
This code example shows how to use the following methods:compareTo
		Comparer comp = new Comparer() {
			 
			@Override 
			public int compare(Object a, Object b) {
				// TODO Auto-generated method stub 
				return ((CollationKey)a).compareTo((CollationKey)b);
			} 
		}; 
		 
		sort(a, b, from, to, up, comp);
	} 
 
	// general method 
	public static void sort(Object[] a, Object[] b, int from, int to,
			boolean up, Comparer c) {
		if (a == null || a.length < 2)
			return; 
 
		int i = from;
		int j = to;
4
CodeRank
This code example shows how to use the following methods:compareTo
		return (CollationKey)getValue();
	} 
	 
	public int compare(AnyCollationKey target)
	{ 
		int ret =  getCollationKey().compareTo(target.getCollationKey());
		 
		return negate_ ? -ret : ret;
	} 
	 
  public Any copyFrom (Any a)
  { 
    if (a != null && a != this)
    { 
    	if (!(a instanceof AnyCollationKey))
				throw new IllegalArgumentException(a.getClass().toString());
    	 
    	AnyCollationKey i = (AnyCollationKey)a;
			this.setValue(i.getValue());
 
4
CodeRank
This code example shows how to use the following methods:compareTo
        { 
            if (o2.isFile())
            { 
                CollationKey key1 = toKey(o1);
                CollationKey key2 = toKey(o2);
                return key1.compareTo(key2);
            } 
            else 
            { 
                // Push o2 directories below o1 files 
                return -1; 
            } 
        } 
        else 
        { 
            if (o2.isDirectory())
            { 
                CollationKey key1 = toKey(o1);
                CollationKey key2 = toKey(o2);
                return key1.compareTo(key2);
4
CodeRank
This code example shows how to use the following methods:compareTo
                    key2 = m_collator.getCollationKey(val2);
                    m_keys.put(val2, key2);
                } 
 
                if ("asc".equals(m_sortOrder)) {
                    return key1.compareTo(key2);
                } else { 
                    return key2.compareTo(key1);
                } 
            } 
        } 
    } 
 
    /** Column ID of the creation date column. */ 
    public static final String COLUMN_ID_DATE = "creationdate";
 
    /** The node name for the node: show menu. */ 
    public static final String NODE_COLWIDTH = "ColWidth";
 
    /** The node name for the node: entries. */ 
4
CodeRank
This code example shows how to use the following methods:compareTo
			if (ckey2 != null)	// this == null
				return 1; 
			return 0;			// both == null 
		} 
 
		return ckey1.compareTo(ckey2);
	} 
	 
	/** 
	 * This method implements the like function for char (with no escape value). 
	 * The difference in this method and the same method in SQLChar is that  
	 * here we use special Collator object to do the comparison rather than 
	 * using the Collator object associated with the default jvm locale. 
	 * 
	 * @param pattern		The pattern to use 
	 * 
	 * @return	A SQL boolean value telling whether the first operand is 
	 *			like the second operand 
	 * 
	 * @exception StandardException		Thrown on error 
4
CodeRank
See Code Examples for Java 8 CollationKey Methods: