Arch4J 1.1

org.arch4j.xml.xerces
Class XercesXMLStream

java.lang.Object
  |
  +--org.arch4j.xml.xerces.XercesXMLStream
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.ErrorHandler, XMLStream

public class XercesXMLStream
extends Object
implements XMLStream, org.xml.sax.ContentHandler, org.xml.sax.ErrorHandler

This class wraps an implementation of the SAX 2 event-based XML parser to create a spiderlogic-specific interface. Any changes or deprecations in event-based parsers in the future can be accounted for within this class. This class is used to open an xml file and get callbacks, through the XMLHandler as the file is parsed. To do this, this class extends the base SAX event handler class and passes each event on to the SpiderLogic XMLHandler, scrubbing out any SAX-specific classes.

Version:
2.0
Author:
Russ Brown, Ross E. Greinke

Constructor Summary
XercesXMLStream()
          Create an XML stream parser with callbacks to a handler.
 
Method Summary
protected  Map buildMap(org.xml.sax.Attributes attributes)
          Used to convert the SAX-specific (@link Attributes} set into a Hashtable.
 void characters(char[] buffer, int start, int length)
          called by SAX2 parser whenever non-tag characters are encountered.
 void endDocument()
          called by SAX2 parser when the end of the document is encountered.
 void endElement(String namespaceURL, String localName, String qname)
          called by SAX2 parser when the end of an element is encountered.
 void endPrefixMapping(String p0)
           
 void error(org.xml.sax.SAXParseException spe)
          called by SAX2 parser when a recoverable parse error is encountered
 void fatalError(org.xml.sax.SAXParseException spe)
          called by SAX2 parser when a non-recoverable parse error is encountered.
 void ignorableWhitespace(char[] p0, int p1, int p2)
           
 void notationDecl(String p0, String p1, String p2)
           
 void parse()
          Begins parsing of the XML file specified in constructor, with callbacks going to the specified handler.
 void processingInstruction(String p0, String p1)
           
 void setDocumentLocator(org.xml.sax.Locator p0)
           
 void setHandler(XMLHandler aHandler)
          Set the handler that will receive callbacks during parsing.
 void setReader(Reader aFileReader)
          Set a Reader which has been opened on the data to parse.
 void skippedEntity(String p0)
           
 void startDocument()
          called by SAX2 parser at the start of the document.
 void startElement(String namespaceURI, String localName, String qname, org.xml.sax.Attributes attributes)
          called by SAX2 parser when the start of a new element is encountered.
 void startPrefixMapping(String p0, String p1)
           
 void unparsedEntityDecl(String p0, String p1, String p2, String p3)
           
 void warning(org.xml.sax.SAXParseException spe)
          called by SAX2 parser when warning situation is encountered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XercesXMLStream

public XercesXMLStream()
Create an XML stream parser with callbacks to a handler. Parsing does not begin until XMLStream.parse() is called.

Method Detail

setReader

public void setReader(Reader aFileReader)
Set a Reader which has been opened on the data to parse.

Specified by:
setReader in interface XMLStream
Parameters:
aFileReader - The stream upon which to read the data to parse.

setHandler

public void setHandler(XMLHandler aHandler)
Set the handler that will receive callbacks during parsing.

Specified by:
setHandler in interface XMLStream
Parameters:
aHandler - The handler that will be called back during parsing.

parse

public void parse()
           throws XMLException
Begins parsing of the XML file specified in constructor, with callbacks going to the specified handler.

Specified by:
parse in interface XMLStream
Throws:
XMLException - If the data stream cannot be parsed.

startDocument

public void startDocument()
called by SAX2 parser at the start of the document.

Specified by:
startDocument in interface org.xml.sax.ContentHandler

characters

public void characters(char[] buffer,
                       int start,
                       int length)
called by SAX2 parser whenever non-tag characters are encountered. May be called multiple times for a single block of characters.

Specified by:
characters in interface org.xml.sax.ContentHandler
Parameters:
buffer - the set of characters containing the detected non-tag characters.
start - the starting index of the detected characers inside buffer
length - length of detected character set, starting at index start

error

public void error(org.xml.sax.SAXParseException spe)
called by SAX2 parser when a recoverable parse error is encountered

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
spe - describes the error and gives its location in the file.

fatalError

public void fatalError(org.xml.sax.SAXParseException spe)
called by SAX2 parser when a non-recoverable parse error is encountered. The parser aborts after this callback.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
spe - describes the error and gives its location in the file.

warning

public void warning(org.xml.sax.SAXParseException spe)
called by SAX2 parser when warning situation is encountered

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
spe - describes the error and gives its location in the file.

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qname,
                         org.xml.sax.Attributes attributes)
called by SAX2 parser when the start of a new element is encountered.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Parameters:
namespaceURI - see http://www.megginson.com/SAX/Java/javadoc/index.html
localName - see http://www.megginson.com/SAX/Java/javadoc/index.html
qname - see http://www.megginson.com/SAX/Java/javadoc/index.html
attributes - the set of attributes and values contained in this element tag.

endElement

public void endElement(String namespaceURL,
                       String localName,
                       String qname)
called by SAX2 parser when the end of an element is encountered.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Parameters:
localName - see http://www.megginson.com/SAX/Java/javadoc/index.html
qname - see http://www.megginson.com/SAX/Java/javadoc/index.html

endDocument

public void endDocument()
called by SAX2 parser when the end of the document is encountered.

Specified by:
endDocument in interface org.xml.sax.ContentHandler

endPrefixMapping

public void endPrefixMapping(String p0)
                      throws org.xml.sax.SAXException
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] p0,
                                int p1,
                                int p2)
                         throws org.xml.sax.SAXException
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException

notationDecl

public void notationDecl(String p0,
                         String p1,
                         String p2)
                  throws org.xml.sax.SAXException
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(String p0,
                                  String p1)
                           throws org.xml.sax.SAXException
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator p0)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

skippedEntity

public void skippedEntity(String p0)
                   throws org.xml.sax.SAXException
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException

startPrefixMapping

public void startPrefixMapping(String p0,
                               String p1)
                        throws org.xml.sax.SAXException
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException

unparsedEntityDecl

public void unparsedEntityDecl(String p0,
                               String p1,
                               String p2,
                               String p3)
                        throws org.xml.sax.SAXException
org.xml.sax.SAXException

buildMap

protected Map buildMap(org.xml.sax.Attributes attributes)
Used to convert the SAX-specific (@link Attributes} set into a Hashtable.

Parameters:
attributes - attribute set to convert to a hashtable.
Returns:
The hashtable of attributes.

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.