|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.ucsb.nceas.morpho.framework.ConfigXML
This class is designed to store configuration information in an XML file. The concept is similar to that of a Properties file except that using the XML format allows for a hierarchy of properties and repeated properties. All 'keys' are element names, while values are always stored as XML text nodes. The XML file is parsed and stored in memory as a DOM object. Note that nodes are specified by node tags rather than paths
Constructor Summary | |
ConfigXML(java.lang.String filename)
String passed to the creator is the XML config file name |
Method Summary | |
void |
addChild(java.lang.String parentName,
int i,
java.lang.String childName,
java.lang.String value)
Add a child node to the specified parent |
java.util.Vector |
get(java.lang.String key)
Gets the value(s) corresponding to a key string (i.e. |
java.lang.String |
get(java.lang.String key,
int i)
Gets the value(s) corresponding to a key string (i.e. |
java.util.Hashtable |
getHashtable(java.lang.String parentName,
java.lang.String keyName,
java.lang.String valueName)
Assume that there is some parent node which has a subset of child nodes that are repeated e.g. |
org.w3c.dom.NodeList |
getPathContent(java.lang.String path)
gets the content of a tag in a given xml file with the given path |
java.util.Vector |
getValuesForPath(java.lang.String pathstring)
|
boolean |
insert(java.lang.String key,
java.lang.String value)
Inserts another node before the first element with the name contained in 'key', otherwise appends it to the end of the config file (last element in root node) |
protected java.lang.String |
normalize(java.lang.String s)
Normalizes the given string. |
void |
print(org.w3c.dom.Node node)
This method can 'print' any DOM subtree. |
void |
removeChildren(java.lang.String parentName,
int i)
removes all children of the specified parent |
void |
removeNode(java.lang.String nodeName,
int i)
deletes indicated node |
void |
save()
Save the configuration file |
void |
saveDOM(org.w3c.dom.Node nd)
This method wraps the 'print' method to send DOM back to the XML document (file) that was used to create the DOM. |
boolean |
set(java.lang.String key,
int i,
java.lang.String value)
used to set a value corresponding to 'key'; value is changed in DOM structure in memory |
protected org.w3c.dom.Attr[] |
sortAttributes(org.w3c.dom.NamedNodeMap attrs)
Returns a sorted list of attributes. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ConfigXML(java.lang.String filename) throws java.io.FileNotFoundException
filename
- name of XML fileMethod Detail |
public java.util.Vector get(java.lang.String key)
key
- 'key' is element name.public java.lang.String get(java.lang.String key, int i)
key
- 'key' is element name.i
- zero based index of elements with the name stored in keypublic boolean set(java.lang.String key, int i, java.lang.String value)
key
- 'key' is element name.i
- index in set of elements with 'key' namevalue
- new value to be inserted in ith keypublic boolean insert(java.lang.String key, java.lang.String value)
key
- element name which will be duplicatedvalue
- value for new elementpublic void addChild(java.lang.String parentName, int i, java.lang.String childName, java.lang.String value)
parentName
- name of parent elementi
- index of parent elementchildName
- element name of new childvalue
- value of new childpublic void removeNode(java.lang.String nodeName, int i)
nodeName
- node tagi
- node indexpublic void removeChildren(java.lang.String parentName, int i)
parentName
- Name of parent nodei
- index of parent nodepublic java.util.Hashtable getHashtable(java.lang.String parentName, java.lang.String keyName, java.lang.String valueName)
public void save()
public void saveDOM(org.w3c.dom.Node nd)
nd
- node (usually the document root)public void print(org.w3c.dom.Node node)
node
- node usually set to the 'doc' node for complete XML file
re-writeprotected org.w3c.dom.Attr[] sortAttributes(org.w3c.dom.NamedNodeMap attrs)
protected java.lang.String normalize(java.lang.String s)
public java.util.Vector getValuesForPath(java.lang.String pathstring)
public org.w3c.dom.NodeList getPathContent(java.lang.String path)
path
- the path to get the content from
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |