Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.opencms.flex.util
Class CmsMessages  view CmsMessages download CmsMessages.java

java.lang.Object
  extended bycom.opencms.flex.util.CmsMessages

public final class CmsMessages
extends java.lang.Object

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() 55 method that can be checked to see if the instance was properly initialized.

Since:
5.0 beta 2
Version:
$Revision: 1.6 $

Field Summary
private  java.util.ResourceBundle m_bundle
           
private  java.util.Locale m_locale
           
 
Constructor Summary
CmsMessages(java.lang.String baseName, java.util.Locale locale)
          Constructor for the messages with an initialized java.util.Locale.
CmsMessages(java.lang.String baseName, java.lang.String language)
          Constructor for the messages with a language string.
CmsMessages(java.lang.String baseName, java.lang.String language, java.lang.String country)
          Constructor for the messages with language and country code strings.
CmsMessages(java.lang.String baseName, java.lang.String language, java.lang.String country, java.lang.String variant)
          Constructor for the messages with language, country code and variant strings.
 
Method Summary
 java.lang.String getDate(java.util.Date date)
          Returns a formatted date.
 java.lang.String getDate(java.util.Date date, int style)
          Returns a formatted date.
 java.lang.String getDate(long timestamp)
          Returns a formatted date.
 java.lang.String getDateTime(java.util.Date date)
          Returns a formatted date with a time.
 java.lang.String getDateTime(java.util.Date date, int style)
          Returns a formatted date with a time.
 java.lang.String getDateTime(long timestamp)
          Returns a formatted date with a time.
 java.lang.String getString(java.lang.String keyName)
          Directly calls the getString(String) method of the wrapped ResourceBundle.
 boolean isInitialized()
          Checks if the bundle was properly initialized.
 java.lang.String key(java.lang.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
 

Field Detail

m_bundle

private java.util.ResourceBundle m_bundle

m_locale

private java.util.Locale m_locale
Constructor Detail

CmsMessages

public CmsMessages(java.lang.String baseName,
                   java.util.Locale locale)
Constructor for the messages with an initialized java.util.Locale.


CmsMessages

public CmsMessages(java.lang.String baseName,
                   java.lang.String language)
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, "", "").


CmsMessages

public CmsMessages(java.lang.String baseName,
                   java.lang.String language,
                   java.lang.String country)
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, "").


CmsMessages

public CmsMessages(java.lang.String baseName,
                   java.lang.String language,
                   java.lang.String country,
                   java.lang.String variant)
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).

Method Detail

isInitialized

public boolean isInitialized()
Checks if the bundle was properly initialized.


key

public java.lang.String key(java.lang.String keyName)
Gets 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.


getString

public java.lang.String getString(java.lang.String keyName)
                           throws java.util.MissingResourceException
Directly calls the getString(String) method of the wrapped ResourceBundle.

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


getDate

public java.lang.String getDate(long timestamp)
Returns a formatted date.


getDate

public java.lang.String getDate(java.util.Date date)
Returns a formatted date.


getDate

public java.lang.String getDate(java.util.Date date,
                                int style)
Returns a formatted date.


getDateTime

public java.lang.String getDateTime(long timestamp)
Returns a formatted date with a time.


getDateTime

public java.lang.String getDateTime(java.util.Date date)
Returns a formatted date with a time.


getDateTime

public java.lang.String getDateTime(java.util.Date date,
                                    int style)
Returns a formatted date with a time.