info.aduna.xml
Class SAXWriter

java.lang.Object
  extended by info.aduna.xml.SAXWriter
All Implemented Interfaces:
ContentHandler

public class SAXWriter
extends Object
implements ContentHandler

SAXWriter is a utility class that translates events sent to a SAX ContentHandler to a character stream send to a Writer. SAXWriter optionally supports indentation.

Fixme: usage of an SAXWriter on an OutputStream when the character data contains non-ASCII codes still needs to be tested!!!


Field Summary
static boolean DEFAULT_INDENT
          Indicates the default behaviour of an SAXWriter concerning indentation.
static int INDENT_INCREASE
          The number of spaces that together form an indentation unit.
 
Constructor Summary
SAXWriter(OutputStream stream)
          Create a new SAXWriter for the specified OutputStream with the default indentation property.
SAXWriter(OutputStream stream, boolean indent)
          Create a new SAXWriter for the specified OutputStream which optionally prints indentation.
SAXWriter(Writer writer)
          Create a new SAXWriter for the specified Writer with the default indentation settings.
SAXWriter(Writer writer, boolean indenting)
          Create a new SAXWriter for the specified Writer which optionally prints indentation.
 
Method Summary
 void characters(char[] buf, int offset, int len)
           
 void endDocument()
           
 void endElement(String uri, String lName, String qName)
           
 void endPrefixMapping(String prefix)
           
 void ignorableWhitespace(char[] buf, int offset, int len)
           
 void processingInstruction(String target, String data)
           
 void setDocumentLocator(Locator locator)
           
 void skippedEntity(String name)
           
 void startDocument()
           
 void startElement(String uri, String lName, String qName, Attributes attrs)
          Inherit comment.
 void startPrefixMapping(String prefix, String uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INDENT

public static final boolean DEFAULT_INDENT
Indicates the default behaviour of an SAXWriter concerning indentation.

See Also:
Constant Field Values

INDENT_INCREASE

public static final int INDENT_INCREASE
The number of spaces that together form an indentation unit.

See Also:
Constant Field Values
Constructor Detail

SAXWriter

public SAXWriter(Writer writer,
                 boolean indenting)
Create a new SAXWriter for the specified Writer which optionally prints indentation.


SAXWriter

public SAXWriter(Writer writer)
Create a new SAXWriter for the specified Writer with the default indentation settings.


SAXWriter

public SAXWriter(OutputStream stream,
                 boolean indent)
          throws IOException
Create a new SAXWriter for the specified OutputStream which optionally prints indentation. The characters will be converted to bytes using the ISO-8859-1 encoding.

Throws:
IOException

SAXWriter

public SAXWriter(OutputStream stream)
          throws IOException
Create a new SAXWriter for the specified OutputStream with the default indentation property. The characters will be converted to bytes using the ISO-8859-1 encoding.

Throws:
IOException
Method Detail

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
Specified by:
startPrefixMapping in interface ContentHandler

endPrefixMapping

public void endPrefixMapping(String prefix)
Specified by:
endPrefixMapping in interface ContentHandler

startElement

public void startElement(String uri,
                         String lName,
                         String qName,
                         Attributes attrs)
                  throws SAXException
Inherit comment. Printing of the specified tag and attributes is postponed until the next invocation of the startElement, endElement or characters methods in order to enable self-closing tags.

Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String lName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] buf,
                       int offset,
                       int len)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] buf,
                                int offset,
                                int len)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
Specified by:
skippedEntity in interface ContentHandler


Copyright © 2010 Aduna. All Rights Reserved.