public abstract class AbstractDocumentWriter extends AbstractXmlWriter implements DocumentWriter
HierarchicalStreamWriter
for DOM writer
implementations. The implementation manages a list of top level DOM nodes. Every time the
last node is closed on the node stack, the next started node is added to the list. This list
can be retrieved using the DocumentWriter.getTopLevelNodes()
method.Constructor and Description |
---|
AbstractDocumentWriter(java.lang.Object container,
NameCoder nameCoder)
Constructs an AbstractDocumentWriter.
|
AbstractDocumentWriter(java.lang.Object container,
XmlFriendlyReplacer replacer)
Deprecated.
As of 1.4 use
AbstractDocumentWriter(Object, NameCoder)
instead. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the writer, if necessary.
|
protected abstract java.lang.Object |
createNode(java.lang.String name)
Create a node.
|
void |
endNode() |
void |
endNodeInternally()
Called when a node ends.
|
void |
flush()
Flush the writer, if necessary.
|
protected java.lang.Object |
getCurrent() |
java.util.List |
getTopLevelNodes()
Retrieve a
List with the top elements. |
void |
startNode(java.lang.String name) |
escapeXmlName
encodeAttribute, encodeNode, startNode, underlyingWriter
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAttribute, setValue, underlyingWriter
public AbstractDocumentWriter(java.lang.Object container, NameCoder nameCoder)
container
- the top level container for the nodes to create (may be
null
)nameCoder
- the object that creates XML-friendly namespublic AbstractDocumentWriter(java.lang.Object container, XmlFriendlyReplacer replacer)
AbstractDocumentWriter(Object, NameCoder)
instead.container
- the top level container for the nodes to create (may be
null
)replacer
- the object that creates XML-friendly namespublic final void startNode(java.lang.String name)
startNode
in interface HierarchicalStreamWriter
protected abstract java.lang.Object createNode(java.lang.String name)
getCurrent()
returns null
the node is a top level node.name
- the node namepublic final void endNode()
endNode
in interface HierarchicalStreamWriter
public void endNodeInternally()
protected final java.lang.Object getCurrent()
public java.util.List getTopLevelNodes()
DocumentWriter
List
with the top elements. In the standard use case this list will
only contain a single element. Additional elements can only occur, if
HierarchicalStreamWriter.startNode(String)
of the implementing
HierarchicalStreamWriter
was called multiple times with an empty node stack. Such
a situation occurs calling
XStream.marshal(Object, HierarchicalStreamWriter)
multiple times directly.getTopLevelNodes
in interface DocumentWriter
List
with top nodespublic void flush()
HierarchicalStreamWriter
flush
in interface HierarchicalStreamWriter
public void close()
HierarchicalStreamWriter
close
in interface HierarchicalStreamWriter
Copyright © 2004–2024 XStream. All rights reserved.