public class

StatefulWriter

extends WriterWrapper
java.lang.Object
   ↳ com.thoughtworks.xstream.io.WriterWrapper
     ↳ com.thoughtworks.xstream.io.StatefulWriter

Class Overview

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.

Summary

Fields
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.
[Expand]
Inherited Fields
From class com.thoughtworks.xstream.io.WriterWrapper
Public Constructors
StatefulWriter(HierarchicalStreamWriter wrapped)
Constructs a StatefulWriter.
Public Methods
void addAttribute(String name, String value)
void close()
Close the writer, if necessary.
void endNode()
void flush()
Flush the writer, if necessary.
void setValue(String text)
Write the value (text content) of the current node.
void startNode(String name, Class clazz)
void startNode(String name)
int state()
Retrieve the state of the writer.
[Expand]
Inherited Methods
From class com.thoughtworks.xstream.io.WriterWrapper
From class java.lang.Object
From interface com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
From interface com.thoughtworks.xstream.io.HierarchicalStreamWriter

Fields

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.

Public Constructors

public StatefulWriter (HierarchicalStreamWriter wrapped)

Constructs a StatefulWriter.

Parameters
wrapped the wrapped writer

Public Methods

public void addAttribute (String name, String value)

public void close ()

Close the writer, if necessary.

public void endNode ()

public void flush ()

Flush the writer, if necessary.

public void setValue (String text)

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

public void startNode (String name, Class clazz)

public void startNode (String name)

public int state ()

Retrieve the state of the writer.

Returns
  • one of the states