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


Java CalendarDataUtility.retrieveFieldValueNames方法代码示例

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


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

示例1: getDisplayNames

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
@Override
public Map<String,Integer> getDisplayNames(int field, int style, Locale locale) {
    if (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale,
                                ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
        return null;
    }
    Map<String, Integer> names;
    names = CalendarDataUtility.retrieveFieldValueNames(getCalendarType(), field, style, locale);
    // If strings[] has fewer than eras[], get more names from eras[].
    if (names != null) {
        if (field == ERA) {
            int size = names.size();
            if (style == ALL_STYLES) {
                Set<Integer> values = new HashSet<>();
                // count unique era values
                for (String key : names.keySet()) {
                    values.add(names.get(key));
                }
                size = values.size();
            }
            if (size < eras.length) {
                int baseStyle = getBaseStyle(style);
                for (int i = size; i < eras.length; i++) {
                    Era era = eras[i];
                    if (baseStyle == ALL_STYLES || baseStyle == SHORT
                            || baseStyle == NARROW_FORMAT) {
                        names.put(era.getAbbreviation(), i);
                    }
                    if (baseStyle == ALL_STYLES || baseStyle == LONG) {
                        names.put(era.getName(), i);
                    }
                }
            }
        }
    }
    return names;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:JapaneseImperialCalendar.java

示例2: getDisplayNames

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
@Override
public Map<String,Integer> getDisplayNames(int field, int style, Locale locale) {
    if (field != ERA) {
        return super.getDisplayNames(field, style, locale);
    }
    return CalendarDataUtility.retrieveFieldValueNames("buddhist", field, style, locale);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:BuddhistCalendar.java

示例3: getDisplayNames

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
@Override
public Map<String,Integer> getDisplayNames(int field, int style, Locale locale) {
    if (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale,
                                ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
        return null;
    }
    Map<String, Integer> names;
    names = CalendarDataUtility.retrieveFieldValueNames(getCalendarType(), field, style, locale);
    // If strings[] has fewer than eras[], get more names from eras[].
    if (names != null) {
        if (field == ERA) {
            int size = names.size();
            if (style == ALL_STYLES) {
                Set<Integer> values = new HashSet<>();
                // count unique era values
                for (String key : names.keySet()) {
                    values.add(names.get(key));
                }
                size = values.size();
            }
            if (size < eras.length) {
                int baseStyle = getBaseStyle(style);
                for (int i = 0; i < eras.length; i++) {
                    if (!names.values().contains(i)) {
                        Era era = eras[i];
                        if (baseStyle == ALL_STYLES || baseStyle == SHORT
                                || baseStyle == NARROW_FORMAT) {
                            names.put(era.getAbbreviation(), i);
                        }
                        if (baseStyle == ALL_STYLES || baseStyle == LONG) {
                            names.put(era.getName(), i);
                        }
                    }
                }
            }
        }
    }
    return names;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:JapaneseImperialCalendar.java

示例4: getDisplayNames

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
/**
 * Returns a {@code Map} containing all names of the calendar
 * {@code field} in the given {@code style} and
 * {@code locale} and their corresponding field values. For
 * example, if this {@code Calendar} is a {@link
 * GregorianCalendar}, the returned map would contain "Jan" to
 * {@link #JANUARY}, "Feb" to {@link #FEBRUARY}, and so on, in the
 * {@linkplain #SHORT short} style in an English locale.
 *
 * <p>Narrow names may not be unique due to use of single characters,
 * such as "S" for Sunday and Saturday. In that case narrow names are not
 * included in the returned {@code Map}.
 *
 * <p>The values of other calendar fields may be taken into
 * account to determine a set of display names. For example, if
 * this {@code Calendar} is a lunisolar calendar system and
 * the year value given by the {@link #YEAR} field has a leap
 * month, this method would return month names containing the leap
 * month name, and month names are mapped to their values specific
 * for the year.
 *
 * <p>The default implementation supports display names contained in
 * a {@link DateFormatSymbols}. For example, if {@code field}
 * is {@link #MONTH} and {@code style} is {@link
 * #ALL_STYLES}, this method returns a {@code Map} containing
 * all strings returned by {@link DateFormatSymbols#getShortMonths()}
 * and {@link DateFormatSymbols#getMonths()}.
 *
 * @param field
 *        the calendar field for which the display names are returned
 * @param style
 *        the style applied to the string representation; one of {@link
 *        #SHORT_FORMAT} ({@link #SHORT}), {@link #SHORT_STANDALONE},
 *        {@link #LONG_FORMAT} ({@link #LONG}), {@link #LONG_STANDALONE},
 *        {@link #NARROW_FORMAT}, or {@link #NARROW_STANDALONE}
 * @param locale
 *        the locale for the display names
 * @return a {@code Map} containing all display names in
 *        {@code style} and {@code locale} and their
 *        field values, or {@code null} if no display names
 *        are defined for {@code field}
 * @exception IllegalArgumentException
 *        if {@code field} or {@code style} is invalid,
 *        or if this {@code Calendar} is non-lenient and any
 *        of the calendar fields have invalid values
 * @exception NullPointerException
 *        if {@code locale} is null
 * @since 1.6
 */
public Map<String, Integer> getDisplayNames(int field, int style, Locale locale) {
    if (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale,
                                ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
        return null;
    }
    if (style == ALL_STYLES || isStandaloneStyle(style)) {
        return CalendarDataUtility.retrieveFieldValueNames(getCalendarType(), field, style, locale);
    }
    // SHORT, LONG, or NARROW
    return getDisplayNamesImpl(field, style, locale);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:Calendar.java

示例5: getDisplayNames

import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
/**
 * Returns a {@code Map} containing all names of the calendar
 * {@code field} in the given {@code style} and
 * {@code locale} and their corresponding field values. For
 * example, if this {@code Calendar} is a {@link
 * GregorianCalendar}, the returned map would contain "Jan" to
 * {@link #JANUARY}, "Feb" to {@link #FEBRUARY}, and so on, in the
 * {@linkplain #SHORT short} style in an English locale.
 *
 * <p>Narrow names may not be unique due to use of single characters,
 * such as "S" for Sunday and Saturday. In that case narrow names are not
 * included in the returned {@code Map}.
 *
 * <p>The values of other calendar fields may be taken into
 * account to determine a set of display names. For example, if
 * this {@code Calendar} is a lunisolar calendar system and
 * the year value given by the {@link #YEAR} field has a leap
 * month, this method would return month names containing the leap
 * month name, and month names are mapped to their values specific
 * for the year.
 *
 * <p>The default implementation supports display names contained in
 * a {@link DateFormatSymbols}. For example, if {@code field}
 * is {@link #MONTH} and {@code style} is {@link
 * #ALL_STYLES}, this method returns a {@code Map} containing
 * all strings returned by {@link DateFormatSymbols#getShortMonths()}
 * and {@link DateFormatSymbols#getMonths()}.
 *
 * @param field
 *        the calendar field for which the display names are returned
 * @param style
 *        the style applied to the string representation; one of {@link
 *        #SHORT_FORMAT} ({@link #SHORT}), {@link #SHORT_STANDALONE},
 *        {@link #LONG_FORMAT} ({@link #LONG}), {@link #LONG_STANDALONE},
 *        {@link #NARROW_FORMAT}, or {@link #NARROW_STANDALONE}
 * @param locale
 *        the locale for the display names
 * @return a {@code Map} containing all display names in
 *        {@code style} and {@code locale} and their
 *        field values, or {@code null} if no display names
 *        are defined for {@code field}
 * @exception IllegalArgumentException
 *        if {@code field} or {@code style} is invalid,
 *        or if this {@code Calendar} is non-lenient and any
 *        of the calendar fields have invalid values
 * @exception NullPointerException
 *        if {@code locale} is null
 * @since 1.6
 */
public Map<String, Integer> getDisplayNames(int field, int style, Locale locale) {
    if (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale,
                                ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
        return null;
    }

    String calendarType = getCalendarType();
    if (style == ALL_STYLES || isStandaloneStyle(style) || isNarrowFormatStyle(style)) {
        Map<String, Integer> map;
        map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field, style, locale);

        // Perform fallback here to follow the CLDR rules
        if (map == null) {
            if (isNarrowFormatStyle(style)) {
                map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field,
                                                                  toStandaloneStyle(style), locale);
            } else if (style != ALL_STYLES) {
                map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field,
                                                                  getBaseStyle(style), locale);
            }
        }
        return map;
    }

    // SHORT or LONG
    return getDisplayNamesImpl(field, style, locale);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:77,代码来源:Calendar.java


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