org.objectweb.easybeans.i18n
Class I18n

java.lang.Object
  extended by org.objectweb.easybeans.i18n.I18n

public final class I18n
extends java.lang.Object

This class defines the way for getting message with ResourceBundle for different language. Inspired from http://java.sun.com/docs/books/tutorial/i18n/

Author:
Florent Benoit

Field Summary
private static java.util.Map<java.lang.String,I18n> bundles
          List of our I18n objects.
private static java.lang.String RESOURCE_BUNDLE_NAME
          Name of the resource bundle to use.
private  java.util.ResourceBundle resourceBundle
          Internal Resource Bundle.
 
Constructor Summary
private I18n(java.lang.String packageName, java.lang.ClassLoader cl)
          Constructor (private access, use getInstance instead).
 
Method Summary
static I18n getInstance(java.lang.Class c)
          Gets the instance for a given class.
static I18n getInstance(java.lang.Class c, java.lang.ClassLoader cl)
          Gets the instance for a given class.
static I18n getInstance(java.lang.String packageName)
          Gets the instance for a given package.
static I18n getInstance(java.lang.String packageName, java.lang.ClassLoader cl)
          Gets the instance for a given package.
 java.lang.String getMessage(java.lang.String key, java.lang.Object... objs)
          Gets the formatted string with the given arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_BUNDLE_NAME

private static final java.lang.String RESOURCE_BUNDLE_NAME
Name of the resource bundle to use.

See Also:
Constant Field Values

bundles

private static java.util.Map<java.lang.String,I18n> bundles
List of our I18n objects.


resourceBundle

private java.util.ResourceBundle resourceBundle
Internal Resource Bundle.

Constructor Detail

I18n

private I18n(java.lang.String packageName,
             java.lang.ClassLoader cl)
Constructor (private access, use getInstance instead).

Parameters:
packageName - name of the package for the bundle.
cl - the classloader used to load bundle.
Method Detail

getInstance

public static I18n getInstance(java.lang.Class c)
Gets the instance for a given class.

Parameters:
c - the class for which we want a bundle.
Returns:
I18n object.

getInstance

public static I18n getInstance(java.lang.Class c,
                               java.lang.ClassLoader cl)
Gets the instance for a given class.

Parameters:
c - the class for which we want a bundle.
cl - the classloader used to load bundle.
Returns:
I18n object.

getInstance

public static I18n getInstance(java.lang.String packageName)
Gets the instance for a given package.

Parameters:
packageName - the package for which we want a bundle.
Returns:
I18n object.

getInstance

public static I18n getInstance(java.lang.String packageName,
                               java.lang.ClassLoader cl)
Gets the instance for a given package.

Parameters:
packageName - the package for which we want a bundle.
cl - the classloader used to load bundle.
Returns:
I18n object.

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object... objs)
Gets the formatted string with the given arguments.

Parameters:
key - the keystring on which to apply arguments.
objs - list of argument for the formatter.
Returns:
the formatted string.