|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.ResourceBundle
org.icenigrid.gridsam.core.util.XMLConfigReader
public class XMLConfigReader
Reads structured resource text data from an XML file and store it on a hashtable.
The hashtable keys are taken from the value of the first attribute of the
<item> elements.
The hash table values are hashtables containing the sub-items names as keys
and the sub-items data as value.
You instantiate the XMLConfigReader class in a program to read data from a XML file. Once the class is instantiated, it reads all the data in a XML file and loads into a DOM tree. Then it populates a hashtable so the getString method can be called to find text information based on a key and subkey.
Copyright (c) 2004-2005 Tecnick.com S.r.l (www.tecnick.com) Via Ugo Foscolo n.19 - 09045 Quartu Sant'Elena (CA) - ITALY www.tecnick.com - info@tecnick.com
Field Summary | |
---|---|
protected java.util.Hashtable |
hashcontents
The hastable that will contain data loaded from XML. |
protected int |
numberOfItems
Number of items (<item> elements). |
protected java.util.Vector |
vectOfItems
Vector to store items keys (<item>). |
Fields inherited from class java.util.ResourceBundle |
---|
parent |
Constructor Summary | |
---|---|
XMLConfigReader(java.lang.String xmlfile)
TMX to Hashtable conversion. |
Method Summary | |
---|---|
double |
getDouble(java.lang.String key,
java.lang.String subkey,
double def)
Call getString method to get a double value. |
int |
getInt(java.lang.String key,
java.lang.String subkey,
int def)
Call getString method to get an int value. |
java.lang.String |
getKey(java.lang.String subkey,
java.lang.String value)
Get the key for the selected subkey and value. |
java.util.Enumeration |
getKeys()
Define getKeys method. |
int |
getNumberOfItems()
Returns the number of items. |
java.lang.String |
getString(java.lang.String key,
java.lang.String subkey)
Overloading of getString method with additional subkey. |
java.lang.String |
getString(java.lang.String key,
java.lang.String subkey,
java.lang.String def)
Overloading of getString method with additional subkey and default parameter. |
java.lang.Object |
handleGetObject(java.lang.String key)
handleGetObject implementation. |
org.w3c.dom.Document |
parseXmlFile(java.lang.String filename,
boolean validating)
Parses an XML file and returns a DOM document. |
Methods inherited from class java.util.ResourceBundle |
---|
getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Hashtable hashcontents
protected int numberOfItems
protected java.util.Vector vectOfItems
Constructor Detail |
---|
public XMLConfigReader(java.lang.String xmlfile)
xmlfile
- the XML file to read, supports also URI resources or JAR resourcesMethod Detail |
---|
public org.w3c.dom.Document parseXmlFile(java.lang.String filename, boolean validating)
filename
- the name of XML filevalidating
- If true, the contents is validated against the DTD specified in the file.
public final java.lang.Object handleGetObject(java.lang.String key) throws java.util.MissingResourceException
handleGetObject
in class java.util.ResourceBundle
key
- the resource key
java.util.MissingResourceException
public int getNumberOfItems()
public java.util.Enumeration getKeys()
getKeys
in class java.util.ResourceBundle
public java.lang.String getString(java.lang.String key, java.lang.String subkey, java.lang.String def)
key
- name of keysubkey
- name of sub keydef
- default value
public java.lang.String getString(java.lang.String key, java.lang.String subkey)
key
- name of keysubkey
- name of sub key
getString(String, String, String)
public int getInt(java.lang.String key, java.lang.String subkey, int def)
key
- name of keysubkey
- name of sub keydef
- default value
public double getDouble(java.lang.String key, java.lang.String subkey, double def)
key
- name of keysubkey
- name of sub keydef
- default value
public java.lang.String getKey(java.lang.String subkey, java.lang.String value)
subkey
- String the subkeyvalue
- String the value to search
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |