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


Java Control类代码示例

本文整理汇总了Java中java.util.ResourceBundle.Control的典型用法代码示例。如果您正苦于以下问题:Java Control类的具体用法?Java Control怎么用?Java Control使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Control类属于java.util.ResourceBundle包,在下文中一共展示了Control类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TestGetLocale

import java.util.ResourceBundle.Control; //导入依赖的package包/类
/**
 * @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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:ResourceBundleTest.java

示例2: getTranslation

import java.util.ResourceBundle.Control; //导入依赖的package包/类
public String getTranslation(String code) {
    if (bundle == null) {
        Locale l = this.locale;
        if (l == null) {
            if (UI.getCurrent() != null) {
                l = UI.getCurrent().getLocale();
            } else {
                l = Locale.getDefault();
            }
        }

        if (useDefaultLocaleFallback) {
            bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASENAME, l);
        } else {
            bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE_BASENAME, l, Control.getNoFallbackControl(Control.FORMAT_PROPERTIES));
        }
    }
    return bundle.getString(code);
}
 
开发者ID:moberwasserlechner,项目名称:vaadin-medium-editor,代码行数:20,代码来源:Options.java

示例3: getLocalizedProperty

import java.util.ResourceBundle.Control; //导入依赖的package包/类
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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:21,代码来源:JRPropertiesUtil.java

示例4: test_Remote_French

import java.util.ResourceBundle.Control; //导入依赖的package包/类
@Test
public void test_Remote_French() {
    TestBundle testBundle = TEST_BUNDLES[0];
    String bundleId = testBundle.id;
    CloudResourceBundleControl ctrl = CloudResourceBundleControl.getInstance(
            account, Control.TTL_DONT_CACHE, null, null, null, null);

    ResourceBundle bundle = ResourceBundle.getBundle(bundleId, new Locale("fr"), ctrl);

    for (Entry<String, String> entry : testBundle.strings.entrySet()) {
        String key = entry.getKey();
        try {
            String frVal = bundle.getString(key);
            assertNotNull("Test1 fr " + key + " value", frVal);
        } catch (MissingResourceException e) {
            fail("Test1 fr should contain " + key);
        }
    }
}
 
开发者ID:IBM-Cloud,项目名称:gp-java-client,代码行数:20,代码来源:CloudResourceBundleControlTest.java

示例5: readLangs

import java.util.ResourceBundle.Control; //导入依赖的package包/类
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.getControl(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);
}
 
开发者ID:proarc,项目名称:proarc,代码行数:17,代码来源:NdkPlugin.java

示例6: getResourceBundle

import java.util.ResourceBundle.Control; //导入依赖的package包/类
/**
 * 
 * @param locale
 *            the Locale
 * @return The ResourceBundle for the application and the locale. The default
 *         name of the properties file is the same as the application class
 *         name.
 * @see MultiResourceBundle MultiResourceBundle to combine several
 *      ResourceBundle
 */
public ResourceBundle getResourceBundle(Locale locale) {
	List<ResourceBundle> resourceBundles = new ArrayList<>();
	Class<?> applicationClass = getClass();
	do {
		try {
			String resourceBundleName = applicationClass.getName();
			resourceBundles.add(ResourceBundle.getBundle(resourceBundleName, locale, Control.getNoFallbackControl(Control.FORMAT_PROPERTIES)));
		} catch (MissingResourceException x) {
			if (applicationClass == getInstance().getClass()) {
				Logger logger = Logger.getLogger(Application.class.getName());
				logger.warning("Missing the default ResourceBundle for " + this.getClass().getName());
				logger.fine("The default ResourceBundle has the same name as the Application that is launched.");
				logger.fine("See the MjExampleApplication.java and MjExampleApplication.properties");
			}
		}
		applicationClass = applicationClass.getSuperclass();
	} while (applicationClass != Application.class);
	return new MultiResourceBundle(resourceBundles);
}
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:30,代码来源:Application.java

示例7: create

import java.util.ResourceBundle.Control; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * <p>This method will throw {@link ControlFactoryException} if the passed 
 * {@code args} are not empty or if the charset specified at 
 * {@code mapping.encoding()} is not valid.</p>
 * 
 * @throws ControlFactoryException If {@code args.length != 0} or the charset 
 *          provided at {@code mapping.encoding()} is not supported.
 */
@Override
public Control create(ResourceMapping mapping, String[] args) {
    final Charset charset;
    if (args.length != 0) {
        throw new ControlFactoryException(
                "This class has no additional parameters");
    } else {
        try {
            charset = Charset.forName(mapping.encoding());
        } catch (UnsupportedCharsetException e) {
            throw new ControlFactoryException(String.format(
                    "Unsupported charset: %s", args[0]), e);
        }
    }
    return new CharsetBundleControl(charset);
}
 
开发者ID:skuzzle,项目名称:stringz,代码行数:27,代码来源:CharsetBundleControlFactory.java

示例8: LocalizerFile

import java.util.ResourceBundle.Control; //导入依赖的package包/类
public LocalizerFile(final String localizerBase, final ClassLoader classLoader, final Control control) {
	super();
	if (log.isTraceEnabled()) log.trace(HelperLog.constructor(localizerBase, classLoader));

	if (null == localizerBase) {
		throw new RuntimeExceptionIsNull("localizerBase"); //$NON-NLS-1$
	}

	if (null == classLoader) {
		throw new RuntimeExceptionIsNull("classLoader"); //$NON-NLS-1$
	}
	
	this.localizerBase = localizerBase;
	this.classLoader = classLoader;
	this.control = control;

	setupBundle(getLocale());
}
 
开发者ID:slaubenberger,项目名称:wichtel,代码行数:19,代码来源:LocalizerFile.java

示例9: getLocalizedSibling

import java.util.ResourceBundle.Control; //导入依赖的package包/类
@Override
public NodeRef getLocalizedSibling(NodeRef nodeRef)
{
    Locale userLocale = I18NUtil.getLocale();
    
    String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
    NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
    // Work out the base name we are working with
    Pair<String, String> split = getExtension(name, false);
    String base = split.getFirst();
    String ext = split.getSecond();
    
    NodeRef resultNodeRef = nodeRef;
    // Search for siblings with the same name
    Control resourceHelper = Control.getControl(Control.FORMAT_DEFAULT);
    List<Locale> candidateLocales = resourceHelper.getCandidateLocales(base, userLocale);
    for (Locale candidateLocale : candidateLocales)
    {
        String filename = resourceHelper.toBundleName(base, candidateLocale) + "." + ext;
        // Attempt to find the file
        NodeRef foundNodeRef = searchSimple(parentNodeRef, filename);
        if (foundNodeRef != null)   // TODO: Check for read permissions
        {
            resultNodeRef = foundNodeRef;
            break;
        }
    }
    // Done
    return resultNodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:FileFolderServiceImpl.java

示例10: getLookupLocales

import java.util.ResourceBundle.Control; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:LocaleServiceProviderPool.java

示例11: getResourceCache

import java.util.ResourceBundle.Control; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:UIDefaults.java

示例12: TestListResourceBundle

import java.util.ResourceBundle.Control; //导入依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:ResourceBundleTest.java

示例13: setupBaseLocales

import java.util.ResourceBundle.Control; //导入依赖的package包/类
private static void setupBaseLocales(String localeList) {
    Arrays.stream(localeList.split(","))
        .map(Locale::forLanguageTag)
        .map(l -> Control.getControl(Control.FORMAT_DEFAULT)
                         .getCandidateLocales("", l))
        .forEach(BASE_LOCALES::addAll);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:CLDRConverter.java

示例14: setupBaseLocales

import java.util.ResourceBundle.Control; //导入依赖的package包/类
private static void setupBaseLocales(String localeList) {
        Arrays.stream(localeList.split(","))
            .map(Locale::forLanguageTag)
            .map(l -> Control.getControl(Control.FORMAT_DEFAULT)
                             .getCandidateLocales("", l))
            .forEach(BASE_LOCALES::addAll);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:8,代码来源:CLDRConverter.java

示例15: toBundleName

import java.util.ResourceBundle.Control; //导入依赖的package包/类
@Override
protected String toBundleName(String baseName, Locale locale) {
    // The resource bundle for Locale.JAPAN is loccated at jdk.test.resources
    // in module "asiabundles".
    String name = locale.equals(Locale.JAPAN) ? baseName : addRegion(baseName);
    return Control.getControl(Control.FORMAT_DEFAULT).toBundleName(name, locale);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:8,代码来源:MyResourcesProvider.java


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