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


Java ULocale.getKeywordValue方法代码示例

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


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

示例1: getCalendarTypeToUse

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private String getCalendarTypeToUse(ULocale uLocale) {
    // Get the correct calendar type
    // TODO: C++ and Java are inconsistent (see #9952).
    String calendarTypeToUse = uLocale.getKeywordValue("calendar");
    if ( calendarTypeToUse == null ) {
        String[] preferredCalendarTypes = Calendar.getKeywordValuesForLocale("calendar", uLocale, true);
        calendarTypeToUse = preferredCalendarTypes[0]; // the most preferred calendar
    }
    if ( calendarTypeToUse == null ) {
        calendarTypeToUse = "gregorian"; // fallback
    }
    return calendarTypeToUse;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:14,代码来源:DateTimePatternGenerator.java

示例2: getCalendarType

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Returns a calendar type for the given locale.
 * When the given locale has calendar keyword, the
 * value of calendar keyword is returned.  Otherwise,
 * the default calendar type for the locale is returned.
 * @param loc The locale
 * @return Calendar type string, such as "gregorian"
 */
public static String getCalendarType(ULocale loc) {
    String calType = loc.getKeywordValue(CALKEY);
    if (calType != null) {
        return calType;
    }

    // Canonicalize, so grandfathered variant will be transformed to keywords
    ULocale canonical = ULocale.createCanonical(loc.toString());
    calType = canonical.getKeywordValue(CALKEY);
    if (calType != null) {
        return calType;
    }

    // When calendar keyword is not available, use the locale's
    // region to get the default calendar type
    String region = ULocale.getRegionForSupplementalData(canonical, true);
    return CalendarPreferences.INSTANCE.getCalendarTypeForRegion(region);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:27,代码来源:CalendarUtil.java

示例3: getInstance

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Returns the default numbering system for the specified ULocale.
 * @stable ICU 4.2
 */
public static NumberingSystem getInstance(ULocale locale) {
    // Check for @numbers
    boolean nsResolved = true;
    String numbersKeyword = locale.getKeywordValue("numbers");
    if (numbersKeyword != null ) {
        for ( String keyword : OTHER_NS_KEYWORDS ) {
            if ( numbersKeyword.equals(keyword)) {
                nsResolved = false;
                break;
            }
        }
    } else {
        numbersKeyword = "default";
        nsResolved = false;
    }

    if (nsResolved) {
        NumberingSystem ns = getInstanceByName(numbersKeyword);
        if (ns != null) {
            return ns;
        }
        // If the @numbers keyword points to a bogus numbering system name,
        // we return the default for the locale.
        numbersKeyword = "default";
    }

    // Attempt to get the numbering system from the cache
    String baseName = locale.getBaseName();
    // TODO: Caching by locale+numbersKeyword could yield a large cache.
    // Try to load for each locale the mappings from OTHER_NS_KEYWORDS and default
    // to real numbering system names; can we get those from supplemental data?
    // Then look up those mappings for the locale and resolve the keyword.
    String key = baseName+"@numbers="+numbersKeyword;
    LocaleLookupData localeLookupData = new LocaleLookupData(locale, numbersKeyword);
    return cachedLocaleData.getInstance(key, localeLookupData);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:41,代码来源:NumberingSystem.java

示例4: initializeData

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
/**
 * Initializes format symbols for the locale and calendar type
 * @param desiredLocale The locale whose symbols are desired.
 * @param type          The calendar type whose date format symbols are desired.
 * @stable ICU 3.0
 */
//TODO: This protected seems to be marked as @stable accidentally.
// We may need to deescalate this API to @internal.
protected void initializeData(ULocale desiredLocale, String type)
{
    String key = desiredLocale.getBaseName() + '+' + type;
    String ns = desiredLocale.getKeywordValue("numbers");
    if (ns != null && ns.length() > 0) {
        key += '+' + ns;
    }
    DateFormatSymbols dfs = DFSCACHE.getInstance(key, desiredLocale);
    initializeData(dfs);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:19,代码来源:DateFormatSymbols.java

示例5: setup

import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private void setup(ULocale locale) {
    int DEFAULT_HASH_SIZE = 19;
    fIntervalPatterns = new HashMap<String, Map<String, PatternInfo>>(DEFAULT_HASH_SIZE);
    // initialize to guard if there is no interval date format defined in
    // resource files
    fFallbackIntervalPattern = "{0} \u2013 {1}";

    try {
        // Get the correct calendar type
        String calendarTypeToUse = locale.getKeywordValue("calendar");
        if ( calendarTypeToUse == null ) {
            String[] preferredCalendarTypes =
                    Calendar.getKeywordValuesForLocale("calendar", locale, true);
            calendarTypeToUse = preferredCalendarTypes[0]; // the most preferred calendar
        }
        if ( calendarTypeToUse == null ) {
            calendarTypeToUse = "gregorian"; // fallback
        }

        // Instantiate the sink to process the data and the resource bundle
        DateIntervalSink sink = new DateIntervalSink(this);
        ICUResourceBundle resource =
                (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, locale);

        // Get the fallback pattern
        String fallbackPattern = resource.getStringWithFallback(CALENDAR_KEY + "/" + calendarTypeToUse
                + "/" + INTERVAL_FORMATS_KEY + "/" + FALLBACK_STRING);
        setFallbackIntervalPattern(fallbackPattern);

        // Already loaded calendar types
        Set<String> loadedCalendarTypes = new HashSet<String>();

        while (calendarTypeToUse != null) {
            // Throw an exception when a loop is detected
            if (loadedCalendarTypes.contains(calendarTypeToUse)) {
                throw new ICUException("Loop in calendar type fallback: " + calendarTypeToUse);
            }

            // Register the calendar type to avoid loops
            loadedCalendarTypes.add(calendarTypeToUse);

            // Get all resources for this calendar type
            String pathToIntervalFormats = CALENDAR_KEY + "/" + calendarTypeToUse;
            resource.getAllItemsWithFallback(pathToIntervalFormats, sink);

            // Get next calendar type to load if there was an alias pointing at it
            calendarTypeToUse = sink.getAndResetNextCalendarType();
        }
    } catch ( MissingResourceException e) {
        // Will fallback to {data0} - {date1}
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:53,代码来源:DateIntervalInfo.java


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