Search in sources :

Example 11 with Collator

use of java.text.Collator in project translationstudio8 by heartsome.

the class PreferenceUtil method getProjectFieldList.

/**
	 * 获取项目属性的文本字段
	 * @return ;
	 */
public static ArrayList<String> getProjectFieldList() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    ArrayList<String> lstField = new ArrayList<String>();
    int fieldCount = store.getInt("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.fieldCount");
    if (fieldCount > 0) {
        for (int i = 0; i < fieldCount; i++) {
            lstField.add(store.getString("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.field" + i));
        }
    }
    // 对中文按拼音排序
    Collator collatorChinese = Collator.getInstance(java.util.Locale.CHINA);
    Collections.sort(lstField, collatorChinese);
    return lstField;
}
Also used : ArrayList(java.util.ArrayList) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Collator(java.text.Collator)

Example 12 with Collator

use of java.text.Collator in project translationstudio8 by heartsome.

the class ProjectConfiger method getAttrMap.

/**
	 * 获取配置文件中的项目属性字段信息
	 * @return
	 * @throws XPathParseException
	 * @throws XPathEvalException
	 * @throws NavException ;
	 */
private LinkedHashMap<String, Object[]> getAttrMap() throws XPathParseException, XPathEvalException, NavException {
    AutoPilot ap = new AutoPilot(vu.getVTDNav());
    Map<String, Object[]> mapAttr = new HashMap<String, Object[]>();
    ap.selectXPath("/projectDescription/hs//attributeList/attribute");
    AutoPilot ap2 = new AutoPilot(vu.getVTDNav());
    final Collator collatorChinese = Collator.getInstance(java.util.Locale.CHINA);
    while (ap.evalXPath() != -1) {
        String attrName = TextUtil.stringToXML(vu.getCurrentElementAttribut("name", ""));
        String attrSelVal = TextUtil.stringToXML(vu.getCurrentElementAttribut("selection", ""));
        vu.getVTDNav().push();
        ap2.selectXPath("./item");
        ArrayList<String> lstAttrVal = new ArrayList<String>();
        while (ap2.evalXPath() != -1) {
            lstAttrVal.add(vu.getElementContent());
        }
        vu.getVTDNav().pop();
        Collections.sort(lstAttrVal, collatorChinese);
        mapAttr.put(attrName, new Object[] { attrSelVal, lstAttrVal });
    }
    List<Entry<String, Object[]>> lstAttr = new ArrayList<Entry<String, Object[]>>(mapAttr.entrySet());
    Collections.sort(lstAttr, new Comparator<Entry<String, Object[]>>() {

        public int compare(Entry<String, Object[]> arg0, Entry<String, Object[]> arg1) {
            return collatorChinese.compare(arg0.getKey(), arg1.getKey());
        }
    });
    LinkedHashMap<String, Object[]> linkedMapAttr = new LinkedHashMap<String, Object[]>();
    for (Entry<String, Object[]> entry : lstAttr) {
        linkedMapAttr.put(entry.getKey(), entry.getValue());
    }
    return linkedMapAttr;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Collator(java.text.Collator) LinkedHashMap(java.util.LinkedHashMap) Entry(java.util.Map.Entry) AutoPilot(com.ximpleware.AutoPilot)

Example 13 with Collator

use of java.text.Collator in project translationstudio8 by heartsome.

the class ProjectConfiger method getFieldMap.

/**
	 * 获取配置文件中的项目文本字段信息
	 * @return
	 * @throws XPathParseException
	 * @throws XPathEvalException
	 * @throws NavException ;
	 */
private LinkedHashMap<String, String> getFieldMap() throws XPathParseException, XPathEvalException, NavException {
    AutoPilot ap = new AutoPilot(vu.getVTDNav());
    Map<String, String> mapField = new HashMap<String, String>();
    ap.selectXPath("/projectDescription/hs//fieldList/field");
    while (ap.evalXPath() != -1) {
        String fieldName = TextUtil.stringToXML(vu.getCurrentElementAttribut("name", ""));
        String fieldValue = vu.getElementContent();
        mapField.put(fieldName, fieldValue);
    }
    List<Entry<String, String>> lstAttr = new ArrayList<Entry<String, String>>(mapField.entrySet());
    final Collator collatorChinese = Collator.getInstance(java.util.Locale.CHINA);
    Collections.sort(lstAttr, new Comparator<Entry<String, String>>() {

        public int compare(Entry<String, String> arg0, Entry<String, String> arg1) {
            return collatorChinese.compare(arg0.getKey(), arg1.getKey());
        }
    });
    LinkedHashMap<String, String> linkedMapAttr = new LinkedHashMap<String, String>();
    for (Entry<String, String> entry : lstAttr) {
        linkedMapAttr.put(entry.getKey(), entry.getValue());
    }
    return linkedMapAttr;
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AutoPilot(com.ximpleware.AutoPilot) ArrayList(java.util.ArrayList) Collator(java.text.Collator) LinkedHashMap(java.util.LinkedHashMap)

Example 14 with Collator

use of java.text.Collator in project es6draft by anba.

the class Realm method getCollator.

/**
     * Returns a {@link Collator} for this realm's locale
     * 
     * @deprecated No longer used
     * @return the locale specific collator
     */
@Deprecated
public Collator getCollator() {
    Collator collator = Collator.getInstance(getLocale());
    // Use Normalized Form D for comparison (cf. 21.1.3.10, Note 2)
    collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
    // `"".localeCompare("") == -1` should yield true
    collator.setStrength(Collator.IDENTICAL);
    return collator;
}
Also used : Collator(java.text.Collator)

Example 15 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)

Aggregations

Collator (java.text.Collator)70 ArrayList (java.util.ArrayList)14 RuleBasedCollator (java.text.RuleBasedCollator)8 HashMap (java.util.HashMap)7 Comparator (java.util.Comparator)5 List (java.util.List)5 GraphObject (com.facebook.model.GraphObject)4 Context (android.content.Context)3 InputMethodInfo (android.view.inputmethod.InputMethodInfo)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 Locale (java.util.Locale)3 Entry (java.util.Map.Entry)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