Class WriterWrapper
java.lang.Object
com.thoughtworks.xstream.io.WriterWrapper
- All Implemented Interfaces:
ExtendedHierarchicalStreamWriter, HierarchicalStreamWriter
- Direct Known Subclasses:
PathTrackingWriter, StatefulWriter
Base class to make it easy to create wrappers (decorators) for HierarchicalStreamWriter.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String key, String value) voidclose()Close the writer, if necessary.voidendNode()voidflush()Flush the writer, if necessary.voidWrite the value (text content) of the current node.voidvoidReturn the underlying HierarchicalStreamWriter implementation.
-
Field Details
-
wrapped
-
-
Constructor Details
-
WriterWrapper
-
-
Method Details
-
startNode
- Specified by:
startNodein interfaceHierarchicalStreamWriter
-
startNode
- Specified by:
startNodein interfaceExtendedHierarchicalStreamWriter
-
endNode
public void endNode()- Specified by:
endNodein interfaceHierarchicalStreamWriter
-
addAttribute
- Specified by:
addAttributein interfaceHierarchicalStreamWriter
-
setValue
Description copied from interface:HierarchicalStreamWriterWrite the value (text content) of the current node.- Specified by:
setValuein interfaceHierarchicalStreamWriter
-
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
-
underlyingWriter
Description copied from interface:HierarchicalStreamWriterReturn the underlying HierarchicalStreamWriter implementation.If a Converter needs to access methods of a specific HierarchicalStreamWriter implementation that are not defined in the HierarchicalStreamWriter interface, it should call this method before casting. This is because the writer passed to the Converter is often wrapped/decorated by another implementation to provide additional functionality (such as XPath tracking).
For example:
MySpecificWriter mySpecificWriter = (MySpecificWriter)writer; // INCORRECT! mySpecificWriter.doSomethingSpecific();
MySpecificWriter mySpecificWriter = (MySpecificWriter)writer.underlyingWriter(); // CORRECT! mySpecificWriter.doSomethingSpecific();
Implementations of HierarchicalStreamWriter should return 'this', unless they are a decorator, in which case they should delegate to whatever they are wrapping.
- Specified by:
underlyingWriterin interfaceHierarchicalStreamWriter
-