Class GlobalMessages

All Implemented Interfaces:
MessageHandler, Handler
Direct Known Subclasses:
LAFMessageHandler

public class GlobalMessages extends AbstractMessageHandler
  • Field Details

  • Constructor Details

    • GlobalMessages

      public GlobalMessages()
      TODO: extend from abstract class to ensure singleton status and migrate instantiation to class controlled private
  • Method Details

    • getInstance

      public static MessageHandler getInstance()
    • getLocales

      protected static Map<String,ResourceBundle> getLocales()
    • buildBundleName

      protected static String buildBundleName(String packageName)
    • getBundle

      public static ResourceBundle getBundle(String packageName) throws MissingResourceException
      Retrieve a resource bundle of the default or fail-over locale.
      Parameters:
      packageName - The package to search in
      Returns:
      The resource bundle
      Throws:
      MissingResourceException - in case both resource bundles couldn't be found.
    • calculateString

      protected String calculateString(String packageName, String key, Object[] parameters)
      Returns the localized string for the given key and parameters in a bundle defined by the the concatenation of packageName and BUNDLE_NAME, using the GlobalMessages class loader.
      Parameters:
      packageName - the package containing the localized messages
      key - the message key being looked up
      parameters - parameters within the looked up message
      Returns:
      the localized string for the given key and parameters in a bundle defined by the the concatenation of packageName and BUNDLE_NAME, using the GlobalMessages class loader.
    • calculateString

      protected String calculateString(String packageName, String key, Object[] parameters, Class<?> resourceClass)
      Returns the localized string for the given key and parameters in a bundle defined by the the concatenation of packageName and BUNDLE_NAME, using the provided resourceClass's class loader.
      Parameters:
      packageName - the package containing the localized messages
      key - the message key being looked up
      parameters - parameters within the looked up message
      resourceClass - the class whose class loader is used to getch the resource bundle
      Returns:
      the localized string for the given key and parameters in a bundle defined by the the concatenation of packageName and BUNDLE_NAME, using the provided resourceClass's class loader.
    • calculateString

      protected String calculateString(String[] pkgNames, String key, Object[] parameters, Class<?> resourceClass)
      Returns the localized string for the given key and parameters in a bundle defined by the the concatenation of the package names defined in packageName and BUNDLE_NAME (the first valid combination of packageName + BUNDLE_NAME wins), sing the provided resourceClass's class loader.
      Parameters:
      pkgNames - an array of packages potentially containing the localized messages the first one found to contain the messages is the one that is used to localize the message
      key - the message key being looked up
      parameters - parameters within the looked up message
      resourceClass - the class whose class loader is used to getch the resource bundle
      Returns:
      the localized string for the given key and parameters in a bundle defined by the the concatenation of the package names defined in packageName and BUNDLE_NAME (the first valid combination of packageName + BUNDLE_NAME wins), sing the provided resourceClass's class loader
    • getString

      public String getString(String key)
      Description copied from interface: MessageHandler
      get a key from the default (System global) bundle
      Returns:
    • getString

      public String getString(String packageName, String key)
      Description copied from interface: MessageHandler
      get a key from the defined package bundle, by key
      Returns:
    • getString

      public String getString(String packageName, String key, String... parameters)
      Description copied from interface: MessageHandler
      get a key from the defined package bundle, by key
      Returns:
    • getString

      public String getString(String packageName, String key, Class<?> resourceClass, String... parameters)
      Description copied from interface: MessageHandler
      Get a string from the defined package bundle, by key and by a resource class
      Returns: