Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.thoughtworks.xstream.io
Class StatefulWriter

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

All Implemented Interfaces:
  ExtendedHierarchicalStreamWriter, HierarchicalStreamWriter

    public class StatefulWriter

extends WriterWrapper

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.

Since:
  1.2
Author:
  Jörg Schaible

Field Summary
`static int` | `STATE_CLOSED` `STATE_CLOSED` is the state if the writer has been closed.
`static int` | `STATE_NODE_END` `STATE_NODE_END` is the state if a node has ended
`static int` | `STATE_NODE_START` `STATE_NODE_START` is the state of a new node has been started.
`static int` | `STATE_OPEN` `STATE_OPEN` is the initial value of the writer.
`static int` | `STATE_VALUE` `STATE_VALUE` is the state if the value of a node has been written.

Fields inherited from class com.thoughtworks.xstream.io.WriterWrapper
`wrapped`

Constructor Summary
`StatefulWriter(HierarchicalStreamWriter wrapped)` Constructs a StatefulWriter.

Method Summary
`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)`
`void` | `startNode(String name, Class clazz)`
`int` | `state()` Retrieve the state of the writer.

Methods inherited from class com.thoughtworks.xstream.io.WriterWrapper
`underlyingWriter`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### STATE_OPEN

    public static int STATE_OPEN

  `STATE_OPEN` is the initial value of the writer.

  Since:
    1.2

### STATE_NODE_START

    public static int STATE_NODE_START

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

  Since:
    1.2

### STATE_VALUE

    public static int STATE_VALUE

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

  Since:
    1.2

### STATE_NODE_END

    public static int STATE_NODE_END

  `STATE_NODE_END` is the state if a node has ended

  Since:
    1.2

### STATE_CLOSED

    public static int STATE_CLOSED

  `STATE_CLOSED` is the state if the writer has been closed.

  Since:
    1.2

Constructor Detail

### StatefulWriter

    public StatefulWriter(HierarchicalStreamWriter wrapped)

  Constructs a StatefulWriter.

  Parameters:
    `wrapped` - the wrapped writer
  Since:
    1.2

Method Detail

### startNode

    public void startNode(String name)

  Specified by:
    `startNode` in interface `HierarchicalStreamWriter`
  Overrides:
    `startNode` in class `WriterWrapper`

### startNode

    public void startNode(String name,
                          Class clazz)

  Specified by:
    `startNode` in interface `ExtendedHierarchicalStreamWriter`
  Overrides:
    `startNode` in class `WriterWrapper`

### addAttribute

    public void addAttribute(String name,
                             String value)

  Specified by:
    `addAttribute` in interface `HierarchicalStreamWriter`
  Overrides:
    `addAttribute` in class `WriterWrapper`

### setValue

    public void setValue(String text)

  Description copied from interface: `HierarchicalStreamWriter`
  Write the value (text content) of the current node.

  Specified by:
    `setValue` in interface `HierarchicalStreamWriter`
  Overrides:
    `setValue` in class `WriterWrapper`

### endNode

    public void endNode()

  Specified by:
    `endNode` in interface `HierarchicalStreamWriter`
  Overrides:
    `endNode` in class `WriterWrapper`

### flush

    public void flush()

  Description copied from interface: `HierarchicalStreamWriter`
  Flush the writer, if necessary.

  Specified by:
    `flush` in interface `HierarchicalStreamWriter`
  Overrides:
    `flush` in class `WriterWrapper`

### close

    public void close()

  Description copied from interface: `HierarchicalStreamWriter`
  Close the writer, if necessary.

  Specified by:
    `close` in interface `HierarchicalStreamWriter`
  Overrides:
    `close` in class `WriterWrapper`

### state

    public int state()

  Retrieve the state of the writer.

  Returns:
    one of the states
  Since:
    1.2
  See Also:
    `STATE_OPEN`, `STATE_NODE_START`, `STATE_VALUE`, `STATE_NODE_END`, `STATE_CLOSED`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2008 XStream. All Rights Reserved.