org.chwf.i18n
Class Message

java.lang.Object
  |
  +--org.chwf.i18n.Message
All Implemented Interfaces:
java.io.Serializable

public class Message
extends java.lang.Object
implements java.io.Serializable

A class for encapsulating an internationalizable message. It is designed to defer computation of the message, to handle the situation when the precise locale is not available at the time when the message is generated. All the information necessary to generate the message is stored in the Message object. It can be printed out using the message's toString() method when the message reaches a point where it is possible to determine the locale.

Every message has a context class. This class will typically be the class that created the message. The context class is used to determine which configuration file should be used to load internationalized messages from.

When the message is rendered, the precise locale is determined using UserLocale.getLocale().

Author:
Paul Strack
See Also:
Serialized Form

Field Summary
static java.lang.Object[] NO_ARGUMENTS
          An empty array for constructing messages with no arguments.
 
Method Summary
static Message getMessage(java.lang.String key, java.lang.Object[] arguments, java.lang.Class context)
          Create a message object.
static Message getMessage(java.lang.String key, java.lang.Object[] arguments, java.lang.String context)
          Create a message object.
 java.lang.String toString()
          Returns the formatted message using the user's locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_ARGUMENTS

public static final java.lang.Object[] NO_ARGUMENTS
An empty array for constructing messages with no arguments.
Method Detail

getMessage

public static Message getMessage(java.lang.String key,
                                 java.lang.Object[] arguments,
                                 java.lang.Class context)
Create a message object.

Parameters:
key - The message key. If the key lookup fails, the key is used as the pattern instead.
arguments - The arguments for the pattern.
context - The context class.
Returns:
The message object.

getMessage

public static Message getMessage(java.lang.String key,
                                 java.lang.Object[] arguments,
                                 java.lang.String context)
Create a message object.

Parameters:
key - The message key. If the key lookup fails, the key is used as the pattern instead.
arguments - The arguments for the pattern.
context - The context resource.
Returns:
The message object.

toString

public java.lang.String toString()
Returns the formatted message using the user's locale.

Overrides:
toString in class java.lang.Object
Returns:
The formatted message.


Copyright © 2002-2004, Paul Strack. All Rights Reserved.