|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bibalex.daf.managers.resourcemanager.ResourceManager
public class ResourceManager
Handles the resource file. This class employs Singleton design pattern to enforce one instance of this class.
The resource file is assumed to be in the following format:
<Resource>
<Section Name="Section Name">
<Element Name="Element Name" Caption="" Attribute1="" Attribute2="" ... />
<Element Name="Element Name" Caption="" Attribute1="" Attribute2="" ... />
.
.
.
</Section>
.
.
.
<Resource/>
Field Summary | |
---|---|
private org.w3c.dom.Node |
currentSection
The current section that values are read from. |
private static org.w3c.dom.Document |
document
The document that is used by the ResourceManager. |
private XmlHandler |
handler
An XmlHandler to handle XPath queries. |
Constructor Summary | |
---|---|
ResourceManager()
Creates a new instance of ResourceManager. |
Method Summary | |
---|---|
org.w3c.dom.Node |
getCurrentSection()
Gets the current section in the document. |
ResourceElement |
getElement(java.lang.String elementName)
Gets the ResourceElement within the given name within the |
ResourceElement[] |
getElements(java.lang.String sectionName)
Gets all the ResourceElements within the given name within the |
static void |
initialize(java.lang.String resourceFile)
Initializes a Document to be shared among all the ResourceManager instances. |
static int |
readInteger(java.lang.String sectionName,
java.lang.String elementName,
int defaultValue)
Reads an integer from the resource file. |
boolean |
setCurrentSection(java.lang.String sectionName)
Sets the current section to read values from. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static org.w3c.dom.Document document
private org.w3c.dom.Node currentSection
private XmlHandler handler
Constructor Detail |
---|
public ResourceManager()
Method Detail |
---|
public static void initialize(java.lang.String resourceFile) throws ResourceManagerException
resourceFile
- The path of the resource file.
ResourceManagerException
- If the Document instance couldn't be created.public static int readInteger(java.lang.String sectionName, java.lang.String elementName, int defaultValue)
sectionName
- The section name.elementName
- The element name whose caption holds the number.defaultValue
- The default number to use if data cannot be read from the resource file.
public boolean setCurrentSection(java.lang.String sectionName)
sectionName
- The name of the section to use.
public org.w3c.dom.Node getCurrentSection()
public ResourceElement getElement(java.lang.String elementName)
elementName
- The name of the ResourceElement to retrieve.
public ResourceElement[] getElements(java.lang.String sectionName)
sectionName
- The name of the section to retrieve.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |