|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ge.research.app.ResourceDiscoveryUtil
This abstract class provides utility methods and behaviors for finding and loading resources for a class. For unqualified resources it implements the desired search order of the class's default resource directory, then the classpath root directory. For all resources loaded, the locale specific resource name is identified for each property within the resource.
| Field Summary | |
static java.lang.String |
PACKAGE_DELIMITER
Constant for the delimiter for package name syntax |
static java.lang.String |
RESOURCES_DIRNAME
Constant for the best practice package name for the location of resources and properties |
| Constructor Summary | |
ResourceDiscoveryUtil()
|
|
| Method Summary | |
static java.lang.String |
getClassUnqualifiedName(java.lang.Class c)
Constructs the resource path string for the given class. |
static java.lang.String |
getResourcePackage(java.lang.Class c)
Constructs the resource path string for the given class. |
static void |
loadClassResources(java.lang.Class theClass,
java.util.Properties props,
java.lang.String bundleName,
LocaleNegotiator localeNegotiator)
Attempts to load in properties found in a resource bundle specified by bundleName.
|
static java.util.Map |
loadClassResources(java.lang.Class theClass,
java.util.Properties props,
java.lang.String bundleName,
LocaleNegotiator localeNegotiator,
boolean createKeysToBundleMap)
Attempts to load in properties found in a resource bundle specified by bundleName.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String PACKAGE_DELIMITER
public static final java.lang.String RESOURCES_DIRNAME
| Constructor Detail |
public ResourceDiscoveryUtil()
| Method Detail |
public static java.lang.String getResourcePackage(java.lang.Class c)
RESOURCES_DIRNAME
c - the class to construct the resource package for
public static java.lang.String getClassUnqualifiedName(java.lang.Class c)
RESOURCES_DIRNAME
c - the class to construct the resource package for
public static final void loadClassResources(java.lang.Class theClass,
java.util.Properties props,
java.lang.String bundleName,
LocaleNegotiator localeNegotiator)
bundleName.
It first tries to load the bundleName resource by appending the current class's resource package name
(com.ge.research.app.ResourceDiscoveryUtil#THIS_CLASS_RESOURCES_PACKAGE) to the bundleName.
If such a resource is found, the properties are copied into a new Properties object. Then
attempts to load in properties found for the baseName as a resource (unmodified).
If such a resource is found, the properties are copied into the Properties object.
if a resource is found in both steps, properties within the unmodified baseName resource override any other matching properties found elsewhere.
A Map pairing the property names found to locale specific resources they were found in is returned by this method.
props - the Properties object in which to put the resource properties foundbundleName - the name of the resource to loadlocaleNegotiator - the locale resolution class to use
Map of each property found to the locale specific resource it was found incom.ge.research.app.ResourceDiscoveryUtil#loadClassResources(java.util.Properties, java.lang.String, com.ge.research.app.LocaleNegotiator, java.util.logging.Level)
public static final java.util.Map loadClassResources(java.lang.Class theClass,
java.util.Properties props,
java.lang.String bundleName,
LocaleNegotiator localeNegotiator,
boolean createKeysToBundleMap)
bundleName.
It first tries to load the bundleName resource by appending the current class's resource package name
(com.ge.research.app.ResourceDiscoveryUtil#THIS_CLASS_RESOURCES_PACKAGE) to the bundleName.
If such a resource is found, the properties are copied into a new Properties object. Then
attempts to load in properties found for the baseName as a resource (unmodified).
If such a resource is found, the properties are copied into the Properties object.
if a resource is found in both steps, properties within the unmodified baseName resource override any other matching properties found elsewhere.
A Map pairing the property names found to locale specific resources they were found in is returned by this method.
props - the Properties object in which to put the resource properties foundbundleName - the name of the resource to loadlocaleNegotiator - the locale resolution class to use
Map of each property found to the locale specific resource it was found incom.ge.research.app.ResourceDiscoveryUtil#loadClassResources(java.util.Properties, java.lang.String, com.ge.research.app.LocaleNegotiator, java.util.logging.Level)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||