public class BundleResourceLoader extends Object implements ResourceLoader
A specialized implementation of the ResourceLoader
interface that
make use of the default Java resource bundles.
This class uses the passed in Locale
and resource group name (which
is interpreted as string) to find a corresponding resource bundle. For this
bundle a wrapping object is returned that implements the
ResourceGroup
interface.
When creating an instance a ClassLoaderProvider
and a class loader
name can be provided. If set, the resource bundle is loaded using the class
loader specified this way.
Constructor and Description |
---|
BundleResourceLoader()
Creates a new instance of
BundleResourceLoader without a special
ClassLoaderProvider ; a default one is created. |
BundleResourceLoader(ClassLoaderProvider clp,
String clName)
Creates a new instance of
BundleResourceLoader and initializes it
with the given class loader provider and the class loader name. |
Modifier and Type | Method and Description |
---|---|
protected ResourceGroup |
createGroup(String name,
Locale locale)
Creates a
ResourceGroup object from the specified bundle. |
String |
getClassLoaderName()
Returns the name of the class loader used for resolving resource bundles.
|
ClassLoaderProvider |
getClassLoaderProvider()
Returns the
ClassLoaderProvider used by this object. |
protected String |
keyForGroup(Locale locale,
Object name)
Constructs a key for the given combination of a locale and a group name.
|
ResourceGroup |
loadGroup(Locale locale,
Object name)
Loads the specified resource group from a resource bundle.
|
public BundleResourceLoader()
BundleResourceLoader
without a special
ClassLoaderProvider
; a default one is created.public BundleResourceLoader(ClassLoaderProvider clp, String clName)
BundleResourceLoader
and initializes it
with the given class loader provider and the class loader name.clp
- the ClassLoaderProvider
; can be null, then a
default instance is createdclName
- the name of the class loader to use; can be null,
then the default class loader of the ClassLoaderProvider
is usedpublic ClassLoaderProvider getClassLoaderProvider()
ClassLoaderProvider
used by this object. Note: This
method never returns null; if no class loader provider was passed
to the constructor, a default instance is returned.ClassLoaderProvider
public String getClassLoaderName()
public ResourceGroup loadGroup(Locale locale, Object name)
loadGroup
in interface ResourceLoader
locale
- the Locale
name
- the group's nameMissingResourceException
- if the group cannot be foundprotected String keyForGroup(Locale locale, Object name)
locale
- the localename
- the group's nameprotected ResourceGroup createGroup(String name, Locale locale) throws MissingResourceException
ResourceGroup
object from the specified bundle.locale
- the Locale
name
- the group's nameMissingResourceException
- if the bundle cannot be foundCopyright © 2016 The JGUIraffe Team. All rights reserved.