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

public Class StatefulWriter

extends WriterWrapper
Class Inheritance
Imports
com.thoughtworks.xstream.core.util.FastStack, java.io.IOException, java.util.HashSet, .Set

Deprecated

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

An wrapper for all HierarchicalStreamWriter implementations, that keeps the state. Writing in a wrong state will throw a StreamException, that wraps either an IOException (writing to a closed writer) or an IllegalStateException. The implementation will also track unbalanced nodes or multiple attributes with the same name.
Author
Jörg Schaible
Since
1.2

Field Summary

Modifier and TypeField and Description
private transient FastStack
private transient int
private transient int
public static int
STATE_CLOSED

STATE_CLOSED is the state if the writer has been closed.

public static int
STATE_NODE_END

STATE_NODE_END is the state if a node has ended

public static int
STATE_NODE_START

STATE_NODE_START is the state of a new node has been started.

public static int
STATE_OPEN

STATE_OPEN is the initial value of the writer.

public static int
STATE_VALUE

STATE_VALUE is the state if the value of a node has been written.

Inherited from com.thoughtworks.xstream.io.WriterWrapper:
wrapped

Constructor Summary

AccessConstructor and Description
public
StatefulWriter(final HierarchicalStreamWriter
the wrapped writer
wrapped
)

Constructs a StatefulWriter.

Method Summary

Modifier and TypeMethod and Description
public void
private void
public void
public void
public void
private Object
public void
setValue(String text)

Overrides com.thoughtworks.xstream.io.WriterWrapper.setValue.

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.setValue.

Write the value (text content) of the current node.
public void
public void
private void
public int

Returns:

one of the states
state
()

Retrieve the state of the writer.

Inherited from com.thoughtworks.xstream.io.WriterWrapper:
underlyingWriter

Field Detail

attributesback to summary
private transient FastStack attributes
balanceback to summary
private transient int balance
stateback to summary
private transient int state
STATE_CLOSEDback to summary
public static int STATE_CLOSED

STATE_CLOSED is the state if the writer has been closed.

Since
1.2
STATE_NODE_ENDback to summary
public static int STATE_NODE_END

STATE_NODE_END is the state if a node has ended

Since
1.2
STATE_NODE_STARTback to summary
public static int STATE_NODE_START

STATE_NODE_START is the state of a new node has been started.

Since
1.2
STATE_OPENback to summary
public static int STATE_OPEN

STATE_OPEN is the initial value of the writer.

Since
1.2
STATE_VALUEback to summary
public static int STATE_VALUE

STATE_VALUE is the state if the value of a node has been written.

Since
1.2

Constructor Detail

StatefulWriterback to summary
public StatefulWriter(final HierarchicalStreamWriter wrapped)

Constructs a StatefulWriter.

Parameters
wrapped:HierarchicalStreamWriter

the wrapped writer

Since
1.2

Method Detail

addAttributeback to summary
public void addAttribute(String name, String value)

Overrides com.thoughtworks.xstream.io.WriterWrapper.addAttribute.

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.addAttribute.

checkClosedback to summary
private void checkClosed()
closeback to summary
public void close()

Overrides com.thoughtworks.xstream.io.WriterWrapper.close.

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

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

Close the writer, if necessary.

endNodeback to summary
public void endNode()

Overrides com.thoughtworks.xstream.io.WriterWrapper.endNode.

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

flushback to summary
public void flush()

Overrides com.thoughtworks.xstream.io.WriterWrapper.flush.

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

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

Flush the writer, if necessary.

readResolveback to summary
private Object readResolve()
setValueback to summary
public void setValue(String text)

Overrides com.thoughtworks.xstream.io.WriterWrapper.setValue.

Implements com.thoughtworks.xstream.io.HierarchicalStreamWriter.setValue.

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

Write the value (text content) of the current node.

startNodeback to summary
public void startNode(final String name)

Overrides com.thoughtworks.xstream.io.WriterWrapper.startNode.

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

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

Overrides com.thoughtworks.xstream.io.WriterWrapper.startNode.

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

startNodeCommonback to summary
private void startNodeCommon()
stateback to summary
public int state()

Retrieve the state of the writer.

Returns:int

one of the states

Since
1.2
See Also
STATE_OPEN, STATE_NODE_START, STATE_VALUE, STATE_NODE_END, STATE_CLOSED