Interface ResourceManager

  • All Known Implementing Classes:
    ResourceManagerImpl

    public interface ResourceManager

    Definition of an interface for accessing resources in a generic way.

    Through this interface applications can access a resource manager object that is able to provide access to resource items or whole resource groups. This service is completely independent on the way the resources of this application are stored. The physical resource access is performed by a ResourceLoader object that is associated with this class.

    Resources supported by this library are always organized in logical resource groups. This allows for a logic structure. When resources are accessed a group name must always be provided.

    This interface defines all needed methods for accessing resources. A single item can be retrieved as object or, for convenience purpose, as string. It is also possible to retrieve a whole resource group.

    Version:
    $Id: ResourceManager.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    See Also:
    ResourceGroup, ResourceLoader
    • Method Detail

      • getResource

        Object getResource​(Locale locale,
                           Object group,
                           Object key)
                    throws MissingResourceException
        Returns the resource for the given Locale, resource group, and key.
        Parameters:
        locale - the Locale
        group - the name of the resource group the resource belongs to
        key - the resource key
        Returns:
        the specified resource
        Throws:
        MissingResourceException - if the resource cannot be found
      • getText

        String getText​(Locale locale,
                       Object group,
                       Object key)
                throws MissingResourceException
        Returns the text resource for the given combination of a Locale, resource group, and resource key. This is a convenience method if the resource is known to be a text resource.
        Parameters:
        locale - the Locale
        group - the name of the resource group the resource belongs to
        key - the resource key
        Returns:
        the specified resource
        Throws:
        MissingResourceException - if the resource cannot be found
      • getResourceLoader

        ResourceLoader getResourceLoader()
        Returns the ResourceLoader that is associated with this resource manager.
        Returns:
        the associated ResourceLoader
      • setResourceLoader

        void setResourceLoader​(ResourceLoader resourceLoader)
        Sets the ResourceLoader for this resource manager. This loader is then used to retrieve resource groups.
        Parameters:
        resourceLoader - the ResourceLoader to be used
      • getResourceGroup

        ResourceGroup getResourceGroup​(Locale locale,
                                       Object group)
                                throws MissingResourceException
        Returns the resource group for the specified Locale with the given name. The returned object can be used to retrieve all resources that belong to this group at once.
        Parameters:
        locale - the Locale
        group - the name of the resource group
        Returns:
        the found resource group
        Throws:
        MissingResourceException - if the resource group cannot be found
      • getDefaultResourceGroup

        Object getDefaultResourceGroup()
        Returns the name of the default resource group.
        Returns:
        the default resource group's name
      • setDefaultResourceGroup

        void setDefaultResourceGroup​(Object grp)
        Sets the name of the default resource group. If a resource is queried with an undefined group name, this default group will be used.
        Parameters:
        grp - the name of the default resource group