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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations