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<OutputNode> |
getAttributes()
This returns a
NodeMap which can be used to add
nodes to the element before that element has been committed. |
OutputNode |
getChild(String name)
This is used to create a child element within the element that
this object represents.
|
String |
getComment()
This is used to get the text comment for the element.
|
Mode |
getMode()
The
Mode is used to indicate the output mode
of this node. |
NamespaceMap |
getNamespaces()
This returns the
NamespaceMap for this node. |
OutputNode |
getParent()
This is used to acquire the
Node that is the
parent of this node. |
String |
getPrefix()
This is used to acquire the prefix for this output node.
|
String |
getPrefix(boolean inherit)
This is used to acquire the prefix for this output node.
|
String |
getReference()
This is used to acquire the namespace URI reference associated
with 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.
|
OutputNode |
setAttribute(String name,
String value)
This method is used for convenience to add an attribute node
to the attribute
NodeMap . |
void |
setComment(String comment)
This is used to set a text comment to the element.
|
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 |
setName(String name)
This is used to change the name of an output node.
|
void |
setReference(String reference)
This is used to set the reference for the node.
|
void |
setValue(String value)
This is used to set a text value to the element.
|
boolean isRoot()
NodeMap<OutputNode> 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 blockString getPrefix()
String getPrefix(boolean inherit)
inherit
- if there is no explicit prefix then inheritString getReference()
void setReference(String reference)
reference
- this is used to set the reference for the nodeNamespaceMap getNamespaces()
NamespaceMap
for this node. Only
an element can have namespaces, so if this node represents an
attribute the elements namespaces will be provided when this is
requested. By adding a namespace it becomes in scope for the
current element all all child elements of that element.String getComment()
void setComment(String comment)
comment
- this is the comment to set on the nodevoid setValue(String value)
value
- this is the text value to add to this elementException
- thrown if the text value cannot be addedvoid setName(String name)
name
- this is the name to change the node toOutputNode setAttribute(String name, String value)
NodeMap
. The attribute added
can be removed from the element by using 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(String name) throws 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 createException
void remove() throws Exception
Exception
- thrown if the node cannot be removedvoid commit() throws 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.Exception
- thrown if the node cannot be committedboolean isCommitted()