GXPARSE hosted by SourceForge.net Logo

ca.gorman.xml.parse.sax
Class SAXAdapter<T extends Parser>

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.xml.sax.ext.DefaultHandler2
          extended by ca.gorman.xml.parse.sax.SAXAdapter<T>
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, EntityResolver2, LexicalHandler

public class SAXAdapter<T extends Parser>
extends DefaultHandler2

Bridge between SAX parser API and XML stream parser API. Acts as a listener to org.xml.sax.XMLReader.


Nested Class Summary
 class SAXAdapter.ParserDelegate
           Provides delegates for some of the methods in Parser.
 
Constructor Summary
SAXAdapter(Coroutine coroutine, Listener<T> listener, T parser)
           Construct a SAXAdapter.
 
Method Summary
 void attributeDecl(String eName, String aName, String type, String valueDefault, String value)
           Report an attribute type declaration.
 void characters(char[] ch, int start, int length)
           Receive notification of character data.
 void comment(char[] ch, int start, int length)
           Report an XML comment anywhere in the document.
 void elementDecl(String name, String model)
           Report an element type declaration.
 void endCDATA()
           Report the end of a CDATA section.
 void endDocument()
           Receive notification of the end of a document.
 void endDTD()
           Report the end of DTD declarations.
 void endElement(String namespaceURI, String localName, String qName)
           Receive notification of the end of an element.
 void endEntity(String name)
           Report the end of an entity.
 void endPrefixMapping(String prefix)
           End the scope of a prefix-URI mapping.
 void error(SAXParseException exception)
           Receive notification of a recoverable error.
 void externalEntityDecl(String name, String publicId, String systemId)
           Report a parsed external entity declaration.
 void fatalError(SAXParseException exception)
           Receive notification of a non-recoverable error.
 InputSource getExternalSubset(String name, String baseURI)
           
 Listener<T> getListener()
           Get Listener.
 SAXAdapter.ParserDelegate getParserDelegate()
           Get delegates for some of the methods in Parser.
 void ignorableWhitespace(char[] ch, int start, int length)
           Receive notification of ignorable whitespace in element content.
 void internalEntityDecl(String name, String value)
           Report an internal entity declaration.
 void notationDecl(String name, String publicId, String systemId)
           Receive notification of a notation declaration event.
 void processingInstruction(String target, String data)
           Receive notification of a processing instruction.
 InputSource resolveEntity(String name, String publicId, String baseURI, String systemId)
           
 void setDocumentLocator(Locator locator)
           Receive an object for locating the origin of SAX document events.
 void setListener(Listener<T> listener)
           Install listener.
 void setParser(T parser)
           Set or reset the Parser instance.
 void skippedEntity(String name)
           Receive notification of a skipped entity.
 void startCDATA()
           Report the start of a CDATA section.
 void startDocument()
           Receive notification of the beginning of a document.
 void startDTD(String name, String publicId, String systemId)
           Report the start of DTD declarations, if any.
 void startElement(String namespaceURI, String localName, String qName, Attributes saxAttributes)
           Receive notification of the beginning of an element.
 void startEntity(String name)
           Report the start of an entity.
 void startPrefixMapping(String prefix, String uri)
           Begin the scope of a prefix-URI Namespace mapping.
 void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
           Receive notification of an unparsed entity declaration event.
 void warning(SAXParseException exception)
           Receive notification of a warning.
 
Methods inherited from class org.xml.sax.ext.DefaultHandler2
resolveEntity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXAdapter

public SAXAdapter(Coroutine coroutine,
                  Listener<T> listener,
                  T parser)

Construct a SAXAdapter.

Throws:
NullPointerException - if any parameter is null.
Method Detail

setListener

public void setListener(Listener<T> listener)

Install listener.

Throws:
NullPointerException - if listener is null.

getListener

public Listener<T> getListener()

Get Listener.


setParser

public void setParser(T parser)

Set or reset the Parser instance.

Throws:
NullPointerException - if parameter is null

setDocumentLocator

public void setDocumentLocator(Locator locator)

Receive an object for locating the origin of SAX document events.

Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler

startDocument

public void startDocument()
                   throws SAXException

Receive notification of the beginning of a document.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException

Receive notification of the end of a document.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException

Begin the scope of a prefix-URI Namespace mapping.

Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class DefaultHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException

End the scope of a prefix-URI mapping.

Specified by:
endPrefixMapping in interface ContentHandler
Overrides:
endPrefixMapping in class DefaultHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes saxAttributes)
                  throws SAXException

Receive notification of the beginning of an element.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException

Receive notification of the end of an element.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException

Receive notification of character data.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws SAXException

Receive notification of ignorable whitespace in element content.

Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class DefaultHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException

Receive notification of a processing instruction.

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class DefaultHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
                   throws SAXException

Receive notification of a skipped entity.

Specified by:
skippedEntity in interface ContentHandler
Overrides:
skippedEntity in class DefaultHandler
Throws:
SAXException

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
                  throws SAXException

Receive notification of a notation declaration event.

Specified by:
notationDecl in interface DTDHandler
Overrides:
notationDecl in class DefaultHandler
Throws:
SAXException

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String systemId,
                               String notationName)
                        throws SAXException

Receive notification of an unparsed entity declaration event.

Specified by:
unparsedEntityDecl in interface DTDHandler
Overrides:
unparsedEntityDecl in class DefaultHandler
Throws:
SAXException

elementDecl

public void elementDecl(String name,
                        String model)
                 throws SAXException

Report an element type declaration.

Specified by:
elementDecl in interface DeclHandler
Overrides:
elementDecl in class DefaultHandler2
Throws:
SAXException

attributeDecl

public void attributeDecl(String eName,
                          String aName,
                          String type,
                          String valueDefault,
                          String value)
                   throws SAXException

Report an attribute type declaration.

Specified by:
attributeDecl in interface DeclHandler
Overrides:
attributeDecl in class DefaultHandler2
Throws:
SAXException

internalEntityDecl

public void internalEntityDecl(String name,
                               String value)
                        throws SAXException

Report an internal entity declaration.

Specified by:
internalEntityDecl in interface DeclHandler
Overrides:
internalEntityDecl in class DefaultHandler2
Throws:
SAXException

externalEntityDecl

public void externalEntityDecl(String name,
                               String publicId,
                               String systemId)
                        throws SAXException

Report a parsed external entity declaration.

Specified by:
externalEntityDecl in interface DeclHandler
Overrides:
externalEntityDecl in class DefaultHandler2
Throws:
SAXException

getExternalSubset

public InputSource getExternalSubset(String name,
                                     String baseURI)
                              throws SAXException
Specified by:
getExternalSubset in interface EntityResolver2
Overrides:
getExternalSubset in class DefaultHandler2
Throws:
SAXException

resolveEntity

public InputSource resolveEntity(String name,
                                 String publicId,
                                 String baseURI,
                                 String systemId)
                          throws SAXException
Specified by:
resolveEntity in interface EntityResolver2
Overrides:
resolveEntity in class DefaultHandler2
Throws:
SAXException

warning

public void warning(SAXParseException exception)
             throws SAXException

Receive notification of a warning.

Specified by:
warning in interface ErrorHandler
Overrides:
warning in class DefaultHandler
Throws:
SAXException

error

public void error(SAXParseException exception)
           throws SAXException

Receive notification of a recoverable error.

Specified by:
error in interface ErrorHandler
Overrides:
error in class DefaultHandler
Throws:
SAXException

fatalError

public void fatalError(SAXParseException exception)
                throws SAXException

Receive notification of a non-recoverable error.

Specified by:
fatalError in interface ErrorHandler
Overrides:
fatalError in class DefaultHandler
Throws:
SAXException

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException

Report the start of DTD declarations, if any.

Specified by:
startDTD in interface LexicalHandler
Overrides:
startDTD in class DefaultHandler2
Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException

Report the end of DTD declarations.

Specified by:
endDTD in interface LexicalHandler
Overrides:
endDTD in class DefaultHandler2
Throws:
SAXException

startEntity

public void startEntity(String name)
                 throws SAXException

Report the start of an entity.

Specified by:
startEntity in interface LexicalHandler
Overrides:
startEntity in class DefaultHandler2
Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException

Report the end of an entity.

Specified by:
endEntity in interface LexicalHandler
Overrides:
endEntity in class DefaultHandler2
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException

Report the start of a CDATA section.

Specified by:
startCDATA in interface LexicalHandler
Overrides:
startCDATA in class DefaultHandler2
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException

Report the end of a CDATA section.

Specified by:
endCDATA in interface LexicalHandler
Overrides:
endCDATA in class DefaultHandler2
Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException

Report an XML comment anywhere in the document.

Specified by:
comment in interface LexicalHandler
Overrides:
comment in class DefaultHandler2
Throws:
SAXException

getParserDelegate

public SAXAdapter.ParserDelegate getParserDelegate()

Get delegates for some of the methods in Parser.


GXPARSE download

GXPARSE Generic XML Stream Parser API and supporting tools.   Release $Name: gxparse-sf-alpha-2_0 $
Copyright 2003-2004 Ian E. Gorman
Released under GNU Lesser General Public License