Class FormattingResourceBundle


  • public final class FormattingResourceBundle
    extends java.util.ResourceBundle

    Simple extension to ResourceBundle that handles message formatting via MessageFormat for values in the resource bundle.

    Since:
    2.0
    Version:
    2.0
    Author:
    Michael Grove
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.ResourceBundle

        java.util.ResourceBundle.Control
    • Field Summary

      • Fields inherited from class java.util.ResourceBundle

        parent
    • Constructor Summary

      Constructors 
      Constructor Description
      FormattingResourceBundle​(java.lang.String theName)
      Create a new ResourceBundle
      FormattingResourceBundle​(java.util.ResourceBundle theResourceBundle)
      Create a new FormattingResourceBundle
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String get​(java.lang.String theKey, java.lang.Object... theArgs)
      Return the string from the ResourceBundle, optionally applying the provided args to the message via String.format(java.lang.String, java.lang.Object...).
      java.util.Enumeration<java.lang.String> getKeys()
      protected java.lang.Object handleGetObject​(java.lang.String key)
      • Methods inherited from class java.util.ResourceBundle

        clearCache, clearCache, containsKey, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, keySet, setParent
      • Methods inherited from class java.lang.Object

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

      • FormattingResourceBundle

        public FormattingResourceBundle​(java.util.ResourceBundle theResourceBundle)
        Create a new FormattingResourceBundle
        Parameters:
        theResourceBundle - the actual bundle
      • FormattingResourceBundle

        public FormattingResourceBundle​(java.lang.String theName)
        Create a new ResourceBundle
        Parameters:
        theName - the name of the bundle to load
    • Method Detail

      • get

        public java.lang.String get​(java.lang.String theKey,
                                    java.lang.Object... theArgs)
        Return the string from the ResourceBundle, optionally applying the provided args to the message via String.format(java.lang.String, java.lang.Object...).
        Parameters:
        theKey - the message key
        theArgs - the optiona list of args to apply to the message
        Returns:
        the message or null if a value w/ the key does not exist
      • handleGetObject

        protected java.lang.Object handleGetObject​(java.lang.String key)
        Specified by:
        handleGetObject in class java.util.ResourceBundle
      • getKeys

        public java.util.Enumeration<java.lang.String> getKeys()
        Specified by:
        getKeys in class java.util.ResourceBundle