Class ProjectResourceBundle


  • public class ProjectResourceBundle
    extends java.util.ResourceBundle

    Wrapper class for resource bundles. Property files are used to store resource strings, which are the only types of resources available. Property files can inherit properties from other files so that a base property file can be used and a small number of properties can be over-ridden by another property file. For example you may create an english version of a resource file named "resource.properties". You then decide that the British English version of all of the properties except one are the same, so there is no need to redefine all of the properties in "resource_en_GB", just the one that is different.

    The basename is the name of the property file without the ".properties" extension.

    Properties will be cached for performance.

    Property values stored in the property files can also contain dynamic variables. Any dynamic variable defined in PropertiesUtil.getVariableValue() can be used (such as {date}), as well as arguments in the form {0}, {1}, etc. Argument values are specified in the various overloaded getString() methods.

    Author:
    Richard A. Sitze (rsitze@us.ibm.com), Karl Moss (kmoss@macromedia.com), Glen Daniels (gdaniels@apache.org)
    • Nested Class Summary

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

        java.util.ResourceBundle.Control
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static org.apache.commons.logging.Log log  
      • Fields inherited from class java.util.ResourceBundle

        parent
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static ProjectResourceBundle getBundle​(java.lang.String projectName, java.lang.Class caller, java.lang.String resourceName, java.util.Locale locale)
      Construct a new ProjectResourceBundle
      static ProjectResourceBundle getBundle​(java.lang.String projectName, java.lang.Class caller, java.lang.String resourceName, java.util.Locale locale, java.util.ResourceBundle extendsBundle)
      Construct a new ProjectResourceBundle
      static ProjectResourceBundle getBundle​(java.lang.String projectName, java.lang.String packageName, java.lang.String resourceName)
      Construct a new ProjectResourceBundle
      static ProjectResourceBundle getBundle​(java.lang.String projectName, java.lang.String packageName, java.lang.String resourceName, java.util.Locale locale, java.lang.ClassLoader loader)
      Construct a new ProjectResourceBundle
      static ProjectResourceBundle getBundle​(java.lang.String projectName, java.lang.String packageName, java.lang.String resourceName, java.util.Locale locale, java.lang.ClassLoader loader, java.util.ResourceBundle extendsBundle)
      Construct a new ProjectResourceBundle
      java.util.Enumeration getKeys()  
      java.lang.String getResourceName()  
      protected java.lang.Object handleGetObject​(java.lang.String key)  
      java.lang.String toString()
      Clears the internal cache
      • 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, wait, wait, wait
    • Field Detail

      • log

        protected static org.apache.commons.logging.Log log
    • Method Detail

      • handleGetObject

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

        public java.util.Enumeration getKeys()
        Specified by:
        getKeys in class java.util.ResourceBundle
      • getBundle

        public static ProjectResourceBundle getBundle​(java.lang.String projectName,
                                                      java.lang.String packageName,
                                                      java.lang.String resourceName)
                                               throws java.util.MissingResourceException
        Construct a new ProjectResourceBundle
        Parameters:
        projectName - The name of the project to which the class belongs. It must be a proper prefix of the caller's package.
        caller - The calling class. This is used to get the package name to further construct the basename as well as to get the proper ClassLoader.
        resourceName - The name of the resource without the ".properties" extension
        Throws:
        java.util.MissingResourceException - if projectName is not a prefix of the caller's package name, or if the resource could not be found/loaded.
      • getBundle

        public static ProjectResourceBundle getBundle​(java.lang.String projectName,
                                                      java.lang.Class caller,
                                                      java.lang.String resourceName,
                                                      java.util.Locale locale)
                                               throws java.util.MissingResourceException
        Construct a new ProjectResourceBundle
        Parameters:
        projectName - The name of the project to which the class belongs. It must be a proper prefix of the caller's package.
        caller - The calling class. This is used to get the package name to further construct the basename as well as to get the proper ClassLoader.
        resourceName - The name of the resource without the ".properties" extension
        Throws:
        java.util.MissingResourceException - if projectName is not a prefix of the caller's package name, or if the resource could not be found/loaded.
      • getBundle

        public static ProjectResourceBundle getBundle​(java.lang.String projectName,
                                                      java.lang.String packageName,
                                                      java.lang.String resourceName,
                                                      java.util.Locale locale,
                                                      java.lang.ClassLoader loader)
                                               throws java.util.MissingResourceException
        Construct a new ProjectResourceBundle
        Parameters:
        projectName - The name of the project to which the class belongs. It must be a proper prefix of the caller's package.
        caller - The calling class. This is used to get the package name to further construct the basename as well as to get the proper ClassLoader.
        resourceName - The name of the resource without the ".properties" extension
        locale - The locale
        Throws:
        java.util.MissingResourceException - if projectName is not a prefix of the caller's package name, or if the resource could not be found/loaded.
      • getBundle

        public static ProjectResourceBundle getBundle​(java.lang.String projectName,
                                                      java.lang.Class caller,
                                                      java.lang.String resourceName,
                                                      java.util.Locale locale,
                                                      java.util.ResourceBundle extendsBundle)
                                               throws java.util.MissingResourceException
        Construct a new ProjectResourceBundle
        Parameters:
        projectName - The name of the project to which the class belongs. It must be a proper prefix of the caller's package.
        caller - The calling class. This is used to get the package name to further construct the basename as well as to get the proper ClassLoader.
        resourceName - The name of the resource without the ".properties" extension
        locale - The locale
        extendsBundle - If non-null, then this ExtendMessages will default to extendsBundle.
        Throws:
        java.util.MissingResourceException - if projectName is not a prefix of the caller's package name, or if the resource could not be found/loaded.
      • getBundle

        public static ProjectResourceBundle getBundle​(java.lang.String projectName,
                                                      java.lang.String packageName,
                                                      java.lang.String resourceName,
                                                      java.util.Locale locale,
                                                      java.lang.ClassLoader loader,
                                                      java.util.ResourceBundle extendsBundle)
                                               throws java.util.MissingResourceException
        Construct a new ProjectResourceBundle
        Parameters:
        projectName - The name of the project to which the class belongs. It must be a proper prefix of the caller's package.
        caller - The calling class. This is used to get the package name to further construct the basename as well as to get the proper ClassLoader.
        resourceName - The name of the resource without the ".properties" extension
        locale - The locale
        extendsBundle - If non-null, then this ExtendMessages will default to extendsBundle.
        Throws:
        java.util.MissingResourceException - if projectName is not a prefix of the caller's package name, or if the resource could not be found/loaded.
      • getResourceName

        public java.lang.String getResourceName()
      • toString

        public java.lang.String toString()
        Clears the internal cache
        Overrides:
        toString in class java.lang.Object