|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.genuine.resources.ResourceManager
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:
text
: A text to be shown - as message text, menu, for an action (menu item, button).
If there is an ampersand (&), the character following the ampersand
is used as mnemonic for actions.image
: An image to be shown - for an action (menu item, button), message boxlargeimage
: A large image to be shown - in a splash screen, info dialog tooltip
: A tool tip to be shown - for an action (menu item, button), menukey
: A key stroke to be registered - for an action (menu item, button)title
: A text to be shown as title - of the application, of a message boxtype
: A typifier - for a message box ("error", "warning", "info", "status")choices
: A comma separated list of resource item names - for a message box to name the buttons
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 |
public static ResourceManager getInstance()
public void addResources(java.lang.String resourcesName)
ResourceBundle
, therefore
that class's conventions for property file and class names do apply.
All definitions are read and accordingly, ResourceItem
objects
are created.
public boolean isResourceItemAvailable(java.lang.String name)
public ResourceItem getResourceItem(java.lang.String name)
ResourceItem
if one has been initialized for the
given name.
java.lang.RuntimeException
- Thrown if there is no resource item with the
given name.public ResourceItem[] getResourceItems(java.lang.String[] names)
ResourceItem
objects that corresponds to the
array of resource item names.
java.lang.RuntimeException
- Thrown if any of the resource items does not exist.public void clear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |