public class XPPReader extends Object
XPPReader
is a Reader of DOM4J documents that
uses the fast
XML Pull Parser 2.x.
It does not currently support comments, CDATA or ProcessingInstructions or
validation but it is very fast for use in SOAP style environments.
Modifier and Type | Field and Description |
---|---|
private DispatchHandler |
dispatchHandler
DispatchHandler to call when each
Element is encountered |
private DocumentFactory |
factory
DocumentFactory used to create new document objects |
private org.gjt.xpp.XmlPullParserFactory |
xppFactory
XmlPullParser used to parse XML |
private org.gjt.xpp.XmlPullParser |
xppParser
XmlPullParser used to parse XML |
Constructor and Description |
---|
XPPReader() |
XPPReader(DocumentFactory factory) |
Modifier and Type | Method and Description |
---|---|
void |
addHandler(String path,
ElementHandler handler)
Adds the
ElementHandler to be called when the
specified path is encounted. |
protected Reader |
createReader(InputStream in)
Factory method to create a Reader from the given InputStream.
|
protected DispatchHandler |
getDispatchHandler() |
DocumentFactory |
getDocumentFactory() |
org.gjt.xpp.XmlPullParserFactory |
getXPPFactory() |
org.gjt.xpp.XmlPullParser |
getXPPParser() |
protected Document |
parseDocument() |
Document |
read(char[] text)
Reads a Document from the given array of characters
|
Document |
read(File file)
Reads a Document from the given
File |
Document |
read(InputStream in)
Reads a Document from the given stream
|
Document |
read(InputStream in,
String systemID)
Reads a Document from the given stream
|
Document |
read(Reader reader)
Reads a Document from the given
Reader |
Document |
read(Reader reader,
String systemID)
Reads a Document from the given
Reader |
Document |
read(String systemID)
Reads a Document from the given URL or filename.
|
Document |
read(URL url)
Reads a Document from the given
URL |
void |
removeHandler(String path)
Removes the
ElementHandler from the event based
processor, for the specified path. |
void |
setDefaultHandler(ElementHandler handler)
When multiple
ElementHandler instances have been
registered, this will set a default ElementHandler
to be called for any path which does NOT have a handler
registered. |
protected void |
setDispatchHandler(DispatchHandler dispatchHandler) |
void |
setDocumentFactory(DocumentFactory factory)
This sets the
DocumentFactory used to create new documents. |
void |
setXPPFactory(org.gjt.xpp.XmlPullParserFactory xppFactory) |
private DocumentFactory factory
DocumentFactory
used to create new document objectsprivate org.gjt.xpp.XmlPullParser xppParser
XmlPullParser
used to parse XMLprivate org.gjt.xpp.XmlPullParserFactory xppFactory
XmlPullParser
used to parse XMLprivate DispatchHandler dispatchHandler
Element
is encounteredpublic XPPReader()
public XPPReader(DocumentFactory factory)
public Document read(File file) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given File
file
- is the File
to read from.DocumentException
- if an error occurs during parsing.MalformedURLException
- if a URL could not be made for the given FileIOException
org.gjt.xpp.XmlPullParserException
public Document read(URL url) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given URL
url
- URL
to read from.DocumentException
- if an error occurs during parsing.IOException
org.gjt.xpp.XmlPullParserException
public Document read(String systemID) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given URL or filename.
If the systemID contains a ':'
character then it is
assumed to be a URL otherwise its assumed to be a file name.
If you want finer grained control over this mechansim then please
explicitly pass in either a URL
or a File
instance
instead of a String
to denote the source of the document.
systemID
- is a URL for a document or a file name.DocumentException
- if an error occurs during parsing.MalformedURLException
- if a URL could not be made for the given FileIOException
org.gjt.xpp.XmlPullParserException
public Document read(InputStream in) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given stream
in
- InputStream
to read from.DocumentException
- if an error occurs during parsing.IOException
org.gjt.xpp.XmlPullParserException
public Document read(Reader reader) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given Reader
reader
- is the reader for the inputDocumentException
- if an error occurs during parsing.IOException
org.gjt.xpp.XmlPullParserException
public Document read(char[] text) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given array of characters
text
- is the text to parseDocumentException
- if an error occurs during parsing.IOException
org.gjt.xpp.XmlPullParserException
public Document read(InputStream in, String systemID) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given stream
in
- InputStream
to read from.systemID
- is the URI for the inputDocumentException
- if an error occurs during parsing.IOException
org.gjt.xpp.XmlPullParserException
public Document read(Reader reader, String systemID) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given Reader
reader
- is the reader for the inputsystemID
- is the URI for the inputDocumentException
- if an error occurs during parsing.IOException
org.gjt.xpp.XmlPullParserException
public org.gjt.xpp.XmlPullParser getXPPParser() throws org.gjt.xpp.XmlPullParserException
org.gjt.xpp.XmlPullParserException
public org.gjt.xpp.XmlPullParserFactory getXPPFactory() throws org.gjt.xpp.XmlPullParserException
org.gjt.xpp.XmlPullParserException
public void setXPPFactory(org.gjt.xpp.XmlPullParserFactory xppFactory)
public DocumentFactory getDocumentFactory()
DocumentFactory
used to create document objectspublic void setDocumentFactory(DocumentFactory factory)
This sets the DocumentFactory
used to create new documents.
This method allows the building of custom DOM4J tree objects to be implemented
easily using a custom derivation of DocumentFactory
factory
- DocumentFactory
used to create DOM4J objectspublic void addHandler(String path, ElementHandler handler)
ElementHandler
to be called when the
specified path is encounted.path
- is the path to be handledhandler
- is the ElementHandler
to be called
by the event based processor.public void removeHandler(String path)
ElementHandler
from the event based
processor, for the specified path.path
- is the path to remove the ElementHandler
for.public void setDefaultHandler(ElementHandler handler)
ElementHandler
instances have been
registered, this will set a default ElementHandler
to be called for any path which does NOT have a handler
registered.handler
- is the ElementHandler
to be called
by the event based processor.protected Document parseDocument() throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException
DocumentException
IOException
org.gjt.xpp.XmlPullParserException
protected DispatchHandler getDispatchHandler()
protected void setDispatchHandler(DispatchHandler dispatchHandler)
protected Reader createReader(InputStream in) throws IOException
IOException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses