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 WriterWrapper

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

All Implemented Interfaces:
  ExtendedHierarchicalStreamWriter, HierarchicalStreamWriter

Direct Known Subclasses:
  PathTrackingWriter, StatefulWriter

    public abstract class WriterWrapper

extends Object
implements ExtendedHierarchicalStreamWriter

Base class to make it easy to create wrappers (decorators) for HierarchicalStreamWriter.

Author:
  Joe Walnes

Field Summary
`protected HierarchicalStreamWriter` | `wrapped`

Constructor Summary
`protected` | `WriterWrapper(HierarchicalStreamWriter wrapped)`

Method Summary
`void` | `addAttribute(String key, 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)`
`HierarchicalStreamWriter` | `underlyingWriter()` Return the underlying HierarchicalStreamWriter implementation.

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

Field Detail

### wrapped

    protected HierarchicalStreamWriter wrapped

Constructor Detail

### WriterWrapper

    protected WriterWrapper(HierarchicalStreamWriter wrapped)

Method Detail

### startNode

    public void startNode(String name)

  Specified by:
    `startNode` in interface `HierarchicalStreamWriter`

### startNode

    public void startNode(String name,
                          Class clazz)

  Specified by:
    `startNode` in interface `ExtendedHierarchicalStreamWriter`

### endNode

    public void endNode()

  Specified by:
    `endNode` in interface `HierarchicalStreamWriter`

### addAttribute

    public void addAttribute(String key,
                             String value)

  Specified by:
    `addAttribute` in interface `HierarchicalStreamWriter`

### 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`

### flush

    public void flush()

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

  Specified by:
    `flush` in interface `HierarchicalStreamWriter`

### close

    public void close()

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

  Specified by:
    `close` in interface `HierarchicalStreamWriter`

### underlyingWriter

    public HierarchicalStreamWriter underlyingWriter()

  Description copied from interface: `HierarchicalStreamWriter`
  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.

  Specified by:
    `underlyingWriter` in interface `HierarchicalStreamWriter`

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.