Package net.sf.jguiraffe.resources.impl
Class ResourceManagerImpl
- java.lang.Object
-
- net.sf.jguiraffe.resources.impl.ResourceManagerImpl
-
- All Implemented Interfaces:
ResourceManager
public class ResourceManagerImpl extends Object implements ResourceManager
A default implementation of the
ResourceManagerinterface.This class provides a fully functional
ResourceManagerimplementation that can be used as is. There is usually no need to subclass this class or use a different implementation.The class uses the associated
ResourceLoaderto retrieve requested resources or resource groups. No caching is performed, this can be done in theResourceLoader.Implementation note: This class is thread-safe.
- Version:
- $Id: ResourceManagerImpl.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description ResourceManagerImpl()Creates a new instance ofResourceManagerImpl.ResourceManagerImpl(ResourceLoader loader)Creates a new instance ofResourceManagerImpland initializes the associated resource loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ResourceLoaderfetchLoader()Fetches the resource loader.ObjectgetDefaultResourceGroup()Returns the name of the default resource group.ObjectgetResource(Locale locale, Object group, Object key)Returns the specified resource.ResourceGroupgetResourceGroup(Locale locale, Object group)Returns the specified resource group.ResourceLoadergetResourceLoader()Returns the associatedResourceLoaderobject.StringgetText(Locale locale, Object group, Object key)Returns the text of the specified resource.voidsetDefaultResourceGroup(Object grp)Sets the name of the default resource group.voidsetResourceLoader(ResourceLoader resourceLoader)Sets theResourceLoaderto use.
-
-
-
Constructor Detail
-
ResourceManagerImpl
public ResourceManagerImpl()
Creates a new instance ofResourceManagerImpl.
-
ResourceManagerImpl
public ResourceManagerImpl(ResourceLoader loader)
Creates a new instance ofResourceManagerImpland initializes the associated resource loader.- Parameters:
loader- the resource loader to use
-
-
Method Detail
-
getResource
public Object getResource(Locale locale, Object group, Object key)
Returns the specified resource.- Specified by:
getResourcein interfaceResourceManager- Parameters:
locale- theLocalegroup- the owning resource group's namekey- the resource key- Returns:
- the found resource
- Throws:
MissingResourceException- if the resource cannot be found
-
getResourceGroup
public ResourceGroup getResourceGroup(Locale locale, Object group)
Returns the specified resource group.- Specified by:
getResourceGroupin interfaceResourceManager- Parameters:
locale- theLocaleof the groupgroup- the group's name- Returns:
- the specified resource group
- Throws:
MissingResourceException- if the group cannot be found
-
getText
public String getText(Locale locale, Object group, Object key) throws MissingResourceException
Returns the text of the specified resource.- Specified by:
getTextin interfaceResourceManager- Parameters:
locale- theLocalegroup- the name of the resource groupkey- the resource key- Returns:
- the text of the specified resource
- Throws:
MissingResourceException- if the resource cannot be found
-
getResourceLoader
public ResourceLoader getResourceLoader()
Returns the associatedResourceLoaderobject.- Specified by:
getResourceLoaderin interfaceResourceManager- Returns:
- the
ResourceLoader
-
setResourceLoader
public void setResourceLoader(ResourceLoader resourceLoader)
Sets theResourceLoaderto use. Requests for resource groups are delegated to this object.- Specified by:
setResourceLoaderin interfaceResourceManager- Parameters:
resourceLoader- theResourceLoaderto use
-
fetchLoader
protected ResourceLoader fetchLoader()
Fetches the resource loader. This method is called whenever access to a resource loader is needed. It checks if a resource loader is defined and if not, throws an exception.- Returns:
- the resource loader to use
-
getDefaultResourceGroup
public Object getDefaultResourceGroup()
Returns the name of the default resource group.- Specified by:
getDefaultResourceGroupin interfaceResourceManager- Returns:
- the name of the default resource group
-
setDefaultResourceGroup
public void setDefaultResourceGroup(Object grp)
Sets the name of the default resource group.- Specified by:
setDefaultResourceGroupin interfaceResourceManager- Parameters:
grp- the name of the default resource group
-
-