com.virtuosotechnologies.lib.xml
Class XMLDocumentUnparser

java.lang.Object
  extended bycom.virtuosotechnologies.lib.xml.XMLUnparser
      extended bycom.virtuosotechnologies.lib.xml.XMLDocumentUnparser

public class XMLDocumentUnparser
extends XMLUnparser

Helper for XML unparsing. This extends XMLUnparser by automatically outputting the XML header and DOCTYPE. It also automatically starts the root element. Therefore, you cannot call makeDefunct() directly. Instead, call finishDocument() when done unparsing.

This class is not thread-safe. Access should be serialized into one thread.


Constructor Summary
protected XMLDocumentUnparser(Writer writer, String encoding, boolean escape16BitChars, String publicDTD, String systemDTD, String rootElement)
          Constructor
 
Method Summary
static XMLDocumentUnparser create(OutputStream stream, String encoding, String systemDTD, String rootElement)
          pseudo-Constructor
static XMLDocumentUnparser create(Writer writer, String encoding, String systemDTD, String rootElement)
          pseudo-Constructor Does not check that the writer matches the given encoding name
 void finishDocument(String rootElement)
          End the document.
 
Methods inherited from class com.virtuosotechnologies.lib.xml.XMLUnparser
addAttribute, addString, createIndentString, endElement, getWriter, isDefunct, makeDefunct, startMultiLineElement, startSingleLineElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLDocumentUnparser

protected XMLDocumentUnparser(Writer writer,
                              String encoding,
                              boolean escape16BitChars,
                              String publicDTD,
                              String systemDTD,
                              String rootElement)
                       throws IOException
Constructor

Parameters:
writer - writer to write to
encoding - name of text encoding used by the writer
systemDTD - url for system dtd
rootElement - root element name
Method Detail

create

public static XMLDocumentUnparser create(OutputStream stream,
                                         String encoding,
                                         String systemDTD,
                                         String rootElement)
                                  throws IOException
pseudo-Constructor

Parameters:
stream - OutputStream to write to
encoding - name of text encoding to use
systemDTD - url for system dtd
rootElement - root element name
Throws:
IOException

create

public static XMLDocumentUnparser create(Writer writer,
                                         String encoding,
                                         String systemDTD,
                                         String rootElement)
                                  throws IOException
pseudo-Constructor Does not check that the writer matches the given encoding name

Parameters:
writer - Writer to write to
encoding - name of text encoding to use
systemDTD - url for system dtd
rootElement - root element name
Throws:
IOException

finishDocument

public void finishDocument(String rootElement)
                    throws IOException
End the document.

Parameters:
rootElement - element name, which must match the original root element
Throws:
IOException - i/o error
IllegalStateException - unparser is defunct
IllegalArgumentException - element name mismatch