Java Doc for CmsLocaleManager.java in  » Content-Management-System » opencms » org » opencms » i18n » 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 » Content Management System » opencms » org.opencms.i18n 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.opencms.i18n.CmsLocaleManager

CmsLocaleManager
public class CmsLocaleManager implements I_CmsEventListener(Code)
Manages the locales configured for this OpenCms installation.

Locale configuration is done in the configuration file opencms-system.xml in the opencms/system/internationalization node and it's sub-nodes.


author:
   Carsten Weinholz
author:
   Alexander Kandzior
version:
   $Revision: 1.56 $
since:
   6.0.0



Field Summary
final public static  StringLOCALE_HANDLER
     Runtime property name for locale handler.
final public static  StringPARAMETER_ENCODING
     Request parameter to force encoding selection.
final public static  StringPARAMETER_LOCALE
     Request parameter to force locale selection.

Constructor Summary
public  CmsLocaleManager()
    
public  CmsLocaleManager(Locale defaultLocale)
    

Method Summary
public  voidaddAvailableLocale(String localeName)
    
public  voidaddDefaultLocale(String localeName)
    
public  voidcmsEvent(CmsEvent event)
    
public  ListgetAvailableLocales()
     Returns the list of available Locale s configured in opencms-system.xml, in the opencms/system/internationalization/localesconfigured node.

The list of configured available locales contains all locales that are allowed to be used in the VFS, for example as languages in XML content files.

The available locales are a superset of the default locales, see CmsLocaleManager.getDefaultLocales() .

It's possible to reduce the system default by setting the propery CmsPropertyDefinition.PROPERTY_AVAILABLE_LOCALES to a comma separated list of locale names.

public  ListgetAvailableLocales(CmsObject cms, String resourceName)
    
public  ListgetAvailableLocales(String names)
    
public  LocalegetBestMatchingLocale(Locale requestedLocale, List defaults, Collection available)
    
public static  LocalegetDefaultLocale()
    
public  LocalegetDefaultLocale(CmsObject cms, String resourceName)
     Returns the "the" default locale for the given resource.

It's possible to override the system default (see CmsLocaleManager.getDefaultLocale() ) by setting the property CmsPropertyDefinition.PROPERTY_LOCALE to a comma separated list of locale names.

public  ListgetDefaultLocales()
     Returns the list of default Locale s configured in opencms-system.xml, in the opencms/system/internationalization/localesdefault node.

Since the default locale is always available, the result list will always contain at least one Locale.

It's possible to override the system default by setting the property CmsPropertyDefinition.PROPERTY_LOCALE to a comma separated list of locale names. This property is inherited from the parent folders.

The default locales must be a subset of the configured available locales, see CmsLocaleManager.getAvailableLocales() . In case an invalid locale has been set with the property, this locale is ignored.

The default locale names are used as a fallback mechanism in case a locale is requested that can not be found, for example when delivering content form an XML content.

There is a list of default locales (instead of just one default locale) since there are scenarios when one default is not enough.

public  ListgetDefaultLocales(CmsObject cms, CmsResource resource)
     Returns an array of default locales for the given resource.

Since the default locale is always available, the result list will always contain at least one Locale.

It's possible to override the system default (see CmsLocaleManager.getDefaultLocales() ) by setting the property CmsPropertyDefinition.PROPERTY_LOCALE to a comma separated list of locale names.

public  ListgetDefaultLocales(CmsObject cms, String resourceName)
     Returns an array of default locales for the given resource.

Since the default locale is always available, the result list will always contain at least one Locale.

It's possible to override the system default (see CmsLocaleManager.getDefaultLocales() ) by setting the property CmsPropertyDefinition.PROPERTY_LOCALE to a comma separated list of locale names.

public  LocalegetFirstMatchingLocale(List locales, Collection available)
    
public  CmsI18nInfogetI18nInfo(HttpServletRequest req, CmsUser user, CmsProject project, String resource)
     Returns the the appropriate locale/encoding for a request, using the "right" locale handler for the given resource.

Certain system folders (like the Workplace) require a special locale handler different from the configured handler.

public static  LocalegetLocale(String localeName)
     Returns a locale created from the given full name.

The full name must consist of language code, country code(optional), variant(optional) separated by "_".

This method will always return a valid Locale! If the provided locale name is not valid (i.e.

public  I_CmsLocaleHandlergetLocaleHandler()
    
public static  StringgetLocaleNames(List localeNames)
    
public static  ListgetLocales(List localeNames)
    
public static  ListgetLocales(String localeNames)
    
final public static  StringgetResourceEncoding(CmsObject cms, CmsResource res)
    
public  voidinitialize(CmsObject cms)
    
public  booleanisInitialized()
    
public  voidsetLocaleHandler(I_CmsLocaleHandler localeHandler)
    

Field Detail
LOCALE_HANDLER
final public static String LOCALE_HANDLER(Code)
Runtime property name for locale handler.



PARAMETER_ENCODING
final public static String PARAMETER_ENCODING(Code)
Request parameter to force encoding selection.



PARAMETER_LOCALE
final public static String PARAMETER_LOCALE(Code)
Request parameter to force locale selection.




Constructor Detail
CmsLocaleManager
public CmsLocaleManager()(Code)
Initializes a new CmsLocaleManager, called from the configuration.




CmsLocaleManager
public CmsLocaleManager(Locale defaultLocale)(Code)
Initializes a new CmsLocaleManager, used for OpenCms runlevel 1 (unit tests) only.


Parameters:
  defaultLocale - the default locale to use





Method Detail
addAvailableLocale
public void addAvailableLocale(String localeName)(Code)
Adds a locale to the list of available locales.


Parameters:
  localeName - the locale to add




addDefaultLocale
public void addDefaultLocale(String localeName)(Code)
Adds a locale to the list of default locales.


Parameters:
  localeName - the locale to add




cmsEvent
public void cmsEvent(CmsEvent event)(Code)
Implements the CmsEvent interface, the locale manager the events to clear the list of cached keys .


Parameters:
  event - CmsEvent that has occurred




getAvailableLocales
public List getAvailableLocales()(Code)
Returns the list of available Locale s configured in opencms-system.xml, in the opencms/system/internationalization/localesconfigured node.

The list of configured available locales contains all locales that are allowed to be used in the VFS, for example as languages in XML content files.

The available locales are a superset of the default locales, see CmsLocaleManager.getDefaultLocales() .

It's possible to reduce the system default by setting the propery CmsPropertyDefinition.PROPERTY_AVAILABLE_LOCALES to a comma separated list of locale names. However, you can not add new available locales, only remove from the configured list.

the list of available locale names, e.g. en, de
See Also:   CmsLocaleManager.getDefaultLocales()




getAvailableLocales
public List getAvailableLocales(CmsObject cms, String resourceName)(Code)
Returns an array of available locale names for the given resource.


Parameters:
  cms - the current cms permission object
Parameters:
  resourceName - the name of the resource an array of available locale names
See Also:   CmsLocaleManager.getAvailableLocales()




getAvailableLocales
public List getAvailableLocales(String names)(Code)
Returns a List of available locales from a comma separated string of locale names.

All names are filtered against the allowed available locales configured in opencms-system.xml.


Parameters:
  names - a comma-separated String of locale names List of locales created from the given locale names
See Also:   CmsLocaleManager.getAvailableLocales()




getBestMatchingLocale
public Locale getBestMatchingLocale(Locale requestedLocale, List defaults, Collection available)(Code)
Tries to find the given requested locale (eventually simplified) in the collection of available locales, if the requested locale is not found it will return the first match from the given list of default locales.


Parameters:
  requestedLocale - the requested locale, if this (or a simplified version of it) is available it will be returned
Parameters:
  defaults - a list of default locales to use in case the requested locale is not available
Parameters:
  available - the available locales to find a match in the best matching locale name or null if no name matches




getDefaultLocale
public static Locale getDefaultLocale()(Code)
Returns the default locale configured in opencms-system.xml, that is the first locale from the list provided in the opencms/system/internationalization/localesdefault node.

the default locale configured in opencms-system.xml




getDefaultLocale
public Locale getDefaultLocale(CmsObject cms, String resourceName)(Code)
Returns the "the" default locale for the given resource.

It's possible to override the system default (see CmsLocaleManager.getDefaultLocale() ) by setting the property CmsPropertyDefinition.PROPERTY_LOCALE to a comma separated list of locale names. This property is inherited from the parent folders. This method will return the first locale from that list.

The default locale must be contained in the set of configured available locales, see CmsLocaleManager.getAvailableLocales() . In case an invalid locale has been set with the property, this locale is ignored and the same result as CmsLocaleManager.getDefaultLocale() is returned.

In case the property CmsPropertyDefinition.PROPERTY_LOCALE has not been set on the resource or a parent folder, this method returns the same result as CmsLocaleManager.getDefaultLocale() .


Parameters:
  cms - the current cms permission object
Parameters:
  resourceName - the name of the resource an array of default locale names
See Also:   CmsLocaleManager.getDefaultLocales()
See Also:   CmsLocaleManager.getDefaultLocales(CmsObject,String)




getDefaultLocales
public List getDefaultLocales()(Code)
Returns the list of default Locale s configured in opencms-system.xml, in the opencms/system/internationalization/localesdefault node.

Since the default locale is always available, the result list will always contain at least one Locale.

It's possible to override the system default by setting the property CmsPropertyDefinition.PROPERTY_LOCALE to a comma separated list of locale names. This property is inherited from the parent folders.

The default locales must be a subset of the configured available locales, see CmsLocaleManager.getAvailableLocales() . In case an invalid locale has been set with the property, this locale is ignored.

The default locale names are used as a fallback mechanism in case a locale is requested that can not be found, for example when delivering content form an XML content.

There is a list of default locales (instead of just one default locale) since there are scenarios when one default is not enough. Consider the following example: The main default locale is set to "en". An example XML content file contains just one language, in this case "de" and not "en". Now a request is made to the file for the locale "fr". If there would be only one default locale ("en"), we would have to give up. But since we allow more then one default, we can deliver the "de" content instead of a blank page.

the list of default locale names, e.g. en, de
See Also:   CmsLocaleManager.getAvailableLocales()




getDefaultLocales
public List getDefaultLocales(CmsObject cms, CmsResource resource)(Code)
Returns an array of default locales for the given resource.

Since the default locale is always available, the result list will always contain at least one Locale.

It's possible to override the system default (see CmsLocaleManager.getDefaultLocales() ) by setting the property CmsPropertyDefinition.PROPERTY_LOCALE to a comma separated list of locale names. This property is inherited from the parent folders.

The default locales must be a subset of the configured available locales, see CmsLocaleManager.getAvailableLocales() . In case an invalid locale has been set with the property, this locale is ignored.

In case the property CmsPropertyDefinition.PROPERTY_LOCALE has not been set on the resource or a parent folder, this method returns the same result as CmsLocaleManager.getDefaultLocales() .

Use this method in case you need to get all configured default options for a resource, if you just need the "the" default locale for a resource, use CmsLocaleManager.getDefaultLocale(CmsObject,String) .


Parameters:
  cms - the current cms permission object
Parameters:
  resource - the resource to read the default locale properties for an array of default locale names
See Also:   CmsLocaleManager.getDefaultLocales()
See Also:   CmsLocaleManager.getDefaultLocale(CmsObject,String)
See Also:   CmsLocaleManager.getDefaultLocales(CmsObject,String)
since:
   7.0.2




getDefaultLocales
public List getDefaultLocales(CmsObject cms, String resourceName)(Code)
Returns an array of default locales for the given resource.

Since the default locale is always available, the result list will always contain at least one Locale.

It's possible to override the system default (see CmsLocaleManager.getDefaultLocales() ) by setting the property CmsPropertyDefinition.PROPERTY_LOCALE to a comma separated list of locale names. This property is inherited from the parent folders.

The default locales must be a subset of the configured available locales, see CmsLocaleManager.getAvailableLocales() . In case an invalid locale has been set with the property, this locale is ignored.

In case the property CmsPropertyDefinition.PROPERTY_LOCALE has not been set on the resource or a parent folder, this method returns the same result as CmsLocaleManager.getDefaultLocales() .

Use this method in case you need to get all configured default options for a resource, if you just need the "the" default locale for a resource, use CmsLocaleManager.getDefaultLocale(CmsObject,String) .


Parameters:
  cms - the current cms permission object
Parameters:
  resourceName - the name of the resource an array of default locale names
See Also:   CmsLocaleManager.getDefaultLocales()
See Also:   CmsLocaleManager.getDefaultLocale(CmsObject,String)
See Also:   CmsLocaleManager.getDefaultLocales(CmsObject,CmsResource)
See Also:   




getFirstMatchingLocale
public Locale getFirstMatchingLocale(List locales, Collection available)(Code)
Returns the first matching locale (eventually simplified) from the available locales.

In case no match is found, code null is returned.


Parameters:
  locales - must be an ascending sorted list of locales in order of preference
Parameters:
  available - the available locales to find a match in the first precise or simplified match, or null in case no match is found




getI18nInfo
public CmsI18nInfo getI18nInfo(HttpServletRequest req, CmsUser user, CmsProject project, String resource)(Code)
Returns the the appropriate locale/encoding for a request, using the "right" locale handler for the given resource.

Certain system folders (like the Workplace) require a special locale handler different from the configured handler. Use this method if you want to resolve locales exactly like the system does for a request.


Parameters:
  req - the current http request
Parameters:
  user - the current user
Parameters:
  project - the current project
Parameters:
  resource - the URI of the requested resource (with full site root added) the i18n information to use for the given request context




getLocale
public static Locale getLocale(String localeName)(Code)
Returns a locale created from the given full name.

The full name must consist of language code, country code(optional), variant(optional) separated by "_".

This method will always return a valid Locale! If the provided locale name is not valid (i.e. leads to an Exception when trying to create the Locale, then the configured default Locale is returned.


Parameters:
  localeName - the full locale name the locale or null if not available




getLocaleHandler
public I_CmsLocaleHandler getLocaleHandler()(Code)
Returns the configured locale handler.

This handler is used to derive the appropriate locale/encoding for a request.

the locale handler




getLocaleNames
public static String getLocaleNames(List localeNames)(Code)
Returns the locale names from the given List of locales as a comma separated String.

For example, if the input List contains Locale.ENGLISH and Locale.GERMANY , the result will be "en, de_DE".

An empty String is returned if the input is null, or contains no elements.


Parameters:
  localeNames - the locale names to generate a String from the locale names from the given List of locales as a comma separated String




getLocales
public static List getLocales(List localeNames)(Code)
Returns a List of locales from an array of locale names.


Parameters:
  localeNames - array of locale names a List of locales derived from the given locale names




getLocales
public static List getLocales(String localeNames)(Code)
Returns a List of locales from a comma-separated string of locale names.


Parameters:
  localeNames - a comma-separated string of locale names a List of locales derived from the given locale names




getResourceEncoding
final public static String getResourceEncoding(CmsObject cms, CmsResource res)(Code)
Returns the content encoding set for the given resource.

The content encoding is controlled by the property CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING , which can be set on the resource or on a parent folder for all resources in this folder.

In case no encoding has been set, the default encoding from org.opencms.main.CmsSystemInfo.getDefaultEncoding is returned.


Parameters:
  cms - the current OpenCms user context
Parameters:
  res - the resource to read the encoding for the content encoding set for the given resource




initialize
public void initialize(CmsObject cms)(Code)
Initializes this locale manager with the OpenCms system configuration.


Parameters:
  cms - an OpenCms context object that must have been initialized with "Admin" permissions




isInitialized
public boolean isInitialized()(Code)
Returns true if this locale manager is fully initialized.

This is required to prevent errors during unit tests, simple unit tests will usually not have a fully initialized locale manager available.

true if the locale manager is fully initialized




setLocaleHandler
public void setLocaleHandler(I_CmsLocaleHandler localeHandler)(Code)
Sets the configured locale handler.


Parameters:
  localeHandler - the locale handler to set




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.