Constructor and Description |
---|
SimpleXml(File f)
Create a new SimpleXml object by loading a file.
|
SimpleXml(InputStream resourceAsStream)
Create a new SimpleXml object by loading a file.
|
SimpleXml(String rootElement)
Create a new SimpleXml just containing the root element.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String key,
String... values)
Add entries to the current set of settings.
|
List<String> |
getList(String key)
Get list of all items matching the key.
|
String |
getString(String key)
Get the first entry that matches the key.
|
StringTree<String> |
getTree(String path)
Return a tree structure reflecting the XML and trimmed values.
|
boolean |
hasKey(String key)
Checks if a setting with the specified key exists.
|
void |
save(File f)
Save the current settings as an XML file.
|
void |
update(String key,
String... values)
Removes current settings for a key and adds new values for the same key.
|
public SimpleXml(File f)
f
- XML file to loadpublic SimpleXml(String rootElement)
rootElement
- Name of the root elementpublic SimpleXml(InputStream resourceAsStream)
resourceAsStream
- XML file to loadpublic void add(String key, String... values)
key
- the key to addvalues
- the values to addArgumentNotValid
- if the key is null or empty, or the value is nullpublic void update(String key, 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 existArgumentNotValid
- if the key is null or empty, or any of the values are nullpublic String getString(String key)
key
- the key of the entry.UnknownID
- if no element matches the keyArgumentNotValid
- if the key is null or emptypublic boolean hasKey(String key)
key
- a key for a settingArgumentNotValid
- if key is null or emptypublic List<String> getList(String key)
key
- the path down to elements to getpublic void save(File f)
f
- the file to write the XML to.public StringTree<String> getTree(String path)
path
- Dotted path into the xml.UnknownID
- If the path does not exist in the tree or is ambiguousCopyright © 2005–2016 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.