org.basex.io.serial
Class SAXSerializer

java.lang.Object
  extended by org.basex.io.serial.Serializer
      extended by org.basex.io.serial.SAXSerializer
All Implemented Interfaces:
org.xml.sax.XMLReader

public final class SAXSerializer
extends Serializer
implements org.xml.sax.XMLReader

Bridge to translate XQuery items to SAX events. The parse(org.xml.sax.InputSource) methods do the following:

  1. notify startDocument()
  2. serialize the item
  3. notify endDocument()

Author:
BaseX Team 2005-12, BSD License, Michael Hedenus

Field Summary
 
Fields inherited from class org.basex.io.serial.Serializer
elem, indent, level, PROPS, tags, undecl
 
Constructor Summary
SAXSerializer(Item it)
          Constructor.
 
Method Summary
protected  void atomic(Item i)
          Serializes an atomic value.
protected  void attribute(byte[] n, byte[] v)
          Serializes an attribute.
protected  void finishClose()
          Closes an element.
protected  void finishComment(byte[] comment)
          Serializes a comment.
protected  void finishEmpty()
          Closes an empty element.
protected  void finishOpen()
          Finishes an opening element node.
protected  void finishPi(byte[] n, byte[] v)
          Serializes a processing instruction.
protected  void finishText(byte[] text)
          Serializes a text.
 org.xml.sax.ContentHandler getContentHandler()
           
 org.xml.sax.DTDHandler getDTDHandler()
           
 org.xml.sax.EntityResolver getEntityResolver()
           
 org.xml.sax.ErrorHandler getErrorHandler()
           
 boolean getFeature(java.lang.String name)
           
 java.lang.Object getProperty(java.lang.String name)
           
 void parse(org.xml.sax.InputSource input)
           
 void parse(java.lang.String id)
           
 void setContentHandler(org.xml.sax.ContentHandler ch)
           
 void setDTDHandler(org.xml.sax.DTDHandler dtd)
           
 void setEntityResolver(org.xml.sax.EntityResolver er)
           
 void setErrorHandler(org.xml.sax.ErrorHandler eh)
           
 void setFeature(java.lang.String name, boolean value)
           
 void setLexicalHandler(org.xml.sax.ext.LexicalHandler lh)
          Sets a lexical handler.
 void setProperty(java.lang.String name, java.lang.Object value)
           
protected  void startOpen(byte[] n)
          Starts an element.
 
Methods inherited from class org.basex.io.serial.Serializer
close, closeDoc, closeElement, closeResult, finished, finishText, get, get, namespace, nsUri, openDoc, openResult, reset, serialize, startElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXSerializer

public SAXSerializer(Item it)
Constructor.

Parameters:
it - item to be serialized
Method Detail

getContentHandler

public org.xml.sax.ContentHandler getContentHandler()
Specified by:
getContentHandler in interface org.xml.sax.XMLReader

getFeature

public boolean getFeature(java.lang.String name)
Specified by:
getFeature in interface org.xml.sax.XMLReader

getProperty

public java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface org.xml.sax.XMLReader

parse

public void parse(org.xml.sax.InputSource input)
           throws org.xml.sax.SAXException
Specified by:
parse in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXException

parse

public void parse(java.lang.String id)
           throws org.xml.sax.SAXException
Specified by:
parse in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXException

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler ch)
Specified by:
setContentHandler in interface org.xml.sax.XMLReader

setLexicalHandler

public void setLexicalHandler(org.xml.sax.ext.LexicalHandler lh)
Sets a lexical handler.

Parameters:
lh - handler reference

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver er)
Specified by:
setEntityResolver in interface org.xml.sax.XMLReader

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Specified by:
getEntityResolver in interface org.xml.sax.XMLReader

setDTDHandler

public void setDTDHandler(org.xml.sax.DTDHandler dtd)
Specified by:
setDTDHandler in interface org.xml.sax.XMLReader

getDTDHandler

public org.xml.sax.DTDHandler getDTDHandler()
Specified by:
getDTDHandler in interface org.xml.sax.XMLReader

setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler eh)
Specified by:
setErrorHandler in interface org.xml.sax.XMLReader

getErrorHandler

public org.xml.sax.ErrorHandler getErrorHandler()
Specified by:
getErrorHandler in interface org.xml.sax.XMLReader

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
                throws org.xml.sax.SAXNotRecognizedException,
                       org.xml.sax.SAXNotSupportedException
Specified by:
setFeature in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws org.xml.sax.SAXNotRecognizedException,
                        org.xml.sax.SAXNotSupportedException
Specified by:
setProperty in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException

startOpen

protected void startOpen(byte[] n)
                  throws java.io.IOException
Description copied from class: Serializer
Starts an element.

Specified by:
startOpen in class Serializer
Parameters:
n - tag name
Throws:
java.io.IOException - I/O exception

attribute

protected void attribute(byte[] n,
                         byte[] v)
                  throws java.io.IOException
Description copied from class: Serializer
Serializes an attribute.

Specified by:
attribute in class Serializer
Parameters:
n - name
v - value
Throws:
java.io.IOException - I/O exception

finishOpen

protected void finishOpen()
                   throws java.io.IOException
Description copied from class: Serializer
Finishes an opening element node.

Specified by:
finishOpen in class Serializer
Throws:
java.io.IOException - I/O exception

finishEmpty

protected void finishEmpty()
                    throws java.io.IOException
Description copied from class: Serializer
Closes an empty element.

Specified by:
finishEmpty in class Serializer
Throws:
java.io.IOException - I/O exception

finishClose

protected void finishClose()
                    throws java.io.IOException
Description copied from class: Serializer
Closes an element.

Specified by:
finishClose in class Serializer
Throws:
java.io.IOException - I/O exception

finishText

protected void finishText(byte[] text)
                   throws java.io.IOException
Description copied from class: Serializer
Serializes a text.

Specified by:
finishText in class Serializer
Parameters:
text - value
Throws:
java.io.IOException - I/O exception

finishComment

protected void finishComment(byte[] comment)
                      throws java.io.IOException
Description copied from class: Serializer
Serializes a comment.

Specified by:
finishComment in class Serializer
Parameters:
comment - value
Throws:
java.io.IOException - I/O exception

finishPi

protected void finishPi(byte[] n,
                        byte[] v)
                 throws java.io.IOException
Description copied from class: Serializer
Serializes a processing instruction.

Specified by:
finishPi in class Serializer
Parameters:
n - name
v - value
Throws:
java.io.IOException - I/O exception

atomic

protected void atomic(Item i)
               throws java.io.IOException
Description copied from class: Serializer
Serializes an atomic value.

Specified by:
atomic in class Serializer
Parameters:
i - item
Throws:
java.io.IOException - I/O exception