www.sdmetrics.com

com.sdmetrics.util
Class XMLParser

java.lang.Object
  extended by com.sdmetrics.util.XMLParser

public class XMLParser
extends java.lang.Object

Encapsulates access to the XML Parser. Creates an instance of a non-validating SAX2 XML reader, and provides a simple method to parse an XML file.


Constructor Summary
XMLParser()
          Constructs a non-validating SAX parser.
 
Method Summary
 java.lang.String getErrorMessage()
          Gets an enhanced error message when parsing of a file failed.
 void parse(java.lang.String uri, org.xml.sax.ContentHandler dh)
          Parses the XML file at the specified URI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLParser

public XMLParser()
          throws org.xml.sax.SAXException,
                 javax.xml.parsers.ParserConfigurationException
Constructs a non-validating SAX parser.

Throws:
javax.xml.parsers.ParserConfigurationException - Problem with the JVM's XML parser configuration.
org.xml.sax.SAXException - The SAX parser could not be initialized.
Method Detail

parse

public void parse(java.lang.String uri,
                  org.xml.sax.ContentHandler dh)
           throws java.lang.Exception
Parses the XML file at the specified URI

Parameters:
uri - URI of the XML file to parse.
dh - Default handler to process the XML elements
Throws:
java.lang.Exception - A problem occurred while parsing

getErrorMessage

public java.lang.String getErrorMessage()
Gets an enhanced error message when parsing of a file failed. The enhanced error message may include line numbers pinpointing the source of the problem in the XMI file, or other clues what went wrong.

Returns:
Description of the error.

www.sdmetrics.com