com.ibm.icu.util
public class GlobalizationPreferences extends Object implements Freezable
Deprecated: This API is ICU internal only.
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:
UNKNOWN:
Field Summary | |
---|---|
static int | CURRENCY
Number Format types |
static int | CURRENCYID
For selecting a choice of display names |
static int | CURRENCY_SYMBOLID
For selecting a choice of display names |
static int | DISPLAYID_LIMIT
For selecting a choice of display names |
static int | INTEGER
Number Format types |
static int | KEYWORDID
For selecting a choice of display names |
static int | KEYWORD_VALUEID
For selecting a choice of display names |
static int | LANGUAGEID
For selecting a choice of display names |
static int | LOCALEID
For selecting a choice of display names |
static int | NONE
Supplement to DateFormat.FULL, LONG, MEDIUM, SHORT. |
static int | NUMBER
Number Format types |
static int | NUMBER_LIMIT
Number Format types |
static int | PERCENT
Number Format types |
static int | SCIENTIFIC
Number Format types |
static int | SCRIPTID
For selecting a choice of display names |
static int | TERRITORYID
For selecting a choice of display names |
static int | TIMEZONEID
For selecting a choice of display names |
static int | VARIANTID
For selecting a choice of display names |
Method Summary | |
---|---|
Object | cloneAsThawed() |
Object | freeze() |
Calendar | getCalendar()
Get a copy of the calendar according to the settings. |
Collator | getCollator()
Get a copy of the collator according to the settings. |
Currency | getCurrency()
Get a copy of the currency computed according to the settings. |
DateFormat | getDateFormat(int dateStyle, int timeStyle)
Gets a date format according to the current settings. |
ULocale | getDateLocale()
Gets the date locale, to be used in computing date formats. |
String | getDisplayName(String id, int type)
Get the display name for an ID: language, script, territory, currency, timezone...
|
ULocale | getLocale(int index)
Convenience function for getting the locales in priority order |
List | getLocales()
Get a copy of the language/locale priority list |
NumberFormat | getNumberFormat(int style)
Gets a number format according to the current settings. |
ULocale | getNumberLocale()
Get the current number locale setting used for getNumberFormat. |
String | getTerritory()
Gets the territory setting. |
TimeZone | getTimeZone()
Get the timezone. |
protected Calendar | guessCalendar()
This function can be overridden by subclasses to use different heuristics.
|
protected Collator | guessCollator()
This function can be overridden by subclasses to use different heuristics.
|
protected Currency | guessCurrency()
This function can be overridden by subclasses to use different heuristics |
protected List | guessLocales()
This function can be overridden by subclasses to use different heuristics
It MUST return a 'safe' value,
one whose modification will not affect this object. |
protected String | guessTerritory()
This function can be overridden by subclasses to use different heuristics. |
protected TimeZone | guessTimeZone()
This function can be overridden by subclasses to use different heuristics.
|
boolean | isFrozen() |
GlobalizationPreferences | reset()
Restore the object to the initial state. |
GlobalizationPreferences | setCalendar(Calendar calendar)
Sets the calendar. |
GlobalizationPreferences | setCollator(Collator collator)
Explicitly set the collator for this object. |
GlobalizationPreferences | setCurrency(Currency currency)
Sets the currency code. |
GlobalizationPreferences | setDateFormat(int dateStyle, int timeStyle, DateFormat format)
Set an explicit date format. |
GlobalizationPreferences | setDateFormat(int dateStyle, int timeStyle, String formatPattern)
Set an explicit date format. |
GlobalizationPreferences | setDateLocale(ULocale dateLocale)
Set the date locale. |
GlobalizationPreferences | setLocale(ULocale uLocale)
Convenience routine for setting the language/locale priority
list from a single locale/language. |
GlobalizationPreferences | setLocales(List locales)
Sets the language/locale priority list. |
GlobalizationPreferences | setLocales(ULocale[] uLocales)
Convenience routine for setting the language/locale priority
list from an array. |
GlobalizationPreferences | setLocales(String acceptLanguageString)
Convenience routine for setting the locale priority list from
an Accept-Language string. |
GlobalizationPreferences | setNumberFormat(int style, DateFormat format)
Sets a number format explicitly. |
GlobalizationPreferences | setNumberFormat(int style, String formatPattern)
Sets a number format explicitly. |
GlobalizationPreferences | setNumberLocale(ULocale numberLocale)
Set the number locale. |
GlobalizationPreferences | setTerritory(String territory)
Sets the territory, which is a valid territory according to for
RFC 3066 (or successor). |
GlobalizationPreferences | setTimeZone(TimeZone timezone)
Sets the timezone ID. |
Deprecated: This API is ICU internal only.
Number Format typesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
Number Format typesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
Supplement to DateFormat.FULL, LONG, MEDIUM, SHORT. Indicates that no value for one of date or time is to be used.UNKNOWN:
Deprecated: This API is ICU internal only.
Number Format typesUNKNOWN:
Deprecated: This API is ICU internal only.
Number Format typesUNKNOWN:
Deprecated: This API is ICU internal only.
Number Format typesUNKNOWN:
Deprecated: This API is ICU internal only.
Number Format typesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
For selecting a choice of display namesUNKNOWN:
Deprecated: This API is ICU internal only.
UNKNOWN:
Deprecated: This API is ICU internal only.
UNKNOWN:
Deprecated: This API is ICU internal only.
Get a copy of the calendar according to the settings.Returns: calendar explicit or implicit.
UNKNOWN:
Deprecated: This API is ICU internal only.
Get a copy of the collator according to the settings.Returns: collator explicit or implicit.
UNKNOWN:
Deprecated: This API is ICU internal only.
Get a copy of the currency computed according to the settings.Returns: currency code, explicit or implicit.
UNKNOWN:
Deprecated: This API is ICU internal only.
Gets a date format according to the current settings. If there is an explicit (non-null) date/time format set, a copy of that is returned. Otherwise, if there is a non-null date locale, that is used. Otherwise, the language priority list is used. NONE should be used for the style, where only the date or time format individually is being gotten.Parameters: dateStyle NONE, or DateFormat.FULL, LONG, MEDIUM, SHORT timeStyle NONE, or DateFormat.FULL, LONG, MEDIUM, SHORT
Returns: a DateFormat, according to the above description
UNKNOWN:
Deprecated: This API is ICU internal only.
Gets the date locale, to be used in computing date formats. Overrides the general locale setting.Returns: date locale. Null if none was set explicitly.
UNKNOWN:
Deprecated: This API is ICU internal only.
Get the display name for an ID: language, script, territory, currency, timezone... Uses the language priority list to do so.Parameters: id language code, script code, ... type specifies the type of the ID: LANGUAGE, etc.
Returns: the display name
UNKNOWN:
Deprecated: This API is ICU internal only.
Convenience function for getting the locales in priority orderParameters: index The index (0..n) of the desired item.
Returns: desired item.
UNKNOWN:
Deprecated: This API is ICU internal only.
Get a copy of the language/locale priority listReturns: a copy of the language/locale priority list.
UNKNOWN:
Deprecated: This API is ICU internal only.
Gets a number format according to the current settings. If there is an explicit (non-null) number format set, a copy of that is returned. Otherwise, if there is a non-null number locale, that is used. Otherwise, the language priority list is used. NONE should be used for the style, where only the date or time format individually is being gotten.Parameters: style CURRENCY, NUMBER, INTEGER, SCIENTIFIC, PERCENT
UNKNOWN:
Deprecated: This API is ICU internal only.
Get the current number locale setting used for getNumberFormat.Returns: number locale. Null if none was set explicitly.
UNKNOWN:
Deprecated: This API is ICU internal only.
Gets the territory setting. If it wasn't explicitly set, it is computed from the general locale setting.Returns: territory code, explicit or implicit.
UNKNOWN:
Deprecated: This API is ICU internal only.
Get the timezone. It was either explicitly set, or is heuristically computed from other settings.Returns: timezone, either implicitly or explicitly set
UNKNOWN:
Deprecated: This API is ICU internal only.
This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.UNKNOWN:
Deprecated: This API is ICU internal only.
This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.UNKNOWN:
Deprecated: This API is ICU internal only.
This function can be overridden by subclasses to use different heuristicsUNKNOWN:
Deprecated: This API is ICU internal only.
This function can be overridden by subclasses to use different heuristics It MUST return a 'safe' value, one whose modification will not affect this object.UNKNOWN:
Deprecated: This API is ICU internal only.
This function can be overridden by subclasses to use different heuristics.UNKNOWN:
Deprecated: This API is ICU internal only.
This function can be overridden by subclasses to use different heuristics. It MUST return a 'safe' value, one whose modification will not affect this object.UNKNOWN:
Deprecated: This API is ICU internal only.
UNKNOWN:
Deprecated: This API is ICU internal only.
Restore the object to the initial state.Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Sets the calendar. If this has not been set, uses default for territory.Parameters: calendar arbitrary calendar
Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Explicitly set the collator for this object.Parameters: collator
Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Sets the currency code. If this has not been set, uses default for territory.Parameters: currency Valid ISO 4217 currency code.
Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Set an explicit date format. Overrides both the date locale, and the locale priority list for a particular combination of dateStyle and timeStyle. NONE should be used if for the style, where only the date or time format individually is being set.Parameters: dateStyle NONE, or DateFormat.FULL, LONG, MEDIUM, SHORT timeStyle NONE, or DateFormat.FULL, LONG, MEDIUM, SHORT format
Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Set an explicit date format. Overrides both the date locale, and the locale priority list for a particular combination of dateStyle and timeStyle. NONE should be used if for the style, where only the date or time format individually is being set.Parameters: dateStyle NONE, or DateFormat.FULL, LONG, MEDIUM, SHORT timeStyle NONE, or DateFormat.FULL, LONG, MEDIUM, SHORT formatPattern date pattern, eg "yyyy-MMM-dd"
Returns: this, for chaining
UNKNOWN:
Parameters: dateLocale If not null, overrides the locale priority list for all the date formats.
Returns: this, for chaining
Deprecated: This API is ICU internal only.
Convenience routine for setting the language/locale priority list from a single locale/language.Parameters: uLocale single locale
Returns: this, for chaining
See Also: GlobalizationPreferences
UNKNOWN:
Deprecated: This API is ICU internal only.
Sets the language/locale priority list. If other information is not (yet) available, this is used to to produce a default value for the appropriate territory, currency, timezone, etc. The user should be given the opportunity to correct those defaults in case they are incorrect.Parameters: locales list of locales in priority order, eg {"be", "fr"} for Breton first, then French if that fails.
Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Convenience routine for setting the language/locale priority list from an array.Parameters: uLocales list of locales in an array
Returns: this, for chaining
See Also: GlobalizationPreferences
UNKNOWN:
Deprecated: This API is ICU internal only.
Convenience routine for setting the locale priority list from an Accept-Language string.Parameters: acceptLanguageString Accept-Language list, as defined by Section 14.4 of the RFC 2616 (HTTP 1.1)
Returns: this, for chaining
See Also: GlobalizationPreferences
UNKNOWN:
Deprecated: This API is ICU internal only.
Sets a number format explicitly. Overrides the number locale and the general locale settings.Parameters: style CURRENCY, NUMBER, INTEGER, SCIENTIFIC, PERCENT
Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Sets a number format explicitly. Overrides the number locale and the general locale settings.Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Set the number locale.Parameters: numberLocale If not null, overrides the locale priority list for all the date formats.
Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Sets the territory, which is a valid territory according to for RFC 3066 (or successor). If not otherwise set, default currency and timezone values will be set from this. The user should be given the opportunity to correct those defaults in case they are incorrect.Parameters: territory code
Returns: this, for chaining
UNKNOWN:
Deprecated: This API is ICU internal only.
Sets the timezone ID. If this has not been set, uses default for territory.Parameters: timezone a valid TZID (see UTS#35).
Returns: this, for chaining
UNKNOWN: