Java 8 Collator - 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 Collator class.

This code example shows how to use the following methods:compare
    private final static Comparator<Map<String, Object>> sDisplayNameComparator =
        new Comparator<Map<String, Object>>() { 
        private final Collator   collator = Collator.getInstance(); 
 
        public int compare(Map<String, Object> map1, Map<String, Object> map2) { 
            return collator.compare(map1.get("title"), map2.get("title")); 
        } 
    }; 
 
    protected Intent activityIntent(String pkg, String componentName) {
        Intent result = new Intent();
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, SampleList.class);
        result.putExtra("com.example.android.apis.Path", path);
        return result;
7
CodeRank
This code example shows how to use the following methods:compare
    private final static Comparator<Map<String, Object>> sDisplayNameComparator =
        new Comparator<Map<String, Object>>() { 
        private final Collator   collator = Collator.getInstance(); 
 
        public int compare(Map<String, Object> map1, Map<String, Object> map2) { 
            return collator.compare(map1.get("title"), map2.get("title")); 
        } 
    }; 
 
    protected Intent activityIntent(String pkg, String componentName) {
        Intent result = new Intent();
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, SampleList.class);
        result.putExtra("com.example.android.apis.Path", path);
        return result;
7
CodeRank
This code example shows how to use the following methods:getStrength, setDecomposition, setStrength, equals
                myCollator.compare("\u00e0\u0325", "a\u0325\u0300") == 0);
    } 
 
    public void testEqualsObject() throws ParseException { 
        String rule = "< a < b < c < d < e";
        RuleBasedCollator coll = new RuleBasedCollator(rule);
 
        assertEquals(Collator.TERTIARY, coll.getStrength());
        // This is a harmony test, but it assumes that RuleBasedCollators default to 
        // NO_DECOMPOSITION, which isn't true on Android. 
        // assertEquals(Collator.NO_DECOMPOSITION, coll.getDecomposition()); 
        RuleBasedCollator other = new RuleBasedCollator(rule);
        assertTrue(coll.equals(other));
 
        coll.setStrength(Collator.PRIMARY);
        assertFalse(coll.equals(other));
 
        coll.setStrength(Collator.TERTIARY);
        coll.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
        other.setDecomposition(Collator.NO_DECOMPOSITION); // See comment above.

7
CodeRank
This code example shows how to use the following methods:getStrength, setDecomposition, setStrength, equals
                myCollator.compare("\u00e0\u0325", "a\u0325\u0300") == 0);
    } 
 
    public void testEqualsObject() throws ParseException { 
        String rule = "< a < b < c < d < e";
        RuleBasedCollator coll = new RuleBasedCollator(rule);
 
        assertEquals(Collator.TERTIARY, coll.getStrength());
        // This is a harmony test, but it assumes that RuleBasedCollators default to 
        // NO_DECOMPOSITION, which isn't true on Android. 
        // assertEquals(Collator.NO_DECOMPOSITION, coll.getDecomposition()); 
        RuleBasedCollator other = new RuleBasedCollator(rule);
        assertTrue(coll.equals(other));
 
        coll.setStrength(Collator.PRIMARY);
        assertFalse(coll.equals(other));
 
        coll.setStrength(Collator.TERTIARY);
        coll.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
        other.setDecomposition(Collator.NO_DECOMPOSITION); // See comment above.

7
CodeRank
This code example shows how to use the following methods:getDecomposition, getStrength, setDecomposition, setStrength, equals
6
CodeRank
This code example shows how to use the following methods:compare
    private final static Comparator<Map<String, Object>> sDisplayNameComparator =
            new Comparator<Map<String, Object>>() { 
                private final Collator collator = Collator.getInstance(); 
 
                public int compare(Map<String, Object> map1, Map<String, Object> map2) { 
                    return collator.compare(map1.get("title"), map2.get("title")); 
                } 
            }; 
 
    protected Intent activityIntent(String pkg, String componentName) {
        Intent result = new Intent();
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, HwTests.class);
        result.putExtra(EXTRA_PATH, path);
        return result;
7
CodeRank
This code example shows how to use the following methods:compare
    private final static Comparator<Map<String, Object>> sDisplayNameComparator =
        new Comparator<Map<String, Object>>() { 
        private final Collator   collator = Collator.getInstance(); 
 
        public int compare(Map<String, Object> map1, Map<String, Object> map2) { 
            return collator.compare(map1.get("title"), map2.get("title")); 
        } 
    }; 
 
    protected Intent activityIntent(String pkg, String componentName) {
        Intent result = new Intent();
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, SampleList.class);
        result.putExtra("com.example.android.apis.Path", path);
        return result;
6
CodeRank
This code example shows how to use the following methods:compare
    private final static Comparator<Map<String, Object>> sDisplayNameComparator =
        new Comparator<Map<String, Object>>() { 
        private final Collator   collator = Collator.getInstance(); 
 
        public int compare(Map<String, Object> map1, Map<String, Object> map2) { 
            return collator.compare(map1.get("title"), map2.get("title")); 
        } 
    }; 
 
    protected Intent activityIntent(String pkg, String componentName) {
        Intent result = new Intent();
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, SampleList.class);
        result.putExtra("com.example.android.apis.Path", path);
        return result;
7
CodeRank
This code example shows how to use the following methods:compare, setStrength
	/** 
	 * Test that ignorable characters do not affect the result in otherwise identical strings. 
	 */ 
	@Test
	public void testIgnoreable() throws Exception {
		assertEquals("ignorable at beginning", 0, collator.compare("\u0008fred", "fred"));
		assertEquals("ignorable at end", 0, collator.compare("fred\u0008", "fred"));
		assertEquals("ignorable in middle", 0, collator.compare("fr\u0008ed", "fred"));
		assertEquals(1, collator.compare("\u0001A", "A\u0008"));
 
		collator.setStrength(Collator.PRIMARY);
		assertEquals("prim: different case", 0, collator.compare("AabBb\u0008", "aabbb"));
	} 
 
	@Test
	public void testSecondaryIgnorable() { 
		assertEquals(-1, collator.compare("A", "A\u0001"));
	} 
 
	@Test
6
CodeRank
This code example shows how to use the following methods:compare
    private final static Comparator<Map<String, Object>> sDisplayNameComparator =
            new Comparator<Map<String, Object>>() { 
        private final Collator collator = Collator.getInstance(); 
 
        public int compare(Map<String, Object> map1, Map<String, Object> map2) { 
            return collator.compare(map1.get("title"), map2.get("title")); 
        } 
    }; 
 
    protected Intent activityIntent(String pkg, String componentName) {
        Intent result = new Intent();
        result.setClassName(pkg, componentName);
        return result;
    } 
 
    protected Intent browseIntent(String path) {
        Intent result = new Intent();
        result.setClass(this, VectorDrawableTest.class);
        result.putExtra(EXTRA_PATH, path);
        return result;
6
CodeRank

Related Java 8 Collator Questions & Answers:

See Code Examples for Java 8 Collator Methods: