Package com.netscape.cmscore.util
Class UtilMessage
- java.lang.Object
-
- com.netscape.cmscore.util.UtilMessage
-
public class UtilMessage extends java.lang.ObjectThis object is used to easily create I18N messages for utility classes and standalone programs.- Version:
- $Revision$, $Date$
- Author:
- mikep
- See Also:
MessageFormatter,UtilResources
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object[]mParams
-
Constructor Summary
Constructors Constructor Description UtilMessage(java.lang.Exception e)Constructs a message from a base exception.UtilMessage(java.lang.String msgFormat)Constructs a message eventUtilMessage(java.lang.String msgFormat, java.lang.Exception exception)Constructs a message from an exception.UtilMessage(java.lang.String msgFormat, java.lang.Object[] params)Constructs a message event with a list of parameters that will be substituted into the message format.UtilMessage(java.lang.String msgFormat, java.lang.String param)Constructs a message with a parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringgetBundleName()Gets the resource bundle name for this class instance.java.lang.StringgetMessage()Returns the current message format string.java.lang.Object[]getParameters()Returns a list of parameters.java.lang.StringtoString()Returns localized message string.java.lang.StringtoString(java.util.Locale locale)Returns the string based on the given locale.
-
-
-
Constructor Detail
-
UtilMessage
public UtilMessage(java.lang.String msgFormat)
Constructs a message event- Parameters:
msgFormat- the message string
-
UtilMessage
public UtilMessage(java.lang.String msgFormat, java.lang.String param)Constructs a message with a parameter. For example,new UtilMessage("failed to load {0}", fileName);- Parameters:
msgFormat- details in message string formatparam- message string parameter
-
UtilMessage
public UtilMessage(java.lang.String msgFormat, java.lang.Exception exception)Constructs a message from an exception. It can be used to carry a system exception that may contain information about the context. For example,try { ... } catch (IOExeption e) { out.println(new UtilMessage("Encountered System Error {0}", e); }- Parameters:
msgFormat- exception details in message string formatexception- system exception
-
UtilMessage
public UtilMessage(java.lang.Exception e)
Constructs a message from a base exception. This will use the msgFormat from the exception itself.try { ... } catch (Exception e) { System.out.println(new UtilMessage(e)); }- Parameters:
exception- CMS exception
-
UtilMessage
public UtilMessage(java.lang.String msgFormat, java.lang.Object[] params)Constructs a message event with a list of parameters that will be substituted into the message format.- Parameters:
msgFormat- message string formatparams- list of message format parameters
-
-
Method Detail
-
getMessage
public java.lang.String getMessage()
Returns the current message format string.- Returns:
- details message
-
getParameters
public java.lang.Object[] getParameters()
Returns a list of parameters.- Returns:
- list of message format parameters
-
toString
public java.lang.String toString()
Returns localized message string. This method should only be called if a localized string is necessary.- Overrides:
toStringin classjava.lang.Object- Returns:
- details message
-
toString
public java.lang.String toString(java.util.Locale locale)
Returns the string based on the given locale.- Parameters:
locale- locale- Returns:
- details message
-
getBundleName
protected java.lang.String getBundleName()
Gets the resource bundle name for this class instance. This should be overridden by subclasses who have their own resource bundles.
-
-