Java Code Examples for sun.util.locale.provider.CalendarDataUtility#retrieveFieldValueNames()
The following examples show how to use
sun.util.locale.provider.CalendarDataUtility#retrieveFieldValueNames() .
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: JapaneseImperialCalendar.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
@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; }
Example 2
Source File: JapaneseImperialCalendar.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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; }
Example 3
Source File: JapaneseImperialCalendar.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@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; }
Example 4
Source File: JapaneseImperialCalendar.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@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; }
Example 5
Source File: JapaneseImperialCalendar.java From Java8CN with Apache License 2.0 | 5 votes |
@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; }
Example 6
Source File: BuddhistCalendar.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@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); }
Example 7
Source File: JapaneseImperialCalendar.java From hottub with GNU General Public License v2.0 | 5 votes |
@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; }
Example 8
Source File: BuddhistCalendar.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@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); }
Example 9
Source File: JapaneseImperialCalendar.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@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; }
Example 10
Source File: JapaneseImperialCalendar.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@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; }
Example 11
Source File: BuddhistCalendar.java From Bytecoder with Apache License 2.0 | 5 votes |
@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); }
Example 12
Source File: JapaneseImperialCalendar.java From JDKSourceCode1.8 with MIT License | 5 votes |
@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; }
Example 13
Source File: BuddhistCalendar.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@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); }
Example 14
Source File: JapaneseImperialCalendar.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@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; }
Example 15
Source File: Calendar.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * 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); }
Example 16
Source File: Calendar.java From openjdk-jdk8u with GNU General Public License v2.0 | 3 votes |
/** * 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); }
Example 17
Source File: Calendar.java From JDKSourceCode1.8 with MIT License | 3 votes |
/** * 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); }
Example 18
Source File: Calendar.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * 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); }
Example 19
Source File: Calendar.java From Java8CN with Apache License 2.0 | 3 votes |
/** * 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); }
Example 20
Source File: Calendar.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * 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); }