BEA Systems, Inc.

com.beasys.commerce.i18n
Class MessageBundle

java.lang.Object
  |
  +--com.beasys.commerce.i18n.MessageBundle
Direct Known Subclasses:
JspMessageBundle

public class MessageBundle
extends java.lang.Object

MessageBundle provides methods which facilitate the internationalization of applications through retrieval of locale-specific static text and constructed messages. Constructed messages are created when message arguments are passed into the getString() or getMessage() methods.


Field Summary
protected static boolean debug
           
protected  java.util.ResourceBundle resourceBundle
           
 
Constructor Summary
protected MessageBundle()
           
 
Method Summary
protected static void debug(java.lang.String aMessage)
          Convenience method for logging a LOG_DEBUG level message
protected static void error(java.lang.String aMessage, java.lang.Exception exception)
          Convenience method for logging a LOG_ERROR level message
static MessageBundle getBundle(java.lang.String baseName)
          Retrieves an instance of a MessageBundle, provided a base name from which the bundle can be constructed.
static MessageBundle getBundle(java.lang.String baseName, java.util.Locale locale)
          Get the appropriate ResourceBundle subclass.
static MessageBundle getBundle(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader loader)
          Get the appropriate ResourceBundle subclass.
static MessageBundle getInstance(java.lang.String baseName)
          Deprecated. Replaced by getBundle(String)
 java.util.Enumeration getKeys()
          Return an enumeration of the keys.
 java.util.Locale getLocale()
          Return the Locale for this MessageBundle.
 java.lang.String getMessage(java.lang.Object[] args, java.lang.String key)
          Constructs a message using the provided arguments and a key into the message bundle's properties table.
 java.lang.Object getObject(java.lang.String key)
          Get an object from a ResourceBundle.
 java.lang.String getString(java.lang.String key)
          Retrieves a static text segment using a key into the message bundle's properties table.
 java.lang.String[] getStringArray(java.lang.String key)
          Get an object from a ResourceBundle.
protected static void info(java.lang.String aMessage)
          Convenience method for logging a LOG_INFO level message
protected static void warning(java.lang.String aMessage)
          Convenience method for logging a LOG_WARNING level message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected static final boolean debug

resourceBundle

protected java.util.ResourceBundle resourceBundle
Constructor Detail

MessageBundle

protected MessageBundle()
Method Detail

getInstance

public static MessageBundle getInstance(java.lang.String baseName)
Deprecated. Replaced by getBundle(String)


getMessage

public java.lang.String getMessage(java.lang.Object[] args,
                                   java.lang.String key)
Constructs a message using the provided arguments and a key into the message bundle's properties table.
Parameters:
args - the arguments used to construct the message. For example, {"Wednesday", "78"};
key - the key into the MessageBundle object's properties For example, "dayAndTemp.msg"
Returns:
String the resultant message For example, "Today is Wednesday, and the temperature is 78 degrees."

getString

public java.lang.String getString(java.lang.String key)
Retrieves a static text segment using a key into the message bundle's properties table.
Parameters:
key - the key into the MessageBundle object's properties For example, "hello.txt"
Returns:
String the static text segment For example, "Hello."

getBundle

public static MessageBundle getBundle(java.lang.String baseName)
Retrieves an instance of a MessageBundle, provided a base name from which the bundle can be constructed.
Parameters:
baseName - the class name used to retrieve the bundle. An example of a base name is "com.beasys.commerce.portal.jspbeans.i18n.GenPrefs", where a text file titled "GenPrefs.properties" exists in the "i18n" directory under the "com.beasys.commerce.portal.jspbeans" package.
Returns:
a MessageBundle

getBundle

public static MessageBundle getBundle(java.lang.String baseName,
                                      java.util.Locale locale)
Get the appropriate ResourceBundle subclass.
Parameters:
baseName - the class name used to retrieve the bundle. An example of a base name is "com.beasys.commerce.portal.jspbeans.i18n.GenPrefs", where a text file titled "GenPrefs.properties" exists in the "i18n" directory under the "com.beasys.commerce.portal.jspbeans" package.
locale - the locale of preference for the resource bundle

getBundle

public static MessageBundle getBundle(java.lang.String baseName,
                                      java.util.Locale locale,
                                      java.lang.ClassLoader loader)
Get the appropriate ResourceBundle subclass.
Parameters:
baseName - the class name used to retrieve the bundle. An example of a base name is "com.beasys.commerce.portal.jspbeans.i18n.GenPrefs", where a text file titled "GenPrefs.properties" exists in the "i18n" directory under the "com.beasys.commerce.portal.jspbeans" package.
locale - the locale of preference for the resource bundle
loader - the class loader to use when trying to load the resource

getKeys

public java.util.Enumeration getKeys()
Return an enumeration of the keys.

getLocale

public java.util.Locale getLocale()
Return the Locale for this MessageBundle. (This function can be used after a call to getBundle() to determine whether the MessageBundle returned really corresponds to the requested locale or is a fallback.)
Returns:
the Locale for this MessageBundle

getObject

public java.lang.Object getObject(java.lang.String key)
Get an object from a ResourceBundle.

getStringArray

public java.lang.String[] getStringArray(java.lang.String key)
Get an object from a ResourceBundle.

debug

protected static void debug(java.lang.String aMessage)
Convenience method for logging a LOG_DEBUG level message

info

protected static void info(java.lang.String aMessage)
Convenience method for logging a LOG_INFO level message

warning

protected static void warning(java.lang.String aMessage)
Convenience method for logging a LOG_WARNING level message

error

protected static void error(java.lang.String aMessage,
                            java.lang.Exception exception)
Convenience method for logging a LOG_ERROR level message

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved