Class CommonGlobalProvider

java.lang.Object
com.webmethods.caf.common.CommonGlobalProvider

public class CommonGlobalProvider extends Object
This class is meant to provide the common resource bundle with a localized format based on the end users needs.
  • Field Details

  • Constructor Details

    • CommonGlobalProvider

      public CommonGlobalProvider()
  • Method Details

    • localize

      public static String localize(String resBundle, String messageKey, Object[] args, ClassLoader loader)
      Localize the bundle using arguments and specific loaders
      Parameters:
      resBundle - resource bundle
      messageKey - the message key
      args - object array of arguments
      loader - class loader
      Returns:
      localized string
    • getResourceBundle

      public static ResourceBundle getResourceBundle(String clazz, ClassLoader loader)
      Get resource bundle based on class and loader types.
      Parameters:
      clazz -
      loader -
      Returns:
    • getResourceBundle

      public static ResourceBundle getResourceBundle(String clazz)
      Get resource bundle based on class input
      Parameters:
      clazz -
      Returns:
    • format

      public static String format(ResourceBundle resourceBundle, String messageKey, Object[] args)
      Format a string from a resource bundle key with arguments
      Parameters:
      resourceBundle - the resource bundle containing the string
      messageKey - the key in the resource bundle
      args - the arguments to used to format the resource string
      Returns:
      the formatted resource string
    • localizeTemplate

      public static String localizeTemplate(String template, Locale locale, ClassLoader loader, String defaultBundleName)
      Replaces tokens in a template with resolved resource-bundle strings. Tokens are in the form of "{bundle.class.name#resource.key}", like "{com.webmethods.portal.foo.Resources#foo.bar.label}"; or "{#foo.bar.label}" if using the specified default-bundle.
      Parameters:
      template - Template containing tokens to localize.
      locale - Locale with which to localize.
      loader - Class loader to use to load resource bundles.
      defaultBundleName - Bundle to use if token doesn't specify bundle.
      Returns:
      Localized string.