|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.icu.util.ULocale
A class analogous to 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 Calendar
, Currency
, UFormat
,
BreakIterator
, Collator
, DateFormatSymbols
, and DecimalFormatSymbols
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 getLocale() method will be implemented in ICU 3.0; ICU 2.8 contains a partial preview implementation. The actual locale is returned correctly, but the valid locale is not, in most cases.
Locale
,
Serialized FormNested Class Summary | |
static class |
ULocale.Type
Opaque selector enum for getLocale(). |
Field Summary | |
static ULocale.Type |
ACTUAL_LOCALE
Selector for getLocale() indicating the locale of the resource containing the data. |
static ULocale |
CANADA
Useful constant for country/region. |
static ULocale |
CANADA_FRENCH
Useful constant for country/region. |
static ULocale |
CHINA
Useful constant for country/region. |
static ULocale |
CHINESE
Useful constant for language. |
static ULocale |
ENGLISH
Useful constant for language. |
static ULocale |
FRANCE
Useful constant for country/region. |
static ULocale |
FRENCH
Useful constant for language. |
static ULocale |
GERMAN
Useful constant for language. |
static ULocale |
GERMANY
Useful constant for country/region. |
static ULocale |
ITALIAN
Useful constant for language. |
static ULocale |
ITALY
Useful constant for country/region. |
static ULocale |
JAPAN
Useful constant for country/region. |
static ULocale |
JAPANESE
Useful constant for language. |
static ULocale |
KOREA
Useful constant for country/region. |
static ULocale |
KOREAN
Useful constant for language. |
static ULocale |
PRC
Useful constant for country/region. |
static ULocale |
ROOT
The root ULocale. |
static ULocale |
SIMPLIFIED_CHINESE
Useful constant for language. |
static ULocale |
TAIWAN
Useful constant for country/region. |
static ULocale |
TRADITIONAL_CHINESE
Useful constant for language. |
static ULocale |
UK
Useful constant for country/region. |
static ULocale |
US
Useful constant for country/region. |
static ULocale.Type |
VALID_LOCALE
Selector for getLocale() indicating the most specific locale for which any data exists. |
Constructor Summary | |
ULocale(java.lang.String localeID)
Construct a ULocale from a RFC 3066 locale ID. |
|
ULocale(java.lang.String a,
java.lang.String b)
Convenience overload of ULocale(String, String, String) for compatibility with java.util.Locale. |
|
ULocale(java.lang.String a,
java.lang.String b,
java.lang.String c)
Construct a ULocale from a localeID constructed from the three 'fields' a, b, and c. |
Method Summary | |
static ULocale |
acceptLanguage(java.lang.String acceptLanguageList,
boolean[] fallback)
Based on a HTTP formatted list of acceptable locales, determine an available locale for the user. |
static ULocale |
acceptLanguage(java.lang.String acceptLanguageList,
ULocale[] availableLocales,
boolean[] fallback)
Based on a HTTP formatted list of acceptable locales, determine an available locale for the user. |
static ULocale |
acceptLanguage(ULocale[] acceptLanguageList,
boolean[] fallback)
Based on an ordered array of acceptable locales, determine an available locale for the user. |
static ULocale |
acceptLanguage(ULocale[] acceptLanguageList,
ULocale[] availableLocales,
boolean[] fallback)
Based on a list of acceptable locales, determine an available locale for the user. |
static java.lang.String |
canonicalize(java.lang.String localeID)
Returns the canonical name for the specified locale ID. |
java.lang.Object |
clone()
This is for compatibility with Locale-- in actuality, since ULocale is immutable, there is no reason to clone it, so this API returns 'this'. |
static ULocale |
createCanonical(java.lang.String nonCanonicalID)
Create a ULocale from the id by first canonicalizing the id. |
boolean |
equals(java.lang.Object obj)
Returns true if the other object is another ULocale with the same full name, or is a String localeID that matches the full name. |
static ULocale |
forLocale(java.util.Locale loc)
Return a ULocale object for a Locale .
|
static ULocale[] |
getAvailableLocales()
Returns a list of all installed locales. |
java.lang.String |
getBaseName()
Returns the (normalized) base name for this locale. |
static java.lang.String |
getBaseName(java.lang.String localeID)
Returns the (normalized) base name for the specified locale. |
java.lang.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. |
static java.lang.String |
getCountry(java.lang.String localeID)
Returns the country/region code for this locale, which will either be the empty string or an uppercase ISO 3166 2-letter code. |
static ULocale |
getDefault()
Returns the current default ULocale. |
java.lang.String |
getDisplayCountry()
Returns this locale's country localized for display in the default locale. |
static java.lang.String |
getDisplayCountry(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns a locale's country localized for display in the provided locale. |
static java.lang.String |
getDisplayCountry(java.lang.String localeID,
ULocale displayLocale)
Returns a locale's country localized for display in the provided locale. |
java.lang.String |
getDisplayCountry(ULocale displayLocale)
Returns this locale's country localized for display in the provided locale. |
static java.lang.String |
getDisplayKeyword(java.lang.String keyword)
Returns a keyword localized for display in the default locale. |
static java.lang.String |
getDisplayKeyword(java.lang.String keyword,
java.lang.String displayLocaleID)
Returns a keyword localized for display in the specified locale. |
static java.lang.String |
getDisplayKeyword(java.lang.String keyword,
ULocale displayLocale)
Returns a keyword localized for display in the specified locale. |
java.lang.String |
getDisplayKeywordValue(java.lang.String keyword)
Returns a keyword value localized for display in the default locale. |
static java.lang.String |
getDisplayKeywordValue(java.lang.String localeID,
java.lang.String keyword,
java.lang.String displayLocaleID)
Returns a keyword value localized for display in the specified locale. |
static java.lang.String |
getDisplayKeywordValue(java.lang.String localeID,
java.lang.String keyword,
ULocale displayLocale)
Returns a keyword value localized for display in the specified locale. |
java.lang.String |
getDisplayKeywordValue(java.lang.String keyword,
ULocale displayLocale)
Returns a keyword value localized for display in the specified locale. |
java.lang.String |
getDisplayLanguage()
Returns this locale's language localized for display in the default locale. |
static java.lang.String |
getDisplayLanguage(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns a locale's language localized for display in the provided locale. |
static java.lang.String |
getDisplayLanguage(java.lang.String localeID,
ULocale displayLocale)
Returns a locale's language localized for display in the provided locale. |
java.lang.String |
getDisplayLanguage(ULocale displayLocale)
Returns this locale's language localized for display in the provided locale. |
java.lang.String |
getDisplayName()
Returns this locale name localized for display in the default locale. |
static java.lang.String |
getDisplayName(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns the locale ID localized for display in the provided locale. |
static java.lang.String |
getDisplayName(java.lang.String localeID,
ULocale displayLocale)
Returns the locale ID localized for display in the provided locale. |
java.lang.String |
getDisplayName(ULocale displayLocale)
Returns this locale name localized for display in the provided locale. |
java.lang.String |
getDisplayScript()
Returns this locale's script localized for display in the default locale. |
static java.lang.String |
getDisplayScript(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns a locale's script localized for display in the provided locale. |
static java.lang.String |
getDisplayScript(java.lang.String localeID,
ULocale displayLocale)
Returns a locale's script localized for display in the provided locale. |
java.lang.String |
getDisplayScript(ULocale displayLocale)
Returns this locale's script localized for display in the provided locale. |
java.lang.String |
getDisplayVariant()
Returns this locale's variant localized for display in the default locale. |
static java.lang.String |
getDisplayVariant(java.lang.String localeID,
java.lang.String displayLocaleID)
Returns a locale's variant localized for display in the provided locale. |
static java.lang.String |
getDisplayVariant(java.lang.String localeID,
ULocale displayLocale)
Returns a locale's variant localized for display in the provided locale. |
java.lang.String |
getDisplayVariant(ULocale displayLocale)
Returns this locale's variant localized for display in the provided locale. |
ULocale |
getFallback()
Returns the fallback locale for this locale. |
static java.lang.String |
getFallback(java.lang.String localeID)
Returns the fallback locale for the specified locale, which might be the empty string. |
java.lang.String |
getISO3Country()
Returns a three-letter abbreviation for this locale's country/region. |
static java.lang.String |
getISO3Country(java.lang.String localeID)
Returns a three-letter abbreviation for this locale's country/region. |
java.lang.String |
getISO3Language()
Returns a three-letter abbreviation for this locale's language. |
static java.lang.String |
getISO3Language(java.lang.String localeID)
Returns a three-letter abbreviation for this locale's language. |
static java.lang.String[] |
getISOCountries()
Returns a list of all 2-letter country codes defined in ISO 3166. |
static java.lang.String[] |
getISOLanguages()
Returns a list of all 2-letter language codes defined in ISO 639. |
java.util.Iterator |
getKeywords()
Returns an iterator over keywords for this locale. |
static java.util.Iterator |
getKeywords(java.lang.String localeID)
Returns an iterator over keywords for the specified locale. |
java.lang.String |
getKeywordValue(java.lang.String keywordName)
Returns the value for a keyword in this locale. |
static java.lang.String |
getKeywordValue(java.lang.String localeID,
java.lang.String keywordName)
Returns the value for a keyword in the specified locale. |
java.lang.String |
getLanguage()
Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code. |
static java.lang.String |
getLanguage(java.lang.String localeID)
Returns the language code for the locale ID, which will either be the empty string or a lowercase ISO 639 code. |
java.lang.String |
getName()
Returns the (normalized) full name for this locale. |
static java.lang.String |
getName(java.lang.String localeID)
Returns the (normalized) full name for the specified locale. |
java.lang.String |
getScript()
Returns the script code for this locale, which might be the empty string. |
static java.lang.String |
getScript(java.lang.String localeID)
Returns the script code for the specified locale, which might be the empty string. |
java.lang.String |
getVariant()
Returns the variant code for this locale, which might be the empty string. |
static java.lang.String |
getVariant(java.lang.String localeID)
Returns the variant code for the specified locale, which might be the empty string. |
int |
hashCode()
Returns the hashCode. |
static void |
setDefault(ULocale newLocale)
Sets the default ULocale. |
ULocale |
setKeywordValue(java.lang.String keyword,
java.lang.String value)
Given a keyword and a value, return a new locale with an updated keyword and value. |
static java.lang.String |
setKeywordValue(java.lang.String localeID,
java.lang.String keyword,
java.lang.String value)
Given a locale id, a keyword, and a value, return a new locale id with an updated keyword and value. |
java.util.Locale |
toLocale()
Convert this ULocale object to a Locale . |
java.lang.String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final ULocale ENGLISH
public static final ULocale FRENCH
public static final ULocale GERMAN
public static final ULocale ITALIAN
public static final ULocale JAPANESE
public static final ULocale KOREAN
public static final ULocale CHINESE
public static final ULocale SIMPLIFIED_CHINESE
public static final ULocale TRADITIONAL_CHINESE
public static final ULocale FRANCE
public static final ULocale GERMANY
public static final ULocale ITALY
public static final ULocale JAPAN
public static final ULocale KOREA
public static final ULocale CHINA
public static final ULocale PRC
public static final ULocale TAIWAN
public static final ULocale UK
public static final ULocale US
public static final ULocale CANADA
public static final ULocale CANADA_FRENCH
public static final ULocale ROOT
public static ULocale.Type ACTUAL_LOCALE
public static ULocale.Type VALID_LOCALE
Note: The valid locale will be returned correctly in ICU 3.0 or later. In ICU 2.8, it is not returned correctly.
Constructor Detail |
public ULocale(java.lang.String localeID)
This constructor does not canonicalize the localeID.
localeID
- string representation of the locale, e.g:
"en_US", "sy_Cyrl_YU", "zh__pinyin", "es_ES@currency=EUR,collation=traditional"public ULocale(java.lang.String a, java.lang.String b)
ULocale(String, String, String)
public ULocale(java.lang.String a, java.lang.String b, java.lang.String c)
ULocale(String localeID)
.
Java locale strings consisting of language, country, and variant will be handled by this form, since the country code (being shorter than four letters long) will not be interpreted as a script code. If a script code is present, the final argument ('c') will be interpreted as the country code. It is recommended that this constructor only be used to ease porting, and that clients instead use the single-argument constructor when constructing a ULocale from a localeID.
a
- first component of the locale idb
- second component of the locale idc
- third component of the locale idULocale(String)
Method Detail |
public static ULocale forLocale(java.util.Locale loc)
Locale
.
The ULocale is canonicalized.
loc
- a JDK localepublic static ULocale createCanonical(java.lang.String nonCanonicalID)
nonCanonicalID
- the locale id to canonicalize
public java.util.Locale toLocale()
Locale
.
public static ULocale getDefault()
public static void setDefault(ULocale newLocale)
newLocale
- the new default locale
java.lang.SecurityException
- if a security manager exists and its
checkPermission
method doesn't allow the operation.
java.lang.NullPointerException
- if newLocale
is nullSecurityManager.checkPermission(java.security.Permission)
,
PropertyPermission
public java.lang.Object clone()
public int hashCode()
public boolean equals(java.lang.Object obj)
public static ULocale[] getAvailableLocales()
public static java.lang.String[] getISOCountries()
public static java.lang.String[] getISOLanguages()
public java.lang.String getLanguage()
getDisplayLanguage()
public static java.lang.String getLanguage(java.lang.String localeID)
getDisplayLanguage()
public java.lang.String getScript()
getDisplayScript()
public static java.lang.String getScript(java.lang.String localeID)
getDisplayScript()
public java.lang.String getCountry()
getDisplayCountry()
public static java.lang.String getCountry(java.lang.String localeID)
localeID
- getDisplayCountry()
public java.lang.String getVariant()
getDisplayVariant()
public static java.lang.String getVariant(java.lang.String localeID)
getDisplayVariant()
public static java.lang.String getFallback(java.lang.String localeID)
public ULocale getFallback()
public java.lang.String getBaseName()
public static java.lang.String getBaseName(java.lang.String localeID)
localeID
- the locale ID as a string
public java.lang.String getName()
public static java.lang.String getName(java.lang.String localeID)
localeID
- the localeID as a string
public java.lang.String toString()
public java.util.Iterator getKeywords()
public static java.util.Iterator getKeywords(java.lang.String localeID)
public java.lang.String getKeywordValue(java.lang.String keywordName)
keywordName
- name of the keyword whose value is desired. Case insensitive.
public static java.lang.String getKeywordValue(java.lang.String localeID, java.lang.String keywordName)
keywordName
- name of the keyword whose value is desired. Case insensitive.
public static java.lang.String canonicalize(java.lang.String localeID)
localeID
- the locale id
public ULocale setKeywordValue(java.lang.String keyword, java.lang.String value)
keyword
- the keyword to add/remove, or null to remove all keywords.value
- the value to add/set, or null to remove this particular keyword.
public static java.lang.String setKeywordValue(java.lang.String localeID, java.lang.String keyword, java.lang.String value)
localeID
- the locale id to modifykeyword
- the keyword to add/remove, or null to remove all keywords.value
- the value to add/set, or null to remove this particular keyword.
public java.lang.String getISO3Language()
ftp://dkuug.dk/i18n/iso-639-2.txt
java.util.MissingResourceException
- Throws MissingResourceException if the
three-letter language abbreviation is not available for this locale.public static java.lang.String getISO3Language(java.lang.String localeID)
ftp://dkuug.dk/i18n/iso-639-2.txt
java.util.MissingResourceException
- Throws MissingResourceException if the
three-letter language abbreviation is not available for this locale.public java.lang.String getISO3Country()
java.util.MissingResourceException
- Throws MissingResourceException if the
three-letter country abbreviation is not available for this locale.public static java.lang.String getISO3Country(java.lang.String localeID)
java.util.MissingResourceException
- Throws MissingResourceException if the
three-letter country abbreviation is not available for this locale.public java.lang.String getDisplayLanguage()
public java.lang.String getDisplayLanguage(ULocale displayLocale)
displayLocale
- the locale in which to display the name.
public static java.lang.String getDisplayLanguage(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the id of the locale whose language will be displayeddisplayLocaleID
- the id of the locale in which to display the name.
public static java.lang.String getDisplayLanguage(java.lang.String localeID, ULocale displayLocale)
localeID
- the id of the locale whose language will be displayed.displayLocale
- the locale in which to display the name.
public java.lang.String getDisplayScript()
public java.lang.String getDisplayScript(ULocale displayLocale)
displayLocale
- the locale in which to display the name.
public static java.lang.String getDisplayScript(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the id of the locale whose script will be displayeddisplayLocaleID
- the id of the locale in which to display the name.
public static java.lang.String getDisplayScript(java.lang.String localeID, ULocale displayLocale)
localeID
- the id of the locale whose script will be displayed.displayLocale
- the locale in which to display the name.
public java.lang.String getDisplayCountry()
public java.lang.String getDisplayCountry(ULocale displayLocale)
displayLocale
- the locale in which to display the name.
public static java.lang.String getDisplayCountry(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the id of the locale whose country will be displayeddisplayLocaleID
- the id of the locale in which to display the name.
public static java.lang.String getDisplayCountry(java.lang.String localeID, ULocale displayLocale)
localeID
- the id of the locale whose country will be displayed.displayLocale
- the locale in which to display the name.
public java.lang.String getDisplayVariant()
public java.lang.String getDisplayVariant(ULocale displayLocale)
displayLocale
- the locale in which to display the name.
public static java.lang.String getDisplayVariant(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the id of the locale whose variant will be displayeddisplayLocaleID
- the id of the locale in which to display the name.
public static java.lang.String getDisplayVariant(java.lang.String localeID, ULocale displayLocale)
localeID
- the id of the locale whose variant will be displayed.displayLocale
- the locale in which to display the name.
public static java.lang.String getDisplayKeyword(java.lang.String keyword)
keyword
- the keyword to be displayed.
getKeywords()
public static java.lang.String getDisplayKeyword(java.lang.String keyword, java.lang.String displayLocaleID)
keyword
- the keyword to be displayed.displayLocaleID
- the id of the locale in which to display the keyword.
getKeywords()
public static java.lang.String getDisplayKeyword(java.lang.String keyword, ULocale displayLocale)
keyword
- the keyword to be displayed.displayLocale
- the locale in which to display the keyword.
getKeywords()
public java.lang.String getDisplayKeywordValue(java.lang.String keyword)
keyword
- the keyword whose value is to be displayed.
public java.lang.String getDisplayKeywordValue(java.lang.String keyword, ULocale displayLocale)
keyword
- the keyword whose value is to be displayed.displayLocale
- the locale in which to display the value.
public static java.lang.String getDisplayKeywordValue(java.lang.String localeID, java.lang.String keyword, java.lang.String displayLocaleID)
localeID
- the id of the locale whose keyword value is to be displayed.keyword
- the keyword whose value is to be displayed.displayLocaleID
- the id of the locale in which to display the value.
public static java.lang.String getDisplayKeywordValue(java.lang.String localeID, java.lang.String keyword, ULocale displayLocale)
localeID
- the id of the locale whose keyword value is to be displayed.keyword
- the keyword whose value is to be displayed.displayLocale
- the id of the locale in which to display the value.
public java.lang.String getDisplayName()
public java.lang.String getDisplayName(ULocale displayLocale)
displayLocale
- the locale in which to display the locale name.
public static java.lang.String getDisplayName(java.lang.String localeID, java.lang.String displayLocaleID)
localeID
- the locale whose name is to be displayed.displayLocaleID
- the id of the locale in which to display the locale name.
public static java.lang.String getDisplayName(java.lang.String localeID, ULocale displayLocale)
localeID
- the locale whose name is to be displayed.displayLocale
- the locale in which to display the locale name.
public static ULocale acceptLanguage(java.lang.String acceptLanguageList, ULocale[] availableLocales, boolean[] fallback)
acceptLanguageList
- list in HTTP "Accept-Language:" format of acceptable localesavailableLocales
- list of available locales. One of these will be returned.fallback
- if non-null, a 1-element array containing a boolean to be set with the fallback status
public static ULocale acceptLanguage(ULocale[] acceptLanguageList, ULocale[] availableLocales, boolean[] fallback)
acceptLanguageList
- list of acceptable localesavailableLocales
- list of available locales. One of these will be returned.fallback
- if non-null, a 1-element array containing a boolean to be set with the fallback status
public static ULocale acceptLanguage(java.lang.String acceptLanguageList, boolean[] fallback)
acceptLanguageList
- list in HTTP "Accept-Language:" format of acceptable localesfallback
- if non-null, a 1-element array containing a boolean to be set with the fallback status
public static ULocale acceptLanguage(ULocale[] acceptLanguageList, boolean[] fallback)
acceptLanguageList
- ordered array of acceptable locales (preferred are listed first)fallback
- if non-null, a 1-element array containing a boolean to be set with the fallback status
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |