|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectXMLDoc
public class XMLDoc
The XMLDoc class provides access to the elements and attributes of a specified XML Document object through a simplified interface. Use the default constructor to instantiate an XMLDoc object. You must then use one of the methods setDocument(), newDocument(), or load() to prepare the object for use. Once the Document object is established, you can use XPath expressions to search the member document. You can also append elements, attributes, and other documents into the member document. Finally, you can serialize the document to a specified outputstream object.
Field Summary | |
---|---|
static int |
AFTER
|
static int |
BEFORE
|
static int |
CHILD
|
private org.w3c.dom.Document |
doc
|
private java.lang.String |
fileName
|
private boolean |
ignore
|
static int |
REPLACE
|
private javax.xml.xpath.XPath |
xpath
|
Constructor Summary | |
---|---|
XMLDoc()
|
Method Summary | |
---|---|
void |
appendAttribute(org.w3c.dom.Element _parent,
java.lang.String _name,
java.lang.String _value)
Use the specified name and value to create and append an attribute to the specified parent element. |
org.w3c.dom.Node |
appendDoc(org.w3c.dom.Node _context,
org.w3c.dom.Document _doc,
int _where)
Clone and append the document element of the specified document to the member document to the specified context node. |
org.w3c.dom.Element |
appendElement(org.w3c.dom.Element _child)
Append the specified element as the document element of the document. |
org.w3c.dom.Element |
appendElement(org.w3c.dom.Element _context,
org.w3c.dom.Element _node,
int _where)
Use the specified name to create and append an element to the specified parent element. |
org.w3c.dom.Element |
appendElement(org.w3c.dom.Element _context,
java.lang.String _name,
int _where)
Use the specified name to create and append an element to the specified parent element. |
org.w3c.dom.Element |
appendElement(org.w3c.dom.Element _context,
java.lang.String _name,
java.lang.String _value,
int _where)
Use the specified name to create and append an element to the specified parent element. |
org.w3c.dom.Node |
appendForeignElement(org.w3c.dom.Node _context,
org.w3c.dom.Node _node,
int _where,
boolean _deep)
|
org.w3c.dom.Element |
createElement(java.lang.String _name)
Use the specified name to create an element. |
org.w3c.dom.Element |
createElement(java.lang.String _name,
java.lang.String _value)
Use the specified name to create an element. |
void |
flushWhiteSpace()
Flush ALL text nodes - temporary until setIgnoringElementContentWhitespace works? From my reading on the inet, that will happen when hell freezes over. |
java.lang.String |
getAttributeValue(org.w3c.dom.Node _node,
java.lang.String _name,
java.lang.String _default)
Get the value of the specified attribute for the specified node, which is assumed to be an element. |
org.w3c.dom.Document |
getDocument()
Return the member Document object. |
org.w3c.dom.Node |
getDocumentElement()
Return the document element |
java.lang.String |
getFileName()
|
java.lang.String |
getValue(org.w3c.dom.Node _context,
java.lang.String _path,
java.lang.String _default)
Search the specified context node for a node identified by the specified XPath expression, and obtain the value of the node. |
java.lang.String |
getValue(java.lang.String _path,
java.lang.String _default)
Search the document for a node identified by the specified XPath expression, and obtain the value of the node. |
boolean |
hasChildren(org.w3c.dom.Node _node)
Check if the specified node has children. |
boolean |
hasPath(org.w3c.dom.Node _context,
java.lang.String _path)
Search the document for a node identified by the specified XPath expression. |
boolean |
hasPath(java.lang.String _path)
Search the document for a node identified by the specified XPath expression. |
void |
ignoreWhiteSpace(boolean _ignore)
Set the flag to ignore white space. |
boolean |
load(java.io.InputStream _stream,
javax.xml.namespace.NamespaceContext _nc)
Load the XML document encapsulated by the specified input stream into the member Document object. |
boolean |
load(java.lang.String _fileName,
javax.xml.namespace.NamespaceContext _nc)
Load the XML configuration document specified by the file name parameter. |
boolean |
newDocument(javax.xml.namespace.NamespaceContext _nc)
Create a Document object, and set it as the managed member object. |
void |
removeAttribute(org.w3c.dom.Element _elem,
org.w3c.dom.Attr _attr)
Remove the specified attribute from the document. |
void |
removeAttribute(org.w3c.dom.Element _elem,
java.lang.String _attr)
Remove the specified attribute from the document. |
org.w3c.dom.Node |
removeNode(org.w3c.dom.Node _node)
Remove the specified node from the document. |
org.w3c.dom.NodeList |
selectChildren(org.w3c.dom.Node _node)
Obtain the nodes that are the children of the specified node. |
org.w3c.dom.NodeList |
selectNodes(org.w3c.dom.Node _context,
java.lang.String _path)
Search the specified context node for the set of nodes identified by the specified XPath expression. |
org.w3c.dom.NodeList |
selectNodes(java.lang.String _path)
Search the document for the set of nodes identified by the specified XPath expression. |
org.w3c.dom.Node |
selectSingleNode(org.w3c.dom.Node _context,
java.lang.String _path)
Search the specified context node for the single node identified by the specified XPath expression. |
org.w3c.dom.Node |
selectSingleNode(java.lang.String _path)
Search the document for the single node identified by the specified XPath expression. |
void |
serialize(java.io.OutputStream _output)
Serialize the member Document object to the specified output- stream. |
void |
serialize(java.lang.String _fileName)
Serialize the member Document object to the specified file. |
boolean |
setAttributeValue(org.w3c.dom.Node _node,
java.lang.String _name,
java.lang.String _value)
Check the value of the specified attribute. |
boolean |
setDocument(org.w3c.dom.Document _doc,
javax.xml.namespace.NamespaceContext _nc)
Set the member Document to the specified Document object. |
void |
setNamespaceContext(javax.xml.namespace.NamespaceContext _nc)
|
void |
setText(org.w3c.dom.Element _parent,
java.lang.String _value)
Set the text() node of the specified element to the specified value. |
boolean |
setValue(org.w3c.dom.Node _context,
java.lang.String _path,
java.lang.String _value)
Search the specified context node for a node identified by the specified XPath expression, and set its value to the specified value. |
boolean |
setValue(java.lang.String _path,
java.lang.String _value)
Search the specified context node for a node identified by the specified XPath expression, and set its value to the specified value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BEFORE
public static final int REPLACE
public static final int AFTER
public static final int CHILD
private boolean ignore
private org.w3c.dom.Document doc
private javax.xml.xpath.XPath xpath
private java.lang.String fileName
Constructor Detail |
---|
public XMLDoc()
Method Detail |
---|
public java.lang.String getFileName()
public void setNamespaceContext(javax.xml.namespace.NamespaceContext _nc)
public void ignoreWhiteSpace(boolean _ignore)
_ignore
- should be true to flush the whitespace from the
document.public void flushWhiteSpace()
public void serialize(java.io.OutputStream _output)
_output
- names the stream to which to serialize the
document.public void serialize(java.lang.String _fileName)
_fileName
- names the file to which to serialize the
document.public boolean setDocument(org.w3c.dom.Document _doc, javax.xml.namespace.NamespaceContext _nc)
_doc
- specifies the Document object for the XMLDoc to
manage.public boolean newDocument(javax.xml.namespace.NamespaceContext _nc)
public boolean load(java.io.InputStream _stream, javax.xml.namespace.NamespaceContext _nc)
_stream
- is the stream object to load.
public boolean load(java.lang.String _fileName, javax.xml.namespace.NamespaceContext _nc)
_fileName
- is the name of the file to be loaded.
public org.w3c.dom.Document getDocument()
public org.w3c.dom.Node getDocumentElement()
public org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node _context, java.lang.String _path)
_context
- is the node within the document relative to
which the XPath expression is evaluated._path
- is the XPath expression that identifies a single
node.
public org.w3c.dom.Node selectSingleNode(java.lang.String _path)
_path
- is the XPath expression that identifies a single
node.
public org.w3c.dom.NodeList selectNodes(org.w3c.dom.Node _context, java.lang.String _path)
_context
- is the node within the document relative to
which the XPath expression is evaluated._path
- is the XPath expression that identifies a set of
nodes.
public org.w3c.dom.NodeList selectNodes(java.lang.String _path)
_path
- is the XPath expression that identifies a set of
nodes.
public org.w3c.dom.NodeList selectChildren(org.w3c.dom.Node _node)
_node
- is the parent of the desired nodes.
public boolean hasChildren(org.w3c.dom.Node _node)
_node
- to check.
public boolean hasPath(org.w3c.dom.Node _context, java.lang.String _path)
_path
- is the XPath expression that identifies a node.
public boolean hasPath(java.lang.String _path)
_path
- is the XPath expression that identifies a node.
public java.lang.String getValue(org.w3c.dom.Node _context, java.lang.String _path, java.lang.String _default)
_context
- is the node within the document relative to
which the XPath expression is evaluated._path
- is the XPath expression that identifies a node._default
- specifies the value to return if the result of
the search is empty.
public java.lang.String getAttributeValue(org.w3c.dom.Node _node, java.lang.String _name, java.lang.String _default)
_node
- is the element containing the attribute._name
- is the name of the attribute._default
- specifies the value to return if the attribute
value is empty.
public boolean setAttributeValue(org.w3c.dom.Node _node, java.lang.String _name, java.lang.String _value)
_node
- is the node within the document containing the
attribute._name
- is the name of the attribute to change._value
- specifies the value to use in setting the
attribute value.
public java.lang.String getValue(java.lang.String _path, java.lang.String _default)
_path
- is the XPath expression that identifies a node._default
- specifies the value to return if the result of
the search is empty.
public boolean setValue(java.lang.String _path, java.lang.String _value)
_path
- is the XPath expression that identifies a node._value
- specifies the value to use in setting the node
value.
public boolean setValue(org.w3c.dom.Node _context, java.lang.String _path, java.lang.String _value)
_context
- is the node within the document relative to
which the XPath expression is evaluated._path
- is the XPath expression that identifies a node._value
- specifies the value to use in setting the node
value.
public org.w3c.dom.Element createElement(java.lang.String _name)
_name
- is the new element to create.
public org.w3c.dom.Element createElement(java.lang.String _name, java.lang.String _value)
_name
- is the new element to create.
public org.w3c.dom.Node appendDoc(org.w3c.dom.Node _context, org.w3c.dom.Document _doc, int _where)
_context
- is the node to which to append the document_doc
- is the document whose document element is to be
appended._where
- identifies whether the document element should be
appended as a sibling before or after the context, or as a
child of the context node.
public org.w3c.dom.Node appendForeignElement(org.w3c.dom.Node _context, org.w3c.dom.Node _node, int _where, boolean _deep)
public org.w3c.dom.Element appendElement(org.w3c.dom.Element _child)
_child
- is the name of the new element.
public org.w3c.dom.Element appendElement(org.w3c.dom.Element _context, org.w3c.dom.Element _node, int _where)
_context
- is the element to which to append the new
element._node
- is the new element to append._where
- specifies the relationship to be established
between the context element and the new element.
public org.w3c.dom.Element appendElement(org.w3c.dom.Element _context, java.lang.String _name, int _where)
_context
- is the element to which to append the new
element._name
- is the name of the new element to append._where
- specifies the relationship to be established
between the context element and the new element.
public org.w3c.dom.Element appendElement(org.w3c.dom.Element _context, java.lang.String _name, java.lang.String _value, int _where)
_context
- is the element to which to append the new
element._name
- is the name of the new element._value
- is the string value of the text node to attach
to the new element._where
- specifies the relationship to be established
between the context element and the new element.
public org.w3c.dom.Node removeNode(org.w3c.dom.Node _node)
_node
- is the element to remove.
public void removeAttribute(org.w3c.dom.Element _elem, org.w3c.dom.Attr _attr)
_elem
- is the element owning the attribute._attr
- is the attribute to remove.public void removeAttribute(org.w3c.dom.Element _elem, java.lang.String _attr)
_elem
- is the element owning the attribute._attr
- is the attribute to remove.public void appendAttribute(org.w3c.dom.Element _parent, java.lang.String _name, java.lang.String _value)
_parent
- is the element to which to append the new
element as a child._name
- is the name of the new attribute._value
- is the string value of the new attribute.public void setText(org.w3c.dom.Element _parent, java.lang.String _value)
_parent
- is the element to assign the text node._value
- is the string value to set as the text node.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |