本文整理汇总了Java中sun.util.resources.OpenListResourceBundle类的典型用法代码示例。如果您正苦于以下问题:Java OpenListResourceBundle类的具体用法?Java OpenListResourceBundle怎么用?Java OpenListResourceBundle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpenListResourceBundle类属于sun.util.resources包,在下文中一共展示了OpenListResourceBundle类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrencyName
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
public String getCurrencyName(String key) {
Object currencyName = null;
String cacheKey = CURRENCY_NAMES + key;
removeEmptyReferences();
ResourceReference data = cache.get(cacheKey);
if (data != null && ((currencyName = data.get()) != null)) {
if (currencyName.equals(NULLOBJECT)) {
currencyName = null;
}
return (String) currencyName;
}
OpenListResourceBundle olrb = localeData.getCurrencyNames(locale);
if (olrb.containsKey(key)) {
currencyName = olrb.getObject(key);
cache.put(cacheKey,
new ResourceReference(cacheKey, currencyName, referenceQueue));
}
return (String) currencyName;
}
示例2: getLocaleName
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
public String getLocaleName(String key) {
Object localeName = null;
String cacheKey = LOCALE_NAMES + key;
removeEmptyReferences();
ResourceReference data = cache.get(cacheKey);
if (data != null && ((localeName = data.get()) != null)) {
if (localeName.equals(NULLOBJECT)) {
localeName = null;
}
return (String) localeName;
}
OpenListResourceBundle olrb = localeData.getLocaleNames(locale);
if (olrb.containsKey(key)) {
localeName = olrb.getObject(key);
cache.put(cacheKey,
new ResourceReference(cacheKey, localeName, referenceQueue));
}
return (String) localeName;
}
示例3: getDisplayVariant
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
/**
* Returns a name for the locale's variant code that is appropriate for display to the
* user. If possible, the name will be localized for inLocale. If the locale
* doesn't specify a variant code, this function returns the empty string.
*
* @exception NullPointerException if <code>inLocale</code> is <code>null</code>
*/
public String getDisplayVariant(Locale inLocale) {
if (variant.length() == 0)
return "";
OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale);
String names[] = getDisplayVariantArray(bundle, inLocale);
// Get the localized patterns for formatting a list, and use
// them to format the list.
String listPattern = null;
String listCompositionPattern = null;
try {
listPattern = bundle.getString("ListPattern");
listCompositionPattern = bundle.getString("ListCompositionPattern");
} catch (MissingResourceException e) {
}
return formatList(names, listPattern, listCompositionPattern);
}
示例4: getDisplayVariant
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
/**
* Returns a name for the locale's variant code that is appropriate for display to the
* user. If possible, the name will be localized for inLocale. If the locale
* doesn't specify a variant code, this function returns the empty string.
*
* @exception NullPointerException if <code>inLocale</code> is <code>null</code>
*/
public String getDisplayVariant(Locale inLocale) {
if (baseLocale.getVariant().length() == 0)
return "";
OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale);
String names[] = getDisplayVariantArray(bundle, inLocale);
// Get the localized patterns for formatting a list, and use
// them to format the list.
String listPattern = null;
String listCompositionPattern = null;
try {
listPattern = bundle.getString("ListPattern");
listCompositionPattern = bundle.getString("ListCompositionPattern");
} catch (MissingResourceException e) {
}
return formatList(names, listPattern, listCompositionPattern);
}
示例5: loadZoneStrings
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
private static final String[][] loadZoneStrings(Locale locale) {
List<String[]> zones = new LinkedList<String[]>();
OpenListResourceBundle rb = getBundle(locale);
Enumeration<String> keys = rb.getKeys();
String[] names = null;
while(keys.hasMoreElements()) {
String key = keys.nextElement();
names = retrieveDisplayNames(rb, key, locale);
if (names != null) {
zones.add(names);
}
}
String[][] zonesArray = new String[zones.size()][];
return zones.toArray(zonesArray);
}
示例6: retrieveDisplayNames
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
private static final String[] retrieveDisplayNames(OpenListResourceBundle rb,
String id, Locale locale) {
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class);
String[] names = null;
// Check whether a provider can provide an implementation that's closer
// to the requested locale than what the Java runtime itself can provide.
if (pool.hasProviders()) {
names = pool.getLocalizedObject(
TimeZoneNameGetter.INSTANCE,
locale, rb, id);
}
if (names == null) {
try {
names = rb.getStringArray(id);
} catch (MissingResourceException mre) {
// fall through
}
}
return names;
}
示例7: getDisplayString
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
private String getDisplayString(String code, Locale inLocale, int type) {
if (code.length() == 0) {
return "";
}
if (inLocale == null) {
throw new NullPointerException();
}
try {
OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale);
String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
String result = null;
// Check whether a provider can provide an implementation that's closer
// to the requested locale than what the Java runtime itself can provide.
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
if (pool.hasProviders()) {
result = pool.getLocalizedObject(
LocaleNameGetter.INSTANCE,
inLocale, bundle, key,
type, code);
}
if (result == null) {
result = bundle.getString(key);
}
if (result != null) {
return result;
}
}
catch (Exception e) {
// just fall through
}
return code;
}
示例8: getDisplayVariantArray
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
/**
* Return an array of the display names of the variant.
* @param bundle the ResourceBundle to use to get the display names
* @return an array of display names, possible of zero length.
*/
private String[] getDisplayVariantArray(OpenListResourceBundle bundle, Locale inLocale) {
// Split the variant name into tokens separated by '_'.
StringTokenizer tokenizer = new StringTokenizer(variant, "_");
String[] names = new String[tokenizer.countTokens()];
// For each variant token, lookup the display name. If
// not found, use the variant name itself.
for (int i=0; i<names.length; ++i) {
names[i] = getDisplayString(tokenizer.nextToken(),
inLocale, DISPLAY_VARIANT);
}
return names;
}
示例9: getDisplayString
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
private String getDisplayString(String code, Locale inLocale, int type) {
if (code.length() == 0) {
return "";
}
if (inLocale == null) {
throw new NullPointerException();
}
try {
OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale);
String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
String result = null;
// Check whether a provider can provide an implementation that's closer
// to the requested locale than what the Java runtime itself can provide.
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
if (pool.hasProviders()) {
result = pool.getLocalizedObject(
LocaleNameGetter.INSTANCE,
inLocale, bundle, key,
type, code);
}
if (result == null) {
result = bundle.getString(key);
}
if (result != null) {
return result;
}
}
catch (Exception e) {
// just fall through
}
return code;
}
示例10: getDisplayVariantArray
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
/**
* Return an array of the display names of the variant.
* @param bundle the ResourceBundle to use to get the display names
* @return an array of display names, possible of zero length.
*/
private String[] getDisplayVariantArray(OpenListResourceBundle bundle, Locale inLocale) {
// Split the variant name into tokens separated by '_'.
StringTokenizer tokenizer = new StringTokenizer(baseLocale.getVariant(), "_");
String[] names = new String[tokenizer.countTokens()];
// For each variant token, lookup the display name. If
// not found, use the variant name itself.
for (int i=0; i<names.length; ++i) {
names[i] = getDisplayString(tokenizer.nextToken(),
inLocale, DISPLAY_VARIANT);
}
return names;
}
示例11: getSymbol
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
/**
* Gets the symbol of this currency for the specified locale.
* For example, for the US Dollar, the symbol is "$" if the specified
* locale is the US, while for other locales it may be "US$". If no
* symbol can be determined, the ISO 4217 currency code is returned.
*
* @param locale the locale for which a display name for this currency is
* needed
* @return the symbol of this currency for the specified locale
* @exception NullPointerException if <code>locale</code> is null
*/
public String getSymbol(Locale locale) {
try {
// Check whether a provider can provide an implementation that's closer
// to the requested locale than what the Java runtime itself can provide.
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
if (pool.hasProviders()) {
// Assuming that all the country locales include necessary currency
// symbols in the Java runtime's resources, so there is no need to
// examine whether Java runtime's currency resource bundle is missing
// names. Therefore, no resource bundle is provided for calling this
// method.
String symbol = pool.getLocalizedObject(
CurrencyNameGetter.INSTANCE,
locale, (OpenListResourceBundle)null,
currencyCode, SYMBOL);
if (symbol != null) {
return symbol;
}
}
ResourceBundle bundle = LocaleData.getCurrencyNames(locale);
return bundle.getString(currencyCode);
} catch (MissingResourceException e) {
// use currency code as symbol of last resort
return currencyCode;
}
}
示例12: getDisplayName
import sun.util.resources.OpenListResourceBundle; //导入依赖的package包/类
/**
* Gets the name that is suitable for displaying this currency for
* the specified locale. If there is no suitable display name found
* for the specified locale, the ISO 4217 currency code is returned.
*
* @param locale the locale for which a display name for this currency is
* needed
* @return the display name of this currency for the specified locale
* @exception NullPointerException if <code>locale</code> is null
* @since 1.7
*/
public String getDisplayName(Locale locale) {
try {
OpenListResourceBundle bundle = LocaleData.getCurrencyNames(locale);
String result = null;
String bundleKey = currencyCode.toLowerCase(Locale.ROOT);
// Check whether a provider can provide an implementation that's closer
// to the requested locale than what the Java runtime itself can provide.
LocaleServiceProviderPool pool =
LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
if (pool.hasProviders()) {
result = pool.getLocalizedObject(
CurrencyNameGetter.INSTANCE,
locale, bundleKey, bundle, currencyCode, DISPLAYNAME);
}
if (result == null) {
result = bundle.getString(bundleKey);
}
if (result != null) {
return result;
}
} catch (MissingResourceException e) {
// fall through
}
// use currency code as symbol of last resort
return currencyCode;
}