Java Doc for CmsMessages.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.CmsMessages

All known Subclasses:   org.opencms.i18n.CmsMultiMessages,  org.opencms.xml.CmsXmlMessages,
CmsMessages
public class CmsMessages (Code)
Reads localized resource Strings from a java.util.ResourceBundle and provides convenience methods to access the Strings from a template.

This class is frequently used from JSP templates. Because of that, throwing of exceptions related to the access of the resource bundle are suppressed so that a template always execute. The class provides an CmsMessages.isInitialized() method that can be checked to see if the instance was properly initialized.


author:
   Alexander Kandzior
version:
   $Revision: 1.25 $
since:
   6.0.0



Field Summary
final public static  StringKEY_SHORT_SUFFIX
     The suffix of a "short" localized key name.
final public static  StringUNKNOWN_KEY_EXTENSION
     Prefix / Suffix for unknown keys.

Constructor Summary
public  CmsMessages(String bundleName, Locale locale)
     Constructor for the messages with an initialized java.util.Locale.
Parameters:
  bundleName - the base ResourceBundle name
Parameters:
  locale - the m_locale to use, eg.
public  CmsMessages(String bundleName, String language)
     Constructor for the messages with a language string.

The language is a 2 letter language ISO code, e.g.

public  CmsMessages(String bundleName, String language, String country)
     Constructor for the messages with language and country code strings.

The language is a 2 letter language ISO code, e.g.

public  CmsMessages(String bundleName, String language, String country, String variant)
     Constructor for the messages with language, country code and variant strings.

The language is a 2 letter language ISO code, e.g.

protected  CmsMessages()
    

Method Summary
public  booleanequals(Object obj)
    
public static  StringformatUnknownKey(String keyName)
    
protected  StringgetBundleName()
    
public  StringgetDate(Date date)
    
public  StringgetDate(Date date, int format)
    
public  StringgetDate(long time)
    
public  StringgetDateTime(Date date)
    
public  StringgetDateTime(Date date, int format)
    
public  StringgetDateTime(long time)
    
public  LocalegetLocale()
    
public  ResourceBundlegetResourceBundle()
    
public  StringgetString(String keyName)
     Directly calls the getString(String) method of the wrapped ResourceBundle.

If you use this this class on a template, you should consider using the CmsMessages.key(String) method to get the value from the ResourceBundle because it handles the exception for you in a convenient way.

public  inthashCode()
    
public  booleanisInitialized()
     Checks if the bundle was properly initialized.
public static  booleanisUnknownKey(String value)
    
public  Stringkey(String keyName)
     Returns the localized resource string for a given message key.

If the key was not found in the bundle, the return value is "??? " + keyName + " ???".

public  Stringkey(String keyName, boolean allowNull)
     Returns the localized resource string for a given message key.

If the key was not found in the bundle, the return value depends on the setting of the allowNull parameter.

public  Stringkey(String key, Object arg0)
    
public  Stringkey(String key, Object arg0, Object arg1)
    
public  Stringkey(String key, Object arg0, Object arg1, Object arg2)
    
public  Stringkey(String key, Object[] args)
     Returns the selected localized message for the initialized resource bundle and locale.

If the key was found in the bundle, it will be formatted using a MessageFormat using the provided parameters.

If the key was not found in the bundle, the return value is "??? " + keyName + " ???".

public  StringkeyDefault(String keyName, String defaultValue)
    
public  StringkeyWithParams(String keyName)
     Returns the localized resource string for a given message key, treating all values appended with "|" as replacement parameters.

If the key was found in the bundle, it will be formatted using a MessageFormat using the provided parameters. The parameters have to be appended to the key separated by a "|". For example, the keyName error.message|First|Second would use the key error.message with the parameters First and Second.

protected  voidsetBundleName(String bundleName)
    
protected  voidsetLocale(Locale locale)
    
protected  voidsetResourceBundle(ResourceBundle resourceBundle)
    
public  StringtoString()
    

Field Detail
KEY_SHORT_SUFFIX
final public static String KEY_SHORT_SUFFIX(Code)
The suffix of a "short" localized key name.



UNKNOWN_KEY_EXTENSION
final public static String UNKNOWN_KEY_EXTENSION(Code)
Prefix / Suffix for unknown keys.




Constructor Detail
CmsMessages
public CmsMessages(String bundleName, Locale locale)(Code)
Constructor for the messages with an initialized java.util.Locale.
Parameters:
  bundleName - the base ResourceBundle name
Parameters:
  locale - the m_locale to use, eg. "de", "en" etc.



CmsMessages
public CmsMessages(String bundleName, String language)(Code)
Constructor for the messages with a language string.

The language is a 2 letter language ISO code, e.g. "EN".

The Locale for the messages will be created like this:
new Locale(language, "", "").


Parameters:
  bundleName - the base ResourceBundle name
Parameters:
  language - ISO language indentificator for the m_locale of the bundle




CmsMessages
public CmsMessages(String bundleName, String language, String country)(Code)
Constructor for the messages with language and country code strings.

The language is a 2 letter language ISO code, e.g. "EN". The country is a 2 letter country ISO code, e.g. "us".

The Locale for the messages will be created like this:
new Locale(language, country, "").
Parameters:
  bundleName - the base ResourceBundle name
Parameters:
  language - ISO language indentificator for the m_locale of the bundle
Parameters:
  country - ISO 2 letter country code for the m_locale of the bundle




CmsMessages
public CmsMessages(String bundleName, String language, String country, String variant)(Code)
Constructor for the messages with language, country code and variant strings.

The language is a 2 letter language ISO code, e.g. "EN". The country is a 2 letter country ISO code, e.g. "us". The variant is a vendor or browser-specific code, e.g. "POSIX".

The Locale for the messages will be created like this:
new Locale(language, country, variant).
Parameters:
  bundleName - the base ResourceBundle name
Parameters:
  language - language indentificator for the m_locale of the bundle
Parameters:
  country - 2 letter country code for the m_locale of the bundle
Parameters:
  variant - a vendor or browser-specific variant code




CmsMessages
protected CmsMessages()(Code)
Empty constructor for subclassing.





Method Detail
equals
public boolean equals(Object obj)(Code)

See Also:   java.lang.Object.equals(java.lang.Object)



formatUnknownKey
public static String formatUnknownKey(String keyName)(Code)
Formats an unknown key.


Parameters:
  keyName - the key to format the formatted unknown key
See Also:   CmsMessages.isUnknownKey(String)




getBundleName
protected String getBundleName()(Code)
Returns the name of the resource bundle this object was initialized with.

the name of the resource bundle this object was initialized with




getDate
public String getDate(Date date)(Code)
Returns a formated date String from a Date value, the format being DateFormat.SHORT and the locale based on this instance.


Parameters:
  date - the Date object to format as String the formatted date




getDate
public String getDate(Date date, int format)(Code)
Returns a formated date String from a Date value, the formatting based on the provided option and the locale based on this instance.


Parameters:
  date - the Date object to format as String
Parameters:
  format - the format to use, see CmsMessages for possible values the formatted date




getDate
public String getDate(long time)(Code)
Returns a formated date String from a timestamp value, the format being DateFormat.SHORT and the locale based on this instance.


Parameters:
  time - the time value to format as date the formatted date




getDateTime
public String getDateTime(Date date)(Code)
Returns a formated date and time String from a Date value, the format being DateFormat.SHORT and the locale based on this instance.


Parameters:
  date - the Date object to format as String the formatted date and time




getDateTime
public String getDateTime(Date date, int format)(Code)
Returns a formated date and time String from a Date value, the formatting based on the provided option and the locale based on this instance.


Parameters:
  date - the Date object to format as String
Parameters:
  format - the format to use, see CmsMessages for possible values the formatted date and time




getDateTime
public String getDateTime(long time)(Code)
Returns a formated date and time String from a timestamp value, the format being DateFormat.SHORT and the locale based on this instance.


Parameters:
  time - the time value to format as date the formatted date and time




getLocale
public Locale getLocale()(Code)
Returns the locale to use for looking up this messages.

the locale to use for looking up this messages




getResourceBundle
public ResourceBundle getResourceBundle()(Code)
Returns the resource bundle this message object was initialized with.

the resource bundle this message object was initialized with or null if initialization was not successful




getString
public String getString(String keyName) throws CmsMessageException(Code)
Directly calls the getString(String) method of the wrapped ResourceBundle.

If you use this this class on a template, you should consider using the CmsMessages.key(String) method to get the value from the ResourceBundle because it handles the exception for you in a convenient way.
Parameters:
  keyName - the key the resource string for the given key
throws:
  CmsMessageException - in case the key is not found or the bundle is not initialized




hashCode
public int hashCode()(Code)

See Also:   java.lang.Object.hashCode



isInitialized
public boolean isInitialized()(Code)
Checks if the bundle was properly initialized. true if bundle was initialized, false otherwise



isUnknownKey
public static boolean isUnknownKey(String value)(Code)
Returns true if the provided value matches the scheme "??? " + keyName + " ???", that is the value appears to be an unknown key.

Also returns true if the given value is null.


Parameters:
  value - the value to check true if the value is matches the scheme for unknown keys
See Also:   CmsMessages.formatUnknownKey(String)




key
public String key(String keyName)(Code)
Returns the localized resource string for a given message key.

If the key was not found in the bundle, the return value is "??? " + keyName + " ???". This will also be returned if the bundle was not properly initialized first.
Parameters:
  keyName - the key for the desired string the resource string for the given key




key
public String key(String keyName, boolean allowNull)(Code)
Returns the localized resource string for a given message key.

If the key was not found in the bundle, the return value depends on the setting of the allowNull parameter. If set to false, the return value is always a String in the format "??? " + keyName + " ???". If set to true, null is returned if the key is not found. This will also be returned if the bundle was not properly initialized first.
Parameters:
  keyName - the key for the desired string
Parameters:
  allowNull - if true, 'null' is an allowed return value the resource string for the given key




key
public String key(String key, Object arg0)(Code)
Returns the selected localized message for the initialized resource bundle and locale.

Convenience method for messages with one argument.


Parameters:
  key - the message key
Parameters:
  arg0 - the message argument the selected localized message for the initialized resource bundle and locale




key
public String key(String key, Object arg0, Object arg1)(Code)
Returns the selected localized message for the initialized resource bundle and locale.

Convenience method for messages with two arguments.


Parameters:
  key - the message key
Parameters:
  arg0 - the first message argument
Parameters:
  arg1 - the second message argument the selected localized message for the initialized resource bundle and locale




key
public String key(String key, Object arg0, Object arg1, Object arg2)(Code)
Returns the selected localized message for the initialized resource bundle and locale.

Convenience method for messages with three arguments.


Parameters:
  key - the message key
Parameters:
  arg0 - the first message argument
Parameters:
  arg1 - the second message argument
Parameters:
  arg2 - the third message argument the selected localized message for the initialized resource bundle and locale




key
public String key(String key, Object[] args)(Code)
Returns the selected localized message for the initialized resource bundle and locale.

If the key was found in the bundle, it will be formatted using a MessageFormat using the provided parameters.

If the key was not found in the bundle, the return value is "??? " + keyName + " ???". This will also be returned if the bundle was not properly initialized first.
Parameters:
  key - the message key
Parameters:
  args - the message arguments the selected localized message for the initialized resource bundle and locale




keyDefault
public String keyDefault(String keyName, String defaultValue)(Code)
Returns the localized resource string for a given message key.

If the key was not found in the bundle, the provided default value is returned.


Parameters:
  keyName - the key for the desired string
Parameters:
  defaultValue - the default value in case the key does not exist in the bundle the resource string for the given key it it exists, or the given default if not




keyWithParams
public String keyWithParams(String keyName)(Code)
Returns the localized resource string for a given message key, treating all values appended with "|" as replacement parameters.

If the key was found in the bundle, it will be formatted using a MessageFormat using the provided parameters. The parameters have to be appended to the key separated by a "|". For example, the keyName error.message|First|Second would use the key error.message with the parameters First and Second. This would be the same as calling CmsMessages.key(StringObject[]) .

If no parameters are appended with "|", this is the same as calling CmsMessages.key(String) .

If the key was not found in the bundle, the return value is "??? " + keyName + " ???". This will also be returned if the bundle was not properly initialized first.
Parameters:
  keyName - the key for the desired string, optinally containing parameters appended with a "|" the resource string for the given key
See Also:   CmsMessages.key(String,Object[])
See Also:   CmsMessages.key(String)




setBundleName
protected void setBundleName(String bundleName)(Code)
Sets the bundleName.


Parameters:
  bundleName - the bundleName to set




setLocale
protected void setLocale(Locale locale)(Code)
Sets the locale.


Parameters:
  locale - the locale to set




setResourceBundle
protected void setResourceBundle(ResourceBundle resourceBundle)(Code)
Sets the resource bundle.


Parameters:
  resourceBundle - the resource bundle to set




toString
public String toString()(Code)

See Also:   java.lang.Object.toString



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.