Top Description Fields Constructors Methods
com.thoughtworks.xstream.io.xml

public abstract Class AbstractDocumentWriter

extends AbstractXmlWriter
implements DocumentWriter
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.io.xml.DocumentWriter, com.thoughtworks.xstream.io.HierarchicalStreamWriter
Known Direct Subclasses
com.thoughtworks.xstream.io.xml.Dom4JWriter, com.thoughtworks.xstream.io.xml.DomWriter, com.thoughtworks.xstream.io.xml.JDom2Writer, com.thoughtworks.xstream.io.xml.JDomWriter, com.thoughtworks.xstream.io.xml.XomWriter, com.thoughtworks.xstream.io.xml.XppDomWriter
Imports
com.thoughtworks.xstream.core.util.FastStack, com.thoughtworks.xstream.io.naming.NameCoder, java.util.ArrayList, .List

Deprecated

as a consequence of AbstractXmlWriter being deprecated. See corresponding docs for further information.

A generic com.thoughtworks.xstream.io.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.
Authors
Laurent Bihanic, Jörg Schaible
Since
1.2.1

Field Summary

Modifier and TypeField and Description
private final FastStack
private final List<E>

Constructor Summary

AccessConstructor and Description
public
AbstractDocumentWriter(final Object
the top level container for the nodes to create (may be null)
container
,
final NameCoder
the object that creates XML-friendly names
nameCoder
)

Constructs an AbstractDocumentWriter.

public
AbstractDocumentWriter(final Object
the top level container for the nodes to create (may be null)
container
,
final XmlFriendlyReplacer
the object that creates XML-friendly names
replacer
)

Constructs an AbstractDocumentWriter.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.close.

Close the writer, if necessary.
protected abstract Object

Returns:

the new node
createNode
(String
the node name
name
)

Create a node.

public final void
public void
endNodeInternally()

Called when a node ends.

public void
flush()

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.flush.

Flush the writer, if necessary.
protected final Object
public List<E>
public final void
Inherited from com.thoughtworks.xstream.io.xml.AbstractXmlWriter:
escapeXmlName

Field Detail

nodeStackback to summary
private final FastStack nodeStack
resultback to summary
private final List<E> result

Constructor Detail

AbstractDocumentWriterback to summary
public AbstractDocumentWriter(final Object container, final NameCoder nameCoder)

Constructs an AbstractDocumentWriter.

Parameters
container:Object

the top level container for the nodes to create (may be null)

nameCoder:NameCoder

the object that creates XML-friendly names

Since
1.4
AbstractDocumentWriterback to summary
public AbstractDocumentWriter(final Object container, final XmlFriendlyReplacer replacer)

Constructs an AbstractDocumentWriter.

Parameters
container:Object

the top level container for the nodes to create (may be null)

replacer:XmlFriendlyReplacer

the object that creates XML-friendly names

Since
1.2.1

Method Detail

closeback to summary
public void close()

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.close.

Doc from com.thoughtworks.xstream.io.HierarchicalStreamWriter.close.

Close the writer, if necessary.

createNodeback to summary
protected abstract Object createNode(String name)

Create a node. The provided node name is not yet XML friendly. If getCurrent() returns null the node is a top level node.

Parameters
name:String

the node name

Returns:Object

the new node

Since
1.2.1
endNodeback to summary
public final void endNode()

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.endNode.

endNodeInternallyback to summary
public void endNodeInternally()

Called when a node ends. Hook for derived implementations.

Since
1.2.1
flushback to summary
public void flush()

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.flush.

Doc from com.thoughtworks.xstream.io.HierarchicalStreamWriter.flush.

Flush the writer, if necessary.

getCurrentback to summary
protected final Object getCurrent()
Since
1.2.1
getTopLevelNodesback to summary
public List<E> getTopLevelNodes()

Implements com.thoughtworks.xstream.io.xml.DocumentWriter.getTopLevelNodes.

Doc from com.thoughtworks.xstream.io.xml.DocumentWriter.getTopLevelNodes.

Retrieve a 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 com.thoughtworks.xstream.XStream#marshal(Object, HierarchicalStreamWriter) multiple times directly.

Returns:List<E>

a List with top nodes

startNodeback to summary
public final void startNode(final String name)

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.startNode.