本文整理汇总了Java中java.text.spi.CollatorProvider类的典型用法代码示例。如果您正苦于以下问题:Java CollatorProvider类的具体用法?Java CollatorProvider怎么用?Java CollatorProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollatorProvider类属于java.text.spi包,在下文中一共展示了CollatorProvider类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCollatorProvider
import java.text.spi.CollatorProvider; //导入依赖的package包/类
@Override
public CollatorProvider getCollatorProvider() {
if (collatorProvider == null) {
CollatorProvider provider = AccessController.doPrivileged(
(PrivilegedAction<CollatorProvider>) () ->
new CollatorProviderImpl(
getAdapterType(),
getLanguageTagSet("CollationData")));
synchronized (this) {
if (collatorProvider == null) {
collatorProvider = provider;
}
}
}
return collatorProvider;
}
示例2: getObject
import java.text.spi.CollatorProvider; //导入依赖的package包/类
public Collator getObject(CollatorProvider collatorProvider,
Locale locale,
String key,
Object... params) {
assert params.length == 1;
Collator result = collatorProvider.getInstance(locale);
if (result != null) {
// put this Collator instance in the cache for two locales, one
// is for the desired locale, and the other is for the actual
// locale where the provider is found, which may be a fall back locale.
cache.put((Locale)params[0], result);
cache.put(locale, result);
return (Collator)result.clone();
}
return null;
}
示例3: getObject
import java.text.spi.CollatorProvider; //导入依赖的package包/类
public Collator getObject(CollatorProvider collatorProvider,
Locale locale,
String key,
Object... params) {
assert params.length == 1;
Collator result = collatorProvider.getInstance(locale);
if (result != null) {
// put this Collator instance in the cache for two locales, one
// is for the desired locale, and the other is for the actual
// locale where the provider is found, which may be a fall back locale.
cache.put((Locale)params[0], result);
cache.put(locale, result);
return (Collator)result.clone();
}
return null;
}
示例4: getInstance
import java.text.spi.CollatorProvider; //导入依赖的package包/类
/**
* Gets the Collator for the desired locale.
* @param desiredLocale the desired locale.
* @return the Collator for the desired locale.
* @see java.util.Locale
* @see java.util.ResourceBundle
*/
public static Collator getInstance(Locale desiredLocale) {
SoftReference<Collator> ref = cache.get(desiredLocale);
Collator result = (ref != null) ? ref.get() : null;
if (result == null) {
LocaleProviderAdapter adapter;
adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
desiredLocale);
CollatorProvider provider = adapter.getCollatorProvider();
result = provider.getInstance(desiredLocale);
if (result == null) {
result = LocaleProviderAdapter.forJRE()
.getCollatorProvider().getInstance(desiredLocale);
}
while (true) {
if (ref != null) {
// Remove the empty SoftReference if any
cache.remove(desiredLocale, ref);
}
ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
if (ref == null) {
break;
}
Collator cachedColl = ref.get();
if (cachedColl != null) {
result = cachedColl;
break;
}
}
}
return (Collator) result.clone(); // make the world safe
}
示例5: getCollatorProvider
import java.text.spi.CollatorProvider; //导入依赖的package包/类
@Override
public CollatorProvider getCollatorProvider() {
if (collatorProvider == null) {
CollatorProvider provider = new CollatorProviderImpl(getAdapterType(),
getLanguageTagSet("CollationData"));
synchronized (this) {
if (collatorProvider == null) {
collatorProvider = provider;
}
}
}
return collatorProvider;
}
示例6: getCollatorProvider
import java.text.spi.CollatorProvider; //导入依赖的package包/类
@Override
public CollatorProvider getCollatorProvider() {
return getLocaleServiceProvider(CollatorProvider.class);
}
示例7: addImpl
import java.text.spi.CollatorProvider; //导入依赖的package包/类
@Override
public void addImpl(CollatorProvider impl) {
for (Locale l : impl.getAvailableLocales()) {
map.putIfAbsent(l, impl);
}
}
示例8: getImpl
import java.text.spi.CollatorProvider; //导入依赖的package包/类
@Override
public CollatorProvider getImpl(Locale locale) {
return SPILocaleProviderAdapter.getImpl(map, locale);
}
示例9: getCollatorProvider
import java.text.spi.CollatorProvider; //导入依赖的package包/类
@Override
public CollatorProvider getCollatorProvider() {
return null;
}