ICU Enhancement
This class is ICU's replacement for java..
ICU
Methods, fields, and other functionality specific to ICU are labeled 'ICU'.
java.util.Locale that provides additional
support for ICU protocol. In ICU 3.0 this class is enhanced to support
RFC 3066 language identifiers.
Many classes and services in ICU follow a factory idiom, in which a factory method or object responds to a client request with an object. The request includes a locale (the requested locale), and the returned object is constructed using data for that locale. The system may lack data for the requested locale, in which case the locale fallback mechanism will be invoked until a populated locale is found (the valid locale). Furthermore, even when a populated locale is found (the valid locale), further fallback may be required to reach a locale containing the specific data required by the service (the actual locale).
ULocale performs 'normalization' and 'canonicalization' of locale ids. Normalization 'cleans up' ICU locale ids as follows:
canonicalize can be called to convert the id
to canonical form, or the canonicalInstance factory method
can be called.
This class provides selectors VALID_LOCALE and ACTUAL_LOCALE intended for use in methods named
getLocale(). These methods exist in several ICU classes,
including com., com., com.,
com.,
com.,
com., and com. and their subclasses, if
any. Once an object of one of these classes has been created,
getLocale() may be called on it to determine the valid and
actual locale arrived at during the object's construction.
Note
The actual locale is returned correctly, but the valid locale is not, in most cases.
java.util.Locale
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| public static enum | |
| public static class | ULocale.Builder
|
| public static enum | ULocale.Category
Enum for locale categories. |
| private static class | |
| public static enum | ULocale.Minimize
Deprecated
This API is ICU internal only.
Options for minimizeSubtags.
|
| public static class | ULocale.Type
Opaque selector enum for getLocale(). |
| Modifier and Type | Field and Description |
|---|---|
| public static ULocale. | |
| private transient volatile BaseLocale | baseLocale
Cache the locale data container fields. |
| private static final SoftCache | |
| public static final ULocale | CANADA
Useful constant for country/region. |
| public static final ULocale | CANADA_FRENCH
Useful constant for country/region. |
| private static String[][] | CANONICALIZE_MAP
This table lists pairs of locale ids for canonicalization. |
| public static final ULocale | CHINA
Useful constant for country/region. |
| public static final ULocale | CHINESE
Useful constant for language. |
| private static Locale[] | |
| private static ULocale[] | |
| private static Locale | defaultLocale
Keep our own default ULocale. |
| private static ULocale | |
| private static final Locale | |
| private static final String | EMPTY_STRING
Handy constant. |
| public static final ULocale | ENGLISH
Useful constant for language. |
| private transient volatile LocaleExtensions | |
| public static final ULocale | FRANCE
Useful constant for country/region. |
| public static final ULocale | FRENCH
Useful constant for language. |
| public static final ULocale | GERMAN
Useful constant for language. |
| public static final ULocale | GERMANY
Useful constant for country/region. |
| private static Set | |
| public static final ULocale | ITALIAN
Useful constant for language. |
| public static final ULocale | ITALY
Useful constant for country/region. |
| public static final ULocale | JAPAN
Useful constant for country/region. |
| public static final ULocale | JAPANESE
Useful constant for language. |
| public static final ULocale | KOREA
Useful constant for country/region. |
| public static final ULocale | KOREAN
Useful constant for language. |
| private static final String | LANG_DIR_STRING
Pairs of (language subtag, + or -) for finding out fast if common languages are LTR (minus) or RTL (plus). |
| private transient volatile Locale | locale
Cache the locale. |
| private static final String | |
| private String | localeID
The raw localeID that we were passed in. |
| private static CacheBase | |
| public static final ULocale | PRC
Useful constant for country/region. |
| public static final char | PRIVATE_USE_EXTENSION
The key for the private use locale extension ('x'). |
| public static final ULocale | ROOT
The root ULocale. |
| private static final long | |
| public static final ULocale | SIMPLIFIED_CHINESE
Useful constant for language. |
| public static final ULocale | TAIWAN
Useful constant for country/region. |
| public static final ULocale | TRADITIONAL_CHINESE
Useful constant for language. |
| public static final ULocale | UK
Useful constant for country/region. |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final char | |
| public static final char | UNICODE_LOCALE_EXTENSION
The key for Unicode locale extension ('u'). |
| public static final ULocale | US
Useful constant for country/region. |
| public static ULocale. | VALID_LOCALE
ICU |
| Access | Constructor and Description |
|---|---|
| private | |
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static ULocale | Returns: one of the locales from the availableLocales list, or null if none matchlist in HTTP "Accept-Language:" format of acceptable locales acceptLanguageList, ULocale[] list of available locales. One of these will be returned. availableLocales, boolean[] if non-null, a 1-element array containing a boolean to be set with
the fallback status fallback)ICU |
| public static ULocale | Returns: one of the locales from the availableLocales list, or null if none matchlist of acceptable locales acceptLanguageList, ULocale[] list of available locales. One of these will be returned. availableLocales, boolean[] if non-null, a 1-element array containing a boolean to be set with
the fallback status fallback)ICU |
| public static ULocale | Returns: one of the locales from the ULocale.getAvailableLocales() list, or null if none matchlist in HTTP "Accept-Language:" format of acceptable locales acceptLanguageList, boolean[] if non-null, a 1-element array containing a boolean to be set with
the fallback status fallback)ICU |
| public static ULocale | Returns: one of the locales from the ULocale.getAvailableLocales() list, or null if none matchordered array of acceptable locales (preferred are listed first) acceptLanguageList, boolean[] if non-null, a 1-element array containing a boolean to be set with
the fallback status fallback)ICU |
| public static ULocale | |
| private static void | appendTag(String
The tag to add. tag, StringBuilder The output buffer. buffer)Append a tag to a StringBuilder, adding the separator if necessary.The tag must not be a zero-length string. |
| private BaseLocale | |
| public static String | |
| public Object | clone()
Overrides java. |
| public int | Returns: a negative integer, zero, or a positive integer as this ULocale is less than, equal to, or greater than the specified ULocale.the ULocale to be compared. other)Implements java. |
| public static ULocale | Returns: the locale created from the canonical version of the ID.the locale id to canonicalize nonCanonicalID)ICU |
| public static ULocale | Returns: the ULocale created from the canonical version of the ULocale.the ULocale to canonicalize locale)Creates a ULocale from the locale by first canonicalizing the locale according to CLDR. |
| private static String | Returns: The new tag string.The language tag to use. lang, String The script tag to use. script, String The region tag to use. region, String Any trailing data to append to the new tag. trailing)Create a tag string from the supplied parameters. |
| public boolean | Returns: true if this Locale is equal to the specified object.the reference object with which to compare. obj)Overrides java. |
| private LocaleExtensions | |
| public static ULocale | Returns: The locale that best represents the language tag.the language tag languageTag)Returns a locale for the specified IETF BCP 47 language tag string. |
| public static ULocale | |
| public static ULocale[] | |
| public static Collection | getAvailableLocalesByType(ULocale.
Returns a list of all installed locales according to the specified type. |
| public String | |
| public static String | |
| public String | |
| public String | getCountry()
Returns the country/region code for this locale, which will either be the empty string or an uppercase ISO 3166 2-letter code. |
| public static String | |
| public static ULocale | |
| public static ULocale | Returns: the default ULocale for the specified category.the category categoryReturns the current default ULocale for the specified category. |
| public String | Returns: the localized country name.Returns this locale's country localized for display in the default Warning this is for the region part of a valid locale ID; it cannot just be the region code (like "FR"). |
| public String | Returns: the localized country name.the locale in which to display the name. displayLocale)Returns this locale's country localized for display in the provided locale Warning this is for the region part of a valid locale ID; it cannot just be the region code (like "FR"). |
| public static String | Returns: the localized country name.the id of the locale whose country will be displayed localeID, String the id of the locale in which to display the name. displayLocaleID)ICU |
| public static String | Returns: the localized country name.the id of the locale whose country will be displayed. localeID, ULocale the locale in which to display the name. displayLocale)ICU |
| private static String | |
| public static String | Returns: the localized keyword name.the keyword to be displayed. keyword)ICU |
| public static String | Returns: the localized keyword name.the keyword to be displayed. keyword, String the id of the locale in which to display the keyword. displayLocaleID)ICU |
| public static String | Returns: the localized keyword name.the keyword to be displayed. keyword, ULocale the locale in which to display the keyword. displayLocale)ICU |
| private static String | |
| public String | Returns: the localized value name.the keyword whose value is to be displayed. keyword)ICU |
| public String | Returns: the localized value name.the keyword whose value is to be displayed. keyword, ULocale the locale in which to display the value. displayLocale)ICU |
| public static String | Returns: the localized value name.the id of the locale whose keyword value is to be displayed. localeID, String the keyword whose value is to be displayed. keyword, String the id of the locale in which to display the value. displayLocaleID)ICU |
| public static String | Returns: the localized value name.the id of the locale whose keyword value is to be displayed. localeID, String the keyword whose value is to be displayed. keyword, ULocale the id of the locale in which to display the value. displayLocale)ICU |
| private static String | |
| public String | Returns: the localized language name.Returns this locale's language localized for display in the default |
| public String | Returns: the localized language name.the locale in which to display the name. displayLocale)Returns this locale's language localized for display in the provided locale. |
| public static String | Returns: the localized language name.the id of the locale whose language will be displayed localeID, String the id of the locale in which to display the name. displayLocaleID)ICU |
| public static String | Returns: the localized language name.the id of the locale whose language will be displayed. localeID, ULocale the locale in which to display the name. displayLocale)ICU |
| private static String | |
| public String | |
| public String | Returns: the localized language name.the locale in which to display the name. displayLocale)ICU |
| public static String | Returns: the localized language name.the id of the locale whose language will be displayed localeID, String the id of the locale in which to display the name. displayLocaleID)ICU |
| public static String | Returns: the localized language name.the id of the locale whose language will be displayed. localeID, ULocale the locale in which to display the name. displayLocale)ICU |
| public String | Returns: the localized locale name.Returns this locale name localized for display in the default |
| public String | Returns: the localized locale name.the locale in which to display the locale name. displayLocale)Returns this locale name localized for display in the provided locale. |
| public static String | Returns: the localized locale name.the locale whose name is to be displayed. localeID, String the id of the locale in which to display the locale name. displayLocaleID)ICU |
| public static String | Returns: the localized locale name.the locale whose name is to be displayed. localeID, ULocale the locale in which to display the locale name. displayLocale)ICU |
| private static String | |
| public String | |
| public String | Returns: the localized locale name.the locale in which to display the locale name. displayLocale)ICU |
| public static String | Returns: the localized locale name.the locale whose name is to be displayed. localeID, String the id of the locale in which to display the locale name. displayLocaleID)ICU |
| public static String | Returns: the localized locale name.the locale whose name is to be displayed. localeID, ULocale the locale in which to display the locale name. displayLocale)ICU |
| private static String | |
| public String | Returns: the localized script name.Returns this locale's script localized for display in the default |
| public String | Returns: the localized script name.the locale in which to display the name. displayLocale)Returns this locale's script localized for display in the provided locale. |
| public static String | Returns: the localized script name.the id of the locale whose script will be displayed localeID, String the id of the locale in which to display the name. displayLocaleID)ICU |
| public static String | Returns: the localized script name.the id of the locale whose script will be displayed. localeID, ULocale the locale in which to display the name. displayLocale)ICU |
| public String | Returns: the localized script name.
Deprecated
This API is ICU internal only.
ICU |
| public String | Returns: the localized script name.the locale in which to display the name. displayLocale)
Deprecated
This API is ICU internal only.
ICU |
| public static String | Returns: the localized script name.the id of the locale whose script will be displayed localeID, String the id of the locale in which to display the name. displayLocaleID)
Deprecated
This API is ICU internal only.
ICU |
| public static String | Returns: the localized script name.the id of the locale whose script will be displayed. localeID, ULocale the locale in which to display the name. displayLocale)
Deprecated
This API is ICU internal only.
ICU |
| private static String | |
| private static String | |
| public String | Returns: the localized variant name.Returns this locale's variant localized for display in the default |
| public String | Returns: the localized variant name.the locale in which to display the name. displayLocale)Returns this locale's variant localized for display in the provided locale. |
| public static String | Returns: the localized variant name.the id of the locale whose variant will be displayed localeID, String the id of the locale in which to display the name. displayLocaleID)ICU |
| public static String | Returns: the localized variant name.the id of the locale whose variant will be displayed. localeID, ULocale the locale in which to display the name. displayLocale)ICU |
| private static String | |
| public String | Returns: The extension, or null if this locale defines no extension for the specified key.the extension key key)Returns the extension (or private use) value associated with the specified key, or null if there is no extension associated with the key. |
| public Set | Returns: the set of extension keys, or the empty set if this locale has no extensionsReturns the set of extension keys associated with this locale, or the empty set if it has no extensions. |
| public static String | |
| public ULocale | |
| private static String | getFallbackString(String fallback)
Returns the given (canonical) locale id minus the last part before the tags. |
| private static ULocale | |
| public String | |
| public static String | |
| public String | |
| public static String | |
| public static String[] | |
| public static String[] | |
| public Iterator | |
| public static Iterator | Returns: an iterator over the keywords in the specified locale, or null if there are no keywords.ICU |
| public String | Returns: the value of the keyword, or null.name of the keyword whose value is desired. Case insensitive. keywordName)ICU |
| public static String | Returns: String the value of the keyword as a stringname of the keyword whose value is desired. Case insensitive. keywordName)ICU |
| public String | getLanguage()
Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code. |
| public static String | getLanguage(String localeID)
Returns the language code for the locale ID, which will either be the empty string or a lowercase ISO 639 code. |
| public String | |
| public String | |
| public static String | |
| public static String | Returns: String with region to use ("" if none found).The locale (includes any keywords) from which
to get the region to use for supplemental data. locale, boolean If true, will try to infer region from other
locale elements if not found any other way. inferRegion)
Deprecated
This API is ICU internal only.
ICU |
| public String | |
| public static String | |
| private static int | Returns: The size of the shortest length subtagGets the shortest length subtag's size. |
| public Set | Returns: The set of attributes.Returns the set of unicode locale attributes associated with this locale, or the empty set if it has no attributes. |
| public Set | Returns: The set of Unicode locale keys, or the empty set if this locale has no Unicode locale keywords.Returns the set of Unicode locale keys defined by this locale, or the empty set if this locale has none. |
| public String | Returns: The Unicode locale type associated with the key, or null if the locale does not define the key.the Unicode locale key key)Returns the Unicode locale type associated with the specified Unicode locale key for this locale. |
| public String | |
| public static String | |
| public int | Returns: a hash code value for this object.Overrides java. |
| private static boolean | Returns: true if the String is empty, or if the reference is null.The string to check string)A trivial utility function that checks for a null reference or checks the length of the supplied String. |
| private static synchronized boolean | |
| public boolean | |
| private static String | |
| public static ULocale | |
| public static ULocale | Returns: The minimized ULocale instance.The ULocale to minimize loc, ULocale.Indicate which should be preferred, when either the region or the script could be suppressed, but not both. fieldToFavor
Deprecated
This API is ICU internal only.
ICU |
| private static int | Returns: The number of chars of the localeID parameter consumed.The locale ID to parse. localeID, String[] An array of three String references to return the subtag strings. tags)Parse the language, script, and region subtags from a tag string, and return the results. |
| public static synchronized void | |
| public static synchronized void | setDefault(ULocale.
the specified category to set the default locale category,the new default locale newLocale)Sets the default |
| public ULocale | Returns: the updated localethe keyword to add/remove, or null to remove all keywords. keyword, String the value to add/set, or null to remove this particular keyword. value)ICU |
| public static String | Returns: the updated locale idthe locale id to modify localeID, String the keyword to add/remove, or null to remove all keywords. keyword, String the value to add/set, or null to remove this particular keyword. value)Given a locale id, a keyword, and a value, return a new locale id with an updated keyword and value. |
| private static String | |
| public String | Returns: a BCP47 language tag representing the localeReturns a well-formed IETF BCP 47 language tag representing this locale. |
| public static String | Returns: the well-formed legacy key, or null if the specified keyword cannot be mapped to a well-formed legacy key.the input locale keyword (either BCP 47 Unicode locale
extension key or legacy key). keyword)ICU |
| public static String | Returns: the well-formed legacy type, or null if the specified keyword value cannot be mapped to a well-formed legacy type.the locale keyword (either legacy keyword such as
"collation" or BCP 47 Unicode locale extension
key such as "co"). keyword, String the locale keyword value (either BCP 47 Unicode locale
extension type such as "phonebk" or legacy keyword value
such as "phonebook"). value)ICU |
| public Locale | Returns: ajava. that either exactly represents this object
or is the closest approximation.ICU |
| public String | Returns: a string representation of the object.Overrides java. |
| public static String | Returns: the well-formed BCP 47 Unicode locale extension key, or null if the specified locale keyword cannot be mapped to a well-formed BCP 47 Unicode locale extension key.the input locale keyword (either legacy key
such as "collation" or BCP 47 Unicode locale extension
key such as "co"). keyword)ICU |
| public static String | Returns: the well-formed BCP47 Unicode locale extension type, or null if the locale keyword value cannot be mapped to a well-formed BCP 47 Unicode locale extension type.the locale keyword (either legacy key such as
"collation" or BCP 47 Unicode locale extension
key such as "co"). keyword, String the locale keyword value (either legacy type
such as "phonebook" or BCP 47 Unicode locale extension
type such as "phonebk"). value)ICU |