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(Object container,
NameCoder nameCoder)
Constructs an AbstractDocumentWriter.
|
AbstractDocumentWriter(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 Object |
createNode(String name)
Create a node.
|
void |
endNode() |
void |
endNodeInternally()
Called when a node ends.
|
void |
flush()
Flush the writer, if necessary.
|
protected Object |
getCurrent() |
List |
getTopLevelNodes()
Retrieve a
List with the top elements. |
void |
startNode(String name) |
escapeXmlName
encodeAttribute, encodeNode, startNode, underlyingWriter
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAttribute, setValue, underlyingWriter
public AbstractDocumentWriter(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(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(String name)
startNode
in interface HierarchicalStreamWriter
protected abstract Object createNode(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 Object getCurrent()
public 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–2016 XStream. All rights reserved.