Search in sources :

Example 1 with Collator

use of java.text.Collator in project XPrivacy by M66B.

the class PrivacyManager method getRestrictions.

public static TreeMap<String, String> getRestrictions(Context context) {
    Collator collator = Collator.getInstance(Locale.getDefault());
    TreeMap<String, String> tmRestriction = new TreeMap<String, String>(collator);
    for (String restrictionName : getRestrictions()) {
        int stringId = context.getResources().getIdentifier("restrict_" + restrictionName, "string", context.getPackageName());
        tmRestriction.put(stringId == 0 ? restrictionName : context.getString(stringId), restrictionName);
    }
    return tmRestriction;
}
Also used : TreeMap(java.util.TreeMap) SuppressLint(android.annotation.SuppressLint) Collator(java.text.Collator)

Example 2 with Collator

use of java.text.Collator in project openkit-android by OpenKit.

the class GraphObjectAdapter method rebuildSections.

private void rebuildSections() {
    sectionKeys = new ArrayList<String>();
    graphObjectsBySection = new HashMap<String, ArrayList<T>>();
    graphObjectsById = new HashMap<String, T>();
    displaySections = false;
    if (cursor == null || cursor.getCount() == 0) {
        return;
    }
    int objectsAdded = 0;
    cursor.moveToFirst();
    do {
        T graphObject = cursor.getGraphObject();
        if (!filterIncludesItem(graphObject)) {
            continue;
        }
        objectsAdded++;
        String sectionKeyOfItem = getSectionKeyOfGraphObject(graphObject);
        if (!graphObjectsBySection.containsKey(sectionKeyOfItem)) {
            sectionKeys.add(sectionKeyOfItem);
            graphObjectsBySection.put(sectionKeyOfItem, new ArrayList<T>());
        }
        List<T> section = graphObjectsBySection.get(sectionKeyOfItem);
        section.add(graphObject);
        graphObjectsById.put(getIdOfGraphObject(graphObject), graphObject);
    } while (cursor.moveToNext());
    if (sortFields != null) {
        final Collator collator = Collator.getInstance();
        for (List<T> section : graphObjectsBySection.values()) {
            Collections.sort(section, new Comparator<GraphObject>() {

                @Override
                public int compare(GraphObject a, GraphObject b) {
                    return compareGraphObjects(a, b, sortFields, collator);
                }
            });
        }
    }
    Collections.sort(sectionKeys, Collator.getInstance());
    displaySections = sectionKeys.size() > 1 && objectsAdded > DISPLAY_SECTIONS_THRESHOLD;
}
Also used : GraphObject(com.facebook.model.GraphObject) Collator(java.text.Collator)

Example 3 with Collator

use of java.text.Collator in project hudson-2.x by hudson.

the class Hudson method getComputers.

/**
     * Gets the read-only list of all {@link Computer}s.
     */
public Computer[] getComputers() {
    Computer[] r = computers.values().toArray(new Computer[computers.size()]);
    Arrays.sort(r, new Comparator<Computer>() {

        final Collator collator = Collator.getInstance();

        public int compare(Computer lhs, Computer rhs) {
            if (lhs.getNode() == Hudson.this) {
                return -1;
            }
            if (rhs.getNode() == Hudson.this) {
                return 1;
            }
            return collator.compare(lhs.getDisplayName(), rhs.getDisplayName());
        }
    });
    return r;
}
Also used : Collator(java.text.Collator)

Example 4 with Collator

use of java.text.Collator in project robovm by robovm.

the class CollatorTest method test_collationKeySize.

public void test_collationKeySize() throws Exception {
    // Test to verify that very large collation keys are not truncated.
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < 1024; i++) {
        b.append("0123456789ABCDEF");
    }
    String sixteen = b.toString();
    b.append("_THE_END");
    String sixteenplus = b.toString();
    Collator mColl = Collator.getInstance();
    mColl.setStrength(Collator.PRIMARY);
    byte[] arr = mColl.getCollationKey(sixteen).toByteArray();
    int len = arr.length;
    assertTrue("Collation key not 0 terminated", arr[arr.length - 1] == 0);
    len--;
    String foo = new String(arr, 0, len, "iso8859-1");
    arr = mColl.getCollationKey(sixteen).toByteArray();
    len = arr.length;
    assertTrue("Collation key not 0 terminated", arr[arr.length - 1] == 0);
    len--;
    String bar = new String(arr, 0, len, "iso8859-1");
    assertTrue("Collation keys should differ", foo.equals(bar));
}
Also used : RuleBasedCollator(java.text.RuleBasedCollator) Collator(java.text.Collator)

Example 5 with Collator

use of java.text.Collator in project robovm by robovm.

the class CollatorTest method test_decompositionCompatibility.

public void test_decompositionCompatibility() throws Exception {
    Collator myCollator = Collator.getInstance();
    myCollator.setDecomposition(Collator.NO_DECOMPOSITION);
    assertFalse("Error: ḁ̀ should not equal to ḁ̀ without decomposition", myCollator.compare("ḁ̀", "ḁ̀") == 0);
    myCollator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
    assertTrue("Error: ḁ̀ should equal to ḁ̀ with decomposition", myCollator.compare("ḁ̀", "ḁ̀") == 0);
}
Also used : RuleBasedCollator(java.text.RuleBasedCollator) Collator(java.text.Collator)

Aggregations

Collator (java.text.Collator)66 ArrayList (java.util.ArrayList)14 RuleBasedCollator (java.text.RuleBasedCollator)7 HashMap (java.util.HashMap)7 List (java.util.List)5 GraphObject (com.facebook.model.GraphObject)4 Comparator (java.util.Comparator)4 Context (android.content.Context)3 InputMethodInfo (android.view.inputmethod.InputMethodInfo)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 Entry (java.util.Map.Entry)3 TreeMap (java.util.TreeMap)3 SharedPreferences (android.content.SharedPreferences)2 ApplicationInfo (android.content.pm.ApplicationInfo)2 PackageInfo (android.content.pm.PackageInfo)2 DBObject (com.mongodb.DBObject)2 SMSException (com.sun.identity.sm.SMSException)2 ServiceSchema (com.sun.identity.sm.ServiceSchema)2 AutoPilot (com.ximpleware.AutoPilot)2