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


Java ULocale.getCountry方法代码示例

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


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

示例1: isSubdivision

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * @param locale
 * @param subtag
 * @return
 */
private boolean isSubdivision(ULocale locale, String subtag) {
    // First check if the subtag is valid
    if (subtag.length() < 3) {
        return false;
    }
    String region = subtag.substring(0, subtag.charAt(0) <= '9' ? 3 : 2);
    String subdivision = subtag.substring(region.length());
    if (ValidIdentifiers.isValid(Datatype.subdivision, datasubtypes, region, subdivision) == null) {
        return false;
    }
    // Then check for consistency with the locale's region
    String localeRegion = locale.getCountry();
    if (localeRegion.isEmpty()) {
        ULocale max = ULocale.addLikelySubtags(locale);
        localeRegion = max.getCountry();
    }
    if (!region.equalsIgnoreCase(localeRegion)) {
        return false;
    }
    return true;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:27,代码来源:LocaleValidityChecker.java

示例2: getAllowedHourFormats

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private void getAllowedHourFormats(ULocale uLocale) {
    // key can be either region or locale (lang_region)
    //        ZW{
    //            allowed{
    //                "h",
    //                "H",
    //            }
    //            preferred{"h"}
    //        }
    //        af_ZA{
    //            allowed{
    //                "h",
    //                "H",
    //                "hB",
    //                "hb",
    //            }
    //            preferred{"h"}
    //        }

    ULocale max = ULocale.addLikelySubtags(uLocale);
    String country = max.getCountry();
    if (country.isEmpty()) {
        country = "001";
    }
    String langCountry = max.getLanguage() + "_" + country;
    String[] list = LOCALE_TO_ALLOWED_HOUR.get(langCountry);
    if (list == null) {
        list = LOCALE_TO_ALLOWED_HOUR.get(country);
        if (list == null) {
            list = LAST_RESORT_ALLOWED_HOUR_FORMAT;
        }
    }
    allowedHourFormats = list;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:35,代码来源:DateTimePatternGenerator.java

示例3: getTargetRegion

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Private method returning the target region. The target regions is determined by
 * the locale of this instance. When a generic name is coming from
 * a meta zone, this region is used for checking if the time zone
 * is a reference zone of the meta zone.
 *
 * @return the target region
 */
private synchronized String getTargetRegion() {
    if (_region == null) {
        _region = _locale.getCountry();
        if (_region.length() == 0) {
            ULocale tmp = ULocale.addLikelySubtags(_locale);
            _region = tmp.getCountry();
            if (_region.length() == 0) {
                _region = "001";
            }
        }
    }
    return _region;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:22,代码来源:TimeZoneFormat.java

示例4: getTargetRegion

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private String getTargetRegion() {
    if (_region == null) {
        String region = _locale.getCountry();
        if (region.length() == 0) {
            ULocale tmp = ULocale.addLikelySubtags(_locale);
            region = tmp.getCountry();
            if (region.length() == 0) {
                region = "001";
            }
        }
        _region = region;
    }
    return _region;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:15,代码来源:TZDBTimeZoneNames.java

示例5: isValid

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
public boolean isValid(ULocale locale, Where where) {
    where.set(null, null);
    final String language = locale.getLanguage();
    final String script = locale.getScript();
    final String region = locale.getCountry();
    final String variantString = locale.getVariant();
    final Set<Character> extensionKeys = locale.getExtensionKeys();
    //        if (language.isEmpty()) {
    //            // the only case where this is valid is if there is only an 'x' extension string
    //            if (!script.isEmpty() || !region.isEmpty() || variantString.isEmpty() 
    //                    || extensionKeys.size() != 1 || !extensionKeys.contains('x')) {
    //                return where.set(Datatype.x, "Null language only with x-...");
    //            }
    //            return true; // for x string, wellformedness = valid
    //        }
    if (!isValid(Datatype.language, language, where)) {
        // special case x
        if (language.equals("x")) {
            where.set(null, null); // for x, well-formed == valid
            return true;
        }
        return false;
    }
    if (!isValid(Datatype.script, script, where)) return false;
    if (!isValid(Datatype.region, region, where)) return false;
    if (!variantString.isEmpty()) {
        for (String variant : SEPARATOR.split(variantString)) {
            if (!isValid(Datatype.variant, variant, where)) return false;
        }
    }
    for (Character c : extensionKeys) {
        try {
            Datatype datatype = Datatype.valueOf(c+"");
            switch (datatype) {
            case x:
                return true; // if it is syntactic (checked by ULocale) it is valid
            case t:
            case u:
                if (!isValidU(locale, datatype, locale.getExtension(c), where)) return false;
                break;
            }
        } catch (Exception e) {
            return where.set(Datatype.illegal, c+"");
        }
    }
    return true;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:48,代码来源:LocaleValidityChecker.java


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