com.ibm.icu.util
Class GlobalizationPreferences

java.lang.Object
  extended bycom.ibm.icu.util.GlobalizationPreferences
All Implemented Interfaces:
java.lang.Cloneable, Freezable

Deprecated. This API is ICU internal only.

public class GlobalizationPreferences
extends java.lang.Object
implements Freezable

This convenience class provides a mechanism for bundling together different globalization preferences. It includes:

The class will heuristically compute implicit, heuristic values for the above based on available data if explicit values are not supplied. These implicit values can be presented to users for confirmation, or replacement if the values are incorrect.

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:

Note:

Status:
Internal. This API is ICU internal only.

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

CURRENCY

public static final int CURRENCY
Deprecated. This API is ICU internal only.

Number Format types

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

NUMBER

public static final int NUMBER
Deprecated. This API is ICU internal only.

Number Format types

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

INTEGER

public static final int INTEGER
Deprecated. This API is ICU internal only.

Number Format types

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

SCIENTIFIC

public static final int SCIENTIFIC
Deprecated. This API is ICU internal only.

Number Format types

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

PERCENT

public static final int PERCENT
Deprecated. This API is ICU internal only.

Number Format types

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

NUMBER_LIMIT

public static final int NUMBER_LIMIT
Deprecated. This API is ICU internal only.

Number Format types

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

NONE

public static final int NONE
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.

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

LOCALEID

public static final int LOCALEID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

LANGUAGEID

public static final int LANGUAGEID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

SCRIPTID

public static final int SCRIPTID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

TERRITORYID

public static final int TERRITORYID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

VARIANTID

public static final int VARIANTID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

KEYWORDID

public static final int KEYWORDID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

KEYWORD_VALUEID

public static final int KEYWORD_VALUEID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

CURRENCYID

public static final int CURRENCYID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

CURRENCY_SYMBOLID

public static final int CURRENCY_SYMBOLID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

TIMEZONEID

public static final int TIMEZONEID
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.

DISPLAYID_LIMIT

public static final int DISPLAYID_LIMIT
Deprecated. This API is ICU internal only.

For selecting a choice of display names

See Also:
Constant Field Values
Status:
Internal. This API is ICU internal only.
Constructor Detail

GlobalizationPreferences

public GlobalizationPreferences()
Deprecated. 
Method Detail

setLocales

public GlobalizationPreferences setLocales(java.util.List locales)
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
Status:
Internal. This API is ICU internal only.

getLocales

public java.util.List getLocales()
Deprecated. This API is ICU internal only.

Get a copy of the language/locale priority list

Returns:
a copy of the language/locale priority list.
Status:
Internal. This API is ICU internal only.

getLocale

public ULocale getLocale(int index)
Deprecated. This API is ICU internal only.

Convenience function for getting the locales in priority order

Parameters:
index - The index (0..n) of the desired item.
Returns:
desired item.
Status:
Internal. This API is ICU internal only.

setLocales

public GlobalizationPreferences setLocales(ULocale[] uLocales)
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:
setLocales(List locales)
Status:
Internal. This API is ICU internal only.

setLocale

public GlobalizationPreferences setLocale(ULocale uLocale)
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:
setLocales(List locales)
Status:
Internal. This API is ICU internal only.

setLocales

public GlobalizationPreferences setLocales(java.lang.String acceptLanguageString)
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:
setLocales(List locales)
Status:
Internal. This API is ICU internal only.

setTerritory

public GlobalizationPreferences setTerritory(java.lang.String territory)
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
Status:
Internal. This API is ICU internal only.

getTerritory

public java.lang.String getTerritory()
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.
Status:
Internal. This API is ICU internal only.

setCurrency

public GlobalizationPreferences setCurrency(Currency currency)
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
Status:
Internal. This API is ICU internal only.

getCurrency

public Currency getCurrency()
Deprecated. This API is ICU internal only.

Get a copy of the currency computed according to the settings.

Returns:
currency code, explicit or implicit.
Status:
Internal. This API is ICU internal only.

setCalendar

public GlobalizationPreferences setCalendar(Calendar calendar)
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
Status:
Internal. This API is ICU internal only.

getCalendar

public Calendar getCalendar()
Deprecated. This API is ICU internal only.

Get a copy of the calendar according to the settings.

Returns:
calendar explicit or implicit.
Status:
Internal. This API is ICU internal only.

setTimeZone

public GlobalizationPreferences setTimeZone(TimeZone timezone)
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
Status:
Internal. This API is ICU internal only.

getTimeZone

public TimeZone getTimeZone()
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
Status:
Internal. This API is ICU internal only.

getCollator

public Collator getCollator()
Deprecated. This API is ICU internal only.

Get a copy of the collator according to the settings.

Returns:
collator explicit or implicit.
Status:
Internal. This API is ICU internal only.

setCollator

public GlobalizationPreferences setCollator(Collator collator)
Deprecated. This API is ICU internal only.

Explicitly set the collator for this object.

Parameters:
collator -
Returns:
this, for chaining
Status:
Internal. This API is ICU internal only.

setDateLocale

public GlobalizationPreferences setDateLocale(ULocale dateLocale)
Deprecated. 
Set the date locale.

Parameters:
dateLocale - If not null, overrides the locale priority list for all the date formats.
Returns:
this, for chaining

getDateLocale

public ULocale getDateLocale()
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.
Status:
Internal. This API is ICU internal only.

setNumberLocale

public GlobalizationPreferences setNumberLocale(ULocale numberLocale)
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
Status:
Internal. This API is ICU internal only.

getNumberLocale

public ULocale getNumberLocale()
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.
Status:
Internal. This API is ICU internal only.

getDisplayName

public java.lang.String getDisplayName(java.lang.String id,
                                       int type)
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
Status:
Internal. This API is ICU internal only.

setDateFormat

public GlobalizationPreferences setDateFormat(int dateStyle,
                                              int timeStyle,
                                              DateFormat format)
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
Status:
Internal. This API is ICU internal only.

setDateFormat

public GlobalizationPreferences setDateFormat(int dateStyle,
                                              int timeStyle,
                                              java.lang.String formatPattern)
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
Status:
Internal. This API is ICU internal only.

getDateFormat

public DateFormat getDateFormat(int dateStyle,
                                int timeStyle)
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
Status:
Internal. This API is ICU internal only.

getNumberFormat

public NumberFormat getNumberFormat(int style)
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
Status:
Internal. This API is ICU internal only.

setNumberFormat

public GlobalizationPreferences setNumberFormat(int style,
                                                DateFormat format)
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
Status:
Internal. This API is ICU internal only.

setNumberFormat

public GlobalizationPreferences setNumberFormat(int style,
                                                java.lang.String formatPattern)
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
Status:
Internal. This API is ICU internal only.

reset

public GlobalizationPreferences reset()
Deprecated. This API is ICU internal only.

Restore the object to the initial state.

Returns:
this, for chaining
Status:
Internal. This API is ICU internal only.

guessTerritory

protected java.lang.String guessTerritory()
Deprecated. This API is ICU internal only.

This function can be overridden by subclasses to use different heuristics.

Status:
Internal. This API is ICU internal only.

guessCurrency

protected Currency guessCurrency()
Deprecated. This API is ICU internal only.

This function can be overridden by subclasses to use different heuristics

Status:
Internal. This API is ICU internal only.

guessLocales

protected java.util.List guessLocales()
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.

Status:
Internal. This API is ICU internal only.

guessCollator

protected Collator guessCollator()
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.

Status:
Internal. This API is ICU internal only.

guessTimeZone

protected TimeZone guessTimeZone()
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.

Status:
Internal. This API is ICU internal only.

guessCalendar

protected Calendar guessCalendar()
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.

Status:
Internal. This API is ICU internal only.

isFrozen

public boolean isFrozen()
Deprecated. This API is ICU internal only.

Description copied from interface: Freezable
Determines whether the object has been locked or not.

Specified by:
isFrozen in interface Freezable
Status:
Internal. This API is ICU internal only.

freeze

public java.lang.Object freeze()
Deprecated. This API is ICU internal only.

Description copied from interface: Freezable
Locks the object.

Specified by:
freeze in interface Freezable
Returns:
the object itself.
Status:
Internal. This API is ICU internal only.

cloneAsThawed

public java.lang.Object cloneAsThawed()
Deprecated. This API is ICU internal only.

Description copied from interface: Freezable
Provides for the clone operation. Any clone is initially unlocked.

Specified by:
cloneAsThawed in interface Freezable
Status:
Internal. This API is ICU internal only.


Copyright (c) 2006 IBM Corporation and others.