Class UtilMessage

java.lang.Object
com.netscape.cmscore.util.UtilMessage

public class UtilMessage extends Object
This object is used to easily create I18N messages for utility classes and standalone programs.
Version:
$Revision$, $Date$
Author:
mikep
See Also:
  • Field Details

    • mParams

      protected Object[] mParams
  • Constructor Details

    • UtilMessage

      public UtilMessage(String msgFormat)
      Constructs a message event

      Parameters:
      msgFormat - the message string
    • UtilMessage

      public UtilMessage(String msgFormat, String param)
      Constructs a message with a parameter. For example,
       new UtilMessage("failed to load {0}", fileName);
       

      Parameters:
      msgFormat - details in message string format
      param - message string parameter
    • UtilMessage

      public UtilMessage(String msgFormat, 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 format
      exception - system exception
    • UtilMessage

      public UtilMessage(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:
      e - CMS exception
    • UtilMessage

      public UtilMessage(String msgFormat, Object[] params)
      Constructs a message event with a list of parameters that will be substituted into the message format.

      Parameters:
      msgFormat - message string format
      params - list of message format parameters
  • Method Details

    • getMessage

      public String getMessage()
      Returns the current message format string.

      Returns:
      details message
    • getParameters

      public Object[] getParameters()
      Returns a list of parameters.

      Returns:
      list of message format parameters
    • toString

      public String toString()
      Returns localized message string. This method should only be called if a localized string is necessary.

      Overrides:
      toString in class Object
      Returns:
      details message
    • toString

      public String toString(Locale locale)
      Returns the string based on the given locale.

      Parameters:
      locale - locale
      Returns:
      details message
    • getBundleName

      protected String getBundleName()
      Gets the resource bundle name for this class instance. This should be overridden by subclasses who have their own resource bundles.