|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
org.openspml.util.XmlParser
A wrapper around the Xerces parser that provides a simpler interface, and maintains a pool of parser objects for better performance.
This implements the Xerces ErrorHandler interface so we can intercept parser errors and mutate them.
Constructor Summary | |
XmlParser(boolean validating)
Construct a private utility object. |
Method Summary | |
static void |
clearPool()
Manually clear the pool |
static void |
dumpPool()
Dump information about the pool. |
void |
error(org.openspml.util.SAXParseException ex)
Parser error callback handler |
void |
fatalError(org.openspml.util.SAXParseException ex)
Parser fatal error callback handler. |
static java.lang.String |
getFilePath(java.lang.String name)
Build an absolute path name for a file. |
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 java.lang.String |
itoa(int i)
|
static void |
main(java.lang.String[] args)
Parses an XML file, and displays any error or warning messages. |
static org.openspml.util.Document |
parse(java.lang.String xml,
boolean validation)
Parses a string with or without validation and returns the Document. |
org.openspml.util.Document |
parseString(java.lang.String xml)
Parses a string and returns the Document. |
void |
pool()
Return the parser to the pool. |
static void |
poolParser(XmlParser p)
Return an object to the pool. |
static java.lang.String |
readFile(java.lang.String name)
Read the contents of a file and return it as a String. |
static byte[] |
readFileBytes(java.io.File file)
|
static byte[] |
readFileBytes(java.lang.String name)
|
static byte[] |
readInputStreamBytes(java.io.InputStream is,
boolean close)
|
org.openspml.util.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.openspml.util.ContentHandler handler)
Parse a stream using SAX. |
void |
saxParse(java.lang.String uri,
org.openspml.util.ContentHandler handler)
Parse a uri using SAX. |
void |
saxParseString(java.lang.String xml,
org.openspml.util.ContentHandler handler)
Parse a string using SAX. |
void |
warning(org.openspml.util.SAXParseException ex)
Parser warning callback handler. |
static void |
writeFile(java.lang.String name,
byte[] contents)
Store the contents of a String in a file. |
static void |
writeFile(java.lang.String name,
java.lang.String contents)
Store the contents of a String in a file. |
Constructor Detail |
public XmlParser(boolean validating) throws org.openspml.util.ParserConfigurationException, org.openspml.util.FactoryConfigurationError
Method Detail |
public static org.openspml.util.Document parse(java.lang.String xml, boolean validation) throws SpmlException
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 java.lang.String itoa(int i)
public static void dumpPool()
public void pool()
public org.openspml.util.Document parseString(java.lang.String xml) throws SpmlException
public org.openspml.util.InputSource resolveEntity(java.lang.String pubid, java.lang.String sysid) throws org.openspml.util.SAXException, java.io.IOException
public void warning(org.openspml.util.SAXParseException ex)
What should we do with warnings, collection them, barf to the console? Might want a flag that treats warnings as errors.
public void error(org.openspml.util.SAXParseException ex) throws org.openspml.util.SAXParseException
We get here for things like DTD syntax errors, and DTD validation errors.
public void fatalError(org.openspml.util.SAXParseException ex) throws org.openspml.util.SAXException
Convert this one to a SpmlException so we can capture the full message text in one place. We get here for things like DTD location failure.
public void saxParse(java.lang.String uri, org.openspml.util.ContentHandler handler) throws SpmlException
Since we assume we don't do this very often, we'll build a new parser every time.
public void saxParse(java.io.InputStream input, org.openspml.util.ContentHandler handler) throws SpmlException
public void saxParseString(java.lang.String xml, org.openspml.util.ContentHandler handler) throws SpmlException
public static void clearPool()
public static java.lang.String readFile(java.lang.String name) throws SpmlException
public static byte[] readFileBytes(java.lang.String name) throws SpmlException
public static byte[] readFileBytes(java.io.File file) throws SpmlException
public static byte[] readInputStreamBytes(java.io.InputStream is, boolean close) throws SpmlException
close
- - if true, close when finished reading.public static void writeFile(java.lang.String name, java.lang.String contents) throws SpmlException
public static void writeFile(java.lang.String name, byte[] contents) throws SpmlException
public static java.lang.String getFilePath(java.lang.String name)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |