com.generationjava.io.xml
Interface XmlWriter

All Known Implementing Classes:
AbstractXmlWriter, DelegatingXmlWriter, EmptyElementXmlWriter, FormattingXmlWriter, JarvWriter, PrettyPrinterXmlWriter, SimpleXmlWriter, XmlEncXmlWriter

public interface XmlWriter

Interface for anything which is able to output Xml. Implementations of this interface are expected to either be filters on other XmlWriters, ie) subclasses of DelegatingXmlWriter, or actual outputters themselves, ie) subclasses of AbstractXmlWriter.


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.
 

Method Detail

writeXmlVersion

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.

Throws:
IOException

writeXmlVersion

XmlWriter writeXmlVersion(String version,
                          String encoding)
                          throws IOException
Throws:
IOException
See Also:
XmlWriter.writeXmlVersion(String, String, String)

writeXmlVersion

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

Throws:
IOException

writeEntityWithText

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

Parameters:
name - String name of tag
text - String of text to go inside the tag
Throws:
IOException

writeEmptyEntity

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

Parameters:
name - String name of tag
Throws:
IOException

writeEntity

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.

Parameters:
name - String name of tag
Throws:
IOException

writeAttribute

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.

Parameters:
String - name of attribute.
Object - value of attribute.
Throws:
IOException

endEntity

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.

Throws:
IOException

close

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.

Throws:
IOException

writeText

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

Throws:
IOException

writeCData

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

Parameters:
String - of CDATA text.
Throws:
IOException

writeComment

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.

Parameters:
String - of text to comment.
Throws:
IOException

getWriter

Writer getWriter()
Obtain the Writer that is at the lowest level of this XmlWriter chain



Copyright © 2000-2007 OSJava. All Rights Reserved.