Search in sources :

Example 16 with Collator

use of java.text.Collator in project j2objc by google.

the class CollatorTest method test_equalsLjava_lang_StringLjava_lang_String.

/**
	 * @tests java.text.Collator#equals(java.lang.String, java.lang.String)
	 */
public void test_equalsLjava_lang_StringLjava_lang_String() {
    Collator c = Collator.getInstance(Locale.FRENCH);
    c.setStrength(Collator.IDENTICAL);
    assertTrue("a) Failed on primary difference", !c.equals("E", "F"));
    assertTrue("a) Failed on secondary difference", !c.equals("e", "é"));
    assertTrue("a) Failed on tertiary difference", !c.equals("e", "E"));
    assertTrue("a) Failed on equivalence", c.equals("e", "e"));
    c.setStrength(Collator.TERTIARY);
    assertTrue("b) Failed on primary difference", !c.equals("E", "F"));
    assertTrue("b) Failed on secondary difference", !c.equals("e", "é"));
    assertTrue("b) Failed on tertiary difference", !c.equals("e", "E"));
    assertTrue("b) Failed on identical", c.equals("", ""));
    assertTrue("b) Failed on equivalence", c.equals("e", "e"));
    c.setStrength(Collator.SECONDARY);
    assertTrue("c) Failed on primary difference", !c.equals("E", "F"));
    assertTrue("c) Failed on secondary difference", !c.equals("e", "é"));
    assertTrue("c) Failed on tertiary difference", c.equals("e", "E"));
    assertTrue("c) Failed on identical", c.equals("", ""));
    assertTrue("c) Failed on equivalence", c.equals("e", "e"));
    c.setStrength(Collator.PRIMARY);
    assertTrue("d) Failed on primary difference", !c.equals("E", "F"));
    assertTrue("d) Failed on secondary difference", c.equals("e", "é"));
    assertTrue("d) Failed on tertiary difference", c.equals("e", "E"));
    assertTrue("d) Failed on identical", c.equals("", ""));
    assertTrue("d) Failed on equivalence", c.equals("e", "e"));
}
Also used : Collator(java.text.Collator)

Example 17 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 18 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 19 with Collator

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

the class PreferenceUtil method getProjectAttributeMap.

/**
	 * 获取项目属性的属性字段
	 * @return key 为属性名称,value 为属性值集合
	 */
public static LinkedHashMap<String, ArrayList<String>> getProjectAttributeMap() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    HashMap<String, ArrayList<String>> mapAttr = new HashMap<String, ArrayList<String>>();
    int attrNameCount = store.getInt("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.attrNameCount");
    // 对中文按拼音排序
    final Collator collatorChinese = Collator.getInstance(java.util.Locale.CHINA);
    LinkedHashMap<String, ArrayList<String>> linkedMapAttr = new LinkedHashMap<String, ArrayList<String>>();
    if (attrNameCount > 0) {
        for (int i = 0; i < attrNameCount; i++) {
            String strAttrName = store.getString("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.attrName" + i);
            int attrValCount = store.getInt("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.attrName" + i + ".count");
            ArrayList<String> lstAttrVal = new ArrayList<String>();
            if (attrValCount > 0) {
                for (int j = 0; j < attrValCount; j++) {
                    lstAttrVal.add(store.getString("net.heartsome.cat.ts.ui.preferencepage.ProjectPropertiesPreferencePage.attrName" + i + ".attrVal" + j));
                }
            }
            Collections.sort(lstAttrVal, collatorChinese);
            mapAttr.put(strAttrName, lstAttrVal);
        }
        List<Entry<String, ArrayList<String>>> lstAttr = new ArrayList<Entry<String, ArrayList<String>>>(mapAttr.entrySet());
        Collections.sort(lstAttr, new Comparator<Entry<String, ArrayList<String>>>() {

            public int compare(Entry<String, ArrayList<String>> arg0, Entry<String, ArrayList<String>> arg1) {
                return collatorChinese.compare(arg0.getKey(), arg1.getKey());
            }
        });
        for (Entry<String, ArrayList<String>> 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) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

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

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