java.util.spi.LocaleNameProvider Java Examples

The following examples show how to use java.util.spi.LocaleNameProvider. 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: Locale.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #2
Source File: Locale.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
 
Example #3
Source File: Locale.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #4
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #5
Source File: Locale.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #6
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
 
Example #7
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
 
Example #8
Source File: Locale.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #9
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
 
Example #10
Source File: Locale.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #11
Source File: Locale.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
 
Example #12
Source File: Locale.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
 
Example #13
Source File: Locale.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private String getDisplayString(String code, String cat, Locale inLocale, int type) {
    Objects.requireNonNull(inLocale);
    Objects.requireNonNull(code);

    if (code.isEmpty()) {
        return "";
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String rbKey = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, rbKey, type, code, cat);
    return result != null ? result : code;
}
 
Example #14
Source File: JRELocaleProviderAdapter.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<LocaleNameProvider>) () ->
                new LocaleNameProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("LocaleNames")));

        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
 
Example #15
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
 
Example #16
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #17
Source File: JRELocaleProviderAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<LocaleNameProvider>) () ->
                new LocaleNameProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("LocaleNames")));

        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
 
Example #18
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
 
Example #19
Source File: Locale.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #20
Source File: Locale.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #21
Source File: Locale.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #22
Source File: Locale.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #23
Source File: Locale.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 3;
    int type = (Integer)params[0];
    String code = (String)params[1];
    String cat = (String)params[2];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    case DISPLAY_UEXT_KEY:
        return localeNameProvider.getDisplayUnicodeExtensionKey(code, locale);
    case DISPLAY_UEXT_TYPE:
        return localeNameProvider.getDisplayUnicodeExtensionType(code, cat, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
 
Example #24
Source File: Bug6989440.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example #25
Source File: Bug6989440.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example #26
Source File: JRELocaleProviderAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType(),
                                                getLanguageTagSet("LocaleNames"));
        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
 
Example #27
Source File: Bug6989440.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example #28
Source File: JRELocaleProviderAdapter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType(),
                                                getLanguageTagSet("LocaleNames"));
        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
 
Example #29
Source File: Bug6989440.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
 
Example #30
Source File: JRELocaleProviderAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType(),
                                                getLanguageTagSet("LocaleNames"));
        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}