www.sdmetrics.com

com.sdmetrics.util
Class SAXHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.sdmetrics.util.SAXHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
XMIReader

public class SAXHandler
extends org.xml.sax.helpers.DefaultHandler

Base class for SDMetrics' XML handlers. Provides locator information and version attribute checking.


Field Summary
protected  org.xml.sax.Locator locator
          Locator of the handler.
 
Constructor Summary
SAXHandler()
           
 
Method Summary
protected  void checkVersion(org.xml.sax.Attributes attrs, java.lang.String since)
          Tests if the indicated "version" number in an XML document is still supported.
protected  void reportError(java.lang.String message)
          Reports a severe error that calls for a SAX Exception.
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

locator

protected org.xml.sax.Locator locator
Locator of the handler.

Constructor Detail

SAXHandler

public SAXHandler()
Method Detail

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler

checkVersion

protected void checkVersion(org.xml.sax.Attributes attrs,
                            java.lang.String since)
                     throws org.xml.sax.SAXException
Tests if the indicated "version" number in an XML document is still supported.

Parameters:
attrs - The list of XML attributes of a document's root element.
since - The smallest version number that can be accepted, or null if all known versions are accepted.
Throws:
org.xml.sax.SAXException - If no "version" attribute exists, or if the indicated version is not known or no longer accepted.
java.lang.IllegalArgumentException - If the "since" version is not known.

reportError

protected void reportError(java.lang.String message)
                    throws org.xml.sax.SAXException
Reports a severe error that calls for a SAX Exception. The method prepends the error message with file location information and throws a SAXException.

Parameters:
message - Message of the SAXException
Throws:
org.xml.sax.SAXException - To report the error to the SAX error handler.

www.sdmetrics.com