uk.org.ogsadai.common.msgs
Class MessageLoader

java.lang.Object
  |
  +--uk.org.ogsadai.common.msgs.MessageLoader

public class MessageLoader
extends java.lang.Object

Utility methods for loading messages from the OGSA-DAI message bundle.

The OGSA-DAI message bundle is assumed to be in a file ogsadai_messages.properties

.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static DAILogger LOG
          DAILogger object for logging in this class.
private static DAIResourceBundle mBundle
          The resource bundle containing the messages.
 
Constructor Summary
private MessageLoader()
          Private constructor - class contains only static utility methods.
 
Method Summary
static java.lang.String getLocalizedMessage(MessageID key)
          Get the message corresponding to the specified key.
static java.lang.String getLocalizedMessage(MessageID key, DAIUniqueID uniqueID)
          Get the message corresponding to the specified key.
static java.lang.String getLocalizedMessage(MessageID key, java.lang.Object[] parameters)
          Get the message corresponding to the specified key and parameters.
static java.lang.String getLocalizedMessage(MessageID key, java.lang.Object[] parameters, DAIUniqueID uniqueID)
          Get the message corresponding to the specified key and parameters.
private static java.lang.String getLocalizedMessage(java.lang.String key)
          Get the message corresponding to the specified key.
private static java.lang.String getLocalizedMessage(java.lang.String key, DAIUniqueID uniqueID)
          Get the message corresponding to the specified key.
private static java.lang.String getLocalizedMessage(java.lang.String key, java.lang.Object[] parameters)
          Get the message corresponding to the specified key and parameters.
private static java.lang.String getLocalizedMessage(java.lang.String key, java.lang.Object[] parameters, DAIUniqueID uniqueID)
          Get the message corresponding to the specified key and parameters.
static java.lang.String getMessage(MessageID key)
          Get the message corresponding to the specified key.
static java.lang.String getMessage(MessageID key, DAIUniqueID uniqueID)
          Get the message corresponding to the specified key.
static java.lang.String getMessage(MessageID key, java.lang.Object[] parameters)
          Get the message corresponding to the specified key and parameters.
static java.lang.String getMessage(MessageID key, java.lang.Object[] parameters, DAIUniqueID uniqueID)
          Get the message corresponding to the specified key and parameters.
private static java.lang.String getMessage(java.lang.String key)
          Get the message corresponding to the specified key.
private static java.lang.String getMessage(java.lang.String key, DAIUniqueID uniqueID)
          Get the message corresponding to the specified key.
private static java.lang.String getMessage(java.lang.String key, java.lang.Object[] parameters)
          Get the message corresponding to the specified key and parameters.
private static java.lang.String getMessage(java.lang.String key, java.lang.Object[] parameters, DAIUniqueID uniqueID)
          Get the message corresponding to the specified key and parameters.
private static java.lang.String getString(java.lang.String key)
          Get the message with the specified key or return null if the resource corresponding to the key cannot not be found.
static void registerMessageBundle(java.lang.String baseName, java.util.Locale locale)
          Registers a new resource bundle with this message loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

LOG

private static DAILogger LOG
DAILogger object for logging in this class.


mBundle

private static DAIResourceBundle mBundle
The resource bundle containing the messages.

Constructor Detail

MessageLoader

private MessageLoader()
Private constructor - class contains only static utility methods.

Method Detail

getString

private static java.lang.String getString(java.lang.String key)
Get the message with the specified key or return null if the resource corresponding to the key cannot not be found.

Parameters:
key - Resource key.
Returns:
resource name or null.

getLocalizedMessage

private static java.lang.String getLocalizedMessage(java.lang.String key)
Get the message corresponding to the specified key.

Parameters:
key - The key for the message.
Returns:
the message string or key if the message could not be located.

getLocalizedMessage

private static java.lang.String getLocalizedMessage(java.lang.String key,
                                                    DAIUniqueID uniqueID)
Get the message corresponding to the specified key.

Parameters:
key - The key for the message.
uniqueID - Unique ID for the message.
Returns:
the message string or [uniqueID] key if the message could not be located.

getLocalizedMessage

private static java.lang.String getLocalizedMessage(java.lang.String key,
                                                    java.lang.Object[] parameters)
Get the message corresponding to the specified key and parameters.

Parameters:
key - The key for the message.
parameters - An array of values to insert into the message parameters.
Returns:
the message string or a string of form key : param1 , param2 , ... if the message could not be located.

getLocalizedMessage

private static java.lang.String getLocalizedMessage(java.lang.String key,
                                                    java.lang.Object[] parameters,
                                                    DAIUniqueID uniqueID)
Get the message corresponding to the specified key and parameters.

Parameters:
key - The key for the message.
parameters - An array of values to insert into the message parameters.
uniqueID - Unique ID for the message.
Returns:
the message string or a string of form [uniqueID] key : param1 , param2 , ... if the message could not be located.

getMessage

private static java.lang.String getMessage(java.lang.String key)
Get the message corresponding to the specified key.

Parameters:
key - The key for the message.
Returns:
key

getMessage

private static java.lang.String getMessage(java.lang.String key,
                                           DAIUniqueID uniqueID)
Get the message corresponding to the specified key.

Parameters:
key - The key for the message.
uniqueID - Unique ID for the message.
Returns:
[uniqueID] key

getMessage

private static java.lang.String getMessage(java.lang.String key,
                                           java.lang.Object[] parameters)
Get the message corresponding to the specified key and parameters.

Parameters:
key - The key for the message.
parameters - An array of values to insert into the message parameters.
Returns:
key : param1 , param2 , ...

getMessage

private static java.lang.String getMessage(java.lang.String key,
                                           java.lang.Object[] parameters,
                                           DAIUniqueID uniqueID)
Get the message corresponding to the specified key and parameters.

Parameters:
key - The key for the message.
parameters - An array of values to insert into the message parameters.
uniqueID - Unique ID for the message.
Returns:
[uniqueID] key : param1 , param2 , ...

getLocalizedMessage

public static java.lang.String getLocalizedMessage(MessageID key)
Get the message corresponding to the specified key. If a message cannot be found then return the key.

Parameters:
key - MessageID key for the message
Returns:
the message string.

getLocalizedMessage

public static java.lang.String getLocalizedMessage(MessageID key,
                                                   DAIUniqueID uniqueID)
Get the message corresponding to the specified key. If a message cannot be found then return the key stamped with the given unique ID.

Parameters:
key - MessageID key for the message.
uniqueID - Unique ID for the message.
Returns:
the message string.

getLocalizedMessage

public static java.lang.String getLocalizedMessage(MessageID key,
                                                   java.lang.Object[] parameters)
Get the message corresponding to the specified key and parameters. If a message cannot be found then return the key and parameters.

Parameters:
key - The MessageID key for the message.
parameters - An array of values to insert into the message parameters.
Returns:
the message string.

getLocalizedMessage

public static java.lang.String getLocalizedMessage(MessageID key,
                                                   java.lang.Object[] parameters,
                                                   DAIUniqueID uniqueID)
Get the message corresponding to the specified key and parameters. If a message cannot be found then return the key and parameters stamped with the given unique ID.

Parameters:
key - The MessageID key for the message.
parameters - An array of values to insert into the message parameters.
uniqueID - Unique ID for the message.
Returns:
the message string.

getMessage

public static java.lang.String getMessage(MessageID key)
Get the message corresponding to the specified key.

Parameters:
key - MessageID key for the message
Returns:
key

getMessage

public static java.lang.String getMessage(MessageID key,
                                          DAIUniqueID uniqueID)
Get the message corresponding to the specified key.

Parameters:
key - MessageID key for the message.
uniqueID - Unique ID for the message.
Returns:
[uniqueID] key

getMessage

public static java.lang.String getMessage(MessageID key,
                                          java.lang.Object[] parameters)
Get the message corresponding to the specified key and parameters.

Parameters:
key - The MessageID key for the message.
parameters - An array of values to insert into the message parameters.
Returns:
key : param1 , param2 , ...

getMessage

public static java.lang.String getMessage(MessageID key,
                                          java.lang.Object[] parameters,
                                          DAIUniqueID uniqueID)
Get the message corresponding to the specified key and parameters.

Parameters:
key - The MessageID key for the message.
parameters - An array of values to insert into the message parameters.
uniqueID - Unique ID for the message.
Returns:
[uniqueID] key : param1 , param2 , ...

registerMessageBundle

public static void registerMessageBundle(java.lang.String baseName,
                                         java.util.Locale locale)
Registers a new resource bundle with this message loader. This will make the messages from the given property file available within the application.

Parameters:
baseName - base name of the resource bundle
locale - the locale to use