Class InoNls


  • public class InoNls
    extends java.lang.Object
    The class provides several utility methods for creating localized messages. It unifies the way in which you can access a message resource and how the keys that should be used are named.
    Author:
    borschet
    • Constructor Summary

      Constructors 
      Constructor Description
      InoNls()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String Msg​(java.lang.String key, java.lang.Object... args)
      Finds the message with the given key according to the default locales.
      static java.lang.String Msg​(java.util.Locale locale, java.lang.String key, java.lang.Object... args)
      Finds the message with the given key and the given locales.
      static java.lang.String MsgPrefix​(java.lang.String prefix, java.lang.String key, java.lang.Object... args)  
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InoNls

        public InoNls()
    • Method Detail

      • Msg

        public static java.lang.String Msg​(java.lang.String key,
                                           java.lang.Object... args)
        Finds the message with the given key according to the default locales.
        Parameters:
        key - a valid message key that can be used to find a message
        args - various arguments to be formatted with the message
        Returns:
        the string message
      • MsgPrefix

        public static java.lang.String MsgPrefix​(java.lang.String prefix,
                                                 java.lang.String key,
                                                 java.lang.Object... args)
      • Msg

        public static java.lang.String Msg​(java.util.Locale locale,
                                           java.lang.String key,
                                           java.lang.Object... args)
                                    throws java.util.MissingResourceException
        Finds the message with the given key and the given locales. The method tries to calculate the path of the resource bundle from the given key. Starting with the actual package, it searches for a bundle with the name "messages" and tries to find the key inside the bundle. If no such key is found, the key is separated into two parts at the position of the last dot in its name. The first part is considered as a package path name and the second part is used as a key name. This key is searched in every package and its container. The first hit is used to format the message which will be returned. If the key is not found in any of the retrieved packages, a default bundle (de.mid.innovator.messages) is used to get the message.
        Parameters:
        locale - valid Java locale
        key - a valid message key that can be used to find a message
        args - various arguments to be formatted with the message
        Returns:
        the string message
        Throws:
        java.util.MissingResourceException - If the key could not be found in any processed bundle.