public interface OutputNode extends Node
OutputNode
object is used to represent a cursor
which can be used to write XML elements and attributes. Each of
the output node objects represents a element, and can be used
to add attributes to that element as well as child elements.Modifier and Type | Method and Description |
---|---|
void |
commit()
The
commit method is used flush and commit any
child nodes that have been created by this node. |
NodeMap |
getAttributes()
This returns a
NodeMap which can be used to add
nodes to the element before that element has been committed. |
OutputNode |
getChild(java.lang.String name)
This is used to create a child element within the element that
this object represents.
|
Mode |
getMode()
The
Mode is used to indicate the output mode
of this node. |
OutputNode |
getParent()
This is used to acquire the
Node that is the
parent of this node. |
boolean |
isCommitted()
This is used to determine whether the node has been committed.
|
boolean |
isRoot()
This method is used to determine if this node is the root
node for the XML document.
|
void |
remove()
This is used to remove any uncommitted changes.
|
void |
setAttribute(java.lang.String name,
java.lang.String value)
This method is used for convinience to add an attribute node
to the attribute
NodeMap . |
void |
setData(boolean data)
This is used to set the output mode of this node to either
be CDATA or escaped.
|
void |
setMode(Mode mode)
This is used to set the output mode of this node to either
be CDATA, escaped, or inherited.
|
void |
setValue(java.lang.String value)
This is used to set a text value to the element.
|
boolean isRoot()
NodeMap getAttributes()
NodeMap
which can be used to add
nodes to the element before that element has been committed.
Nodes can be removed or added to the map and will appear as
attributes on the written element when it is committed.Mode getMode()
Mode
is used to indicate the output mode
of this node. Three modes are possible, each determines
how a value, if specified, is written to the resulting XML
document. This is determined by the setData
method which will set the output to be CDATA or escaped,
if neither is specified the mode is inherited.void setMode(Mode mode)
mode
- this is the output mode to set the node tovoid setData(boolean data)
data
- if true the value is written as a CDATA blockvoid setValue(java.lang.String value)
value
- this is the text value to add to this elementjava.lang.Exception
- thrown if the text value cannot be addedvoid setAttribute(java.lang.String name, java.lang.String value)
NodeMap
. The attribute added
can be removed from the element by useing the node map.name
- this is the name of the attribute to be addedvalue
- this is the value of the node to be addedOutputNode getParent()
Node
that is the
parent of this node. This will return the node that is
the direct parent of this node and allows for siblings to
make use of nodes with their parents if required.OutputNode getChild(java.lang.String name) throws java.lang.Exception
OutputNode
object can be used to add
attributes to the child element as well as other elements.name
- this is the name of the child element to createjava.lang.Exception
void remove() throws java.lang.Exception
java.lang.Exception
- thrown if the node cannot be removedvoid commit() throws java.lang.Exception
commit
method is used flush and commit any
child nodes that have been created by this node. This allows
the output to be completed when building of the XML document
has been completed. If output fails an exception is thrown.java.lang.Exception
- thrown if the node cannot be committedboolean isCommitted()