com.retek.commons.gui.util
Class MessageTranslator

java.lang.Object
  extended bycom.retek.commons.gui.util.TranslatorManager
      extended bycom.retek.commons.gui.util.MessageTranslator

public class MessageTranslator
extends TranslatorManager

This class encapsulates a RPropertyBundle object and defines the KEY-VALUE pair as being a message code and fully translated message text. The message text in the properties file may contain {0} {1} {2} as placeholders for dynamic argument placing. The class supplies easy methods for accessing these underlying messages to retrieve internationalized messages.

Retek Inc. Copyright (c) 2002


Field Summary
 
Fields inherited from class com.retek.commons.gui.util.TranslatorManager
EMPTY
 
Constructor Summary
MessageTranslator()
          Returns new MessageManager object.
MessageTranslator(java.util.Locale locale, java.lang.String filename)
          Returns new MessageManager object.
MessageTranslator(java.lang.String filename)
          Returns new MessageManager object.
 
Method Summary
 java.lang.String getMessage(java.lang.Exception exception)
          Retrieves the expanded message translation for an generic exception message.
 java.lang.String getMessage(java.lang.String messageCode)
          Retrieves the expanded message translation for the specific message code.
 java.lang.String getMessage(java.lang.String messageCode, java.lang.String valueOne)
          Retrieves the expanded message translation for a specific message code.
 java.lang.String getMessage(java.lang.String messageCode, java.lang.String[] valueArray)
          Retrieves the expanded message translation for the specific message code.
 java.lang.String getMessage(java.lang.String messageCode, java.lang.String valueOne, java.lang.String valueTwo)
          Retrieves the expanded message translation for a specific message code.
 java.lang.String getMessage(UiBusinessException exception)
          Retrieves the full message translation for a UiBusinessException message/error code.
 
Methods inherited from class com.retek.commons.gui.util.TranslatorManager
getBundle, getLocale, setBundle, setLocale, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageTranslator

public MessageTranslator()
Returns new MessageManager object.


MessageTranslator

public MessageTranslator(java.lang.String filename)
                  throws UiBundleException
Returns new MessageManager object.

Parameters:
filename - The filename of the properties file to load.
Throws:
UiBundleException - Thrown if the method fails to load the properties file.

MessageTranslator

public MessageTranslator(java.util.Locale locale,
                         java.lang.String filename)
                  throws UiBundleException
Returns new MessageManager object.

Parameters:
locale - The Locale to load the message translation for.
filename - The filename of the properties file to load.
Throws:
UiBundleException - Thrown if the method fails to load the properties file.
Method Detail

getMessage

public java.lang.String getMessage(UiBusinessException exception)
Retrieves the full message translation for a UiBusinessException message/error code. If no translation for the message code contained within the UiBusinessException, this method assumes that the exception contains a direct message and will return it untranslated.

Parameters:
exception - A UiBusinessException to retrieve a translated message from.
Returns:
The fully translated and expanded message.

getMessage

public java.lang.String getMessage(java.lang.Exception exception)
Retrieves the expanded message translation for an generic exception message. If no translation exists, the original exception message is returned. This method allows the programmer to store an Rcom Error Code in the message error of a regular Exception and then get the translation.

Parameters:
exception - An Exception object to attempt to translate.
Returns:
The fully translated and expanded message.

getMessage

public java.lang.String getMessage(java.lang.String messageCode)
Retrieves the expanded message translation for the specific message code. If no translation exists exists for the message code, the original message code is returned.

Parameters:
messageCode - The message code to retrieve a message for.
Returns:
The fully translated and expanded message.

getMessage

public java.lang.String getMessage(java.lang.String messageCode,
                                   java.lang.String valueOne)
Retrieves the expanded message translation for a specific message code. If no translation exists, the original message code is returned. This method allows a single string parameter to replace the first placeholder in the message text.

Parameters:
messageCode - The message code to retrieve the message for.
valueOne - A string value to replace a placeholder in the message text.
Returns:
The translated and expanded message.

getMessage

public java.lang.String getMessage(java.lang.String messageCode,
                                   java.lang.String valueOne,
                                   java.lang.String valueTwo)
Retrieves the expanded message translation for a specific message code. If no translation exists, the original message code is returned. This method allows a pair of string parameters to replace the first few placeholders in the message text.

Parameters:
messageCode - The message code to retrieve the message for.
valueOne - A string value to replace a placeholder in the message text.
valueTwo - A string value to replace a placeholder in the message text.
Returns:
The translated and expanded message.

getMessage

public java.lang.String getMessage(java.lang.String messageCode,
                                   java.lang.String[] valueArray)
Retrieves the expanded message translation for the specific message code. If no translation exists, the original message code is returned. This method uses the string array to replace any placeholders found in the message text in sequence.

Parameters:
messageCode - The message code to retrieve the message for.
valueArray - An array of strings to replace placeholders in the message text.
Returns:
The translated and expanded message.


Copyright © 2005 Retek Inc. All Rights Reserved. - Generated at Fri, 01/21/2005 14:25