Class I18NResourceBundle


  • public class I18NResourceBundle
    extends java.util.ResourceBundle
    A class that lazily opens a package-specific resource bundle containing localization data for a class.
    • 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static I18NResourceBundle getBundleForClass​(java.lang.Class c)
      Get a package-specific resource bundle for a class containing localization data.
      java.util.Enumeration getKeys()
      A required internal method for ResourceBundle.
      java.lang.String getName()
      Returns the name of this bundle (useful for methods using bundle name instead of instance, such as Logger creation,
      java.lang.String getOptionalString​(java.lang.String key)
      Get an entry from the bundle, returning null if it is not found.
      java.lang.String getString​(java.lang.String key, java.lang.Object arg)
      Get an entry from the resource bundle.
      java.lang.String getString​(java.lang.String key, java.lang.Object... args)
      Get an entry from the resource bundle.
      protected java.lang.Object handleGetObject​(java.lang.String key)
      A required internal method for ResourceBundle.
      • 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
    • Method Detail

      • getBundleForClass

        public static I18NResourceBundle getBundleForClass​(java.lang.Class c)
        Get a package-specific resource bundle for a class containing localization data. The bundle is named i18n.properties in the same package as the given class.
        Parameters:
        c - the class for which to obtain the resource bundle
        Returns:
        the appropriate resource bundle for the class
      • getString

        public java.lang.String getString​(java.lang.String key,
                                          java.lang.Object arg)
        Get an entry from the resource bundle. If the resource cannot be found, a message is printed to the console and the result will be a string containing the method parameters.
        Parameters:
        key - the name of the entry to be returned
        arg - an argument to be formatted into the result using MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
        Returns:
        the formatted string
      • getString

        public java.lang.String getString​(java.lang.String key,
                                          java.lang.Object... args)
        Get an entry from the resource bundle. If the resource cannot be found, a message is printed to the console and the result will be a string containing the method parameters.
        Parameters:
        key - the name of the entry to be returned
        args - an array of arguments to be formatted into the result using MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
        Returns:
        the formatted string
      • getOptionalString

        public java.lang.String getOptionalString​(java.lang.String key)
        Get an entry from the bundle, returning null if it is not found.
        Parameters:
        key - the name of the entry to be returned
        Returns:
        the value of the entry, or null if it is not found.
      • handleGetObject

        protected java.lang.Object handleGetObject​(java.lang.String key)
                                            throws java.util.MissingResourceException
        A required internal method for ResourceBundle. Load the actual resource bundle, if it has not yet been loaded, then hand the request off to that bundle. If the resource cannot be found, a message is printed to the console and the result will be the original tag.
        Specified by:
        handleGetObject in class java.util.ResourceBundle
        Throws:
        java.util.MissingResourceException
      • getKeys

        public java.util.Enumeration getKeys()
        A required internal method for ResourceBundle. Load the actual resource bundle, if it has not yet been loaded, then hand the request off to that bundle.
        Specified by:
        getKeys in class java.util.ResourceBundle
      • getName

        public java.lang.String getName()
        Returns the name of this bundle (useful for methods using bundle name instead of instance, such as Logger creation,
        Returns:
        the name of this resource bundle