Java Code Examples for java.util.Locale#getUnicodeLocaleType()

The following examples show how to use java.util.Locale#getUnicodeLocaleType() . 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: HostLocaleProviderAdapterImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedNativeDigitLocale(Locale locale) {
    // special case for th_TH_TH
    if (JRELocaleConstants.TH_TH_TH.equals(locale)) {
        return isNativeDigit("th-TH");
    }

    String numtype = null;
    Locale base = locale;
    if (locale.hasExtensions()) {
        numtype = locale.getUnicodeLocaleType("nu");
        base = locale.stripExtensions();
    }

    if (supportedLocaleSet.contains(base)) {
        // Only supports Latin or Thai (in thai locales) digits.
        if (numtype == null || numtype.equals("latn")) {
            return true;
        } else if (locale.getLanguage().equals("th")) {
            return "thai".equals(numtype) &&
                   isNativeDigit(locale.toLanguageTag());
        }
    }

    return false;
}
 
Example 2
Source File: HostLocaleProviderAdapterImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType =
        getCalendarID(base.toLanguageTag()).replaceFirst("gregorian", "gregory");

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
Example 3
Source File: HostLocaleProviderAdapterImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType =
        getCalendarID(base.toLanguageTag()).replaceFirst("gregorian", "gregory");

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
Example 4
Source File: HostLocaleProviderAdapterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType =
        getCalendarID(base.toLanguageTag()).replaceFirst("gregorian", "gregory");

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
Example 5
Source File: HostLocaleProviderAdapterImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType =
        getCalendarID(base.toLanguageTag()).replaceFirst("gregorian", "gregory");

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
Example 6
Source File: HostLocaleProviderAdapterImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedNativeDigitLocale(Locale locale) {
    // special case for th_TH_TH
    if (JRELocaleConstants.TH_TH_TH.equals(locale)) {
        return isNativeDigit("th-TH");
    }

    String numtype = null;
    Locale base = locale;
    if (locale.hasExtensions()) {
        numtype = locale.getUnicodeLocaleType("nu");
        base = locale.stripExtensions();
    }

    if (supportedLocaleSet.contains(base)) {
        // Only supports Latin or Thai (in thai locales) digits.
        if (numtype == null || numtype.equals("latn")) {
            return true;
        } else if (locale.getLanguage().equals("th")) {
            return "thai".equals(numtype) &&
                   isNativeDigit(locale.toLanguageTag());
        }
    }

    return false;
}
 
Example 7
Source File: HostLocaleProviderAdapterImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedNativeDigitLocale(Locale locale) {
    // special case for th_TH_TH
    if (JRELocaleConstants.TH_TH_TH.equals(locale)) {
        return isNativeDigit("th-TH");
    }

    String numtype = null;
    Locale base = locale;
    if (locale.hasExtensions()) {
        numtype = locale.getUnicodeLocaleType("nu");
        base = locale.stripExtensions();
    }

    if (supportedLocaleSet.contains(base)) {
        // Only supports Latin or Thai (in thai locales) digits.
        if (numtype == null || numtype.equals("latn")) {
            return true;
        } else if (locale.getLanguage().equals("th")) {
            return "thai".equals(numtype) &&
                   isNativeDigit(locale.toLanguageTag());
        }
    }

    return false;
}
 
Example 8
Source File: HostLocaleProviderAdapterImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedNativeDigitLocale(Locale locale) {
    // special case for th_TH_TH
    if (JRELocaleConstants.TH_TH_TH.equals(locale)) {
        return isNativeDigit("th-TH");
    }

    String numtype = null;
    Locale base = locale;
    if (locale.hasExtensions()) {
        numtype = locale.getUnicodeLocaleType("nu");
        base = locale.stripExtensions();
    }

    if (supportedLocaleSet.contains(base)) {
        // Only supports Latin or Thai (in thai locales) digits.
        if (numtype == null || numtype.equals("latn")) {
            return true;
        } else if (locale.getLanguage().equals("th")) {
            return "thai".equals(numtype) &&
                   isNativeDigit(locale.toLanguageTag());
        }
    }

    return false;
}
 
Example 9
Source File: HostLocaleProviderAdapterImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType =
        getCalendarID(base.toLanguageTag()).replaceFirst("gregorian", "gregory");

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
Example 10
Source File: HostLocaleProviderAdapterImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSupportedNativeDigitLocale(Locale locale) {
    // special case for th_TH_TH
    if (JRELocaleConstants.TH_TH_TH.equals(locale)) {
        return isNativeDigit("th-TH");
    }

    String numtype = null;
    Locale base = locale;
    if (locale.hasExtensions()) {
        numtype = locale.getUnicodeLocaleType("nu");
        base = locale.stripExtensions();
    }

    if (supportedLocaleSet.contains(base)) {
        // Only supports Latin or Thai (in thai locales) digits.
        if (numtype == null || numtype.equals("latn")) {
            return true;
        } else if (locale.getLanguage().equals("th")) {
            return "thai".equals(numtype) &&
                   isNativeDigit(locale.toLanguageTag());
        }
    }

    return false;
}
 
Example 11
Source File: CalendarNameProviderImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isSupportedLocale(Locale locale) {
    if (Locale.ROOT.equals(locale)) {
        return true;
    }
    String calendarType = null;
    if (locale.hasExtensions()) {
        calendarType = locale.getUnicodeLocaleType("ca");
        locale = locale.stripExtensions();
    }

    if (calendarType != null) {
        switch (calendarType) {
        case "buddhist":
        case "japanese":
        case "gregory":
        case "islamic":
        case "roc":
            break;
        default:
            // Unknown calendar type
            return false;
        }
    }
    if (langtags.contains(locale.toLanguageTag())) {
        return true;
    }
    if (type == LocaleProviderAdapter.Type.JRE) {
        String oldname = locale.toString().replace('_', '-');
        return langtags.contains(oldname);
    }
    return false;
}
 
Example 12
Source File: CalendarNameProviderImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isSupportedLocale(Locale locale) {
    if (Locale.ROOT.equals(locale)) {
        return true;
    }
    String calendarType = null;
    if (locale.hasExtensions()) {
        calendarType = locale.getUnicodeLocaleType("ca");
        locale = locale.stripExtensions();
    }

    if (calendarType != null) {
        switch (calendarType) {
        case "buddhist":
        case "japanese":
        case "gregory":
        case "islamic":
        case "roc":
            break;
        default:
            // Unknown calendar type
            return false;
        }
    }
    if (langtags.contains(locale.toLanguageTag())) {
        return true;
    }
    if (type == LocaleProviderAdapter.Type.JRE) {
        String oldname = locale.toString().replace('_', '-');
        return langtags.contains(oldname);
    }
    return false;
}
 
Example 13
Source File: HostLocaleProviderAdapterImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        // strip off extensions and variant.
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    int calid = getCalendarID(base.toLanguageTag());
    if (calid <= 0 || calid >= calIDToLDML.length) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType = calIDToLDML[calid]
            .replaceFirst("_.*", ""); // remove locale part.

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
Example 14
Source File: LiteralsTest.java    From ldp4j with Apache License 2.0 5 votes vote down vote up
private Calendar nonGregorianCalendar() {
	Locale locale=null;
	for(Locale aLocale:Locale.getAvailableLocales()) {
		String unicodeLocaleType = aLocale.getUnicodeLocaleType("ca");
		if(unicodeLocaleType!=null) {
			locale=aLocale;
			break;
		}
	}
	Calendar calendar=Calendar.getInstance(locale);
	calendar.setTime(NOW);
	return calendar;
}
 
Example 15
Source File: CalendarNameProviderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isSupportedLocale(Locale locale) {
    if (Locale.ROOT.equals(locale)) {
        return true;
    }
    String calendarType = null;
    if (locale.hasExtensions()) {
        calendarType = locale.getUnicodeLocaleType("ca");
        locale = locale.stripExtensions();
    }

    if (calendarType != null) {
        switch (calendarType) {
        case "buddhist":
        case "japanese":
        case "gregory":
        case "islamic":
        case "roc":
            break;
        default:
            // Unknown calendar type
            return false;
        }
    }
    if (langtags.contains(locale.toLanguageTag())) {
        return true;
    }
    if (type == LocaleProviderAdapter.Type.JRE) {
        String oldname = locale.toString().replace('_', '-');
        return langtags.contains(oldname);
    }
    return false;
}
 
Example 16
Source File: HostLocaleProviderAdapterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static boolean isSupportedCalendarLocale(Locale locale) {
    Locale base = locale;

    if (base.hasExtensions() || base.getVariant() != "") {
        // strip off extensions and variant.
        base = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    if (!supportedLocaleSet.contains(base)) {
        return false;
    }

    int calid = getCalendarID(base.toLanguageTag());
    if (calid <= 0 || calid >= calIDToLDML.length) {
        return false;
    }

    String requestedCalType = locale.getUnicodeLocaleType("ca");
    String nativeCalType = calIDToLDML[calid]
            .replaceFirst("_.*", ""); // remove locale part.

    if (requestedCalType == null) {
        return Calendar.getAvailableCalendarTypes().contains(nativeCalType);
    } else {
        return requestedCalType.equals(nativeCalType);
    }
}
 
Example 17
Source File: CalendarNameProviderImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isSupportedLocale(Locale locale) {
    if (Locale.ROOT.equals(locale)) {
        return true;
    }
    String calendarType = null;
    if (locale.hasExtensions()) {
        calendarType = locale.getUnicodeLocaleType("ca");
        locale = locale.stripExtensions();
    }

    if (calendarType != null) {
        switch (calendarType) {
        case "buddhist":
        case "japanese":
        case "gregory":
        case "islamic":
        case "roc":
            break;
        default:
            // Unknown calendar type
            return false;
        }
    }
    if (langtags.contains(locale.toLanguageTag())) {
        return true;
    }
    if (type == LocaleProviderAdapter.Type.JRE) {
        String oldname = locale.toString().replace('_', '-');
        return langtags.contains(oldname);
    }
    return false;
}
 
Example 18
Source File: CalendarNameProviderImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isSupportedLocale(Locale locale) {
    if (Locale.ROOT.equals(locale)) {
        return true;
    }
    String calendarType = null;
    if (locale.hasExtensions()) {
        calendarType = locale.getUnicodeLocaleType("ca");
        locale = locale.stripExtensions();
    }

    if (calendarType != null) {
        switch (calendarType) {
        case "buddhist":
        case "japanese":
        case "gregory":
        case "islamic":
        case "roc":
            break;
        default:
            // Unknown calendar type
            return false;
        }
    }
    if (langtags.contains(locale.toLanguageTag())) {
        return true;
    }
    if (type == LocaleProviderAdapter.Type.JRE) {
        String oldname = locale.toString().replace('_', '-');
        return langtags.contains(oldname);
    }
    return false;
}
 
Example 19
Source File: CalendarNameProviderImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isSupportedLocale(Locale locale) {
    if (Locale.ROOT.equals(locale)) {
        return true;
    }
    String calendarType = null;
    if (locale.hasExtensions()) {
        calendarType = locale.getUnicodeLocaleType("ca");
        locale = locale.stripExtensions();
    }

    if (calendarType != null) {
        switch (calendarType) {
        case "buddhist":
        case "japanese":
        case "gregory":
        case "islamic":
        case "roc":
            break;
        default:
            // Unknown calendar type
            return false;
        }
    }
    if (langtags.contains(locale.toLanguageTag())) {
        return true;
    }
    if (type == LocaleProviderAdapter.Type.JRE) {
        String oldname = locale.toString().replace('_', '-');
        return langtags.contains(oldname);
    }
    return false;
}
 
Example 20
Source File: CalendarNameProviderImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isSupportedLocale(Locale locale) {
    if (Locale.ROOT.equals(locale)) {
        return true;
    }
    String calendarType = null;
    if (locale.hasExtensions()) {
        calendarType = locale.getUnicodeLocaleType("ca");
        locale = locale.stripExtensions();
    }

    if (calendarType != null) {
        switch (calendarType) {
        case "buddhist":
        case "japanese":
        case "gregory":
        case "islamic":
        case "roc":
            break;
        default:
            // Unknown calendar type
            return false;
        }
    }
    if (langtags.contains(locale.toLanguageTag())) {
        return true;
    }
    if (type == LocaleProviderAdapter.Type.JRE) {
        String oldname = locale.toString().replace('_', '-');
        return langtags.contains(oldname);
    }
    return false;
}