|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.townleyenterprises.common.ResourceLoader
This class provides a way to access Java resource strings from a
location relative to a specific class. This class assumes that all
resources are located in a sub-directory under the current package
called 'resources'. Thus, in Unix, the resource strings for
com.foo.MyClass
will be located in:
com/foo/resources/strings.properties
and the images
will be located under com/foo/resources/
.
This class supports a system property which will control how missing resources are reported. The property is:
true
or yes
to display messages about
missing resources
Constructor Summary | |
ResourceLoader(java.lang.Class cls)
This constructor takes a class to use as the basis for finding resources. |
|
ResourceLoader(java.lang.Class cls,
java.util.Locale locale)
This constructor takes a class to use as the basis for finding resources for the specific locale. |
|
ResourceLoader(java.lang.Class cls,
java.lang.String name)
This version of the constructor is used to load resource settings from an arbitrarily named resource property file. |
|
ResourceLoader(java.lang.Class cls,
java.lang.String name,
java.util.Locale locale)
This version of the constructor is used to load resource settings from an arbitrarily named resource property file. |
|
ResourceLoader(java.lang.Object obj)
The constructor takes an object to use as the basis for finding resources. |
Method Summary | |
javax.swing.ImageIcon |
getIcon(java.lang.String key)
This method is used to load an image for the default locale. |
javax.swing.ImageIcon |
getIcon(java.lang.String key,
java.util.Locale locale)
This method is used to load an image for the specified locale and key. |
java.util.Collection |
getKeys()
This method returns the collection of keys for the resource provider. |
java.util.ResourceBundle |
getResourceBundle()
This method returns the reference to the bundle for the default locale for this instance. |
java.util.ResourceBundle |
getResourceBundle(java.util.Locale locale)
This method is used to get a direct reference to the resource bundle. |
java.lang.String |
getString(java.lang.String key)
This method is used to find a given resource string. |
java.lang.String |
getString(java.lang.String key,
java.util.Locale locale)
This method is used to find a given resource string based on the specified locale. |
java.lang.String |
toString()
Provide some clue as to what we're doing and who we are. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ResourceLoader(java.lang.Object obj)
obj
- the object to provide the base resource locationpublic ResourceLoader(java.lang.Class cls)
cls
- the class providing the base resource locationpublic ResourceLoader(java.lang.Class cls, java.util.Locale locale)
cls
- the class providing the base resource locationlocale
- the locale of the resources to loadpublic ResourceLoader(java.lang.Class cls, java.lang.String name)
cls
- the class providing the base resource locationname
- the name of the resourcespublic ResourceLoader(java.lang.Class cls, java.lang.String name, java.util.Locale locale)
cls
- the class providing the base resource locationname
- the name of the resourceslocale
- the locale to useMethod Detail |
public java.lang.String getString(java.lang.String key)
getString
in interface ResourceProvider
key
- the resource string key. If the key can't be
found or the resulting string is empty, the key is
returned.
public java.lang.String getString(java.lang.String key, java.util.Locale locale)
ResourceProvider
getString
in interface ResourceProvider
key
- the resource string keylocale
- the locale
public javax.swing.ImageIcon getIcon(java.lang.String key)
getIcon
in interface ResourceProvider
key
- the image key
public javax.swing.ImageIcon getIcon(java.lang.String key, java.util.Locale locale)
getIcon
in interface ResourceProvider
key
- the image keylocale
- the locale
public java.util.Collection getKeys()
ResourceProvider
getKeys
in interface ResourceProvider
public java.util.ResourceBundle getResourceBundle()
public java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
locale
- the specific locale
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |