Class ULocale
- java.lang.Object
-
- com.adobe.agl.util.ULocale
-
- All Implemented Interfaces:
java.io.Serializable
public final class ULocale extends java.lang.Object implements java.io.Serializable
A class analogous toLocale
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:
- language, script, country, variant, and keywords are properly cased
(lower, title, upper, upper, and lower case respectively) - hyphens used as separators are converted to underscores
- three-letter language and country ids are converted to two-letter equivalents where available
- surrounding spaces are removed from keywords and values
- if there are multiple keywords, they are put in sorted order
- POSIX ids are converted to ICU format IDs
- 'grandfathered' 3066 ids are converted to ICU standard form
- 'PREEURO' and 'EURO' variants are converted to currency keyword form, with the currency id appropriate to the country of the locale (for PREEURO) or EUR (for EURO).
canonicalize
can be called to convert the id to canonical form, or thecanonicalInstance
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, includingcom.adobe.agl.util.Calendar
,Currency
,UFormat
,BreakIterator
,Collator
,com.adobe.agl.text.DateFormatSymbols
, andDecimalFormatSymbols
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.
- See Also:
Locale
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ULocale(java.lang.String localeID)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Equals based on locale.static ULocale
forLocale(java.util.Locale loc)
Return a ULocale object for aLocale
.java.lang.String
getCountry()
static ULocale
getDefault()
ULocale
getFallback()
java.lang.String
getLanguage()
java.lang.String
getScript()
int
hashCode()
Return hashcode based on localejava.util.Locale
toLocale()
-
-
-
Field Detail
-
ROOT
public static final ULocale ROOT
The root ULocale.
-
-
Method Detail
-
forLocale
public static ULocale forLocale(java.util.Locale loc)
Return a ULocale object for aLocale
. The ULocale is canonicalized.- Parameters:
loc
- a JDK locale
-
getLanguage
public java.lang.String getLanguage()
-
getCountry
public java.lang.String getCountry()
-
getScript
public java.lang.String getScript()
-
getDefault
public static ULocale getDefault()
-
toLocale
public java.util.Locale toLocale()
-
getFallback
public ULocale getFallback()
-
hashCode
public int hashCode()
Return hashcode based on locale- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Equals based on locale.- Overrides:
equals
in classjava.lang.Object
-
-