Class AbstractDocumentWriter
java.lang.Object
com.thoughtworks.xstream.io.AbstractWriter
com.thoughtworks.xstream.io.xml.AbstractXmlWriter
com.thoughtworks.xstream.io.xml.AbstractDocumentWriter
- All Implemented Interfaces:
ExtendedHierarchicalStreamWriter, HierarchicalStreamWriter, DocumentWriter, XmlFriendlyWriter
- Direct Known Subclasses:
Dom4JWriter, DomWriter, JDom2Writer, JDomWriter, XppDomWriter
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 DocumentWriter.getTopLevelNodes() method.- Since:
- 1.2.1
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDocumentWriter(Object container, NameCoder nameCoder) Constructs an AbstractDocumentWriter.AbstractDocumentWriter(Object container, XmlFriendlyReplacer replacer) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the writer, if necessary.protected abstract ObjectcreateNode(String name) Create a node.final voidendNode()voidCalled when a node ends.voidflush()Flush the writer, if necessary.protected final ObjectRetrieve aListwith the top elements.final voidMethods inherited from class AbstractXmlWriter
escapeXmlNameMethods inherited from class AbstractWriter
encodeAttribute, encodeNode, startNode, underlyingWriterMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HierarchicalStreamWriter
addAttribute, setValue, underlyingWriter
-
Field Details
-
result
-
nodeStack
-
-
Constructor Details
-
AbstractDocumentWriter
-
AbstractDocumentWriter
Deprecated.As of 1.4 useAbstractDocumentWriter(Object, NameCoder)instead.Constructs an AbstractDocumentWriter.- Parameters:
container- the top level container for the nodes to create (may benull)replacer- the object that creates XML-friendly names- Since:
- 1.2.1
-
-
Method Details
-
startNode
- Specified by:
startNodein interfaceHierarchicalStreamWriter
-
createNode
Create a node. The provided node name is not yet XML friendly. IfgetCurrent()returnsnullthe node is a top level node.- Parameters:
name- the node name- Returns:
- the new node
- Since:
- 1.2.1
-
endNode
public final void endNode()- Specified by:
endNodein interfaceHierarchicalStreamWriter
-
endNodeInternally
public void endNodeInternally()Called when a node ends. Hook for derived implementations.- Since:
- 1.2.1
-
getCurrent
- Since:
- 1.2.1
-
getTopLevelNodes
Description copied from interface:DocumentWriterRetrieve aListwith the top elements. In the standard use case this list will only contain a single element. Additional elements can only occur, ifHierarchicalStreamWriter.startNode(String)of the implementingHierarchicalStreamWriterwas called multiple times with an empty node stack. Such a situation occurs callingXStream.marshal(Object, HierarchicalStreamWriter)multiple times directly.- Specified by:
getTopLevelNodesin interfaceDocumentWriter- Returns:
- a
Listwith top nodes
-
flush
public void flush()Description copied from interface:HierarchicalStreamWriterFlush the writer, if necessary.- Specified by:
flushin interfaceHierarchicalStreamWriter
-
close
public void close()Description copied from interface:HierarchicalStreamWriterClose the writer, if necessary.- Specified by:
closein interfaceHierarchicalStreamWriter
-
AbstractDocumentWriter(Object, NameCoder)instead.