public class Configurer
extends java.lang.Object
implements org.w3c.dom.DOMErrorHandler, org.w3c.dom.ls.LSParserFilter
LSParserFilter
s provide applications the ability to examine
nodes as they are being constructed while parsing. As each node is
examined, it may be modified or removed, or the entire parse may be
terminated early.
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEFAULT_NAMESPACES
Default namespaces support (true).
|
protected static int |
DEFAULT_PARSE_MODE
Field DEFAULT_PARSE_MODE
|
protected static boolean |
DEFAULT_SCHEMA_VALIDATION
Default Schema validation support (false).
|
protected static boolean |
DEFAULT_VALIDATION
Default validation support (false).
|
protected static int |
FILE_PARSE_MODE
Field FILE_PARSE_MODE
|
protected static int |
STRING_PARSE_MODE
Field STRING_PARSE_MODE
|
Constructor and Description |
---|
Configurer() |
Modifier and Type | Method and Description |
---|---|
short |
acceptNode(org.w3c.dom.Node enode) |
static org.w3c.dom.Node |
getNode(org.w3c.dom.Document doc,
java.lang.String path)
Method to get the Node object associated with a specific path
into an XML document.
|
static java.lang.String |
getValue(org.w3c.dom.Document doc,
java.lang.String path)
Method to get the value of the Node object given by the path argument or
null if there is no such object.
|
int |
getWhatToShow() |
boolean |
handleError(org.w3c.dom.DOMError error)
Method to handle errors.
|
static void |
newContainer(org.w3c.dom.Document doc,
java.lang.String path,
java.lang.String name)
Method to add a new container DataNode object to the
Node object given by the path argument.
|
static void |
newValue(org.w3c.dom.Document doc,
java.lang.String path,
java.lang.String name,
java.lang.String value)
Method to add an attribute (name/value pair) DataNode object
to or replace one with the same name associated with the
Node object given by the path argument.
|
static org.w3c.dom.Document |
parseFile(java.lang.String configFile)
Method to parse a file containing an XML configuration.
|
static org.w3c.dom.Document |
parseString(java.lang.String xmlConfig)
Method to parse a string containing an XML configuration.
|
static void |
removeEmptyTextNodes(org.w3c.dom.Element node)
Remove any empty text (child) nodes from a DOM node.
|
static java.lang.String |
serialize(org.w3c.dom.Document doc)
Method to serialize a DOM XML document into a string.
|
static void |
setLogger(Logger logger) |
static void |
setValue(org.w3c.dom.Document doc,
java.lang.String path,
java.lang.String value)
Method to set the value of the DataNode object associated with the
Node object given by the path argument.
|
short |
startElement(org.w3c.dom.Element elt) |
static DataNode |
treeToPanel(org.w3c.dom.Node node,
int level)
Recursive method to, using the given arg as the top of the tree, add all nodes
in the tree to a JPanel for display in a GUI.
|
protected static final boolean DEFAULT_NAMESPACES
protected static final boolean DEFAULT_VALIDATION
protected static final boolean DEFAULT_SCHEMA_VALIDATION
protected static final int DEFAULT_PARSE_MODE
protected static final int STRING_PARSE_MODE
protected static final int FILE_PARSE_MODE
public static void setLogger(Logger logger)
public static void removeEmptyTextNodes(org.w3c.dom.Element node)
node
- node from which to remove empty (child) text nodespublic static org.w3c.dom.Document parseFile(java.lang.String configFile) throws DataNotFoundException
configFile
- file containing an XML configurationDataNotFoundException
- whenpublic static org.w3c.dom.Document parseString(java.lang.String xmlConfig) throws DataNotFoundException
xmlConfig
- string containing an XML configurationDataNotFoundException
- whenpublic static java.lang.String serialize(org.w3c.dom.Document doc)
doc
- DOM object to serialize to stringpublic boolean handleError(org.w3c.dom.DOMError error)
handleError
in interface org.w3c.dom.DOMErrorHandler
error
- error of type DOMErrorpublic short acceptNode(org.w3c.dom.Node enode)
acceptNode
in interface org.w3c.dom.ls.LSParserFilter
LSParserFilter.acceptNode(Node)
public int getWhatToShow()
getWhatToShow
in interface org.w3c.dom.ls.LSParserFilter
LSParserFilter.getWhatToShow()
public short startElement(org.w3c.dom.Element elt)
startElement
in interface org.w3c.dom.ls.LSParserFilter
LSParserFilter.startElement(Element)
public static java.lang.String getValue(org.w3c.dom.Document doc, java.lang.String path) throws DataNotFoundException
doc
- DOM XML Document objectpath
- path into the XML objectDataNotFoundException
- never thrownpublic static void setValue(org.w3c.dom.Document doc, java.lang.String path, java.lang.String value) throws DataNotFoundException
doc
- DOM XML Document objectpath
- path into the XML objectvalue
- value to set the DataNode object toDataNotFoundException
- whenpublic static void newValue(org.w3c.dom.Document doc, java.lang.String path, java.lang.String name, java.lang.String value) throws DataNotFoundException
Not Used.
doc
- DOM XML Document objectpath
- path into the XML objectname
- name of new attribute to addvalue
- value of the new attributeDataNotFoundException
- whenpublic static void newContainer(org.w3c.dom.Document doc, java.lang.String path, java.lang.String name) throws DataNotFoundException
Not Used.
doc
- DOM XML Document objectpath
- path into the XML objectname
- name of new container to addDataNotFoundException
- whenpublic static DataNode treeToPanel(org.w3c.dom.Node node, int level)
(Formerly method named getDataNodes.)
node
- Node object to be displayed in a JPanellevel
- level of node in XML document tree (0 = top)public static org.w3c.dom.Node getNode(org.w3c.dom.Document doc, java.lang.String path) throws DataNotFoundException
doc
- DOM XML Document objectpath
- path into the XML objectDataNotFoundException
- when