Class MessageUtil


  • public class MessageUtil
    extends Object
    • Constructor Detail

      • MessageUtil

        public MessageUtil()
    • Method Detail

      • formatErrorMessage

        public static String formatErrorMessage​(String key,
                                                String msg)
        Get a formatted error message. The message consists of two parts. The first part is the error numeric Id associated with the key used to identify the message in the resource file. For instance, suppose the error key is MyClass.ERROR_0068_TEST_ERROR. The first part of the error msg would be "0068". The second part of the returned string is simply the msg parameter. Currently the format is: error key - error msg For instance: "0068 - A test error message."
        Parameters:
        key - String containing the key that was used to obtain the msg parameter from the resource file.
        msg - String containing the message that was obtained from the resource file using the key parameter.
        Returns:
        String containing the formatted error message.
      • getString

        public static String getString​(ResourceBundle bundle,
                                       String key)
        Get the message from the specified resource bundle using the specified key.
        Parameters:
        bundle - ResourceBundle containing the desired String
        key - String containing the key to locate the desired String in the ResourceBundle.
        Returns:
        String containing the message from the specified resource bundle accessed using the specified key
      • getErrorString

        public static String getErrorString​(ResourceBundle bundle,
                                            String key)
        Get a message from the specified resource bundle using the specified key, and format it. see formatErrorMessage for details on how the message is formatted.
        Parameters:
        bundle - ResourceBundle containing the desired String
        key - String containing the key to locate the desired String in the ResourceBundle.
        Returns:
        String containing the formatted message.
      • formatMessage

        public static String formatMessage​(String pattern,
                                           Object... params)