|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.util.XmlParser
A simplified wrapper around the Xerces DOM parser. We also provide static methods for a parser pool. The pool is necessary since the parser object is not reentrant, and we'd prefer not to synchronize everything on XML parsing.
This implements the Xerces ErrorHandler interface so we can intercept parser errors and mutate them.
Field Summary | |
static java.lang.String |
code_id
|
Method Summary | |
static void |
clearPool()
Manually clear the pool |
static void |
dumpPool()
Dump information about the pool. |
void |
error(org.xml.sax.SAXParseException ex)
Parser error callback handler |
void |
fatalError(org.xml.sax.SAXParseException ex)
Parser fatal error callback handler. |
static XmlParser |
getParser()
Obtain a parser from the pool. |
static XmlParser |
getParser(boolean validating)
|
static void |
getStatus(java.lang.StringBuffer b)
Retrieve information about the pool. |
static void |
main(java.lang.String[] args)
Parses an XML file, and displays any error or warning messages. |
org.w3c.dom.Document |
parse(java.lang.String uri)
Parses the specified URI and returns the document. |
org.w3c.dom.Document |
parseString(java.lang.String xml)
Parses a string without validation and returns the Document. |
org.w3c.dom.Document |
parseString(java.lang.String xml,
boolean validation)
Parses a string with or without validation and returns the Document. |
void |
pool()
Return the parser to the pool. |
static void |
poolParser(XmlParser p)
Return an object to the pool. |
org.xml.sax.InputSource |
resolveEntity(java.lang.String pubid,
java.lang.String sysid)
Attempt to resolve an entity reference to an absolute file path. |
void |
saxParse(java.io.InputStream input,
org.xml.sax.ContentHandler handler)
Parse a stream using SAX. |
void |
saxParse(java.io.Reader input,
org.xml.sax.ContentHandler handler)
Parse a reader using SAX. |
void |
saxParse(java.lang.String uri,
org.xml.sax.ContentHandler handler)
Parse a uri using SAX. |
void |
saxParseString(java.lang.String xml,
org.xml.sax.ContentHandler handler)
Parse a string using SAX. |
void |
saxParseString(java.lang.String xml,
org.xml.sax.ContentHandler handler,
org.xml.sax.ErrorHandler errorHandler)
Parse a string using SAX. |
boolean |
setValidation(boolean validation)
Turn validation in a parser on or off. |
void |
warning(org.xml.sax.SAXParseException ex)
Parser warning callback handler. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
Method Detail |
public static XmlParser getParser()
public static XmlParser getParser(boolean validating)
public static void poolParser(XmlParser p)
public static void getStatus(java.lang.StringBuffer b)
public static void dumpPool()
public void pool()
public boolean setValidation(boolean validation)
public org.w3c.dom.Document parse(java.lang.String uri) throws WavesetException
WavesetException
public org.w3c.dom.Document parseString(java.lang.String xml) throws WavesetException
WavesetException
public org.w3c.dom.Document parseString(java.lang.String xml, boolean validation) throws WavesetException
WavesetException
public org.xml.sax.InputSource resolveEntity(java.lang.String pubid, java.lang.String sysid) throws org.xml.sax.SAXException, java.io.IOException
resolveEntity
in interface org.xml.sax.EntityResolver
org.xml.sax.SAXException
java.io.IOException
public void warning(org.xml.sax.SAXParseException ex)
What should we do with warnings, collection them, barf to the console? Might want a flag that treats warnings as errors.
warning
in interface org.xml.sax.ErrorHandler
public void error(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXParseException
We get here for things like DTD syntax errors, and DTD validation errors.
error
in interface org.xml.sax.ErrorHandler
org.xml.sax.SAXParseException
public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
Convert this one to a WavesetException so we can capture the full message text in one place. We get here for things like DTD location failure.
fatalError
in interface org.xml.sax.ErrorHandler
org.xml.sax.SAXException
public void saxParse(java.lang.String uri, org.xml.sax.ContentHandler handler) throws WavesetException
Since we assume we don't do this very often, we'll build a new parser every time.
WavesetException
public void saxParse(java.io.InputStream input, org.xml.sax.ContentHandler handler) throws WavesetException
WavesetException
public void saxParse(java.io.Reader input, org.xml.sax.ContentHandler handler) throws WavesetException
WavesetException
public void saxParseString(java.lang.String xml, org.xml.sax.ContentHandler handler) throws WavesetException
WavesetException
public void saxParseString(java.lang.String xml, org.xml.sax.ContentHandler handler, org.xml.sax.ErrorHandler errorHandler) throws WavesetException
WavesetException
public static void clearPool()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |