com.softwareag.tamino.db.api.objectModel.stream
Class TStreamWritingDefaultHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.softwareag.tamino.db.api.objectModel.stream.TStreamWritingDefaultHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler

public class TStreamWritingDefaultHandler
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ext.LexicalHandler

TStreamWritingDefaultHandler is a DefaultHandler that is responsible for writing all obtained SAX events to a given data sunk. This handler is capable to substitute the SAX based root element tag with a root element tag explicitly given by a client and serializes this substitute instead to the data sunk.

Version:
$Revision: 1.13 $
Author:
Marcus Schreyer

Constructor Summary
TStreamWritingDefaultHandler(java.io.Writer writer)
          Initialzes the handler with the given character output stream..
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character content for a specific element.
 void comment(char[] ch, int start, int length)
          Report an XML comment anywhere in the document.
 void endCDATA()
          Report the end of a CDATA section.
 void endDocument()
          Receive notification of the end of the parsed document.
 void endDTD()
          Report the end of DTD declarations.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Receive notification of the ending of an element.
 void endEntity(java.lang.String name)
          Report the end of an entity.
 java.lang.String getEncodingAttribute()
          Get the encoding string for the XML declaration.
 java.util.Locale getLocale()
          Gets the locale.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable whitespace within element content.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification for a processing instruction.
 void setEncodingAttribute(java.lang.String encoding)
          Set the encoding string for the XML declaration.
 void setLocale(java.util.Locale locale)
           
 void setRootElement(java.lang.String rootElement)
          Sets a new root element tag.
 void setWriter(java.io.Writer writer)
          Sets a new character output stream to which events can be written to.
 void startCDATA()
          Report the start of a CDATA section.
 void startDocument()
          Receive notification for the start of a new document.
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Report the start of DTD declarations, if any.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Receive notification of the beginning of an element.
 void startEntity(java.lang.String name)
          Report the beginning of an entity in content.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, notationDecl, 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

TStreamWritingDefaultHandler

public TStreamWritingDefaultHandler(java.io.Writer writer)
Initialzes the handler with the given character output stream..

Method Detail

setEncodingAttribute

public void setEncodingAttribute(java.lang.String encoding)
Set the encoding string for the XML declaration.

Parameters:
encoding - the enconding string set in the XML declaration.

getEncodingAttribute

public java.lang.String getEncodingAttribute()
Get the encoding string for the XML declaration.

Returns:
the enconding string set in the XML declaration.

setWriter

public void setWriter(java.io.Writer writer)
Sets a new character output stream to which events can be written to.


setRootElement

public void setRootElement(java.lang.String rootElement)
Sets a new root element tag. This element tag substitutes the root element tag that is given by the startElement event for the root element. As a consequence the root element specified here is serialized to the underlying data sunk.


setLocale

public void setLocale(java.util.Locale locale)

getLocale

public java.util.Locale getLocale()
Gets the locale.

Returns:
the locale.

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Receive notification for the start of a new document.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Receive notification for a processing instruction. The given processing instruction is written to the current given character output stream.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Overrides:
processingInstruction in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Receive notification of the beginning of an element. The given element is written to the to the current given character output stream.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Receive notification of the ending of an element. End of element is written to character output stream.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character content for a specific element. Element content is written to character output stream.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Receive notification of the end of the parsed document. As a side effect the character output stream is flushed.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Receive notification of ignorable whitespace within element content.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Report an XML comment anywhere in the document.

Specified by:
comment in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Report the start of a CDATA section. This will be called by lexical hndlers.

Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
Report the end of a CDATA section. This is will be called by lexical hndlers.

Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws org.xml.sax.SAXException
Report the start of DTD declarations, if any.

Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
Report the end of DTD declarations.

Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
Report the end of an entity.

Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
Report the beginning of an entity in content.

Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException


Copyright (c) 2013 Software AG. All Rights Reserved.