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
ResourceManager
interface.This class provides a fully functional
ResourceManager
implementation 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
ResourceLoader
to 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 ofResourceManagerImpl
and initializes the associated resource loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ResourceLoader
fetchLoader()
Fetches the resource loader.Object
getDefaultResourceGroup()
Returns the name of the default resource group.Object
getResource(Locale locale, Object group, Object key)
Returns the specified resource.ResourceGroup
getResourceGroup(Locale locale, Object group)
Returns the specified resource group.ResourceLoader
getResourceLoader()
Returns the associatedResourceLoader
object.String
getText(Locale locale, Object group, Object key)
Returns the text of the specified resource.void
setDefaultResourceGroup(Object grp)
Sets the name of the default resource group.void
setResourceLoader(ResourceLoader resourceLoader)
Sets theResourceLoader
to use.
-
-
-
Constructor Detail
-
ResourceManagerImpl
public ResourceManagerImpl()
Creates a new instance ofResourceManagerImpl
.
-
ResourceManagerImpl
public ResourceManagerImpl(ResourceLoader loader)
Creates a new instance ofResourceManagerImpl
and 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:
getResource
in interfaceResourceManager
- Parameters:
locale
- theLocale
group
- 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:
getResourceGroup
in interfaceResourceManager
- Parameters:
locale
- theLocale
of 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:
getText
in interfaceResourceManager
- Parameters:
locale
- theLocale
group
- 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 associatedResourceLoader
object.- Specified by:
getResourceLoader
in interfaceResourceManager
- Returns:
- the
ResourceLoader
-
setResourceLoader
public void setResourceLoader(ResourceLoader resourceLoader)
Sets theResourceLoader
to use. Requests for resource groups are delegated to this object.- Specified by:
setResourceLoader
in interfaceResourceManager
- Parameters:
resourceLoader
- theResourceLoader
to 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:
getDefaultResourceGroup
in 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:
setDefaultResourceGroup
in interfaceResourceManager
- Parameters:
grp
- the name of the default resource group
-
-