public abstract class

AbstractDocumentWriter

extends AbstractXmlWriter
implements DocumentWriter
java.lang.Object
   ↳ com.thoughtworks.xstream.io.xml.AbstractXmlWriter
     ↳ com.thoughtworks.xstream.io.xml.AbstractDocumentWriter
Known Direct Subclasses

Class Overview

A generic 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 getTopLevelNodes() method.

Summary

Public Constructors
AbstractDocumentWriter(Object container, XmlFriendlyReplacer replacer)
Constructs an AbstractDocumentWriter.
Public Methods
void close()
Close the writer, if necessary.
final void endNode()
void endNodeInternally()
Called when a node ends.
void flush()
Flush the writer, if necessary.
List getTopLevelNodes()
Retrieve a List with the top elements.
final void startNode(String name)
Protected Methods
abstract Object createNode(String name)
Create a node.
final Object getCurrent()
[Expand]
Inherited Methods
From class com.thoughtworks.xstream.io.xml.AbstractXmlWriter
From class java.lang.Object
From interface com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
From interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
From interface com.thoughtworks.xstream.io.xml.DocumentWriter
From interface com.thoughtworks.xstream.io.xml.XmlFriendlyWriter

Public Constructors

public AbstractDocumentWriter (Object container, XmlFriendlyReplacer replacer)

Constructs an AbstractDocumentWriter.

Parameters
container the top level container for the nodes to create (may be null)
replacer the object that creates XML-friendly names

Public Methods

public void close ()

Close the writer, if necessary.

public final void endNode ()

public void endNodeInternally ()

Called when a node ends. Hook for derived implementations.

public void flush ()

Flush the writer, if necessary.

public List 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 startNode(String) of the implementing HierarchicalStreamWriter was called multiple times with an empty node stack. Such a situation occurs calling marshal(Object, HierarchicalStreamWriter) multiple times directly.

Returns
  • a List with top nodes

public final void startNode (String name)

Protected Methods

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 the node name
Returns
  • the new node

protected final Object getCurrent ()