com.ibm.icu.util
public class GlobalizationPreferences extends Object implements Freezable
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: ICU 3.6 This API might change or be removed in a future release.
Field Summary | |
---|---|
static int | BI_CHARACTER
Break iterator types |
static int | BI_LINE
Break iterator types |
static int | BI_SENTENCE
Break iterator types |
static int | BI_TITLE
Break iterator types |
static int | BI_WORD
Break iterator types |
static int | DF_FULL
Date Format types |
static int | DF_LONG
Date Format types |
static int | DF_MEDIUM
Date Format types |
static int | DF_NONE
Date Format types |
static int | DF_SHORT
Date Format types |
static int | ID_CURRENCY
For selecting a choice of display names |
static int | ID_CURRENCY_SYMBOL
For selecting a choice of display names |
static int | ID_KEYWORD
For selecting a choice of display names |
static int | ID_KEYWORD_VALUE
For selecting a choice of display names |
static int | ID_LANGUAGE
For selecting a choice of display names |
static int | ID_LOCALE
For selecting a choice of display names |
static int | ID_SCRIPT
For selecting a choice of display names |
static int | ID_TERRITORY
For selecting a choice of display names |
static int | ID_TIMEZONE
For selecting a choice of display names |
static int | ID_VARIANT
For selecting a choice of display names |
static int | NF_CURRENCY
Number Format types |
static int | NF_INTEGER
Number Format types |
static int | NF_NUMBER
Number Format types |
static int | NF_PERCENT
Number Format types |
static int | NF_SCIENTIFIC
Number Format types |
Constructor Summary | |
---|---|
GlobalizationPreferences()
Default constructor |
Method Summary | |
---|---|
Object | cloneAsThawed() |
Object | freeze() |
BreakIterator | getBreakIterator(int type)
Get a copy of the break iterator for the specified type according to the
settings.
|
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. |
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. |
ResourceBundle | getResourceBundle(String baseName)
Convenience function to get a ResourceBundle instance using
the specified base name based on the language/locale priority list
stored in this object.
|
ResourceBundle | getResourceBundle(String baseName, ClassLoader loader)
Convenience function to get a ResourceBundle instance using
the specified base name and class loader based on the language/locale
priority list stored in this object.
|
String | getTerritory()
Gets the territory setting. |
TimeZone | getTimeZone()
Get the timezone. |
protected BreakIterator | guessBreakIterator(int type)
This function can be overridden by subclasses to use different heuristics.
|
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 DateFormat | guessDateFormat(int dateStyle, int timeStyle)
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 NumberFormat | guessNumberFormat(int style)
This function can be overridden by subclasses to use different heuristics.
|
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() |
protected List | processLocales(List inputLocales)
Process a language/locale priority list specified via setLocales .
|
GlobalizationPreferences | reset()
Restore the object to the initial state.
|
GlobalizationPreferences | setBreakIterator(int type, BreakIterator iterator)
Explicitly set the break iterator for this object.
|
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 | setLocale(ULocale uLocale)
Convenience routine for setting the language/locale priority
list from a single locale/language.
|
GlobalizationPreferences | setLocales(List inputLocales)
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, NumberFormat format)
Sets a number format explicitly. |
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
Break iterator typesUNKNOWN: ICU 3.6
Deprecated: This API is ICU internal only
Break iterator typesUNKNOWN: ICU 3.6
Deprecated: This API is ICU internal only
Break iterator typesUNKNOWN: ICU 3.6
Deprecated: This API is ICU internal only
Break iterator typesUNKNOWN: ICU 3.6
Deprecated: This API is ICU internal only
Break iterator typesUNKNOWN: ICU 3.6
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: type break type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE
Returns: break iterator explicit or implicit
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: calendar explicit or implicit.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: collator explicit or implicit.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: currency code, explicit or implicit.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: dateStyle DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE timeStyle DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE
Returns: a DateFormat, according to the above description
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: id language code, script code, ... type specifies the type of the ID: ID_LANGUAGE, etc.
Returns: the display name
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: index The index (0..n) of the desired item.
Returns: desired item. null if index is out of range
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: a copy of the language/locale priority list.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: style NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: baseName the base name of the resource bundle, a fully qualified class name
Returns: a resource bundle for the given base name and locale based on the language/locale priority list stored in this object
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: baseName the base name of the resource bundle, a fully qualified class name loader the class object from which to load the resource bundle
Returns: a resource bundle for the given base name and locale based on the language/locale priority list stored in this object
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: territory code, explicit or implicit.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: timezone, either implicitly or explicitly set
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: type
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: dateStyle timeStyle
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: style
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
setLocales
.
The input locale list may be expanded or re-ordered to represent the prioritized
language/locale order actually used by this object by the algorithm exaplained
below.
getResourceBundle
for this object. A subclass may override this method
to customize the algorithm used for populating the locale list.
Parameters: inputLocales The list of input locales
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: type break type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE iterator a break iterator
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: calendar arbitrary calendar
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: collator
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: currency Valid ISO 4217 currency code.
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: dateStyle DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE timeStyle DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE format The date format
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: uLocale single locale
Returns: this, for chaining
See Also: GlobalizationPreferences
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: inputLocales list of locales in priority order, eg {"be", "fr"} for Breton first, then French if that fails.
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: uLocales list of locales in an array
Returns: this, for chaining
See Also: GlobalizationPreferences
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
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: ICU 3.6 This API might change or be removed in a future release.
Parameters: style NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER format The number format
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: territory code
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.
Parameters: timezone a valid TZID (see UTS#35).
Returns: this, for chaining
UNKNOWN: ICU 3.6 This API might change or be removed in a future release.