com.generationjava.io.xml
Class DelegatingXmlWriter

java.lang.Object
  extended by com.generationjava.io.xml.DelegatingXmlWriter
All Implemented Interfaces:
XmlWriter
Direct Known Subclasses:
EmptyElementXmlWriter, FormattingXmlWriter, JarvWriter, PrettyPrinterXmlWriter

public class DelegatingXmlWriter
extends Object
implements XmlWriter

Superclass for any XmlWriter which will wrap another XmlWriter. It passes all calls on to the underlying XmlWriter, and is expected to be used by all filtering XmlWriters. Possibly this class should be abstract.


Constructor Summary
DelegatingXmlWriter(XmlWriter xmlWriter)
           
 
Method Summary
 void close()
          Close this writer.
 XmlWriter endEntity()
          End the current entity.
 Writer getWriter()
          Obtain the Writer that is at the lowest level of this XmlWriter chain
 XmlWriter writeAttribute(String attr, Object value)
          Write an attribute out for the current entity.
 XmlWriter writeCData(String cdata)
          Write out a chunk of CDATA.
 XmlWriter writeComment(String comment)
          Write out a chunk of comment.
 XmlWriter writeEmptyEntity(String name)
          A helper method.
 XmlWriter writeEntity(String name)
          Begin to write out an entity.
 XmlWriter writeEntityWithText(String name, Object text)
          A helper method.
 XmlWriter writeText(Object text)
          Output body text.
 XmlWriter writeXmlVersion()
          Makes it easy to output the xml version if such a thing is desired.
 XmlWriter writeXmlVersion(String version, String encoding)
           
 XmlWriter writeXmlVersion(String version, String encoding, String standalone)
          Output the version, encoding and standalone nature of an xml file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingXmlWriter

public DelegatingXmlWriter(XmlWriter xmlWriter)
Method Detail

writeXmlVersion

public XmlWriter writeXmlVersion()
                          throws IOException
Makes it easy to output the xml version if such a thing is desired. While it usually is desired, it is less surprising not to handle it.

Specified by:
writeXmlVersion in interface XmlWriter
Throws:
IOException

writeXmlVersion

public XmlWriter writeXmlVersion(String version,
                                 String encoding)
                          throws IOException
Specified by:
writeXmlVersion in interface XmlWriter
Throws:
IOException
See Also:
DelegatingXmlWriter.writeXmlVersion(String, String, String)

writeXmlVersion

public XmlWriter writeXmlVersion(String version,
                                 String encoding,
                                 String standalone)
                          throws IOException
Output the version, encoding and standalone nature of an xml file.

Specified by:
writeXmlVersion in interface XmlWriter
Throws:
IOException

writeEntityWithText

public XmlWriter writeEntityWithText(String name,
                                     Object text)
                              throws IOException
A helper method. It writes out an entity which contains only text.

Specified by:
writeEntityWithText in interface XmlWriter
Parameters:
name - String name of tag
text - String of text to go inside the tag
Throws:
IOException

writeEmptyEntity

public XmlWriter writeEmptyEntity(String name)
                           throws IOException
A helper method. It writes out empty entities.

Specified by:
writeEmptyEntity in interface XmlWriter
Parameters:
name - String name of tag
Throws:
IOException

writeEntity

public XmlWriter writeEntity(String name)
                      throws IOException
Begin to write out an entity. Unlike the helper tags, this tag will need to be ended with the endEntity method.

Specified by:
writeEntity in interface XmlWriter
Parameters:
name - String name of tag
Throws:
IOException

writeAttribute

public XmlWriter writeAttribute(String attr,
                                Object value)
                         throws IOException
Write an attribute out for the current entity. Any xml characters in the value are escaped. Currently it does not actually throw the exception, but the api is set that way for future changes.

Specified by:
writeAttribute in interface XmlWriter
Parameters:
String - name of attribute.
Object - value of attribute.
Throws:
IOException

endEntity

public XmlWriter endEntity()
                    throws IOException
End the current entity. This will throw an exception if it is called when there is not a currently open entity.

Specified by:
endEntity in interface XmlWriter
Throws:
IOException

close

public void close()
           throws IOException
Close this writer. It does not close the underlying writer, but does throw an exception if there are as yet unclosed tags.

Specified by:
close in interface XmlWriter
Throws:
IOException

writeText

public XmlWriter writeText(Object text)
                    throws IOException
Output body text. Any xml characters are escaped.

Specified by:
writeText in interface XmlWriter
Throws:
IOException

writeCData

public XmlWriter writeCData(String cdata)
                     throws IOException
Write out a chunk of CDATA. This helper method surrounds the passed in data with the CDATA tag.

Specified by:
writeCData in interface XmlWriter
Parameters:
String - of CDATA text.
Throws:
IOException

writeComment

public XmlWriter writeComment(String comment)
                       throws IOException
Write out a chunk of comment. This helper method surrounds the passed in data with the xml comment tag.

Specified by:
writeComment in interface XmlWriter
Parameters:
String - of text to comment.
Throws:
IOException

getWriter

public Writer getWriter()
Description copied from interface: XmlWriter
Obtain the Writer that is at the lowest level of this XmlWriter chain

Specified by:
getWriter in interface XmlWriter


Copyright © 2000-2007 OSJava. All Rights Reserved.