org.PingOO.DLAI.lib.util
Class ResourceManager

java.lang.Object
  |
  +--org.PingOO.DLAI.lib.util.ResourceManager

public final class ResourceManager
extends java.lang.Object

Manages the access to localized datas and resource bundles.

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)

Field Summary
static java.lang.String DEFAULT_MODULE
          Defines the key of the default ResourceBundle.
static java.lang.String EMPTY_LOCALIZED
          Defines the String to return in case of the resource bundle cannot find the resource.
private static java.util.Hashtable RESOURCE_TABLE
          Contains all ResourceBundles used within the program.
 
Constructor Summary
private ResourceManager()
          Hides the constructor from the outside.
 
Method Summary
static java.lang.String getString(java.lang.String identifier)
          Gets a localized resource from a resource file.
static java.lang.String getString(java.lang.String module, java.lang.String identifier)
          Gets a localized resource from a resource file.
(package private) static void initialize()
          Initializes the ResourceBundle container.
private static void loadBundle(java.lang.String module)
          Loads a bundle from a special set.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEFAULT_MODULE

public static final java.lang.String DEFAULT_MODULE
Defines the key of the default ResourceBundle.

EMPTY_LOCALIZED

public static final java.lang.String EMPTY_LOCALIZED
Defines the String to return in case of the resource bundle cannot find the resource.

RESOURCE_TABLE

private static java.util.Hashtable RESOURCE_TABLE
Contains all ResourceBundles used within the program.
Constructor Detail

ResourceManager

private ResourceManager()
Hides the constructor from the outside.
Method Detail

initialize

static final void initialize()
Initializes the ResourceBundle container.

getString

public static final java.lang.String getString(java.lang.String identifier)
Gets a localized resource from a resource file.
The retrieving algorithm checks the shared lib resource file.
Parameters:
identifier - What's identies the data to retrieve from the resource file.
Returns:
The localized data or (empty) if the resource can not be found.

getString

public static final java.lang.String getString(java.lang.String module,
                                               java.lang.String identifier)
Gets a localized resource from a resource file.
The retrieving algorithm first checks the module's own resource file, then checks the shared lib resource file.
Appli's resource files must be suffixed by the name of the appli, if the name of the appli is myAppli then :
The file named MyAppli.properties contains the resources in the default language (usually international english).
While the file MyAppli_fr.properties contains the resources for all french based languages.
And MyAppli_fr_FR.properties contains the resources for the metropolitan french language.

For convinience and performance, programs can also directly try to retrieve a resource from the shared file by using ResourceManager.DEFAULT_MODULE instead of their own module name.

Parameters:
module - The appli's own module name.
identifier - What's identies the data to retrieve from the resource file.
Returns:
The localized data or (empty) if the resource can not be found.

loadBundle

private static void loadBundle(java.lang.String module)
Loads a bundle from a special set.
Parameters:
module - The set to be loaded.