Class FormattedResourceBundle

java.lang.Object
io.sf.jclf.util.FormattedResourceBundle

public class FormattedResourceBundle extends Object
A resource bundle that contains MessageFormat strings. If a given message does not contain a format, then a String is directly bundled.

Methods are analog to the ones in ResourceBundle.

See Also:
  • Method Details

    • getString

      public String getString(String key)
      Gets the MessageFormat pattern, or the plain String value, associated to a given key.
      Parameters:
      key - the bundle key.
      Returns:
      the associated MessageFormat pattern, or the plain String value.
    • formatString

      public String formatString(String key, String arg)
      Formats a message according to a MessageFormat and a String argument.
      Parameters:
      key - the bundle key.
      arg - the String argument to be used for the MessageFormat.
      Returns:
      the formatted String, see class description.
    • formatString

      public String formatString(String key, String arg1, String arg2)
      Formats a message according to a MessageFormat and two String arguments.
      Parameters:
      key - the bundle key.
      arg1 - the first String argument to be used for the MessageFormat.
      arg2 - the second String argument to be used for the MessageFormat.
      Returns:
      the formatted String, see class description.
    • formatString

      public String formatString(String key, String arg, int i)
      Formats a message according to a MessageFormat, a String argument and an integer argument.
      Parameters:
      key - the bundle key.
      arg - the String argument to be used for the MessageFormat.
      i - the integer argument to be used for the MessageFormat.
      Returns:
      the formatted String, see class description.
    • formatString

      public String formatString(String key, Object[] o)
      Formats an array of objects according to a MessageFormat identified by key.
      Parameters:
      key - the bundle key.
      o - the array to be formatted.
      Returns:
      the formatted String, see class description.
    • formatString

      public String formatString(String key, int i)
      Parameters:
      key - the bundle key.
      i - the integer to be formatted.
      Returns:
      the formatted String, see class description.
    • setParent

      public void setParent(FormattedResourceBundle parent)
      Sets the parent for this resource bundle.
      Parameters:
      parent - the parent bundle.
    • getKeys

      public Enumeration<String> getKeys()
      Gets an enumeration of bundle keys.
      Returns:
      the keys enumeration.
    • getLocalBundle

      public static FormattedResourceBundle getLocalBundle(String baseName) throws MissingResourceException
      Get the appropriate FormattedResourceBundle class.
      Parameters:
      baseName - see class description.
      Returns:
      the resource bundle.
      Throws:
      MissingResourceException
    • getLocalBundle

      public static FormattedResourceBundle getLocalBundle(String baseName, Locale locale)
      Get the appropriate FormattedResourceBundle class.
      Parameters:
      baseName - see class description.
      locale - see class description.
      Returns:
      the resource bundle.
    • getLocalBundle

      public static FormattedResourceBundle getLocalBundle(String baseName, Locale locale, ClassLoader loader) throws MissingResourceException
      Get the appropriate FormattedResourceBundle subclass.
      Parameters:
      baseName - see class description.
      locale - see class description.
      loader - the ClassLoader to load the resource from
      Returns:
      the resource bundle.
      Throws:
      MissingResourceException