com.wutka.jox
Class JOXBeanWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--java.io.FilterWriter
              |
              +--com.wutka.jox.JOXBeanWriter
All Implemented Interfaces:
com.wutka.jox.JOXOutput

public class JOXBeanWriter
extends java.io.FilterWriter
implements com.wutka.jox.JOXOutput

A writer filter that writes out a bean as an XML document. The writer can write out basic Java types, their object equivalents and also strings, dates and other beans. The XML tag names are the same as the bean properties.


Field Summary
protected static java.lang.String DEFAULT_ENCODING
           
protected  java.lang.String encoding
           
protected  com.wutka.jox.JOXBeanOutput output
           
 
Fields inherited from class java.io.FilterWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
JOXBeanWriter(com.wutka.dtd.DTD dtd, java.io.Writer baseWriter)
          Create a new writer around an existing writer and specifies a DTD for selecting which attributes should be written and what the names should look like.
JOXBeanWriter(com.wutka.dtd.DTD dtd, java.io.Writer baseWriter, java.lang.String anEncoding)
          Create a new writer around an existing writer and specifies a DTD for selecting which attributes should be written and what the names should look like.
JOXBeanWriter(java.lang.String dtdURI, java.io.Writer baseWriter)
          Create a new writer around an existing writer and specifies a DTD for selecting which attributes should be written and what the names should look like.
JOXBeanWriter(java.lang.String dtdURI, java.io.Writer baseWriter, java.lang.String anEncoding)
          Create a new writer around an existing writer and specifies a DTD for selecting which attributes should be written and what the names should look like.
JOXBeanWriter(java.io.Writer baseWriter)
          Creates a new writer around an existing writer
JOXBeanWriter(java.io.Writer baseWriter, boolean writeAttributes)
          Creates a new writer around an existing writer
JOXBeanWriter(java.io.Writer baseWriter, boolean writeAttributes, java.lang.String anEncoding)
          Creates a new writer around an existing writer
JOXBeanWriter(java.io.Writer baseWriter, java.lang.String anEncoding)
          Creates a new writer around an existing writer
 
Method Summary
 void writeObject(java.lang.String rootName, java.lang.Object ob)
          Writes a bean as XML, using rootName as the tag name for the document root.
 void writeString(java.lang.String str)
          Write a string to the writer This method is used by the output utility to write a string to either an output stream or a writer.
 
Methods inherited from class java.io.FilterWriter
close, flush, write, write, write
 
Methods inherited from class java.io.Writer
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

protected static final java.lang.String DEFAULT_ENCODING

output

protected com.wutka.jox.JOXBeanOutput output

encoding

protected java.lang.String encoding
Constructor Detail

JOXBeanWriter

public JOXBeanWriter(java.io.Writer baseWriter)
Creates a new writer around an existing writer
Parameters:
baseWriter - The underlying writer

JOXBeanWriter

public JOXBeanWriter(java.io.Writer baseWriter,
                     java.lang.String anEncoding)
Creates a new writer around an existing writer
Parameters:
baseWriter - The underlying writer
anEncoding - The XML encoding to use

JOXBeanWriter

public JOXBeanWriter(java.io.Writer baseWriter,
                     boolean writeAttributes)
Creates a new writer around an existing writer
Parameters:
baseWriter - The underlying writer
writeAttributes - Indicates whether we should write simple properties as attributes

JOXBeanWriter

public JOXBeanWriter(java.io.Writer baseWriter,
                     boolean writeAttributes,
                     java.lang.String anEncoding)
Creates a new writer around an existing writer
Parameters:
baseWriter - The underlying writer
writeAttributes - Indicates whether we should write simple properties as attributes
anEncoding - The XML encoding to use

JOXBeanWriter

public JOXBeanWriter(java.lang.String dtdURI,
                     java.io.Writer baseWriter)
              throws java.io.IOException
Create a new writer around an existing writer and specifies a DTD for selecting which attributes should be written and what the names should look like.
Parameters:
dtdURI - The URI of the DTD
baseWriter - The underlying writer

JOXBeanWriter

public JOXBeanWriter(java.lang.String dtdURI,
                     java.io.Writer baseWriter,
                     java.lang.String anEncoding)
              throws java.io.IOException
Create a new writer around an existing writer and specifies a DTD for selecting which attributes should be written and what the names should look like.
Parameters:
dtdURI - The URI of the DTD
baseWriter - The underlying writer
anEncoding - The XML encoding to use

JOXBeanWriter

public JOXBeanWriter(com.wutka.dtd.DTD dtd,
                     java.io.Writer baseWriter)
              throws java.io.IOException
Create a new writer around an existing writer and specifies a DTD for selecting which attributes should be written and what the names should look like.
Parameters:
dtd - The DTD to use
baseWriter - The underlying writer

JOXBeanWriter

public JOXBeanWriter(com.wutka.dtd.DTD dtd,
                     java.io.Writer baseWriter,
                     java.lang.String anEncoding)
              throws java.io.IOException
Create a new writer around an existing writer and specifies a DTD for selecting which attributes should be written and what the names should look like.
Parameters:
dtd - The DTD to use
baseWriter - The underlying writer
anEncoding - The XML encoding to use
Method Detail

writeObject

public void writeObject(java.lang.String rootName,
                        java.lang.Object ob)
                 throws java.io.IOException
Writes a bean as XML, using rootName as the tag name for the document root. Other tag names will come from the names of the bean attributes.
Parameters:
rootName - The name of the document root
ob - The object to write out
Throws:
java.io.IOException - If there is an error writing the object

writeString

public void writeString(java.lang.String str)
                 throws java.io.IOException
Write a string to the writer This method is used by the output utility to write a string to either an output stream or a writer.
Specified by:
writeString in interface com.wutka.jox.JOXOutput
Parameters:
str - The string to write