be.ac.vub.cocompose.io.xml
Class SAXWriter

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bybe.ac.vub.cocompose.io.xml.SAXWriter
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, StreamWriter

public class SAXWriter
extends DefaultHandler
implements StreamWriter

XML writer for writing any XML document to an OutputStream. Based on the SAX2 DefaultHandler class.

Since:
0.1.0
Version:
0.2.0, 09/01/2004
Author:
Dennis Wagelaar

Constructor Summary
SAXWriter()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Characters.
 void endDocument()
          End document.
 void endElement(String uri, String local, String raw)
          End element.
 String getCharset()
          Gets the encoding character set (e.g.
 void ignorableWhitespace(char[] ch, int start, int length)
          Ignorable whitespace.
 void notationDecl(String name, String publicId, String systemId)
          DTD declaration.
 void processingInstruction(String target, String data)
          Processing instruction.
 void setCharset(String charset)
          Sets the encoding character set (e.g.
 void setOutputStream(OutputStream outputStream)
          Sets the output stream for writing.
 void startDocument()
          Start document.
 void startElement(String uri, String local, String raw, Attributes attrs)
          Start element.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXWriter

public SAXWriter()
Method Detail

processingInstruction

public void processingInstruction(String target,
                                  String data)
Processing instruction.

Specified by:
processingInstruction in interface ContentHandler
Parameters:
target - Processing instruction element name.
data - Processing instruction element data.

startDocument

public void startDocument()
Start document.

Specified by:
startDocument in interface ContentHandler

startElement

public void startElement(String uri,
                         String local,
                         String raw,
                         Attributes attrs)
Start element.

Specified by:
startElement in interface ContentHandler
Parameters:
uri - Ignored.
local - Ignored.
raw - Element name.
attrs - Element attributes.

characters

public void characters(char[] ch,
                       int start,
                       int length)
Characters.

Specified by:
characters in interface ContentHandler
Parameters:
ch - Characters to print.
start - Starting index of characters.
length - Length of characters.

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
Ignorable whitespace.

Specified by:
ignorableWhitespace in interface ContentHandler
Parameters:
ch - Characters to print.
start - Starting index of characters.
length - Length of characters.

endElement

public void endElement(String uri,
                       String local,
                       String raw)
End element.

Specified by:
endElement in interface ContentHandler
Parameters:
uri - Ignored.
local - Ignored.
raw - Element name.

endDocument

public void endDocument()
End document.

Specified by:
endDocument in interface ContentHandler

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
DTD declaration.

Specified by:
notationDecl in interface DTDHandler
Parameters:
name - DTD name.
publicId - DTD public ID.
systemId - DTD system ID.

getCharset

public String getCharset()
Gets the encoding character set (e.g. "UTF-8").

Specified by:
getCharset in interface StreamWriter
Returns:
the character set.

setCharset

public void setCharset(String charset)
                throws UnsupportedEncodingException
Sets the encoding character set (e.g. "UTF-8").

Specified by:
setCharset in interface StreamWriter
Parameters:
charset - - the character set.
Throws:
UnsupportedEncodingException - - if the character set is not supported.

setOutputStream

public void setOutputStream(OutputStream outputStream)
Sets the output stream for writing.

Specified by:
setOutputStream in interface StreamWriter
Parameters:
outputStream - - the output stream.