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


Java Locale.hasExtensions方法代码示例

本文整理汇总了Java中java.util.Locale.hasExtensions方法的典型用法代码示例。如果您正苦于以下问题:Java Locale.hasExtensions方法的具体用法?Java Locale.hasExtensions怎么用?Java Locale.hasExtensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Locale的用法示例。


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

示例1: isSupportedCalendarLocale

import java.util.Locale; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:HostLocaleProviderAdapterImpl.java

示例2: isSupportedNativeDigitLocale

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

示例3: isSupportedLocale

import java.util.Locale; //导入方法依赖的package包/类
@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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:CalendarNameProviderImpl.java

示例4: isSupportedCalendarLocale

import java.util.Locale; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:HostLocaleProviderAdapterImpl.java

示例5: stripVariantAndExtensions

import java.util.Locale; //导入方法依赖的package包/类
private static Locale stripVariantAndExtensions(Locale locale) {
    if (locale.hasExtensions() || locale.getVariant() != "") {
        // strip off extensions and variant.
        locale = new Locale.Builder()
                        .setLocale(locale)
                        .clearExtensions()
                        .build();
    }

    return locale;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:HostLocaleProviderAdapterImpl.java


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