|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.util.XMLConfig
public class XMLConfig
XML configuration management.
This class uses DOM paths of a specific form to refer to nodes in the XML document. Consider this XML structure:
| Nested Class Summary | |
|---|---|
static class |
XMLConfig.XMLConfigException
Exception in XMLConfig methods. |
| Field Summary | |
|---|---|
static String |
NL
Newline string. |
| Constructor Summary | |
|---|---|
XMLConfig()
Creates an empty configuration. |
|
XMLConfig(File f)
Creates a configuration from a file. |
|
XMLConfig(InputStream is)
Creates a configuration from an input stream. |
|
XMLConfig(Reader r)
Creates a configuration from a reader. |
|
XMLConfig(String filename)
Creates a configuration from a file name. |
|
XMLConfig(XMLConfig parent,
Node node)
Creates a configuration that is a part of another configuration, starting at the specified node. |
|
| Method Summary | |
|---|---|
Node |
createNode(String path)
Create the node specified by the DOM path. |
Node |
createNode(String path,
Node n)
Create the node specified by the DOM path. |
Node |
createNode(String path,
Node n,
boolean overwrite)
Create the node specified by the DOM path. |
String |
get(String path)
Returns the value as specified by the DOM path. |
String |
get(String path,
Node root)
Returns the value as specified by the DOM path. |
String |
get(String path,
Node root,
String defaultVal)
Returns the value as specified by the DOM path, or the default value if the value could not be found. |
String |
get(String path,
String defaultVal)
Returns the value as specified by the DOM path, or the default value if the value could not be found. |
boolean |
getBool(String path)
Returns the value as specified by the DOM path. |
boolean |
getBool(String path,
boolean defaultVal)
Returns the value as specified by the DOM path, or the default value if the value could not be found. |
boolean |
getBool(String path,
Node root)
Returns the value as specified by the DOM path. |
boolean |
getBool(String path,
Node root,
boolean defaultVal)
Returns the value as specified by the DOM path, or the default value if the value could not be found. |
int |
getInt(String path)
Returns the value as specified by the DOM path. |
int |
getInt(String path,
int defaultVal)
Returns the value as specified by the DOM path, or the default value if the value could not be found. |
int |
getInt(String path,
Node root)
Returns the value as specified by the DOM path. |
int |
getInt(String path,
Node root,
int defaultVal)
Returns the value as specified by the DOM path, or the default value if the value could not be found. |
List<String> |
getMultiple(String path)
Returns the value as specified by the DOM path. |
List<String> |
getMultiple(String path,
Node root)
Returns the value as specified by the DOM path. |
static String |
getNodePath(Node n)
Return the path of a node as it is used in XMLConfig. |
List<Node> |
getNodes(String path)
Returns the nodes as specified by the DOM path. |
List<Node> |
getNodes(String path,
Node root)
Returns the nodes as specified by the DOM path. |
boolean |
isDelegated()
|
void |
save(File f)
Saves configuration to a file. |
void |
save(OutputStream os)
Saves configuration to an output stream |
void |
save(String filename)
Saves configuration to a file specified by a file name. |
Node |
set(String path,
String value)
Set the value of the node or attribute specified by the DOM path. |
Node |
set(String path,
String value,
boolean overwrite)
Set the value of the node or attribute specified by the DOM path. |
Node |
set(String path,
String value,
Node n,
boolean overwrite)
Set the value of the node or attribute specified by the DOM path. |
String |
toString()
Returns a string representation of the object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String NL
| Constructor Detail |
|---|
public XMLConfig()
public XMLConfig(InputStream is)
is - input streampublic XMLConfig(Reader r)
r - reader
public XMLConfig(XMLConfig parent,
Node node)
parent - the configuration that contains this partnode - the node in the parent configuration where this part startspublic XMLConfig(File f)
f - filepublic XMLConfig(String filename)
filename - file name| Method Detail |
|---|
public boolean isDelegated()
public void save(OutputStream os)
os - output streampublic void save(File f)
f - filepublic void save(String filename)
filename - file namepublic String get(String path)
path - DOM path
public String get(String path,
Node root)
path - DOM pathroot - node where the search should start
public String get(String path,
String defaultVal)
path - DOM pathdefaultVal - default value in case value is not in DOM
public String get(String path,
Node root,
String defaultVal)
path - DOM pathroot - node where the search should startdefaultVal - default value in case value is not in DOM
public int getInt(String path)
path - DOM path
IllegalArgumentException
public int getInt(String path,
Node root)
path - DOM pathroot - node where the search should start
IllegalArgumentException
public int getInt(String path,
int defaultVal)
path - DOM pathdefaultVal - default value in case value is not in DOM
IllegalArgumentException
public int getInt(String path,
Node root,
int defaultVal)
path - DOM pathroot - node where the search should startdefaultVal - default value in case value is not in DOM
IllegalArgumentExceptionpublic boolean getBool(String path)
path - DOM path
IllegalArgumentException
public boolean getBool(String path,
Node root)
path - DOM pathroot - node where the search should start
IllegalArgumentException
public boolean getBool(String path,
boolean defaultVal)
path - DOM pathdefaultVal - default value in case value is not in DOM
IllegalArgumentException
public boolean getBool(String path,
Node root,
boolean defaultVal)
path - DOM pathroot - node where the search should startdefaultVal - default value in case value is not in DOM
IllegalArgumentExceptionpublic List<String> getMultiple(String path)
path - DOM path
public List<String> getMultiple(String path,
Node root)
path - DOM pathroot - node where the search should start
public List<Node> getNodes(String path)
path - DOM path
public List<Node> getNodes(String path,
Node root)
path - DOM pathroot - node where the search should start
public Node set(String path,
String value)
path - DOM pathvalue - node or attribute value
public Node set(String path,
String value,
boolean overwrite)
path - DOM pathvalue - node or attribute valueoverwrite - whether to overwrite (true) or add (false)
public Node set(String path,
String value,
Node n,
boolean overwrite)
path - DOM pathvalue - node or attribute valuen - node where the search should startoverwrite - whether to overwrite (true) or add (false) -- only applies for last node!
public Node createNode(String path)
path - DOM path
public Node createNode(String path,
Node n)
path - DOM pathn - node where the search should start, or null for the root
public Node createNode(String path,
Node n,
boolean overwrite)
path - DOM pathn - node where the search should start, or null for the rootoverwrite - whether to overwrite (true) or add (false) -- only applies for last node!
public String toString()
toString in class Objectpublic static String getNodePath(Node n)
n - node
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||