to.etc.webapp.nls
Class BundleBase

java.lang.Object
  extended by to.etc.webapp.nls.BundleBase
All Implemented Interfaces:
NlsMessageProvider
Direct Known Subclasses:
BundleRef, BundleStack

public abstract class BundleBase
extends java.lang.Object
implements NlsMessageProvider

Base class for bundle related things, exposing formatters and other code around the single "findMessage" method.

Author:
Frits Jalvingh Created on Dec 31, 2010

Constructor Summary
BundleBase()
           
 
Method Summary
abstract  java.lang.String findMessage(java.util.Locale loc, java.lang.String code)
          Locate the specified key for the specified locale.
 java.lang.String formatMessage(java.lang.String key, java.lang.Object... param)
          Gets the string, and applies default message formatting using the parameters passed in the current locale.
 java.lang.String getString(java.util.Locale loc, java.lang.String key)
          Returns a translation of key in the specified locale (or the one closest to it).
 java.lang.String getString(java.lang.String key)
          Returns the translation of the key passed in the current client locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BundleBase

public BundleBase()
Method Detail

findMessage

public abstract java.lang.String findMessage(java.util.Locale loc,
                                             java.lang.String code)
Description copied from interface: NlsMessageProvider
Locate the specified key for the specified locale. This does fallback, meaning that if the exact locale is not matched it will try a less restrictive one, until the empty (default) locale has been reached. The first match is returned; if not even the empty locale returns a match this returns null.

Specified by:
findMessage in interface NlsMessageProvider
Returns:

getString

public java.lang.String getString(java.util.Locale loc,
                                  java.lang.String key)
Returns a translation of key in the specified locale (or the one closest to it). If no translation exists for the message in the specified bundle then we try the "default" bundle; if it still does not exist we return a string containing the key with ????.

Parameters:
loc -
key -
Throws:
ResourceNotFoundException - the bundle cannot be located.

getString

public java.lang.String getString(java.lang.String key)
Returns the translation of the key passed in the current client locale.

Parameters:
key -
Returns:

formatMessage

public java.lang.String formatMessage(java.lang.String key,
                                      java.lang.Object... param)
Gets the string, and applies default message formatting using the parameters passed in the current locale.

Parameters:
key -
param -
Returns: