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.
Note:| Modifier and Type | Field and Description |
|---|---|
| private static final HashMap | |
| public static final int | BI_CHARACTER
Break iterator type |
| private static final int | |
| public static final int | BI_LINE
Break iterator type |
| public static final int | BI_SENTENCE
Break iterator type |
| public static final int | BI_TITLE
Break iterator type |
| public static final int | BI_WORD
Break iterator type |
| private BreakIterator[] | |
| private Calendar | |
| private Collator | |
| private Currency | |
| private DateFormat[][] | |
| public static final int | DF_FULL
Date Format type |
| private static final int | |
| public static final int | DF_LONG
Date Format type |
| public static final int | DF_MEDIUM
Date Format type |
| public static final int | DF_NONE
Date Format type |
| public static final int | DF_SHORT
Date Format type |
| private volatile boolean | |
| public static final int | ID_CURRENCY
For selecting a choice of display names |
| public static final int | ID_CURRENCY_SYMBOL
For selecting a choice of display names |
| public static final int | ID_KEYWORD
For selecting a choice of display names |
| public static final int | ID_KEYWORD_VALUE
For selecting a choice of display names |
| public static final int | ID_LANGUAGE
For selecting a choice of display names |
| public static final int | ID_LOCALE
For selecting a choice of display names |
| public static final int | ID_SCRIPT
For selecting a choice of display names |
| public static final int | ID_TERRITORY
For selecting a choice of display names |
| public static final int | ID_TIMEZONE
For selecting a choice of display names |
| public static final int | ID_VARIANT
For selecting a choice of display names |
| private List | |
| private static final String[][] | |
| private static final Map | language_territory_hack_map
Warning All of this data is temporary, until we start importing from CLDR!!! |
| private List | |
| public static final int | NF_CURRENCY
Number Format type |
| public static final int | NF_INTEGER
Number Format type |
| private static final int | |
| public static final int | NF_NUMBER
Number Format type |
| public static final int | NF_PERCENT
Number Format type |
| public static final int | NF_SCIENTIFIC
Number Format type |
| private NumberFormat[] | |
| private String | |
| pack-priv static final String[][] | |
| pack-priv static final Map | |
| private TimeZone | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public GlobalizationPreferences | cloneAsThawed()
Implements com. |
| public GlobalizationPreferences | |
| private ULocale | |
| public BreakIterator | Returns: break iterator explicit or implicitbreak type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE type)Get a copy of the break iterator for the specified type according to the settings. |
| public Calendar | Returns: calendar explicit or implicit.Get a copy of the calendar according to the settings. |
| public Collator | Returns: collator explicit or implicit.Get a copy of the collator according to the settings. |
| public Currency | Returns: currency code, explicit or implicit.Get a copy of the currency computed according to the settings. |
| public DateFormat | Returns: a DateFormat, according to the above descriptionDF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE dateStyle, int DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE timeStyle)Gets a date format according to the current settings. |
| public String | Returns: the display namelanguage code, script code, ... id, int specifies the type of the ID: ID_LANGUAGE, etc. type)Get the display name for an ID: language, script, territory, currency, timezone... |
| public ULocale | Returns: desired item. null if index is out of rangeThe index (0..n) of the desired item. index)Convenience function for getting the locales in priority order |
| public List | Returns: a copy of the language/locale priority list.Get a copy of the language/locale priority list |
| public NumberFormat | getNumberFormat(int
NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER style)Gets a number format according to the current settings. |
| public ResourceBundle | Returns: a resource bundle for the given base name and locale based on the language/locale priority list stored in this objectthe base name of the resource bundle, a fully qualified
class name baseName)Convenience function to get a ResourceBundle instance using the specified base name based on the language/locale priority list stored in this object. |
| public ResourceBundle | Returns: a resource bundle for the given base name and locale based on the language/locale priority list stored in this objectthe base name of the resource bundle, a fully qualified
class name baseName, ClassLoader the class object from which to load the resource bundle 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. |
| public String | |
| public TimeZone | |
| protected BreakIterator | guessBreakIterator(int type)
This function can be overridden by subclasses to use different heuristics. |
| protected Calendar | |
| protected Collator | |
| protected Currency | |
| 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 | |
| protected TimeZone | |
| private boolean | |
| public boolean | isFrozen()
Implements com. |
| protected List | processLocales(List<ULocale>
The list of input locales inputLocales)Process a language/locale priority list specified via |
| public GlobalizationPreferences | |
| public GlobalizationPreferences | Returns: this, for chainingbreak type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE type, BreakIterator a break iterator iterator)Explicitly set the break iterator for this object. |
| public GlobalizationPreferences | |
| public GlobalizationPreferences | Returns: this, for chainingThe collator object to be passed. collator)Explicitly set the collator for this object. |
| public GlobalizationPreferences | Returns: this, for chainingValid ISO 4217 currency code. currency)Sets the currency code. |
| public GlobalizationPreferences | Returns: this, for chainingDF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE dateStyle, int DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE timeStyle, DateFormat The date format format)Set an explicit date format. |
| public GlobalizationPreferences | |
| public GlobalizationPreferences | Returns: this, for chaininglist of locales in priority order, eg {"be", "fr"}
for Breton first, then French if that fails. inputLocales)Sets the language/locale priority list. |
| public GlobalizationPreferences | Returns: this, for chaininglist of locales in an array uLocales)Convenience routine for setting the language/locale priority list from an array. |
| public GlobalizationPreferences | Returns: this, for chainingAccept-Language list, as defined by
Section 14.4 of the RFC 2616 (HTTP 1.1) acceptLanguageString)Convenience routine for setting the locale priority list from an Accept-Language string. |
| public GlobalizationPreferences | Returns: this, for chainingNF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER style, NumberFormat The number format format)Sets a number format explicitly. |
| public GlobalizationPreferences | Returns: this, for chainingcode territory)Sets the territory, which is a valid territory according to for RFC 3066 (or successor). |
| public GlobalizationPreferences | Returns: this, for chaininga valid TZID (see UTS#35). timezone)Sets the timezone ID. If this has not been set, uses default for territory. |
| available_locales | back to summary |
|---|---|
| private static final HashMap<ULocale, BitSet> available_locales | |
| BI_CHARACTER | back to summary |
|---|---|
| public static final int BI_CHARACTER Break iterator type
| |
| BI_LIMIT | back to summary |
|---|---|
| private static final int BI_LIMIT | |
| BI_LINE | back to summary |
|---|---|
| public static final int BI_LINE Break iterator type
| |
| BI_SENTENCE | back to summary |
|---|---|
| public static final int BI_SENTENCE Break iterator type
| |
| BI_TITLE | back to summary |
|---|---|
| public static final int BI_TITLE Break iterator type
| |
| BI_WORD | back to summary |
|---|---|
| public static final int BI_WORD Break iterator type
| |
| breakIterators | back to summary |
|---|---|
| private BreakIterator[] breakIterators | |
| calendar | back to summary |
|---|---|
| private Calendar calendar | |
| collator | back to summary |
|---|---|
| private Collator collator | |
| currency | back to summary |
|---|---|
| private Currency currency | |
| dateFormats | back to summary |
|---|---|
| private DateFormat[][] dateFormats | |
| DF_FULL | back to summary |
|---|---|
| public static final int DF_FULL Date Format type
| |
| DF_LIMIT | back to summary |
|---|---|
| private static final int DF_LIMIT | |
| DF_LONG | back to summary |
|---|---|
| public static final int DF_LONG Date Format type
| |
| DF_MEDIUM | back to summary |
|---|---|
| public static final int DF_MEDIUM Date Format type
| |
| DF_NONE | back to summary |
|---|---|
| public static final int DF_NONE Date Format type
| |
| DF_SHORT | back to summary |
|---|---|
| public static final int DF_SHORT Date Format type
| |
| frozen | back to summary |
|---|---|
| private volatile boolean frozen | |
| ID_CURRENCY | back to summary |
|---|---|
| public static final int ID_CURRENCY For selecting a choice of display names
| |
| ID_CURRENCY_SYMBOL | back to summary |
|---|---|
| public static final int ID_CURRENCY_SYMBOL For selecting a choice of display names
| |
| ID_KEYWORD | back to summary |
|---|---|
| public static final int ID_KEYWORD For selecting a choice of display names
| |
| ID_KEYWORD_VALUE | back to summary |
|---|---|
| public static final int ID_KEYWORD_VALUE For selecting a choice of display names
| |
| ID_LANGUAGE | back to summary |
|---|---|
| public static final int ID_LANGUAGE For selecting a choice of display names
| |
| ID_LOCALE | back to summary |
|---|---|
| public static final int ID_LOCALE For selecting a choice of display names
| |
| ID_SCRIPT | back to summary |
|---|---|
| public static final int ID_SCRIPT For selecting a choice of display names
| |
| ID_TERRITORY | back to summary |
|---|---|
| public static final int ID_TERRITORY For selecting a choice of display names
| |
| ID_TIMEZONE | back to summary |
|---|---|
| public static final int ID_TIMEZONE For selecting a choice of display names
| |
| ID_VARIANT | back to summary |
|---|---|
| public static final int ID_VARIANT For selecting a choice of display names
| |
| implicitLocales | back to summary |
|---|---|
| private List<ULocale> implicitLocales | |
| language_territory_hack | back to summary |
|---|---|
| private static final String[][] language_territory_hack | |
| language_territory_hack_map | back to summary |
|---|---|
| private static final Map<String, String> language_territory_hack_map Warning All of this data is temporary, until we start importing from CLDR!!! | |
| locales | back to summary |
|---|---|
| private List<ULocale> locales | |
| NF_CURRENCY | back to summary |
|---|---|
| public static final int NF_CURRENCY Number Format type
| |
| NF_INTEGER | back to summary |
|---|---|
| public static final int NF_INTEGER Number Format type
| |
| NF_LIMIT | back to summary |
|---|---|
| private static final int NF_LIMIT | |
| NF_NUMBER | back to summary |
|---|---|
| public static final int NF_NUMBER Number Format type
| |
| NF_PERCENT | back to summary |
|---|---|
| public static final int NF_PERCENT Number Format type
| |
| NF_SCIENTIFIC | back to summary |
|---|---|
| public static final int NF_SCIENTIFIC Number Format type
| |
| numberFormats | back to summary |
|---|---|
| private NumberFormat[] numberFormats | |
| territory | back to summary |
|---|---|
| private String territory | |
| territory_tzid_hack | back to summary |
|---|---|
| pack-priv static final String[][] territory_tzid_hack | |
| territory_tzid_hack_map | back to summary |
|---|---|
| pack-priv static final Map<String, String> territory_tzid_hack_map | |
| timezone | back to summary |
|---|---|
| private TimeZone timezone | |
| TYPE_BREAKITERATOR | back to summary |
|---|---|
| private static final int TYPE_BREAKITERATOR | |
| TYPE_CALENDAR | back to summary |
|---|---|
| private static final int TYPE_CALENDAR | |
| TYPE_COLLATOR | back to summary |
|---|---|
| private static final int TYPE_COLLATOR | |
| TYPE_DATEFORMAT | back to summary |
|---|---|
| private static final int TYPE_DATEFORMAT | |
| TYPE_GENERIC | back to summary |
|---|---|
| private static final int TYPE_GENERIC | |
| TYPE_LIMIT | back to summary |
|---|---|
| private static final int TYPE_LIMIT | |
| TYPE_NUMBERFORMAT | back to summary |
|---|---|
| private static final int TYPE_NUMBERFORMAT | |
| GlobalizationPreferences | back to summary |
|---|---|
| public GlobalizationPreferences() Default constructor
| |
| cloneAsThawed | back to summary |
|---|---|
| public GlobalizationPreferences cloneAsThawed() Implements com. Doc from com. Provides for the clone operation. Any clone is initially unfrozen. | |
| freeze | back to summary |
|---|---|
| public GlobalizationPreferences freeze() Implements com. Doc from com. Freezes the object.
| |
| getAvailableLocale | back to summary |
|---|---|
| private ULocale getAvailableLocale(int type) | |
| getBreakIterator | back to summary |
|---|---|
| public BreakIterator getBreakIterator(int type) Get a copy of the break iterator for the specified type according to the settings.
| |
| getCalendar | back to summary |
|---|---|
| public Calendar getCalendar() Get a copy of the calendar according to the settings. | |
| getCollator | back to summary |
|---|---|
| public Collator getCollator() Get a copy of the collator according to the settings. | |
| getCurrency | back to summary |
|---|---|
| public Currency getCurrency() Get a copy of the currency computed according to the settings. | |
| getDateFormat | back to summary |
|---|---|
| public DateFormat getDateFormat(int dateStyle, int timeStyle) 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, the language priority list is used. DF_NONE should be used for the style, where only the date or time format individually is being gotten.
| |
| getDisplayName | back to summary |
|---|---|
| public String getDisplayName(String id, int type) Get the display name for an ID: language, script, territory, currency, timezone... Uses the language priority list to do so. | |
| getLocale | back to summary |
|---|---|
| public ULocale getLocale(int index) Convenience function for getting the locales in priority order | |
| getLocales | back to summary |
|---|---|
| public List Get a copy of the language/locale priority list | |
| getNumberFormat | back to summary |
|---|---|
| public NumberFormat getNumberFormat(int style) 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, the language priority list is used.
| |
| getResourceBundle | back to summary |
|---|---|
| public 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.
| |
| getResourceBundle | back to summary |
|---|---|
| public 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.
| |
| getTerritory | back to summary |
|---|---|
| public String getTerritory() Gets the territory setting. If it wasn't explicitly set, it is computed from the general locale setting. | |
| getTimeZone | back to summary |
|---|---|
| public TimeZone getTimeZone() Get the timezone. It was either explicitly set, or is heuristically computed from other settings. | |
| guessBreakIterator | back to summary |
|---|---|
| protected BreakIterator guessBreakIterator(int type) 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.
| |
| guessCalendar | back to summary |
|---|---|
| protected Calendar guessCalendar() 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.
| |
| guessCollator | back to summary |
|---|---|
| protected Collator guessCollator() 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.
| |
| guessCurrency | back to summary |
|---|---|
| protected Currency guessCurrency() This function can be overridden by subclasses to use different heuristics
| |
| guessDateFormat | back to summary |
|---|---|
| protected DateFormat guessDateFormat(int dateStyle, int timeStyle) 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.
| |
| guessLocales | back to summary |
|---|---|
| protected List 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.
| |
| guessNumberFormat | back to summary |
|---|---|
| protected NumberFormat guessNumberFormat(int style) 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.
| |
| guessTerritory | back to summary |
|---|---|
| protected String guessTerritory() This function can be overridden by subclasses to use different heuristics.
| |
| guessTimeZone | back to summary |
|---|---|
| protected TimeZone guessTimeZone() 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.
| |
| isAvailableLocale | back to summary |
|---|---|
| private boolean isAvailableLocale(ULocale loc, int type) | |
| isFrozen | back to summary |
|---|---|
| public boolean isFrozen() Implements com. Doc from com. Determines whether the object has been frozen or not. | |
| processLocales | back to summary |
|---|---|
| protected List Process a language/locale priority list specified via | |
| reset | back to summary |
|---|---|
| public GlobalizationPreferences reset() Restore the object to the initial state.
| |
| setBreakIterator | back to summary |
|---|---|
| public GlobalizationPreferences setBreakIterator(int type, BreakIterator iterator) Explicitly set the break iterator for this object.
| |
| setCalendar | back to summary |
|---|---|
| public GlobalizationPreferences setCalendar(Calendar calendar) Sets the calendar. If this has not been set, uses default for territory.
| |
| setCollator | back to summary |
|---|---|
| public GlobalizationPreferences setCollator(Collator collator) Explicitly set the collator for this object.
| |
| setCurrency | back to summary |
|---|---|
| public GlobalizationPreferences setCurrency(Currency currency) Sets the currency code. If this has not been set, uses default for territory.
| |
| setDateFormat | back to summary |
|---|---|
| public GlobalizationPreferences setDateFormat(int dateStyle, int timeStyle, DateFormat format) Set an explicit date format. Overrides the locale priority list for a particular combination of dateStyle and timeStyle. DF_NONE should be used if for the style, where only the date or time format individually is being set.
| |
| setLocale | back to summary |
|---|---|
| public GlobalizationPreferences setLocale(ULocale uLocale) Convenience routine for setting the language/locale priority list from a single locale/language.
| |
| setLocales | back to summary |
|---|---|
| public GlobalizationPreferences setLocales(List<ULocale> inputLocales) 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.
| |
| setLocales | back to summary |
|---|---|
| public GlobalizationPreferences setLocales(ULocale[] uLocales) Convenience routine for setting the language/locale priority list from an array.
| |
| setLocales | back to summary |
|---|---|
| public GlobalizationPreferences setLocales(String acceptLanguageString) Convenience routine for setting the locale priority list from an Accept-Language string.
| |
| setNumberFormat | back to summary |
|---|---|
| public GlobalizationPreferences setNumberFormat(int style, NumberFormat format) Sets a number format explicitly. Overrides the general locale settings.
| |
| setTerritory | back to summary |
|---|---|
| public GlobalizationPreferences setTerritory(String territory) 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.
| |
| setTimeZone | back to summary |
|---|---|
| public GlobalizationPreferences setTimeZone(TimeZone timezone) Sets the timezone ID. If this has not been set, uses default for territory.
| |