Package com.ibm.icu.text
Class LocaleDisplayNames
- java.lang.Object
-
- com.ibm.icu.text.LocaleDisplayNames
-
- Direct Known Subclasses:
LocaleDisplayNames.LastResortLocaleDisplayNames
,LocaleDisplayNamesImpl
public abstract class LocaleDisplayNames extends java.lang.Object
Returns display names of ULocales and components of ULocales. For more information on language, script, region, variant, key, and values, seeULocale
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LocaleDisplayNames.DialectHandling
Enum used ingetInstance(ULocale, DialectHandling)
.private static class
LocaleDisplayNames.LastResortLocaleDisplayNames
Minimum implementation of LocaleDisplayNamesstatic class
LocaleDisplayNames.UiListItem
Struct-like class used to return information for constructing a UI list, each corresponding to a locale.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.Method
FACTORY_DIALECTHANDLING
private static java.lang.reflect.Method
FACTORY_DISPLAYCONTEXT
-
Constructor Summary
Constructors Modifier Constructor Description protected
LocaleDisplayNames()
Deprecated.This API is ICU internal only.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract DisplayContext
getContext(DisplayContext.Type type)
Returns the current value for a specified DisplayContext.Type.abstract LocaleDisplayNames.DialectHandling
getDialectHandling()
Returns the dialect handling used in the display names.static LocaleDisplayNames
getInstance(ULocale locale)
Convenience overload ofgetInstance(ULocale, DialectHandling)
that specifies STANDARD dialect handling.static LocaleDisplayNames
getInstance(ULocale locale, DisplayContext... contexts)
Returns an instance of LocaleDisplayNames that returns names formatted for the provided locale, using the provided DisplayContext settingsstatic LocaleDisplayNames
getInstance(ULocale locale, LocaleDisplayNames.DialectHandling dialectHandling)
Returns an instance of LocaleDisplayNames that returns names formatted for the provided locale, using the provided dialectHandling.static LocaleDisplayNames
getInstance(java.util.Locale locale)
Convenience overload ofgetInstance(Locale, DisplayContext...)
that specifiesDisplayContext.STANDARD_NAMES
.static LocaleDisplayNames
getInstance(java.util.Locale locale, DisplayContext... contexts)
Returns an instance of LocaleDisplayNames that returns names formatted for the providedLocale
, using the provided DisplayContext settingsabstract ULocale
getLocale()
Returns the locale used to determine the display names.java.util.List<LocaleDisplayNames.UiListItem>
getUiList(java.util.Set<ULocale> localeSet, boolean inSelf, java.util.Comparator<java.lang.Object> collator)
Return a list of information used to construct a UI list of locale names.abstract java.util.List<LocaleDisplayNames.UiListItem>
getUiListCompareWholeItems(java.util.Set<ULocale> localeSet, java.util.Comparator<LocaleDisplayNames.UiListItem> comparator)
Return a list of information used to construct a UI list of locale names, providing more access to control the sorting.abstract java.lang.String
keyDisplayName(java.lang.String key)
Returns the display name of the provided locale key.abstract java.lang.String
keyValueDisplayName(java.lang.String key, java.lang.String value)
Returns the display name of the provided value (used with the provided key).abstract java.lang.String
languageDisplayName(java.lang.String lang)
Returns the display name of the provided language code.abstract java.lang.String
localeDisplayName(ULocale locale)
Returns the display name of the provided ulocale.abstract java.lang.String
localeDisplayName(java.lang.String localeId)
Returns the display name of the provided locale id.abstract java.lang.String
localeDisplayName(java.util.Locale locale)
Returns the display name of the provided locale.abstract java.lang.String
regionDisplayName(java.lang.String region)
Returns the display name of the provided region code.abstract java.lang.String
scriptDisplayName(int scriptCode)
Returns the display name of the provided script code.abstract java.lang.String
scriptDisplayName(java.lang.String script)
Returns the display name of the provided script code.java.lang.String
scriptDisplayNameInContext(java.lang.String script)
Deprecated.This API is ICU internal only.abstract java.lang.String
variantDisplayName(java.lang.String variant)
Returns the display name of the provided variant.
-
-
-
Method Detail
-
getInstance
public static LocaleDisplayNames getInstance(ULocale locale)
Convenience overload ofgetInstance(ULocale, DialectHandling)
that specifies STANDARD dialect handling.- Parameters:
locale
- the display locale- Returns:
- a LocaleDisplayNames instance
-
getInstance
public static LocaleDisplayNames getInstance(java.util.Locale locale)
Convenience overload ofgetInstance(Locale, DisplayContext...)
that specifiesDisplayContext.STANDARD_NAMES
.- Parameters:
locale
- the displayLocale
- Returns:
- a LocaleDisplayNames instance
-
getInstance
public static LocaleDisplayNames getInstance(ULocale locale, LocaleDisplayNames.DialectHandling dialectHandling)
Returns an instance of LocaleDisplayNames that returns names formatted for the provided locale, using the provided dialectHandling.- Parameters:
locale
- the display localedialectHandling
- how to select names for locales- Returns:
- a LocaleDisplayNames instance
-
getInstance
public static LocaleDisplayNames getInstance(ULocale locale, DisplayContext... contexts)
Returns an instance of LocaleDisplayNames that returns names formatted for the provided locale, using the provided DisplayContext settings- Parameters:
locale
- the display localecontexts
- one or more context settings (e.g. for dialect handling, capitalization, etc.- Returns:
- a LocaleDisplayNames instance
-
getInstance
public static LocaleDisplayNames getInstance(java.util.Locale locale, DisplayContext... contexts)
Returns an instance of LocaleDisplayNames that returns names formatted for the providedLocale
, using the provided DisplayContext settings- Parameters:
locale
- the displayLocale
contexts
- one or more context settings (e.g. for dialect handling, capitalization, etc.- Returns:
- a LocaleDisplayNames instance
-
getLocale
public abstract ULocale getLocale()
Returns the locale used to determine the display names. This is not necessarily the same locale passed togetInstance(com.ibm.icu.util.ULocale)
.- Returns:
- the display locale
-
getDialectHandling
public abstract LocaleDisplayNames.DialectHandling getDialectHandling()
Returns the dialect handling used in the display names.- Returns:
- the dialect handling enum
-
getContext
public abstract DisplayContext getContext(DisplayContext.Type type)
Returns the current value for a specified DisplayContext.Type.- Parameters:
type
- the DisplayContext.Type whose value to return- Returns:
- the current DisplayContext setting for the specified type
-
localeDisplayName
public abstract java.lang.String localeDisplayName(ULocale locale)
Returns the display name of the provided ulocale. When no display names are available for all or portions of the original locale ID, those portions may be used directly (possibly in a more canonical form) as part of the returned display name.- Parameters:
locale
- the locale whose display name to return- Returns:
- the display name of the provided locale
-
localeDisplayName
public abstract java.lang.String localeDisplayName(java.util.Locale locale)
Returns the display name of the provided locale. When no display names are available for all or portions of the original locale ID, those portions may be used directly (possibly in a more canonical form) as part of the returned display name.- Parameters:
locale
- the locale whose display name to return- Returns:
- the display name of the provided locale
-
localeDisplayName
public abstract java.lang.String localeDisplayName(java.lang.String localeId)
Returns the display name of the provided locale id. When no display names are available for all or portions of the original locale ID, those portions may be used directly (possibly in a more canonical form) as part of the returned display name.- Parameters:
localeId
- the id of the locale whose display name to return- Returns:
- the display name of the provided locale
-
languageDisplayName
public abstract java.lang.String languageDisplayName(java.lang.String lang)
Returns the display name of the provided language code.- Parameters:
lang
- the language code- Returns:
- the display name of the provided language code
-
scriptDisplayName
public abstract java.lang.String scriptDisplayName(java.lang.String script)
Returns the display name of the provided script code.- Parameters:
script
- the script code- Returns:
- the display name of the provided script code
-
scriptDisplayNameInContext
@Deprecated public java.lang.String scriptDisplayNameInContext(java.lang.String script)
Deprecated.This API is ICU internal only.Returns the display name of the provided script code when used in the context of a full locale name.- Parameters:
script
- the script code- Returns:
- the display name of the provided script code
-
scriptDisplayName
public abstract java.lang.String scriptDisplayName(int scriptCode)
Returns the display name of the provided script code. SeeUScript
for recognized script codes.- Parameters:
scriptCode
- the script code number- Returns:
- the display name of the provided script code
-
regionDisplayName
public abstract java.lang.String regionDisplayName(java.lang.String region)
Returns the display name of the provided region code.- Parameters:
region
- the region code- Returns:
- the display name of the provided region code
-
variantDisplayName
public abstract java.lang.String variantDisplayName(java.lang.String variant)
Returns the display name of the provided variant.- Parameters:
variant
- the variant string- Returns:
- the display name of the provided variant
-
keyDisplayName
public abstract java.lang.String keyDisplayName(java.lang.String key)
Returns the display name of the provided locale key.- Parameters:
key
- the locale key name- Returns:
- the display name of the provided locale key
-
keyValueDisplayName
public abstract java.lang.String keyValueDisplayName(java.lang.String key, java.lang.String value)
Returns the display name of the provided value (used with the provided key).- Parameters:
key
- the locale key namevalue
- the locale key's value- Returns:
- the display name of the provided value
-
getUiList
public java.util.List<LocaleDisplayNames.UiListItem> getUiList(java.util.Set<ULocale> localeSet, boolean inSelf, java.util.Comparator<java.lang.Object> collator)
Return a list of information used to construct a UI list of locale names.- Parameters:
collator
- how to collate—should normally be Collator.getInstance(getDisplayLocale())inSelf
- if true, compares the nameInSelf, otherwise the nameInDisplayLocale. Set depending on which field (displayLocale vs self) is to show up in the UI. If both are to show up in the UI, then it should be the one used for the primary sort order.localeSet
- a list of locales to present in a UI list. The casing uses the settings in the LocaleDisplayNames instance.- Returns:
- an ordered list of UiListItems.
- Throws:
IllformedLocaleException
- if any of the locales in localeSet are malformed.
-
getUiListCompareWholeItems
public abstract java.util.List<LocaleDisplayNames.UiListItem> getUiListCompareWholeItems(java.util.Set<ULocale> localeSet, java.util.Comparator<LocaleDisplayNames.UiListItem> comparator)
Return a list of information used to construct a UI list of locale names, providing more access to control the sorting. Normally use getUiList instead.- Parameters:
comparator
- how to sort the UiListItems in the result.localeSet
- a list of locales to present in a UI list. The casing uses the settings in the LocaleDisplayNames instance.- Returns:
- an ordered list of UiListItems.
- Throws:
IllformedLocaleException
- if any of the locales in localeSet are malformed.
-
-