com.sap.mdm.logging
Class MessageResolver

java.lang.Object
  extended bycom.sap.mdm.logging.MessageResolver

public class MessageResolver
extends Object

The class is used to get translated semantic messages for logging. The language of the translated message can be specified by locale parameter, if no locale specified the current value of the default locale of the JVM is used. There is option to specify user defined resource bundle for a messages. If no resource bundle specified the API default resource bundle is used.

Since:
7.1.07

Method Summary
static Locale getCurrentLocale()
          Returns the current value of locale
static String getExceptionMessage(String key)
          Returns translated message.
static String getExceptionMessage(String key, Locale locale)
          Returns translated message.
static String getExceptionMessage(String key, Object param)
          Returns translated message formatted using the given parameter.
static String getExceptionMessage(String key, Object[] params)
          Returns translated message formatted using the given parameter.
static String getExceptionMessage(String key, Object[] params, Locale locale)
          Returns translated message formatted using the given parameter.
static String getExceptionMessage(String key, Object param, Locale locale)
          Returns translated message formatted using the given parameter.
static String getLogMessage(String key)
          Returns translated message.
static String getLogMessage(String key, Locale locale)
          Returns translated message.
static String getLogMessage(String key, Object param)
          Returns translated message formatted using the given parameter.
static String getLogMessage(String key, Object[] params)
          Returns translated message formatted using the given parameter.
static String getLogMessage(String key, Object[] params, Locale locale)
          Returns translated message formatted using the given parameter.
static String getLogMessage(String key, Object param, Locale locale)
          Returns translated message formatted using the given parameter.
static String getMessage(String key, Locale locale, String resourceBundleBaseName)
          Returns the translated and formatted message.
static String getMessage(String key, Object[] params, Locale locale, String resourceBundleBaseName)
          Returns the translated and formatted message.
static String getMessage(String key, Object[] params, String resourceBundleBaseName)
          Returns the translated and formatted message.
static String getMessage(String key, Object param, Locale locale, String resourceBundleBaseName)
          Returns the translated and formatted message.
static String getMessage(String key, Object param, String resourceBundleBaseName)
          Returns the translated and formatted message.
static String getMessage(String key, String resourceBundleBaseName)
          Returns the translated and formatted message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLogMessage

public static String getLogMessage(String key)
Returns translated message.

The message is taken from the default log resource bundle. The message is translated into the language specified by the current value of the JVM locale.

Parameters:
key - key of the message in the resource bundle
Returns:
translated message

getLogMessage

public static String getLogMessage(String key,
                                   Locale locale)
Returns translated message.

The message is taken from the default log resource bundle. The message is translated into the language specified by locale parameter.

Parameters:
key - key of the message in resource bundle
locale - locale specifies the desired language of the translation for the message. if null uses the current value from the JVM
Returns:
translated message

getLogMessage

public static String getLogMessage(String key,
                                   Object param)
Returns translated message formatted using the given parameter.

The message is taken from the default log resource bundle. The message is translated into the language specified by the current value of the JVM locale.

Parameters:
key - key of the message in resource bundle
param - object used to format the message
Returns:
translated and formatted message

getLogMessage

public static String getLogMessage(String key,
                                   Object param,
                                   Locale locale)
Returns translated message formatted using the given parameter.

The message is taken from the default log resource bundle. The message is translated into the language specified by locale parameter.

Parameters:
key - key of the message in resource bundle
param - object used to format the message
locale - locale specifies the desired language of the translation for the message. if null uses the current value of the locale for the JVM.
Returns:
translated and formatted message

getLogMessage

public static String getLogMessage(String key,
                                   Object[] params)
Returns translated message formatted using the given parameter.

The message is taken from the default resource bundle. The message is translated into the language specified by the current value of the JVM locale.

Parameters:
key - key of the message in resource bundle
params - array of objects used to format the message
Returns:
translated and formatted message

getLogMessage

public static String getLogMessage(String key,
                                   Object[] params,
                                   Locale locale)
Returns translated message formatted using the given parameter.

The message is taken from the default resource bundle. The message is translated into the language specified by locale parameter.

Parameters:
key - key of the message in resource bundle
params - array of objects used to format the message
locale - locale specifies the desired language of the translation for the message. if null uses the current value of the locale for the JVM.
Returns:
translated and formatted message

getExceptionMessage

public static String getExceptionMessage(String key)
Returns translated message.

The message is taken from the default resource bundle. The message is translated into the language specified by the current value of the JVM locale.

Parameters:
key - key of the message in the resource bundle
Returns:
translated message

getExceptionMessage

public static String getExceptionMessage(String key,
                                         Locale locale)
Returns translated message.

The message is taken from the default resource bundle. The message is translated into the language specified by locale parameter.

Parameters:
key - key of the message in resource bundle
locale - locale specifies the desired language of the translation for the message. if null uses the current value of the locale for the JVM
Returns:
translated message

getExceptionMessage

public static String getExceptionMessage(String key,
                                         Object param)
Returns translated message formatted using the given parameter.

The message is taken from the default resource bundle. The message is translated into the language specified by the current value of default locale.

Parameters:
key - key of the message in resource bundle
param - object used to format the message
Returns:
translated and formatted message

getExceptionMessage

public static String getExceptionMessage(String key,
                                         Object param,
                                         Locale locale)
Returns translated message formatted using the given parameter.

The message is taken from the default resource bundle. The message is translated into the language specified by locale parameter.

Parameters:
key - key of the message in resource bundle
param - object used to format the message
locale - locale specifies the desired language of the translation for the message. if null uses the current value of the locale for the JVM.
Returns:
translated and formatted message

getExceptionMessage

public static String getExceptionMessage(String key,
                                         Object[] params)
Returns translated message formatted using the given parameter.

The message is taken from the default resource bundle. The message is translated into the language specified by the current value of the JVM locale.

Parameters:
key - key of the message in resource bundle
params - array of objects used to format the message
Returns:
translated and formatted message

getExceptionMessage

public static String getExceptionMessage(String key,
                                         Object[] params,
                                         Locale locale)
Returns translated message formatted using the given parameter.

The message is taken from the default resource bundle. The message is translated into the language specified by locale parameter.

Parameters:
key - key of the message in resource bundle
params - array of objects used to format the message
locale - locale specifies the desired language of the translation for the message. if null uses the current value of the JVM locale.
Returns:
translated and formatted message

getMessage

public static String getMessage(String key,
                                String resourceBundleBaseName)
Returns the translated and formatted message.

The message is taken from the resource bundle specified by user. The message is translated into the language specified by the current value of the JVM locale.

Parameters:
key - the key of the message in resource bundle
resourceBundleBaseName - the base name of the resource bundle, a fully qualified class name. If null uses the default name 'MessagesBundle'
Returns:
the translated and formatted message
Throws:
IllegalArgumentException - if message cannot be formatted

getMessage

public static String getMessage(String key,
                                Locale locale,
                                String resourceBundleBaseName)
Returns the translated and formatted message.

The message is taken from the resource bundle specified by user. The message is translated into the language specified by locale parameter.

Parameters:
key - the key of the message in resource bundle
locale - specifies the desired language of the translation for the message. If null uses the current value of the locale for the JVM.
resourceBundleBaseName - the base name of the resource bundle, a fully qualified class name. If null uses the default name 'MessagesBundle'
Returns:
the translated and formatted message
Throws:
IllegalArgumentException - if message cannot be formatted

getMessage

public static String getMessage(String key,
                                Object param,
                                String resourceBundleBaseName)
Returns the translated and formatted message.

The message is taken from the resource bundle specified by user. The message is translated into the language specified by the current value of the JVM locale. The message is formatted using the specified parameter.

Parameters:
key - the key of the message in resource bundle
param - the parameter used for formatting the message
resourceBundleBaseName - the base name of the resource bundle, a fully qualified class name. If null uses the default name 'MessagesBundle'
Returns:
the translated and formatted message
Throws:
IllegalArgumentException - if message cannot be formatted

getMessage

public static String getMessage(String key,
                                Object param,
                                Locale locale,
                                String resourceBundleBaseName)
Returns the translated and formatted message.

The message is taken from the resource bundle specified by user. The message is translated into the language specified by locale parameter. The message is formatted using the specified parameter.

Parameters:
key - the key of the message in resource bundle
param - the parameter used for formatting the message
locale - specifies the desired language of the translation for the message. If null uses the current value of the locale for the JVM.
resourceBundleBaseName - the base name of the resource bundle, a fully qualified class name. If null uses the default name 'MessagesBundle'
Returns:
the translated and formatted message
Throws:
IllegalArgumentException - if message cannot be formatted

getMessage

public static String getMessage(String key,
                                Object[] params,
                                String resourceBundleBaseName)
Returns the translated and formatted message.

The message is taken from the resource bundle specified by user. The message is translated into the language specified by the current value of the JVM locale. The message is formatted using the specified parameters.

Parameters:
key - the key of the message in resource bundle
params - an array of parameter objects used for formatting the message
resourceBundleBaseName - the base name of the resource bundle, a fully qualified class name. If null uses the default name 'MessagesBundle'
Returns:
the translated and formatted message
Throws:
IllegalArgumentException - if message cannot be formatted

getMessage

public static String getMessage(String key,
                                Object[] params,
                                Locale locale,
                                String resourceBundleBaseName)
Returns the translated and formatted message.

The message is taken from the resource bundle specified by user. The message is translated into the language specified by locale parameter. The message is formatted using the specified parameters.

Parameters:
key - the key of the message in resource bundle
params - an array of parameter objects used for formatting the message
locale - specifies the desired language of the translation for the message. If null uses the current value of the locale for the JVM.
resourceBundleBaseName - the base name of the resource bundle, a fully qualified class name. If null uses the default name 'MessagesBundle'
Returns:
the translated and formatted message
Throws:
IllegalArgumentException - if message cannot be formatted

getCurrentLocale

public static Locale getCurrentLocale()
Returns the current value of locale

Returns:
the current locale


Copyright 2004-2007 by SAP AG. All Rights Reserved.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies (SAP Group) for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.