net.sf.genuine.resources
Class ResourceManager

java.lang.Object
  extended bynet.sf.genuine.resources.ResourceManager

public class ResourceManager
extends java.lang.Object

This class manages all resources that are defined in property files. It is a singleton that needs to be initialized at the program's startup. Initialization is done by passing the names of property files to addResources(String).

Each entry in a property file contains the value of a resource item's property in form of a name/value pair. The name contains both the resource item's name and the resource item's property name.

The name of the property file does not influence the names of the resource items. It is recommended, though, to let the name of each resource item start with the property file name. Example: file name is "app.properties", all resource items should start with "app.".

The name of a resource item is the text before the last dot. The text after the last dot is the name of the particular resource item property.

Examples:

The following resource item properties are defined and can therefore be used:

Author:
Tim Wellhausen

Method Summary
 void addResources(java.lang.String resourcesName)
          Takes the name of resources to be loaded and available during runtime.
 void clear()
          Removes all resources.
static ResourceManager getInstance()
          Returns an instance to the single object
 ResourceItem getResourceItem(java.lang.String name)
          Returns a ResourceItem if one has been initialized for the given name.
 ResourceItem[] getResourceItems(java.lang.String[] names)
          Returns an array of ResourceItem objects that corresponds to the array of resource item names.
 boolean isResourceItemAvailable(java.lang.String name)
          Returns true if there is a resource item with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ResourceManager getInstance()
Returns an instance to the single object


addResources

public void addResources(java.lang.String resourcesName)
Takes the name of resources to be loaded and available during runtime. The given name is used to instantiate a ResourceBundle, therefore that class's conventions for property file and class names do apply. All definitions are read and accordingly, ResourceItem objects are created.


isResourceItemAvailable

public boolean isResourceItemAvailable(java.lang.String name)
Returns true if there is a resource item with the given name.


getResourceItem

public ResourceItem getResourceItem(java.lang.String name)
Returns a ResourceItem if one has been initialized for the given name.

Throws:
java.lang.RuntimeException - Thrown if there is no resource item with the given name.

getResourceItems

public ResourceItem[] getResourceItems(java.lang.String[] names)
Returns an array of ResourceItem objects that corresponds to the array of resource item names.

Throws:
java.lang.RuntimeException - Thrown if any of the resource items does not exist.

clear

public void clear()
Removes all resources.