to.etc.webapp.nls
Class BundleRef

java.lang.Object
  extended by to.etc.webapp.nls.BundleBase
      extended by to.etc.webapp.nls.BundleRef
All Implemented Interfaces:
IBundle, NlsMessageProvider

public final class BundleRef
extends BundleBase
implements IBundle

A bundleRef represents a single set of messages in multiple languages. It differs from a ResourceBundle in that a single instantiated ResourceBundle is always for a single language; this makes a ResourceBundle unusable for server based code since every request can be in a different language.

BundleRefs specify a code location in the webapp's classpath. The code location consists of a class which defines the "start location" to look for the message files and which determines the basic classloader to use to load those files. BundleRef's are cached globally; when you define the same BundleRef multiple times in the code you will always get a reference to the same bundle. This prevents the same bundle from being reloaded multiple times.

Author:
Frits Jalvingh Created on Sep 18, 2006

Method Summary
static BundleRef create(java.lang.Class<?> clz, java.lang.String name)
          Create or find the BundleRef representing this path.
static BundleRef createWrapper(NlsMessageProvider mp)
           
 boolean exists()
           
 java.lang.String findMessage(java.util.Locale loc, java.lang.String code)
          Locate the specified key for the specified locale.
 
Methods inherited from class to.etc.webapp.nls.BundleBase
formatMessage, getString, getString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface to.etc.webapp.nls.IBundle
formatMessage, getString, getString
 

Method Detail

createWrapper

public static BundleRef createWrapper(NlsMessageProvider mp)

create

public static BundleRef create(java.lang.Class<?> clz,
                               java.lang.String name)
Create or find the BundleRef representing this path. If the ref already exists it gets returned, else it gets created lazily.

Parameters:
clz -
name -
Returns:

exists

public boolean exists()

findMessage

public 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
Specified by:
findMessage in class BundleBase
Returns: