|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.icu.util.GlobalizationPreferences
This convenience class provides a mechanism for bundling together different globalization preferences. It includes:
To reset any explicit field so that it will get heuristic values, pass in null. For example, myPreferences.setLocale(null);
All of the heuristics can be customized by subclasses, by overriding getTerritory(), guessCollator(), etc.
The class also supplies display names for languages, scripts, territories, currencies, timezones, etc. These are computed according to the locale/language preference list. Thus, if the preference is Breton; French; English, then the display name for a language will be returned in Breton if available, otherwise in French if available, otherwise in English.
The codes used to reference territory, currency, etc. are as defined elsewhere in ICU, and are taken from CLDR (which reflects RFC 3066bis usage, ISO 4217, and the TZ Timezone database identifiers).
This is at a prototype stage, and has not incorporated all the design changes that we would like yet; further feedback is welcome.
TODO:
Field Summary | |
static int |
CURRENCY
Deprecated. This API is ICU internal only. |
static int |
CURRENCY_SYMBOLID
Deprecated. This API is ICU internal only. |
static int |
CURRENCYID
Deprecated. This API is ICU internal only. |
static int |
DISPLAYID_LIMIT
Deprecated. This API is ICU internal only. |
static int |
INTEGER
Deprecated. This API is ICU internal only. |
static int |
KEYWORD_VALUEID
Deprecated. This API is ICU internal only. |
static int |
KEYWORDID
Deprecated. This API is ICU internal only. |
static int |
LANGUAGEID
Deprecated. This API is ICU internal only. |
static int |
LOCALEID
Deprecated. This API is ICU internal only. |
static int |
NONE
Deprecated. This API is ICU internal only. |
static int |
NUMBER
Deprecated. This API is ICU internal only. |
static int |
NUMBER_LIMIT
Deprecated. This API is ICU internal only. |
static int |
PERCENT
Deprecated. This API is ICU internal only. |
static int |
SCIENTIFIC
Deprecated. This API is ICU internal only. |
static int |
SCRIPTID
Deprecated. This API is ICU internal only. |
static int |
TERRITORYID
Deprecated. This API is ICU internal only. |
static int |
TIMEZONEID
Deprecated. This API is ICU internal only. |
static int |
VARIANTID
Deprecated. This API is ICU internal only. |
Constructor Summary | |
GlobalizationPreferences()
Deprecated. |
Method Summary | |
java.lang.Object |
cloneAsThawed()
Deprecated. Provides for the clone operation. |
java.lang.Object |
freeze()
Deprecated. Locks the object. |
Calendar |
getCalendar()
Deprecated. This API is ICU internal only. |
Collator |
getCollator()
Deprecated. This API is ICU internal only. |
Currency |
getCurrency()
Deprecated. This API is ICU internal only. |
DateFormat |
getDateFormat(int dateStyle,
int timeStyle)
Deprecated. This API is ICU internal only. |
ULocale |
getDateLocale()
Deprecated. This API is ICU internal only. |
java.lang.String |
getDisplayName(java.lang.String id,
int type)
Deprecated. This API is ICU internal only. |
ULocale |
getLocale(int index)
Deprecated. This API is ICU internal only. |
java.util.List |
getLocales()
Deprecated. This API is ICU internal only. |
NumberFormat |
getNumberFormat(int style)
Deprecated. This API is ICU internal only. |
ULocale |
getNumberLocale()
Deprecated. This API is ICU internal only. |
java.lang.String |
getTerritory()
Deprecated. This API is ICU internal only. |
TimeZone |
getTimeZone()
Deprecated. This API is ICU internal only. |
protected Calendar |
guessCalendar()
Deprecated. This API is ICU internal only. |
protected Collator |
guessCollator()
Deprecated. This API is ICU internal only. |
protected Currency |
guessCurrency()
Deprecated. This API is ICU internal only. |
protected java.util.List |
guessLocales()
Deprecated. This API is ICU internal only. |
protected java.lang.String |
guessTerritory()
Deprecated. This API is ICU internal only. |
protected TimeZone |
guessTimeZone()
Deprecated. This API is ICU internal only. |
boolean |
isFrozen()
Deprecated. Determines whether the object has been locked or not. |
GlobalizationPreferences |
reset()
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setCalendar(Calendar calendar)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setCollator(Collator collator)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setCurrency(Currency currency)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setDateFormat(int dateStyle,
int timeStyle,
DateFormat format)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setDateFormat(int dateStyle,
int timeStyle,
java.lang.String formatPattern)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setDateLocale(ULocale dateLocale)
Deprecated. Set the date locale. |
GlobalizationPreferences |
setLocale(ULocale uLocale)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setLocales(java.util.List locales)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setLocales(java.lang.String acceptLanguageString)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setLocales(ULocale[] uLocales)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setNumberFormat(int style,
DateFormat format)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setNumberFormat(int style,
java.lang.String formatPattern)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setNumberLocale(ULocale numberLocale)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setTerritory(java.lang.String territory)
Deprecated. This API is ICU internal only. |
GlobalizationPreferences |
setTimeZone(TimeZone timezone)
Deprecated. This API is ICU internal only. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int CURRENCY
public static final int NUMBER
public static final int INTEGER
public static final int SCIENTIFIC
public static final int PERCENT
public static final int NUMBER_LIMIT
public static final int NONE
public static final int LOCALEID
public static final int LANGUAGEID
public static final int SCRIPTID
public static final int TERRITORYID
public static final int VARIANTID
public static final int KEYWORDID
public static final int KEYWORD_VALUEID
public static final int CURRENCYID
public static final int CURRENCY_SYMBOLID
public static final int TIMEZONEID
public static final int DISPLAYID_LIMIT
Constructor Detail |
public GlobalizationPreferences()
Method Detail |
public GlobalizationPreferences setLocales(java.util.List locales)
locales
- list of locales in priority order, eg {"be", "fr"}
for Breton first, then French if that fails.
public java.util.List getLocales()
public ULocale getLocale(int index)
index
- The index (0..n) of the desired item.
public GlobalizationPreferences setLocales(ULocale[] uLocales)
uLocales
- list of locales in an array
setLocales(List locales)
public GlobalizationPreferences setLocale(ULocale uLocale)
uLocale
- single locale
setLocales(List locales)
public GlobalizationPreferences setLocales(java.lang.String acceptLanguageString)
acceptLanguageString
- Accept-Language list, as defined by
Section 14.4 of the RFC 2616 (HTTP 1.1)
setLocales(List locales)
public GlobalizationPreferences setTerritory(java.lang.String territory)
territory
- code
public java.lang.String getTerritory()
public GlobalizationPreferences setCurrency(Currency currency)
currency
- Valid ISO 4217 currency code.
public Currency getCurrency()
public GlobalizationPreferences setCalendar(Calendar calendar)
calendar
- arbitrary calendar
public Calendar getCalendar()
public GlobalizationPreferences setTimeZone(TimeZone timezone)
timezone
- a valid TZID (see UTS#35).
public TimeZone getTimeZone()
public Collator getCollator()
public GlobalizationPreferences setCollator(Collator collator)
collator
-
public GlobalizationPreferences setDateLocale(ULocale dateLocale)
dateLocale
- If not null, overrides the locale priority list for all the date formats.
public ULocale getDateLocale()
public GlobalizationPreferences setNumberLocale(ULocale numberLocale)
numberLocale
- If not null, overrides the locale priority list for all the date formats.
public ULocale getNumberLocale()
public java.lang.String getDisplayName(java.lang.String id, int type)
id
- language code, script code, ...type
- specifies the type of the ID: LANGUAGE, etc.
public GlobalizationPreferences setDateFormat(int dateStyle, int timeStyle, DateFormat format)
dateStyle
- NONE, or DateFormat.FULL, LONG, MEDIUM, SHORTtimeStyle
- NONE, or DateFormat.FULL, LONG, MEDIUM, SHORTformat
-
public GlobalizationPreferences setDateFormat(int dateStyle, int timeStyle, java.lang.String formatPattern)
dateStyle
- NONE, or DateFormat.FULL, LONG, MEDIUM, SHORTtimeStyle
- NONE, or DateFormat.FULL, LONG, MEDIUM, SHORTformatPattern
- date pattern, eg "yyyy-MMM-dd"
public DateFormat getDateFormat(int dateStyle, int timeStyle)
dateStyle
- NONE, or DateFormat.FULL, LONG, MEDIUM, SHORTtimeStyle
- NONE, or DateFormat.FULL, LONG, MEDIUM, SHORT
public NumberFormat getNumberFormat(int style)
style
- CURRENCY, NUMBER, INTEGER, SCIENTIFIC, PERCENTpublic GlobalizationPreferences setNumberFormat(int style, DateFormat format)
style
- CURRENCY, NUMBER, INTEGER, SCIENTIFIC, PERCENT
public GlobalizationPreferences setNumberFormat(int style, java.lang.String formatPattern)
public GlobalizationPreferences reset()
protected java.lang.String guessTerritory()
protected Currency guessCurrency()
protected java.util.List guessLocales()
protected Collator guessCollator()
protected TimeZone guessTimeZone()
protected Calendar guessCalendar()
public boolean isFrozen()
Freezable
isFrozen
in interface Freezable
public java.lang.Object freeze()
Freezable
freeze
in interface Freezable
public java.lang.Object cloneAsThawed()
Freezable
cloneAsThawed
in interface Freezable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |