Interface ResourceManager
-
- All Known Implementing Classes:
ResourceManagerImpl
public interface ResourceManagerDefinition 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
ResourceLoaderobject 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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ObjectgetDefaultResourceGroup()Returns the name of the default resource group.ObjectgetResource(Locale locale, Object group, Object key)Returns the resource for the givenLocale, resource group, and key.ResourceGroupgetResourceGroup(Locale locale, Object group)Returns the resource group for the specifiedLocalewith the given name.ResourceLoadergetResourceLoader()Returns theResourceLoaderthat is associated with this resource manager.StringgetText(Locale locale, Object group, Object key)Returns the text resource for the given combination of aLocale, resource group, and resource key.voidsetDefaultResourceGroup(Object grp)Sets the name of the default resource group.voidsetResourceLoader(ResourceLoader resourceLoader)Sets theResourceLoaderfor this resource manager.
-
-
-
Method Detail
-
getResource
Object getResource(Locale locale, Object group, Object key) throws MissingResourceException
Returns the resource for the givenLocale, resource group, and key.- Parameters:
locale- theLocalegroup- the name of the resource group the resource belongs tokey- 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 aLocale, resource group, and resource key. This is a convenience method if the resource is known to be a text resource.- Parameters:
locale- theLocalegroup- the name of the resource group the resource belongs tokey- the resource key- Returns:
- the specified resource
- Throws:
MissingResourceException- if the resource cannot be found
-
getResourceLoader
ResourceLoader getResourceLoader()
Returns theResourceLoaderthat is associated with this resource manager.- Returns:
- the associated
ResourceLoader
-
setResourceLoader
void setResourceLoader(ResourceLoader resourceLoader)
Sets theResourceLoaderfor this resource manager. This loader is then used to retrieve resource groups.- Parameters:
resourceLoader- theResourceLoaderto be used
-
getResourceGroup
ResourceGroup getResourceGroup(Locale locale, Object group) throws MissingResourceException
Returns the resource group for the specifiedLocalewith the given name. The returned object can be used to retrieve all resources that belong to this group at once.- Parameters:
locale- theLocalegroup- 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
-
-