本文整理汇总了Java中java.text.Collator.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Collator.getInstance方法的具体用法?Java Collator.getInstance怎么用?Java Collator.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.Collator
的用法示例。
在下文中一共展示了Collator.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Collation
import java.text.Collator; //导入方法依赖的package包/类
private Collation(String name, String language, String country,
int strength, int decomposition, boolean ucc) {
locale = new Locale(language, country);
collator = Collator.getInstance(locale);
if (strength >= 0) {
collator.setStrength(strength);
}
if (decomposition >= 0) {
collator.setDecomposition(decomposition);
}
strength = collator.getStrength();
isUnicodeSimple = false;
this.name = HsqlNameManager.newInfoSchemaObjectName(name, true,
SchemaObject.COLLATION);
charset = Charset.SQL_TEXT;
isUpperCaseCompare = ucc;
isFinal = true;
}
示例2: generateIndexFile
import java.text.Collator; //导入方法依赖的package包/类
protected void generateIndexFile(RootDoc root, WRDoc wrDoc)
throws Exception {
List<String> tagList = new ArrayList<String>(wrDoc.getWRTags());
Collator cmp = Collator.getInstance(java.util.Locale.CHINA);
Collections.sort(tagList, cmp);
Map<String, Object> tagMap = new HashMap<String, Object>();
DocData bean = this.generateDocData(wrDoc);
Gson gson = new Gson();
tagMap.put("response", gson.toJson(bean));
tagMap.put("searchengine", this.configurationEx.searchengine);
this.configurationEx
.getWriterFactory()
.getFreemarkerWriter()
.generateHtmlFile("index.ftl", tagMap,
this.configurationEx.destDirName, null);
}
示例3: setCollation
import java.text.Collator; //导入方法依赖的package包/类
void setCollation(String name) throws HsqlException {
String jname = (String) Collation.nameToJavaName.get(name);
if (jname == null) {
throw Trace.error(Trace.INVALID_COLLATION_NAME_NO_SUBCLASS);
}
this.name = name;
String[] parts = StringUtil.split(jname, "-");
String language = parts[0];
String country = parts.length == 2 ? parts[1]
: "";
locale = new Locale(language, country);
collator = Collator.getInstance(locale);
}
示例4: setCollation
import java.text.Collator; //导入方法依赖的package包/类
void setCollation(String newName) {
String jname = (String) Collation.nameToJavaName.get(newName);
if (jname == null) {
throw Error.error(ErrorCode.X_42501, jname);
}
name.rename(newName, true);
String[] parts = StringUtil.split(jname, "-");
String language = parts[0];
String country = parts.length == 2 ? parts[1]
: "";
locale = new Locale(language, country);
collator = Collator.getInstance(locale);
equalIsIdentical = false;
}
示例5: getSupportedCountries
import java.text.Collator; //导入方法依赖的package包/类
/** @return The list of supported countries sorted by their localized display names. */
public static List<DropdownKeyValue> getSupportedCountries() {
List<String> countryCodes = new ArrayList<>();
List<String> countryNames = new ArrayList<>();
List<DropdownKeyValue> countries = new ArrayList<>();
nativeGetSupportedCountries(countryCodes, countryNames);
for (int i = 0; i < countryCodes.size(); i++) {
countries.add(new DropdownKeyValue(countryCodes.get(i), countryNames.get(i)));
}
final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.PRIMARY);
Collections.sort(countries, new Comparator<DropdownKeyValue>() {
@Override
public int compare(DropdownKeyValue lhs, DropdownKeyValue rhs) {
int result = collator.compare(lhs.getValue(), rhs.getValue());
if (result == 0) result = lhs.getKey().compareTo(rhs.getKey());
return result;
}
});
return countries;
}
示例6: DocCollator
import java.text.Collator; //导入方法依赖的package包/类
private DocCollator(Locale locale, int strength) {
instance = Collator.getInstance(locale);
instance.setStrength(strength);
keys = new LinkedHashMap<String, CollationKey>(MAX_SIZE + 1, 0.75f, true) {
private static final long serialVersionUID = 1L;
@Override
protected boolean removeEldestEntry(Entry<String, CollationKey> eldest) {
return size() > MAX_SIZE;
}
};
}
示例7: generateDocData
import java.text.Collator; //导入方法依赖的package包/类
protected DocData generateDocData(WRDoc wrDoc) {
DocData result = new DocData();
List<String> tagList = new ArrayList<String>(wrDoc.getWRTags());
Collator cmp = Collator.getInstance(java.util.Locale.CHINA);
Collections.sort(tagList, cmp);
for (String tag : tagList) {
result.getFacet_counts()
.getFacet_fields()
.addTagField(tag, wrDoc.getTaggedOpenAPIs().get(tag).size());
Doc doc = new Doc();
doc.setTag(tag);
for (OpenAPI openAPI : wrDoc.getTaggedOpenAPIs().get(tag)) {
API api = new API();
api.setUrl(openAPI.getRequestMapping().getUrl());
api.setTooltip(openAPI.getRequestMapping().getTooltip());
api.setMethodType(openAPI.getRequestMapping().getMethodType());
String filename = generateWRAPIFileName(openAPI
.getRequestMapping().getContainerName(), openAPI
.getRequestMapping().getUrl(), openAPI
.getRequestMapping().getMethodType());
api.setFilepath(filename);
api.setBrief(openAPI.getBrief());
doc.getAPIs().add(api);
}
result.addDoc(doc);
}
return result;
}
示例8: getComparator
import java.text.Collator; //导入方法依赖的package包/类
/**
* Lazy loads a static comparator to compare chips.
* @return {@link Comparator}
*/
public static Comparator<Chip> getComparator() {
if (comparator == null) {
comparator = new Comparator<Chip>() {
@Override
public int compare(Chip c1, Chip c2) {
if (collator == null) {
collator = Collator.getInstance(Locale.getDefault());
}
return collator.compare(c1.getTitle(), c2.getTitle());
}
};
}
return comparator;
}
示例9: TestCollationKey
import java.text.Collator; //导入方法依赖的package包/类
public final void TestCollationKey( )
{
logln("testing CollationKey begins...");
Collator col = null;
try {
col = Collator.getInstance(Locale.ROOT);
} catch (Exception foo) {
errln("Error : " + foo.getMessage());
errln("Default collation creation failed.");
}
if (col == null) {
return;
}
String test1 = "Abcda", test2 = "abcda";
logln("Use tertiary comparison level testing ....");
CollationKey sortk1 = col.getCollationKey(test1);
CollationKey sortk2 = col.getCollationKey(test2);
doAssert(sortk1.compareTo(sortk2) > 0,
"Result should be \"Abcda\" >>> \"abcda\"");
CollationKey sortk3 = sortk2;
CollationKey sortkNew = sortk1;
doAssert(sortk1 != sortk2, "The sort keys should be different");
doAssert(sortk1.hashCode() != sortk2.hashCode(), "sort key hashCode() failed");
doAssert(sortk2.compareTo(sortk3) == 0, "The sort keys should be the same");
doAssert(sortk1 == sortkNew, "The sort keys assignment failed");
doAssert(sortk1.hashCode() == sortkNew.hashCode(), "sort key hashCode() failed");
doAssert(sortkNew != sortk3, "The sort keys should be different");
doAssert(sortk1.compareTo(sortk3) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
doAssert(sortk2.compareTo(sortk3) == 0, "Result should be \"abcda\" == \"abcda\"");
long cnt1, cnt2;
byte byteArray1[] = sortk1.toByteArray();
byte byteArray2[] = sortk2.toByteArray();
doAssert(byteArray1 != null && byteArray2 != null, "CollationKey.toByteArray failed.");
logln("testing sortkey ends...");
}
示例10: sort
import java.text.Collator; //导入方法依赖的package包/类
/**
* Performs a locale-sensitive sort by name of a node array
* @param nodes the node array
*/
private static void sort(Object[] nodes)
{
final Collator col = Collator.getInstance(I18NUtil.getLocale());
Arrays.sort(nodes, new Comparator<Object>(){
@Override
public int compare(Object o1, Object o2)
{
return col.compare(((ScriptNode)o1).getName(), ((ScriptNode)o2).getName());
}});
}
示例11: hasCollators
import java.text.Collator; //导入方法依赖的package包/类
/** Returns an array of collators, possibly <code>null</code>. The collators
* correspond to any SortFields which were given a specific locale.
* @param fields Array of sort fields.
* @return Array, possibly <code>null</code>.
*/
private Collator[] hasCollators (final SortField[] fields) {
if (fields == null) return null;
Collator[] ret = new Collator[fields.length];
for (int i=0; i<fields.length; ++i) {
Locale locale = fields[i].getLocale();
if (locale != null)
ret[i] = Collator.getInstance (locale);
}
return ret;
}
示例12: comparator
import java.text.Collator; //导入方法依赖的package包/类
static Comparator<Project> comparator() {
return new Comparator<Project>() {
Collator COLL = Collator.getInstance();
@Override public int compare(Project o1, Project o2) {
int r = COLL.compare(ProjectUtils.getInformation(o1).getDisplayName(),
ProjectUtils.getInformation(o2).getDisplayName());
if (r != 0) {
return r;
} else {
return o1 == o2 ? 0 : o1.hashCode() - o2.hashCode();
}
}
};
}
示例13: sort
import java.text.Collator; //导入方法依赖的package包/类
public static void sort(List<? extends Sortable> list) {
final Collator chineseCollator = Collator.getInstance(Locale.CHINA);
Collections.sort(list, new Comparator<Sortable>() {
@Override
public int compare(Sortable o1, Sortable o2) {
return chineseCollator.compare(o1.sortName(), o2.sortName());
}
});
}
示例14: getCollationKeyInBytes
import java.text.Collator; //导入方法依赖的package包/类
private static byte[] getCollationKeyInBytes(String name) {
if (mColl == null) {
mColl = Collator.getInstance();
mColl.setStrength(Collator.PRIMARY);
}
return mColl.getCollationKey(name).toByteArray();
}
示例15: getCollator
import java.text.Collator; //导入方法依赖的package包/类
public Collator getCollator(Locale locale) {
if (locale == DEFAULT_LOCALE)
return DEFAULT_COLLATOR;
else
return Collator.getInstance(locale);
}