Java Code Examples for java.util.ResourceBundle#Control

The following examples show how to use java.util.ResourceBundle#Control . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bug8167143.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that candidate locales list retrieved for zh__Hant and for zh__Hans
 * do not have first candidate locale as zh_TW_Hant and zh_CN_Hans
 * respectively.
 */
private static void testCandidateLocales() {
    ResourceBundle.Control Control = ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT);
    Locale zh_Hant = Locale.forLanguageTag("zh-Hant");
    Locale zh_Hans = Locale.forLanguageTag("zh-Hans");
    List<Locale> zhHantCandidateLocs = Control.getCandidateLocales("", zh_Hant);
    List<Locale> zhHansCandidateLocs = Control.getCandidateLocales("", zh_Hans);
    if (!zhHantCandidateLocs.equals(ZH_HANT_CANDLOCS)) {
        reportDifference(zhHantCandidateLocs, ZH_HANT_CANDLOCS, "zh_Hant");

    }
    if (!zhHansCandidateLocs.equals(ZH_HANS_CANDLOCS)) {
        reportDifference(zhHansCandidateLocs, ZH_HANS_CANDLOCS, "zh_Hans");

    }
}
 
Example 2
Source File: UserControlProvider.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ResourceBundle.Control getControl(String baseName) {
    System.out.println(getClass().getName()+".getControl called for " + baseName);

    // Throws a NPE if baseName is null.
    if (baseName.startsWith("com.foo.Xml")) {
        System.out.println("\treturns " + XMLCONTROL);
        return XMLCONTROL;
    }
    System.out.println("\treturns null");
    return null;
}
 
Example 3
Source File: UserControlProvider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public ResourceBundle.Control getControl(String baseName) {
    System.out.println(getClass().getName()+".getControl called for " + baseName);

    // Throws a NPE if baseName is null.
    if (baseName.startsWith("com.foo.Xml")) {
        System.out.println("\treturns " + XMLCONTROL);
        return XMLCONTROL;
    }
    System.out.println("\treturns null");
    return null;
}
 
Example 4
Source File: PropertyResourceBundleControlTest.java    From confucius-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testNewControl() {
    SortedMap<String, Charset> charsetsSortedMap = Charset.availableCharsets();
    for (String encoding : charsetsSortedMap.keySet()) {
        ResourceBundle.Control control = PropertyResourceBundleControl.newControl(encoding);
        Assert.assertNotNull(control);
    }
}
 
Example 5
Source File: UserControlProvider.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public ResourceBundle.Control getControl(String baseName) {
    System.out.println(getClass().getName()+".getControl called for " + baseName);

    // Throws a NPE if baseName is null.
    if (baseName.startsWith("com.foo.Xml")) {
        System.out.println("\treturns " + XMLCONTROL);
        return XMLCONTROL;
    }
    System.out.println("\treturns null");
    return null;
}
 
Example 6
Source File: UserControlProvider.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public ResourceBundle.Control getControl(String baseName) {
    System.out.println(getClass().getName()+".getControl called for " + baseName);

    // Throws a NPE if baseName is null.
    if (baseName.startsWith("com.foo.Xml")) {
        System.out.println("\treturns " + XMLCONTROL);
        return XMLCONTROL;
    }
    System.out.println("\treturns null");
    return null;
}
 
Example 7
Source File: UserControlProvider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public ResourceBundle.Control getControl(String baseName) {
    System.out.println(getClass().getName()+".getControl called for " + baseName);

    // Throws a NPE if baseName is null.
    if (baseName.startsWith("com.foo.Xml")) {
        System.out.println("\treturns " + XMLCONTROL);
        return XMLCONTROL;
    }
    System.out.println("\treturns null");
    return null;
}
 
Example 8
Source File: UserControlProvider.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public ResourceBundle.Control getControl(String baseName) {
    System.out.println(getClass().getName()+".getControl called for " + baseName);

    // Throws a NPE if baseName is null.
    if (baseName.startsWith("com.foo.Xml")) {
        System.out.println("\treturns " + XMLCONTROL);
        return XMLCONTROL;
    }
    System.out.println("\treturns null");
    return null;
}
 
Example 9
Source File: UTF8Bundle.java    From AndrOBD with GNU General Public License v3.0 4 votes vote down vote up
public UTF8Bundle(ResourceBundle.Control control)
{
    ctrl = control;
}
 
Example 10
Source File: ResourceBundleTest.java    From j2objc with Apache License 2.0 4 votes vote down vote up
public void test_getCandidateLocales() throws Exception {
    ResourceBundle.Control c = ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT);
    assertEquals("[en_US, en, ]", c.getCandidateLocales("base", Locale.US).toString());
    assertEquals("[de_CH, de, ]", c.getCandidateLocales("base", new Locale("de", "CH")).toString());
}
 
Example 11
Source File: TResourceBundle.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public static ResourceBundle.Control getControl(final List aList) {
    return (ResourceBundle.Control) (Object) INSTANCE;
}
 
Example 12
Source File: TResourceBundle.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public static ResourceBundle.Control getNoFallbackControl(final List aList) {
    return (ResourceBundle.Control) (Object) INSTANCE;
}
 
Example 13
Source File: PropertyResourceBundleUtils.java    From confucius-commons with Apache License 2.0 2 votes vote down vote up
/**
 * {@link ResourceBundle#getBundle(String, Locale, ClassLoader)} with specified encoding
 *
 * @param baseName
 *         the base name of the resource bundle, a fully qualified class name
 * @param locale
 *         the locale for which a resource bundle is desired
 * @param classLoader
 *         the class loader from which to load the resource bundle
 * @param encoding
 *         the control which gives information for the resource bundle loading process
 * @return
 * @throws NullPointerException
 *         if <code>baseName</code>, <code>locale</code>, or <code>loader</code> is <code>null</code>
 * @throws MissingResourceException
 *         if no resource bundle for the specified base name can be found
 * @throws IllegalArgumentException
 *         if the given <code>control</code> doesn't perform properly (e.g., <code>control.getCandidateLocales</code>
 *         returns null.) Note that validation of <code>control</code> is performed as needed.
 */
public static ResourceBundle getBundle(String baseName, Locale locale, ClassLoader classLoader, String encoding) {
    ResourceBundle.Control control = PropertyResourceBundleControl.newControl(encoding);
    return ResourceBundle.getBundle(baseName, locale, classLoader, control);
}
 
Example 14
Source File: ResourceBundleControlProvider.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a {@code ResourceBundle.Control} instance that is used
 * to handle resource bundle loading for the given {@code
 * baseName}. This method must return {@code null} if the given
 * {@code baseName} isn't handled by this provider.
 *
 * @param baseName the base name of the resource bundle
 * @return a {@code ResourceBundle.Control} instance,
 *         or {@code null} if the given {@code baseName} is not
 *         applicable to this provider.
 * @throws NullPointerException if {@code baseName} is {@code null}
 */
public ResourceBundle.Control getControl(String baseName);
 
Example 15
Source File: ResourceBundleControlProvider.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a {@code ResourceBundle.Control} instance that is used
 * to handle resource bundle loading for the given {@code
 * baseName}. This method must return {@code null} if the given
 * {@code baseName} isn't handled by this provider.
 *
 * @param baseName the base name of the resource bundle
 * @return a {@code ResourceBundle.Control} instance,
 *         or {@code null} if the given {@code baseName} is not
 *         applicable to this provider.
 * @throws NullPointerException if {@code baseName} is {@code null}
 */
public ResourceBundle.Control getControl(String baseName);
 
Example 16
Source File: ResourceBundleControlProvider.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a {@code ResourceBundle.Control} instance that is used
 * to handle resource bundle loading for the given {@code
 * baseName}. This method must return {@code null} if the given
 * {@code baseName} isn't handled by this provider.
 *
 * @param baseName the base name of the resource bundle
 * @return a {@code ResourceBundle.Control} instance,
 *         or {@code null} if the given {@code baseName} is not
 *         applicable to this provider.
 * @throws NullPointerException if {@code baseName} is {@code null}
 */
public ResourceBundle.Control getControl(String baseName);
 
Example 17
Source File: ResourceBundleControlProvider.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a {@code ResourceBundle.Control} instance that is used
 * to handle resource bundle loading for the given {@code
 * baseName}. This method must return {@code null} if the given
 * {@code baseName} isn't handled by this provider.
 *
 * @param baseName the base name of the resource bundle
 * @return a {@code ResourceBundle.Control} instance,
 *         or {@code null} if the given {@code baseName} is not
 *         applicable to this provider.
 * @throws NullPointerException if {@code baseName} is {@code null}
 */
public ResourceBundle.Control getControl(String baseName);
 
Example 18
Source File: ResourceBundleControlProvider.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a {@code ResourceBundle.Control} instance that is used
 * to handle resource bundle loading for the given {@code
 * baseName}. This method must return {@code null} if the given
 * {@code baseName} isn't handled by this provider.
 *
 * @param baseName the base name of the resource bundle
 * @return a {@code ResourceBundle.Control} instance,
 *         or {@code null} if the given {@code baseName} is not
 *         applicable to this provider.
 * @throws NullPointerException if {@code baseName} is {@code null}
 */
public ResourceBundle.Control getControl(String baseName);
 
Example 19
Source File: ResourceBundleControlProvider.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a {@code ResourceBundle.Control} instance that is used
 * to handle resource bundle loading for the given {@code
 * baseName}. This method must return {@code null} if the given
 * {@code baseName} isn't handled by this provider.
 *
 * @param baseName the base name of the resource bundle
 * @return a {@code ResourceBundle.Control} instance,
 *         or {@code null} if the given {@code baseName} is not
 *         applicable to this provider.
 * @throws NullPointerException if {@code baseName} is {@code null}
 */
public ResourceBundle.Control getControl(String baseName);
 
Example 20
Source File: ResourceBundleControlProvider.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a {@code ResourceBundle.Control} instance that is used
 * to handle resource bundle loading for the given {@code
 * baseName}. This method must return {@code null} if the given
 * {@code baseName} isn't handled by this provider.
 *
 * @param baseName the base name of the resource bundle
 * @return a {@code ResourceBundle.Control} instance,
 *         or {@code null} if the given {@code baseName} is not
 *         applicable to this provider.
 * @throws NullPointerException if {@code baseName} is {@code null}
 */
public ResourceBundle.Control getControl(String baseName);