类java.util.ResourceBundle.Control源码实例Demo

下面列出了怎么用java.util.ResourceBundle.Control的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码2 项目: TencentKona-8   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码3 项目: jdk8u60   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码4 项目: openjdk-jdk8u   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码6 项目: openjdk-jdk9   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码7 项目: jdk8u-jdk   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码8 项目: hottub   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码9 项目: openjdk-8-source   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码10 项目: jasperreports   文件: JRPropertiesUtil.java
public String getLocalizedProperty(String property, Locale locale)
{
	Control control = Control.getControl(Control.FORMAT_PROPERTIES);
	String value = null;
	
	// we're not looking at the fallback locale to be consistent with JRResourcesUtil.loadResourceBundle
	List<Locale> locales = control.getCandidateLocales(property, locale);
	for (Locale candidate : locales)
	{
		String candidateString = candidate.toString();
		String candidateProperty = candidateString.isEmpty() ? property : (property + "_" + candidateString);
		String candidateValue = getProperty(candidateProperty);
		if (candidateValue != null)// test for empty?
		{
			value = candidateValue;
			break;
		}
	}
	return value;
}
 
源代码11 项目: openjdk-8   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码12 项目: jdk8u_jdk   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
private String getTranslatedText(String resourceName, String key, Locale locale) {
    try {
        // Modify the search order so that the following applies:
        // 1.) baseName + "_" + language + "_" + country
        // 2.) baseName + "_" + language
        // 3.) baseName
        // 4.) null -> leads to a default text
        // Not using the default fallback strategy helps that not the default locale
        // search order is applied between 2.) and 3.).
        ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceName, locale, this.resourceClassLoader,
                Control.getNoFallbackControl(Control.FORMAT_PROPERTIES));

        if (resourceBundle != null) {
            return resourceBundle.getString(key);
        }
    } catch (Exception ex) {
        // nothing to do
    }

    return null;
}
 
源代码14 项目: openhab-core   文件: SemanticTags.java
/**
 * Determines the semantic entity type of an item, i.e. a sub-type of Location, Equipment or Point.
 *
 * @param item the item to get the semantic type for
 * @return a sub-type of Location, Equipment or Point
 */
public static @Nullable Class<? extends Tag> getSemanticType(Item item) {
    Set<String> tags = item.getTags();
    for (String tag : tags) {
        Class<? extends Tag> type = getById(tag);
        if (type != null && !Property.class.isAssignableFrom(type)) {
            return type;
        }
    }
    // we haven't found any type as a tag, but if there is a Property tag, we can conclude that it is a Point
    if (getProperty(item) != null) {
        StateDescription stateDescription = item.getStateDescription();
        if (stateDescription != null && stateDescription.isReadOnly()) {
            return Measurement.class;
        } else {
            return org.openhab.core.semantics.model.point.Control.class;
        }
    } else {
        return null;
    }
}
 
源代码15 项目: proarc   文件: NdkPlugin.java
private ValueMap<? extends LanguageTermDefinition> readLangs(Locale locale) {
    ArrayList<LangTermValue> langs = new ArrayList<LangTermValue>();
    // to read properties file in UTF-8 use PropertyResourceBundle(Reader)
    Control control = ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES);

    ResourceBundle rb = ResourceBundle.getBundle(BundleName.LANGUAGES_ISO639_2.toString(), locale, control);
    for (String key : rb.keySet()) {
        LangTermValue lt = new LangTermValue();
        lt.setAuthority("iso639-2b");
        lt.setType(CodeOrText.CODE);
        lt.setValue(key);
        lt.setTitle(rb.getString(key));
        langs.add(lt);
    }
    Collections.sort(langs, new LangComparator(locale));
    return new ValueMap<LangTermValue>(BundleName.LANGUAGES_ISO639_2.getValueMapId(), langs);
}
 
源代码16 项目: jdk8u-jdk   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码17 项目: jdk8u-dev-jdk   文件: ResourceBundleTest.java
/**
 * @bug 4108126
 */
public void TestGetLocale() {
    // try to find TestResource_fr_CH.  Should get fr_CH as its locale
    ResourceBundle test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "CH", ""));
    Locale locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
        errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);

    // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("fr", "BE", ""));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);

    // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
    // as its locale
    test = ResourceBundle.getBundle("TestResource",
                    new Locale("iw", "IL", ""),
                    Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    locale = test.getLocale();
    if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
        errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
                        + locale);
}
 
源代码18 项目: smarthome   文件: LanguageResourceBundleManager.java
private String getTranslatedText(String resourceName, String key, Locale locale) {
    try {
        // Modify the search order so that the following applies:
        // 1.) baseName + "_" + language + "_" + country
        // 2.) baseName + "_" + language
        // 3.) baseName
        // 4.) null -> leads to a default text
        // Not using the default fallback strategy helps that not the default locale
        // search order is applied between 2.) and 3.).
        ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceName, locale, this.resourceClassLoader,
                Control.getNoFallbackControl(Control.FORMAT_PROPERTIES));

        if (resourceBundle != null) {
            return resourceBundle.getString(key);
        }
    } catch (Exception ex) {
        // nothing to do
    }

    return null;
}
 
源代码19 项目: jdk1.8-source-analysis   文件: UIDefaults.java
/**
 * Returns a Map of the known resources for the given locale.
 */
private Map<String, Object> getResourceCache(Locale l) {
    Map<String, Object> values = resourceCache.get(l);

    if (values == null) {
        values = new TextAndMnemonicHashMap();
        for (int i=resourceBundles.size()-1; i >= 0; i--) {
            String bundleName = resourceBundles.get(i);
            try {
                Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                ResourceBundle b;
                if (c != null) {
                    b = ResourceBundle.getBundle(bundleName, l, c);
                } else {
                    b = ResourceBundle.getBundle(bundleName, l);
                }
                Enumeration keys = b.getKeys();

                while (keys.hasMoreElements()) {
                    String key = (String)keys.nextElement();

                    if (values.get(key) == null) {
                        Object value = b.getObject(key);

                        values.put(key, value);
                    }
                }
            } catch( MissingResourceException mre ) {
                // Keep looking
            }
        }
        resourceCache.put(l, values);
    }
    return values;
}
 
/**
 * Returns a list of candidate locales for service look up.
 * @param locale the input locale
 * @return the list of candidate locales for the given locale
 */
static List<Locale> getLookupLocales(Locale locale) {
    // Note: We currently use the default implementation of
    // ResourceBundle.Control.getCandidateLocales. The result
    // returned by getCandidateLocales are already normalized
    // (no extensions) for service look up.
    List<Locale> lookupLocales = Control.getNoFallbackControl(Control.FORMAT_DEFAULT)
                                        .getCandidateLocales("", locale);
    return lookupLocales;
}
 
源代码21 项目: dragonwell8_jdk   文件: UIDefaults.java
/**
 * Returns a Map of the known resources for the given locale.
 */
private Map<String, Object> getResourceCache(Locale l) {
    Map<String, Object> values = resourceCache.get(l);

    if (values == null) {
        values = new TextAndMnemonicHashMap();
        for (int i=resourceBundles.size()-1; i >= 0; i--) {
            String bundleName = resourceBundles.get(i);
            try {
                Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                ResourceBundle b;
                if (c != null) {
                    b = ResourceBundle.getBundle(bundleName, l, c);
                } else {
                    b = ResourceBundle.getBundle(bundleName, l,
                            ClassLoader.getSystemClassLoader());
                }
                Enumeration keys = b.getKeys();

                while (keys.hasMoreElements()) {
                    String key = (String)keys.nextElement();

                    if (values.get(key) == null) {
                        Object value = b.getObject(key);

                        values.put(key, value);
                    }
                }
            } catch( MissingResourceException mre ) {
                // Keep looking
            }
        }
        resourceCache.put(l, values);
    }
    return values;
}
 
源代码22 项目: dragonwell8_jdk   文件: ResourceBundleTest.java
public void TestListResourceBundle() {
    // load up the resource and check to make sure we got the right class
    // (we don't define be_BY or be, so we fall back on the root default)
    ResourceBundle  bundle = ResourceBundle.getBundle("TestResource",
                        new Locale("be", "BY"),
                        Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    if (!bundle.getClass().getName().equals("TestResource"))
        errln("Expected TestResource, got " + bundle.getClass().getName());

    doListResourceBundleTest(bundle);
}
 
源代码23 项目: TencentKona-8   文件: LocaleServiceProviderPool.java
/**
 * Returns a list of candidate locales for service look up.
 * @param locale the input locale
 * @return the list of candidate locales for the given locale
 */
static List<Locale> getLookupLocales(Locale locale) {
    // Note: We currently use the default implementation of
    // ResourceBundle.Control.getCandidateLocales. The result
    // returned by getCandidateLocales are already normalized
    // (no extensions) for service look up.
    List<Locale> lookupLocales = Control.getNoFallbackControl(Control.FORMAT_DEFAULT)
                                        .getCandidateLocales("", locale);
    return lookupLocales;
}
 
源代码24 项目: TencentKona-8   文件: UIDefaults.java
/**
 * Returns a Map of the known resources for the given locale.
 */
private Map<String, Object> getResourceCache(Locale l) {
    Map<String, Object> values = resourceCache.get(l);

    if (values == null) {
        values = new TextAndMnemonicHashMap();
        for (int i=resourceBundles.size()-1; i >= 0; i--) {
            String bundleName = resourceBundles.get(i);
            try {
                Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                ResourceBundle b;
                if (c != null) {
                    b = ResourceBundle.getBundle(bundleName, l, c);
                } else {
                    b = ResourceBundle.getBundle(bundleName, l,
                            ClassLoader.getSystemClassLoader());
                }
                Enumeration keys = b.getKeys();

                while (keys.hasMoreElements()) {
                    String key = (String)keys.nextElement();

                    if (values.get(key) == null) {
                        Object value = b.getObject(key);

                        values.put(key, value);
                    }
                }
            } catch( MissingResourceException mre ) {
                // Keep looking
            }
        }
        resourceCache.put(l, values);
    }
    return values;
}
 
源代码25 项目: TencentKona-8   文件: ResourceBundleTest.java
public void TestListResourceBundle() {
    // load up the resource and check to make sure we got the right class
    // (we don't define be_BY or be, so we fall back on the root default)
    ResourceBundle  bundle = ResourceBundle.getBundle("TestResource",
                        new Locale("be", "BY"),
                        Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    if (!bundle.getClass().getName().equals("TestResource"))
        errln("Expected TestResource, got " + bundle.getClass().getName());

    doListResourceBundleTest(bundle);
}
 
源代码26 项目: jdk8u60   文件: LocaleServiceProviderPool.java
/**
 * Returns a list of candidate locales for service look up.
 * @param locale the input locale
 * @return the list of candidate locales for the given locale
 */
static List<Locale> getLookupLocales(Locale locale) {
    // Note: We currently use the default implementation of
    // ResourceBundle.Control.getCandidateLocales. The result
    // returned by getCandidateLocales are already normalized
    // (no extensions) for service look up.
    List<Locale> lookupLocales = Control.getNoFallbackControl(Control.FORMAT_DEFAULT)
                                        .getCandidateLocales("", locale);
    return lookupLocales;
}
 
源代码27 项目: jdk8u60   文件: UIDefaults.java
/**
 * Returns a Map of the known resources for the given locale.
 */
private Map<String, Object> getResourceCache(Locale l) {
    Map<String, Object> values = resourceCache.get(l);

    if (values == null) {
        values = new TextAndMnemonicHashMap();
        for (int i=resourceBundles.size()-1; i >= 0; i--) {
            String bundleName = resourceBundles.get(i);
            try {
                Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                ResourceBundle b;
                if (c != null) {
                    b = ResourceBundle.getBundle(bundleName, l, c);
                } else {
                    b = ResourceBundle.getBundle(bundleName, l);
                }
                Enumeration keys = b.getKeys();

                while (keys.hasMoreElements()) {
                    String key = (String)keys.nextElement();

                    if (values.get(key) == null) {
                        Object value = b.getObject(key);

                        values.put(key, value);
                    }
                }
            } catch( MissingResourceException mre ) {
                // Keep looking
            }
        }
        resourceCache.put(l, values);
    }
    return values;
}
 
源代码28 项目: jdk8u60   文件: ResourceBundleTest.java
public void TestListResourceBundle() {
    // load up the resource and check to make sure we got the right class
    // (we don't define be_BY or be, so we fall back on the root default)
    ResourceBundle  bundle = ResourceBundle.getBundle("TestResource",
                        new Locale("be", "BY"),
                        Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
    if (!bundle.getClass().getName().equals("TestResource"))
        errln("Expected TestResource, got " + bundle.getClass().getName());

    doListResourceBundleTest(bundle);
}
 
源代码29 项目: JDKSourceCode1.8   文件: UIDefaults.java
/**
 * Returns a Map of the known resources for the given locale.
 */
private Map<String, Object> getResourceCache(Locale l) {
    Map<String, Object> values = resourceCache.get(l);

    if (values == null) {
        values = new TextAndMnemonicHashMap();
        for (int i=resourceBundles.size()-1; i >= 0; i--) {
            String bundleName = resourceBundles.get(i);
            try {
                Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                ResourceBundle b;
                if (c != null) {
                    b = ResourceBundle.getBundle(bundleName, l, c);
                } else {
                    b = ResourceBundle.getBundle(bundleName, l,
                            ClassLoader.getSystemClassLoader());
                }
                Enumeration keys = b.getKeys();

                while (keys.hasMoreElements()) {
                    String key = (String)keys.nextElement();

                    if (values.get(key) == null) {
                        Object value = b.getObject(key);

                        values.put(key, value);
                    }
                }
            } catch( MissingResourceException mre ) {
                // Keep looking
            }
        }
        resourceCache.put(l, values);
    }
    return values;
}
 
源代码30 项目: openjdk-jdk8u   文件: LocaleServiceProviderPool.java
/**
 * Returns a list of candidate locales for service look up.
 * @param locale the input locale
 * @return the list of candidate locales for the given locale
 */
static List<Locale> getLookupLocales(Locale locale) {
    // Note: We currently use the default implementation of
    // ResourceBundle.Control.getCandidateLocales. The result
    // returned by getCandidateLocales are already normalized
    // (no extensions) for service look up.
    List<Locale> lookupLocales = Control.getNoFallbackControl(Control.FORMAT_DEFAULT)
                                        .getCandidateLocales("", locale);
    return lookupLocales;
}
 
 类所在包
 同包方法