|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.opencms.flex.util.CmsMessages
Reads localized resource Strings from a java.util.ResourceBundle
and provides convenience methods to access the Strings from a template.
This class is to be 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 isInitialized() method
that can be checked to see if the instance was properly initialized.
| Constructor Summary | |
CmsMessages(String baseName,
Locale locale)
Constructor for the messages with an initialized java.util.Locale. |
|
CmsMessages(String baseName,
String language)
Constructor for the messages with a language string. |
|
CmsMessages(String baseName,
String language,
String country)
Constructor for the messages with language and country code strings. |
|
CmsMessages(String baseName,
String language,
String country,
String variant)
Constructor for the messages with language, country code and variant strings. |
|
| Method Summary | |
String |
getDate(Date date)
Returns a formatted date. |
String |
getDate(Date date,
int style)
Returns a formatted date. |
String |
getDate(long timestamp)
Returns a formatted date. |
String |
getDateTime(Date date)
Returns a formatted date with a time. |
String |
getDateTime(Date date,
int style)
Returns a formatted date with a time. |
String |
getDateTime(long timestamp)
Returns a formatted date with a time. |
String |
getString(String keyName)
Directly calls the getString(String) method of the wrapped ResourceBundle. |
boolean |
isInitialized()
Checks if the bundle was properly initialized. |
String |
key(String keyName)
Gets the localized resource string for a given message key. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CmsMessages(String baseName,
Locale locale)
java.util.Locale.
baseName - the base ResourceBundle name
public CmsMessages(String baseName,
String language)
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, "", "").
baseName - the base ResourceBundle namelanguage - ISO language indentificator for the locale of the bundle
public CmsMessages(String baseName,
String language,
String country)
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, "").
baseName - the base ResourceBundle namelanguage - ISO language indentificator for the locale of the bundlecountry - ISO 2 letter country code for the locale of the bundle
public CmsMessages(String baseName,
String language,
String country,
String variant)
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).
baseName - the base ResourceBundle namelanguage - language indentificator for the locale of the bundlecountry - 2 letter country code for the locale of the bundlevariant - a vendor or browser-specific variant code| Method Detail |
public boolean isInitialized()
true if bundle was initialized, false otherwisepublic String key(String keyName)
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.
keyName - the key for the desired string
public String getString(String keyName)
throws MissingResourceException
If you use this this class on a template, you should consider using
the key(String) method to get the value from the ResourceBundle because it
handles the exception for you in a convenient way.
keyName - the key
MissingResourceException - in case the key is not found of the bundle is not initializedpublic String getDate(long timestamp)
timestamp - the date timestamp to format
public String getDate(Date date)
date - the date to format
public String getDate(Date date,
int style)
date - the date to formatstyle - the style to format the date with
DateFormatpublic String getDateTime(long timestamp)
timestamp - the date timestamp to format
public String getDateTime(Date date)
date - the date to format
public String getDateTime(Date date,
int style)
date - the date to formatstyle - the style to format the date with
DateFormat
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||