Package java.text

Examples of java.text.Collator$CollatorGetter


    IndexReader reader = writer.getReader();
    writer.close();

    IndexSearcher search = newSearcher(reader);

    Collator c = Collator.getInstance(new Locale("da", "dk"));

    // Unicode order would not include "H\u00C5T" in [ "H\u00D8T", "MAND" ],
    // but Danish collation does.
    ScoreDoc[] result = search.search
      (csrq("content", "H\u00D8T", "MAND", F, F, c), null, 1000).scoreDocs;
View Full Code Here


        }
    }

    public int compare( String content, String facetValue ){
        Locale    loc       = Locale.getDefault();
        Collator  collator  = Collator.getInstance( loc );
        return collator.compare( content, facetValue );
    }
View Full Code Here

            {
                // For now, create and configure a collator instance. I can't
                // actually imagine that this'd be slower than caching them
                // a la ClassCache, so we aren't trying to outsmart ourselves
                // with a caching mechanism for now.
                Collator collator = Collator.getInstance(cx.getLocale());
                collator.setStrength(Collator.IDENTICAL);
                collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
                return ScriptRuntime.wrapNumber(collator.compare(
                        ScriptRuntime.toString(thisObj),
                        ScriptRuntime.toString(args, 0)));
            }
            case Id_toLocaleLowerCase:
            {
View Full Code Here

            assertEquals(i, coll.getDecomposition());
        }
    }

    public void testCollator_GetInstance() {
        Collator coll = Collator.getInstance();
        Object obj1 = "a";
        Object obj2 = "b";
        assertEquals(-1, coll.compare(obj1, obj2));

        Collator.getInstance();
        assertFalse(coll.equals("A", "\uFF21"));
    }
View Full Code Here

        // }
    }

    // Test CollationKey
    public void testCollationKey() {
        Collator coll = Collator.getInstance(Locale.US);
        String text = "abc";
        CollationKey key = coll.getCollationKey(text);
        key.hashCode();

        CollationKey key2 = coll.getCollationKey("abc");

        assertEquals(0, key.compareTo(key2));
    }
View Full Code Here

        // Regression for Harmony-1066
        assertTrue(head instanceof Serializable);

        // Regression for ill-behaved collator
        Collator c = new Collator() {
            @Override
            public int compare(String o1, String o2) {
                if (o1 == null) {
                    return 0;
                }
View Full Code Here

    * for one character strings.
    */
    public void _compareSubstring() {
        boolean result = true ;
        char[] chars = new char[2] ;
        Collator col = null ;

        log.println(" #### Testing English locale ####") ;
        oObj.loadDefaultCollator(loc, 0) ;
        col = Collator.getInstance(new java.util.Locale("en", "EN")) ;
        for (char ch = 0x0020; ch < 0x007F; ch ++) {
View Full Code Here

    * for one character strings.
    */
    public void _compareString() {
        boolean result = true ;
        char[] chars = new char[2] ;
        Collator col = null ;
        log.println(" #### Testing English locale ####") ;
        oObj.loadDefaultCollator(
            new com.sun.star.lang.Locale("en", "EN", ""), 0) ;
        col = Collator.getInstance(new java.util.Locale("en", "EN")) ;
        for (char ch = 0x0020; ch < 0x007F; ch ++) {
View Full Code Here

     *
     * @param name the language name
     * @return the collator
     */
    public static Collator getCollator(String name) {
        Collator result = null;
        if (name.startsWith(ICU4J)) {
            name = name.substring(ICU4J.length());
        } else if (name.startsWith(DEFAULT)) {
            name = name.substring(DEFAULT.length());
        }
View Full Code Here

        String name = readAliasIdentifier();
        command.setString(name);
        if (equalsToken(name, CompareMode.OFF)) {
            return command;
        }
        Collator coll = CompareMode.getCollator(name);
        if (coll == null) {
            throw DbException.getInvalidValueException("collation", name);
        }
        if (readIf("STRENGTH")) {
            if (readIf("PRIMARY")) {
                command.setInt(Collator.PRIMARY);
            } else if (readIf("SECONDARY")) {
                command.setInt(Collator.SECONDARY);
            } else if (readIf("TERTIARY")) {
                command.setInt(Collator.TERTIARY);
            } else if (readIf("IDENTICAL")) {
                command.setInt(Collator.IDENTICAL);
            }
        } else {
            command.setInt(coll.getStrength());
        }
        return command;
    }
View Full Code Here

TOP

Related Classes of java.text.Collator$CollatorGetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.