|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.common.utils.SimpleXml
public class SimpleXml
Utility class to load and save data from/to XML files using a very simple XML format.
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
log
|
Constructor Summary | |
---|---|
SimpleXml(java.io.File f)
Create a new SimpleXml object by loading a file. |
|
SimpleXml(java.io.InputStream resourceAsStream)
Create a new SimpleXml object by loading a file. |
|
SimpleXml(java.lang.String rootElement)
Create a new SimpleXml just containing the root element. |
Method Summary | |
---|---|
void |
add(java.lang.String key,
java.lang.String... values)
Add entries to the current set of settings. |
java.util.List<java.lang.String> |
getList(java.lang.String key)
Get list of all items matching the key. |
java.lang.String |
getString(java.lang.String key)
Get the first entry that matches the key. |
StringTree<java.lang.String> |
getTree(java.lang.String path)
Return a tree structure reflecting the XML and trimmed values. |
boolean |
hasKey(java.lang.String key)
Checks if a setting with the specified key exists. |
void |
save(java.io.File f)
Save the current settings as an XML file. |
void |
update(java.lang.String key,
java.lang.String... values)
Removes current settings for a key and adds new values for the same key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log log
Constructor Detail |
---|
public SimpleXml(java.io.File f)
f
- XML file to loadpublic SimpleXml(java.lang.String rootElement)
rootElement
- Name of the root elementpublic SimpleXml(java.io.InputStream resourceAsStream)
resourceAsStream
- XML file to loadMethod Detail |
---|
public void add(java.lang.String key, java.lang.String... values)
key
- the key to addvalues
- the values to add
ArgumentNotValid
- if the key is null or empty, or the value is nullpublic void update(java.lang.String key, java.lang.String... values)
key
- The key for which the value should be updated.values
- The new values that should be set for the key.
UnknownID
- if the key does not exist
ArgumentNotValid
- if the key is null or empty, or any of the values are nullpublic java.lang.String getString(java.lang.String key)
key
- the key of the entry.
UnknownID
- if no element matches the key
ArgumentNotValid
- if the key is null or emptypublic boolean hasKey(java.lang.String key)
key
- a key for a setting
ArgumentNotValid
- if key is null or emptypublic java.util.List<java.lang.String> getList(java.lang.String key)
key
- the path down to elements to get
public void save(java.io.File f)
f
- the file to write the XML to.public StringTree<java.lang.String> getTree(java.lang.String path)
path
- Dotted path into the xml.
UnknownID
- If the path does not exist in the tree or is ambiguous
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |