本文整理汇总了Java中com.ibm.icu.util.ULocale.getFallback方法的典型用法代码示例。如果您正苦于以下问题:Java ULocale.getFallback方法的具体用法?Java ULocale.getFallback怎么用?Java ULocale.getFallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.util.ULocale
的用法示例。
在下文中一共展示了ULocale.getFallback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
* Get a DayPeriodRules object given a locale.
* If data hasn't been loaded, it will be loaded for all locales at once.
* @param locale locale for which the DayPeriodRules object is requested.
* @return a DayPeriodRules object for `locale`.
*/
public static DayPeriodRules getInstance(ULocale locale) {
String localeCode = locale.getName();
if (localeCode.isEmpty()) { localeCode = "root"; }
Integer ruleSetNum = null;
while (ruleSetNum == null) {
ruleSetNum = DATA.localesToRuleSetNumMap.get(localeCode);
if (ruleSetNum == null) {
localeCode = ULocale.getFallback(localeCode);
if (localeCode.isEmpty()) {
// Saves a lookup in the map.
break;
}
} else {
break;
}
}
if (ruleSetNum == null || DATA.rules[ruleSetNum] == null) {
// Data doesn't exist for the locale requested.
return null;
}
return DATA.rules[ruleSetNum];
}
示例2: getNameListForLocale
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private String[] getNameListForLocale(ULocale loc) {
if (loc != null && ruleSetDisplayNames != null) {
String[] localeNames = { loc.getBaseName(), ULocale.getDefault(Category.DISPLAY).getBaseName() };
for (String lname : localeNames) {
while (lname.length() > 0) {
String[] names = ruleSetDisplayNames.get(lname);
if (names != null) {
return names;
}
lname = ULocale.getFallback(lname);
}
}
}
return null;
}
示例3: getUnitPatterns
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
@Override
public Map<String, String> getUnitPatterns() {
Map<String, String> result = new HashMap<String, String>();
ULocale locale = rb.getULocale();
for (;locale != null; locale = locale.getFallback()) {
ICUResourceBundle r = (ICUResourceBundle) UResourceBundle.getBundleInstance(
ICUData.ICU_CURR_BASE_NAME, locale);
if (r == null) {
continue;
}
ICUResourceBundle cr = r.findWithFallback("CurrencyUnitPatterns");
if (cr == null) {
continue;
}
for (int index = 0, size = cr.getSize(); index < size; ++index) {
ICUResourceBundle b = (ICUResourceBundle) cr.get(index);
String key = b.getKey();
if (result.containsKey(key)) {
continue;
}
result.put(key, b.getString());
}
}
// Default result is the empty map. Callers who require a pattern will have to
// supply a default.
return Collections.unmodifiableMap(result);
}