Java Doc for GlobalizationPreferences.java in  » Internationalization-Localization » icu4j » com » ibm » icu » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ibm.icu.util.GlobalizationPreferences

GlobalizationPreferences
public class GlobalizationPreferences implements Freezable(Code)
This convenience class provides a mechanism for bundling together different globalization preferences. It includes:
  • A list of locales/languages in preference order
  • A territory
  • A currency
  • A timezone
  • A calendar
  • A collator (for language-sensitive sorting, searching, and matching).
  • Explicit overrides for date/time formats, etc.
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:

  • Add Holidays
  • Add convenience to get/take Locale as well as ULocale.
  • Add Lenient datetime formatting when that is available.
  • Should this be serializable?
  • Other utilities?
Note:
  • to get the display name for the first day of the week, use the calendar + display names.
  • to get the work days, ask the calendar (when that is available).
  • to get papersize / measurement system/bidi-orientation, ask the locale (when that is available there)
  • to get the field order in a date, and whether a time is 24hour or not, ask the DateFormat (when that is available there)
  • it will support HOST locale when it becomes available (it is a special locale that will ask the services to use the host platform's values).


Field Summary
final public static  intBI_CHARACTERBI_WORDBI_LINEBI_SENTENCEBI_TITLE
    
final public static  intDF_FULLDF_LONGDF_MEDIUMDF_SHORTDF_NONE
    
final public static  intID_LOCALEID_LANGUAGEID_SCRIPTID_TERRITORYID_VARIANTID_KEYWORDID_KEYWORD_VALUEID_CURRENCYID_CURRENCY_SYMBOLID_TIMEZONE
    
final public static  intNF_NUMBERNF_CURRENCYNF_PERCENTNF_SCIENTIFICNF_INTEGER
    
final static  String[][]territory_tzid_hack
    
final static  Mapterritory_tzid_hack_map
    

Constructor Summary
public  GlobalizationPreferences()
    

Method Summary
public  ObjectcloneAsThawed()
    
public  Objectfreeze()
    
public  BreakIteratorgetBreakIterator(int type)
     Get a copy of the break iterator for the specified type according to the settings.
public  CalendargetCalendar()
     Get a copy of the calendar according to the settings.
public  CollatorgetCollator()
     Get a copy of the collator according to the settings.
public  CurrencygetCurrency()
     Get a copy of the currency computed according to the settings.
public  DateFormatgetDateFormat(int dateStyle, int timeStyle)
     Gets a date format according to the current settings.
public  StringgetDisplayName(String id, int type)
     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, ...
Parameters:
  type - specifies the type of the ID: ID_LANGUAGE, etc.
public  ULocalegetLocale(int index)
     Convenience function for getting the locales in priority order
Parameters:
  index - The index (0..n) of the desired item.
public  ListgetLocales()
    
public  NumberFormatgetNumberFormat(int style)
     Gets a number format according to the current settings.
public  ResourceBundlegetResourceBundle(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.
public  ResourceBundlegetResourceBundle(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.
public  StringgetTerritory()
     Gets the territory setting.
public  TimeZonegetTimeZone()
     Get the timezone.
protected  BreakIteratorguessBreakIterator(int type)
     This function can be overridden by subclasses to use different heuristics.
protected  CalendarguessCalendar()
     This function can be overridden by subclasses to use different heuristics.
protected  CollatorguessCollator()
     This function can be overridden by subclasses to use different heuristics.
protected  CurrencyguessCurrency()
    
protected  DateFormatguessDateFormat(int dateStyle, int timeStyle)
     This function can be overridden by subclasses to use different heuristics.
protected  ListguessLocales()
    
protected  NumberFormatguessNumberFormat(int style)
     This function can be overridden by subclasses to use different heuristics.
protected  StringguessTerritory()
     This function can be overridden by subclasses to use different heuristics.
protected  TimeZoneguessTimeZone()
     This function can be overridden by subclasses to use different heuristics.
public  booleanisFrozen()
    
protected  ListprocessLocales(List inputLocales)
     Process a language/locale priority list specified via 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.

Step 1: Move later occurence of more specific locale before ealier occurence of less specific locale.
Before: en, fr_FR, en_US, en_GB
After: en_US, en_GB, en, fr_FR

Step 2: Append a fallback locale to each locale.
Before: en_US, en_GB, en, fr_FR
After: en_US, en, en_GB, en, en, fr_FR, fr

Step 3: Remove ealier occurence of duplicated locale entries.
Before: en_US, en, en_GB, en, en, fr_FR, fr
After: en_US, en_GB, en, fr_FR, fr

The final locale list is used to produce a default value for the appropriate territory, currency, timezone, etc.
public  GlobalizationPreferencesreset()
     Restore the object to the initial state.
public  GlobalizationPreferencessetBreakIterator(int type, BreakIterator iterator)
     Explicitly set the break iterator for this object.
public  GlobalizationPreferencessetCalendar(Calendar calendar)
     Sets the calendar.
public  GlobalizationPreferencessetCollator(Collator collator)
     Explicitly set the collator for this object.
public  GlobalizationPreferencessetCurrency(Currency currency)
     Sets the currency code.
public  GlobalizationPreferencessetDateFormat(int dateStyle, int timeStyle, DateFormat format)
     Set an explicit date format.
public  GlobalizationPreferencessetLocale(ULocale uLocale)
     Convenience routine for setting the language/locale priority list from a single locale/language.
public  GlobalizationPreferencessetLocales(List inputLocales)
     Sets the language/locale priority list.
public  GlobalizationPreferencessetLocales(ULocale[] uLocales)
     Convenience routine for setting the language/locale priority list from an array.
public  GlobalizationPreferencessetLocales(String acceptLanguageString)
     Convenience routine for setting the locale priority list from an Accept-Language string.
public  GlobalizationPreferencessetNumberFormat(int style, NumberFormat format)
     Sets a number format explicitly.
public  GlobalizationPreferencessetTerritory(String territory)
     Sets the territory, which is a valid territory according to for RFC 3066 (or successor).
public  GlobalizationPreferencessetTimeZone(TimeZone timezone)
     Sets the timezone ID.

Field Detail
BI_CHARACTERBI_WORDBI_LINEBI_SENTENCEBI_TITLE
final public static int BI_CHARACTERBI_WORDBI_LINEBI_SENTENCEBI_TITLE(Code)
Break iterator types



DF_FULLDF_LONGDF_MEDIUMDF_SHORTDF_NONE
final public static int DF_FULLDF_LONGDF_MEDIUMDF_SHORTDF_NONE(Code)
Date Format types



ID_LOCALEID_LANGUAGEID_SCRIPTID_TERRITORYID_VARIANTID_KEYWORDID_KEYWORD_VALUEID_CURRENCYID_CURRENCY_SYMBOLID_TIMEZONE
final public static int ID_LOCALEID_LANGUAGEID_SCRIPTID_TERRITORYID_VARIANTID_KEYWORDID_KEYWORD_VALUEID_CURRENCYID_CURRENCY_SYMBOLID_TIMEZONE(Code)
For selecting a choice of display names



NF_NUMBERNF_CURRENCYNF_PERCENTNF_SCIENTIFICNF_INTEGER
final public static int NF_NUMBERNF_CURRENCYNF_PERCENTNF_SCIENTIFICNF_INTEGER(Code)
Number Format types



territory_tzid_hack
final static String[][] territory_tzid_hack(Code)



territory_tzid_hack_map
final static Map territory_tzid_hack_map(Code)




Constructor Detail
GlobalizationPreferences
public GlobalizationPreferences()(Code)
Default constructor




Method Detail
cloneAsThawed
public Object cloneAsThawed()(Code)



freeze
public Object freeze()(Code)



getBreakIterator
public BreakIterator getBreakIterator(int type)(Code)
Get a copy of the break iterator for the specified type according to the settings.
Parameters:
  type - break type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE break iterator explicit or implicit



getCalendar
public Calendar getCalendar()(Code)
Get a copy of the calendar according to the settings. calendar explicit or implicit.



getCollator
public Collator getCollator()(Code)
Get a copy of the collator according to the settings. collator explicit or implicit.



getCurrency
public Currency getCurrency()(Code)
Get a copy of the currency computed according to the settings. currency code, explicit or implicit.



getDateFormat
public DateFormat getDateFormat(int dateStyle, int timeStyle)(Code)
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.
Parameters:
  dateStyle - DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE
Parameters:
  timeStyle - DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE a DateFormat, according to the above description



getDisplayName
public String getDisplayName(String id, int type)(Code)
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, ...
Parameters:
  type - specifies the type of the ID: ID_LANGUAGE, etc. the display name



getLocale
public ULocale getLocale(int index)(Code)
Convenience function for getting the locales in priority order
Parameters:
  index - The index (0..n) of the desired item. desired item. null if index is out of range



getLocales
public List getLocales()(Code)
Get a copy of the language/locale priority list a copy of the language/locale priority list.



getNumberFormat
public NumberFormat getNumberFormat(int style)(Code)
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.
Parameters:
  style - NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER



getResourceBundle
public ResourceBundle getResourceBundle(String baseName)(Code)
Convenience function to get a ResourceBundle instance using the specified base name based on the language/locale priority list stored in this object.
Parameters:
  baseName - the base name of the resource bundle, a fully qualifiedclass name a resource bundle for the given base name and locale based on thelanguage/locale priority list stored in this object



getResourceBundle
public ResourceBundle getResourceBundle(String baseName, ClassLoader loader)(Code)
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.
Parameters:
  baseName - the base name of the resource bundle, a fully qualifiedclass name
Parameters:
  loader - the class object from which to load the resource bundle a resource bundle for the given base name and locale based on thelanguage/locale priority list stored in this object



getTerritory
public String getTerritory()(Code)
Gets the territory setting. If it wasn't explicitly set, it is computed from the general locale setting. territory code, explicit or implicit.



getTimeZone
public TimeZone getTimeZone()(Code)
Get the timezone. It was either explicitly set, or is heuristically computed from other settings. timezone, either implicitly or explicitly set



guessBreakIterator
protected BreakIterator guessBreakIterator(int type)(Code)
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.
Parameters:
  type -



guessCalendar
protected Calendar guessCalendar()(Code)
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
protected Collator guessCollator()(Code)
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
protected Currency guessCurrency()(Code)
This function can be overridden by subclasses to use different heuristics



guessDateFormat
protected DateFormat guessDateFormat(int dateStyle, int timeStyle)(Code)
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.
Parameters:
  dateStyle -
Parameters:
  timeStyle -



guessLocales
protected List guessLocales()(Code)
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
protected NumberFormat guessNumberFormat(int style)(Code)
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.
Parameters:
  style -



guessTerritory
protected String guessTerritory()(Code)
This function can be overridden by subclasses to use different heuristics.



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



isFrozen
public boolean isFrozen()(Code)



processLocales
protected List processLocales(List inputLocales)(Code)
Process a language/locale priority list specified via 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.

Step 1: Move later occurence of more specific locale before ealier occurence of less specific locale.
Before: en, fr_FR, en_US, en_GB
After: en_US, en_GB, en, fr_FR

Step 2: Append a fallback locale to each locale.
Before: en_US, en_GB, en, fr_FR
After: en_US, en, en_GB, en, en, fr_FR, fr

Step 3: Remove ealier occurence of duplicated locale entries.
Before: en_US, en, en_GB, en, en, fr_FR, fr
After: en_US, en_GB, en, fr_FR, fr

The final locale list is used to produce a default value for the appropriate territory, currency, timezone, etc. The list also represents the lookup order used in 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



reset
public GlobalizationPreferences reset()(Code)
Restore the object to the initial state. this, for chaining



setBreakIterator
public GlobalizationPreferences setBreakIterator(int type, BreakIterator iterator)(Code)
Explicitly set the break iterator for this object.
Parameters:
  type - break type - BI_CHARACTER or BI_WORD, BI_LINE, BI_SENTENCE, BI_TITLE
Parameters:
  iterator - a break iterator this, for chaining



setCalendar
public GlobalizationPreferences setCalendar(Calendar calendar)(Code)
Sets the calendar. If this has not been set, uses default for territory.
Parameters:
  calendar - arbitrary calendar this, for chaining



setCollator
public GlobalizationPreferences setCollator(Collator collator)(Code)
Explicitly set the collator for this object.
Parameters:
  collator - this, for chaining



setCurrency
public GlobalizationPreferences setCurrency(Currency currency)(Code)
Sets the currency code. If this has not been set, uses default for territory.
Parameters:
  currency - Valid ISO 4217 currency code. this, for chaining



setDateFormat
public GlobalizationPreferences setDateFormat(int dateStyle, int timeStyle, DateFormat format)(Code)
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.
Parameters:
  dateStyle - DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE
Parameters:
  timeStyle - DF_FULL, DF_LONG, DF_MEDIUM, DF_SHORT or DF_NONE
Parameters:
  format - The date format this, for chaining



setLocale
public GlobalizationPreferences setLocale(ULocale uLocale)(Code)
Convenience routine for setting the language/locale priority list from a single locale/language.
See Also:   GlobalizationPreferences.setLocales(List locales)
Parameters:
  uLocale - single locale this, for chaining



setLocales
public GlobalizationPreferences setLocales(List inputLocales)(Code)
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:
  inputLocales - list of locales in priority order, eg {"be", "fr"} for Breton first, then French if that fails. this, for chaining



setLocales
public GlobalizationPreferences setLocales(ULocale[] uLocales)(Code)
Convenience routine for setting the language/locale priority list from an array.
See Also:   GlobalizationPreferences.setLocales(List locales)
Parameters:
  uLocales - list of locales in an array this, for chaining



setLocales
public GlobalizationPreferences setLocales(String acceptLanguageString)(Code)
Convenience routine for setting the locale priority list from an Accept-Language string.
See Also:   GlobalizationPreferences.setLocales(List locales)
Parameters:
  acceptLanguageString - Accept-Language list, as defined by Section 14.4 of the RFC 2616 (HTTP 1.1) this, for chaining



setNumberFormat
public GlobalizationPreferences setNumberFormat(int style, NumberFormat format)(Code)
Sets a number format explicitly. Overrides the general locale settings.
Parameters:
  style - NF_NUMBER, NF_CURRENCY, NF_PERCENT, NF_SCIENTIFIC, NF_INTEGER
Parameters:
  format - The number format this, for chaining



setTerritory
public GlobalizationPreferences setTerritory(String territory)(Code)
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 this, for chaining



setTimeZone
public GlobalizationPreferences setTimeZone(TimeZone timezone)(Code)
Sets the timezone ID. If this has not been set, uses default for territory.
Parameters:
  timezone - a valid TZID (see UTS#35). this, for chaining



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.