Top Description Inners Fields Constructors Methods
sun.util.locale.provider

public Class CalendarNameProviderImpl

extends CalendarNameProvider
implements AvailableLanguageTags
Class Inheritance
All Implemented Interfaces
sun.util.locale.provider.AvailableLanguageTags
Known Direct Subclasses
sun.util.cldr.CLDRCalendarNameProviderImpl
Static Imports
java.util.Calendar.*

Concrete implementation of the CalendarNameProvider class for the JRE LocaleProviderAdapter.
Authors
Masayoshi Okutsu, Naoto Sato

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
CalendarNameProviderImpl.LengthBasedComparator

Comparator implementation for TreeMap which iterates keys from longest to shortest.

Field Summary

Modifier and TypeField and Description
protected final Set<String>
private static final int[]
protected final LocaleProviderAdapter.Type

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Set<String>
getAvailableLanguageTags()

Implements sun.util.locale.provider.AvailableLanguageTags.getAvailableLanguageTags.

Returns a set of available language tags of a LocaleServiceProvider.

public Locale[]
getAvailableLocales()

Implements abstract java.util.spi.LocaleServiceProvider.getAvailableLocales.

Returns an array of all locales for which this locale service provider can provide localized objects or names.

private static int
getBaseStyle(int style)

public String
getDisplayName(String
the calendar type. (Any calendar type given by locale is ignored.)
calendarType
,
int
the Calendar field index, such as Calendar#DAY_OF_WEEK
field
,
int
the value of the Calendar field, such as Calendar#MONDAY
value
,
int style, Locale
the desired locale
locale
)

Implements abstract java.util.spi.CalendarNameProvider.getDisplayName.

Returns the string representation (display name) of the calendar field value in the given style and locale.

public String
getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime)

public Map<String, Integer>
getDisplayNames(String
the calendar type. (Any calendar type given by locale is ignored.)
calendarType
,
int
the calendar field for which the display names are returned
field
,
int style, Locale
the desired locale
locale
)

Implements abstract java.util.spi.CalendarNameProvider.getDisplayNames.

Returns a Map containing all string representations (display names) of the Calendar field in the given style and locale and their corresponding field values.

private Map<String, Integer>
getDisplayNamesImpl(String calendarType, int field, int style, Locale locale, boolean javatime)

public String
getJavaTimeDisplayName(String calendarType, int field, int value, int style, Locale locale)

public Map<String, Integer>
getJavaTimeDisplayNames(String calendarType, int field, int style, Locale locale)

private String
getResourceKey(String type, int field, int style, boolean javatime)

private static String
getResourceKeyFor(LocaleProviderAdapter.Type adapterType, String type, int field, int style, boolean javatime)

private boolean
hasDuplicates(String[] strings)

public boolean
isSupportedLocale(Locale
a Locale to be tested
locale
)

Overrides java.util.spi.LocaleServiceProvider.isSupportedLocale.

Returns true if the given locale is supported by this locale service provider.

private static String
toStyleName(int baseStyle)

Field Detail

langtagsback to summary
protected final Set<String> langtags
REST_OF_STYLESback to summary
private static final int[] REST_OF_STYLES
typeback to summary
protected final LocaleProviderAdapter.Type type

Constructor Detail

CalendarNameProviderImplback to summary
public CalendarNameProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags)

Method Detail

getAvailableLanguageTagsback to summary
public Set<String> getAvailableLanguageTags()

Implements sun.util.locale.provider.AvailableLanguageTags.getAvailableLanguageTags.

Doc from sun.util.locale.provider.AvailableLanguageTags.getAvailableLanguageTags.

Returns a set of available language tags of a LocaleServiceProvider. Note that the returned set doesn't contain the language tag for Locale.Root.

Returns:Set<String>

a Set of available language tags.

Annotations
@Override
getAvailableLocalesback to summary
public Locale[] getAvailableLocales()

Implements abstract java.util.spi.LocaleServiceProvider.getAvailableLocales.

Doc from java.util.spi.LocaleServiceProvider.getAvailableLocales.

Returns an array of all locales for which this locale service provider can provide localized objects or names. This information is used to compose getAvailableLocales() values of the locale-dependent services, such as DateFormat.getAvailableLocales().

The array returned by this method should not include two or more Locale objects only differing in their extensions.

Returns:Locale[]

an array of all locales for which this locale service provider can provide localized objects or names

Annotations
@Override
getBaseStyleback to summary
private static int getBaseStyle(int style)
getDisplayNameback to summary
public String getDisplayName(String calendarType, int field, int value, int style, Locale locale)

Implements abstract java.util.spi.CalendarNameProvider.getDisplayName.

Doc from java.util.spi.CalendarNameProvider.getDisplayName.

Returns the string representation (display name) of the calendar field value in the given style and locale. If no string representation is applicable, null is returned.

field is a Calendar field index, such as Calendar#MONTH. The time zone fields, Calendar#ZONE_OFFSET and Calendar#DST_OFFSET, are not supported by this method. null must be returned if any time zone fields are specified.

value is the numeric representation of the field value. For example, if field is Calendar#DAY_OF_WEEK, the valid values are Calendar#SUNDAY to Calendar#SATURDAY (inclusive).

style gives the style of the string representation. It is one of Calendar#SHORT_FORMAT (SHORT), Calendar#SHORT_STANDALONE, Calendar#LONG_FORMAT (LONG), Calendar#LONG_STANDALONE, Calendar#NARROW_FORMAT, or Calendar#NARROW_STANDALONE.

For example, the following call will return "Sunday".

getDisplayName("gregory", Calendar.DAY_OF_WEEK, Calendar.SUNDAY,
               Calendar.LONG_STANDALONE, Locale.ENGLISH);
Parameters
calendarType:String

the calendar type. (Any calendar type given by locale is ignored.)

field:int

the Calendar field index, such as Calendar#DAY_OF_WEEK

value:int

the value of the Calendar field, such as Calendar#MONDAY

style:int

the string representation style: one of Calendar#SHORT_FORMAT (SHORT), Calendar#SHORT_STANDALONE, Calendar#LONG_FORMAT (LONG), Calendar#LONG_STANDALONE, Calendar#NARROW_FORMAT, or Calendar#NARROW_STANDALONE

locale:Locale

the desired locale

Returns:String

the string representation of the field value, or null if the string representation is not applicable or the given calendar type is unknown

Annotations
@Override
getDisplayNameImplback to summary
public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime)
getDisplayNamesback to summary
public Map<String, Integer> getDisplayNames(String calendarType, int field, int style, Locale locale)

Implements abstract java.util.spi.CalendarNameProvider.getDisplayNames.

Doc from java.util.spi.CalendarNameProvider.getDisplayNames.

Returns a Map containing all string representations (display names) of the Calendar field in the given style and locale and their corresponding field values.

field is a Calendar field index, such as Calendar#MONTH. The time zone fields, Calendar#ZONE_OFFSET and Calendar#DST_OFFSET, are not supported by this method. null must be returned if any time zone fields are specified.

style gives the style of the string representation. It must be one of Calendar#ALL_STYLES, Calendar#SHORT_FORMAT (SHORT), Calendar#SHORT_STANDALONE, Calendar#LONG_FORMAT (LONG), Calendar#LONG_STANDALONE, Calendar#NARROW_FORMAT, or Calendar#NARROW_STANDALONE. Note that narrow names may not be unique due to use of single characters, such as "S" for Sunday and Saturday, and that no narrow names are included in that case.

For example, the following call will return a Map containing "January" to Calendar#JANUARY, "Jan" to Calendar#JANUARY, "February" to Calendar#FEBRUARY, "Feb" to Calendar#FEBRUARY, and so on.

getDisplayNames("gregory", Calendar.MONTH, Calendar.ALL_STYLES, Locale.ENGLISH);
Parameters
calendarType:String

the calendar type. (Any calendar type given by locale is ignored.)

field:int

the calendar field for which the display names are returned

style:int

the style applied to the display names; one of Calendar#ALL_STYLES, Calendar#SHORT_FORMAT (SHORT), Calendar#SHORT_STANDALONE, Calendar#LONG_FORMAT (LONG), Calendar#LONG_STANDALONE, Calendar#NARROW_FORMAT, or Calendar#NARROW_STANDALONE

locale:Locale

the desired locale

Returns:Map<String, Integer>

a Map containing all display names of field in style and locale and their field values, or null if no display names are defined for field

Annotations
@Override
getDisplayNamesImplback to summary
private Map<String, Integer> getDisplayNamesImpl(String calendarType, int field, int style, Locale locale, boolean javatime)
getJavaTimeDisplayNameback to summary
public String getJavaTimeDisplayName(String calendarType, int field, int value, int style, Locale locale)
getJavaTimeDisplayNamesback to summary
public Map<String, Integer> getJavaTimeDisplayNames(String calendarType, int field, int style, Locale locale)
getResourceKeyback to summary
private String getResourceKey(String type, int field, int style, boolean javatime)
getResourceKeyForback to summary
private static String getResourceKeyFor(LocaleProviderAdapter.Type adapterType, String type, int field, int style, boolean javatime)
hasDuplicatesback to summary
private boolean hasDuplicates(String[] strings)
isSupportedLocaleback to summary
public boolean isSupportedLocale(Locale locale)

Overrides java.util.spi.LocaleServiceProvider.isSupportedLocale.

Doc from java.util.spi.LocaleServiceProvider.isSupportedLocale.

Returns true if the given locale is supported by this locale service provider. The given locale may contain extensions that should be taken into account for the support determination.

The default implementation returns true if the given locale is equal to any of the available Locales returned by getAvailableLocales() with ignoring any extensions in both the given locale and the available locales. Concrete locale service provider implementations should override this method if those implementations are Locale extensions-aware. For example, DecimalFormatSymbolsProvider implementations will need to check extensions in the given locale to see if any numbering system is specified and can be supported. However, CollatorProvider implementations may not be affected by any particular numbering systems, and in that case, extensions for numbering systems should be ignored.

Parameters
locale:Locale

a Locale to be tested

Returns:boolean

true if the given locale is supported by this provider; false otherwise.

Annotations
@Override
toStyleNameback to summary
private static String toStyleName(int baseStyle)
sun.util.locale.provider back to summary

private Class CalendarNameProviderImpl.LengthBasedComparator

extends Object
implements Comparator<String>
Class Inheritance
  • java.lang.Object
  • sun.util.locale.provider.CalendarNameProviderImpl.LengthBasedComparator
All Implemented Interfaces
java.util.Comparator

Comparator implementation for TreeMap which iterates keys from longest to shortest.

Field Summary

Modifier and TypeField and Description
private static final CalendarNameProviderImpl.LengthBasedComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(String
the first object to be compared.
o1
,
String
the second object to be compared.
o2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
private static final CalendarNameProviderImpl.LengthBasedComparator INSTANCE

Constructor Detail

LengthBasedComparatorback to summary
private LengthBasedComparator()

Method Detail

compareback to summary
public int compare(String o1, String o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
o1:String

the first object to be compared.

o2:String

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override