org.weborganic.aeson
Class JSONSerializer

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.weborganic.aeson.JSONSerializer
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public final class JSONSerializer
extends DefaultHandler
implements ContentHandler

This serializer is a content handler implementation so that it can be used directly against an XML instance or wrapped inside a SAXResult implementation.

When used as part of a SAXResult, it is preferable to use the dedicated JSONResult class.

Version:
23 November 2013
Author:
Christophe Lauret

Field Summary
static String NS_URI
          Namespace used for instructions understood by this serializer.
 
Constructor Summary
JSONSerializer()
          Zero-argument default constructor.
JSONSerializer(OutputStream out)
          Construct a JSONSerializer from a byte stream.
JSONSerializer(Writer w)
          Construct a JSONSerializer from a character stream.
 
Method Summary
 void characters(char[] ch, int start, int len)
           
 void endDocument()
           
 void endElement(String uri, String localName, String qName)
           
 void setDocumentLocator(Locator locator)
           
 void startDocument()
           
 void startElement(String uri, String localName, String qName, Attributes atts)
           
 void warning(SAXParseException ex)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startPrefixMapping
 

Field Detail

NS_URI

public static final String NS_URI
Namespace used for instructions understood by this serializer.

See Also:
Constant Field Values
Constructor Detail

JSONSerializer

public JSONSerializer()
Zero-argument default constructor.

Parsed output will go to System.out.


JSONSerializer

public JSONSerializer(OutputStream out)
Construct a JSONSerializer from a byte stream.

Parameters:
out - A valid OutputStream.

JSONSerializer

public JSONSerializer(Writer w)
Construct a JSONSerializer from a character stream.

Parameters:
writer - A valid character stream.
Method Detail

startDocument

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

endDocument

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

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

warning

public void warning(SAXParseException ex)
Specified by:
warning in interface ErrorHandler
Overrides:
warning in class DefaultHandler

characters

public void characters(char[] ch,
                       int start,
                       int len)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException

setDocumentLocator

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