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

public abstract Class AbstractWriter

extends Object
implements ExtendedHierarchicalStreamWriter
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter, com.thoughtworks.xstream.io.HierarchicalStreamWriter
Known Direct Subclasses
com.thoughtworks.xstream.io.json.AbstractJsonWriter, com.thoughtworks.xstream.io.xml.AbstractXmlWriter
Imports
com.thoughtworks.xstream.core.util.Cloneables, com.thoughtworks.xstream.io.naming.NameCoder, .NoNameCoder

Deprecated

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

Abstract base class for all HierarchicalStreamWriter implementations. Implementations of HierarchicalStreamWriter should rather be derived from this class then implementing the interface directly.
Author
Jörg Schaible
Since
1.4

Field Summary

Modifier and TypeField and Description
private NameCoder

Constructor Summary

AccessConstructor and Description
protected
AbstractWriter()

Creates an AbstractWriter with a NameCoder that does nothing.

protected
AbstractWriter(NameCoder
the name coder used to write names in the target format
nameCoder
)

Creates an AbstractWriter with a provided NameCoder.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the name in the target format
encodeAttribute
(String
the original name
name
)

Encode the attribute name into the name of the target format.

public String

Returns:

the name in the target format
encodeNode
(String
the original name
name
)

Encode the node name into the name of the target format.

public void
public HierarchicalStreamWriter
underlyingWriter()

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.underlyingWriter.

Return the underlying HierarchicalStreamWriter implementation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameCoderback to summary
private NameCoder nameCoder

Constructor Detail

AbstractWriterback to summary
protected AbstractWriter()

Creates an AbstractWriter with a NameCoder that does nothing.

Since
1.4
AbstractWriterback to summary
protected AbstractWriter(NameCoder nameCoder)

Creates an AbstractWriter with a provided NameCoder.

Parameters
nameCoder:NameCoder

the name coder used to write names in the target format

Since
1.4

Method Detail

encodeAttributeback to summary
public String encodeAttribute(String name)

Encode the attribute name into the name of the target format.

Parameters
name:String

the original name

Returns:String

the name in the target format

Since
1.4
encodeNodeback to summary
public String encodeNode(String name)

Encode the node name into the name of the target format.

Parameters
name:String

the original name

Returns:String

the name in the target format

Since
1.4
startNodeback to summary
public void startNode(String name, Class<T> clazz)

Implements com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter.startNode.

underlyingWriterback to summary
public HierarchicalStreamWriter underlyingWriter()

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.underlyingWriter.

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

Return 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.