当前位置: 首页>>代码示例>>Java>>正文


Java Collator.getInstance方法代码示例

本文整理汇总了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;
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:23,代码来源:Collation.java

示例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);
}
 
开发者ID:WinRoad-NET,项目名称:htmldoclet4jdk8,代码行数:17,代码来源:HtmlDoclet.java

示例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);
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:Collation.java

示例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;
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:20,代码来源:Collation.java

示例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;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:AutofillProfileBridge.java

示例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;
        }
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:Utils.java

示例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;
}
 
开发者ID:WinRoad-NET,项目名称:htmldoclet4jdk7,代码行数:29,代码来源:HtmlDoclet.java

示例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;
}
 
开发者ID:tylersuehr7,项目名称:chips-input-layout,代码行数:19,代码来源:Chip.java

示例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...");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:APITest.java

示例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());
        }});        
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:ScriptNode.java

示例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;
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:16,代码来源:FieldDocSortedHitQueue.java

示例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();
            }
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ProjectRenderer.java

示例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());
        }
    });
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:10,代码来源:SortUtil.java

示例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();
}
 
开发者ID:kkmike999,项目名称:KBUnitTest,代码行数:8,代码来源:ShadowDatabaseUtils.java

示例15: getCollator

import java.text.Collator; //导入方法依赖的package包/类
public Collator getCollator(Locale locale) {
    if (locale == DEFAULT_LOCALE)
        return DEFAULT_COLLATOR;
    else
        return Collator.getInstance(locale);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:CollatorFactoryBase.java


注:本文中的java.text.Collator.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。