Class XPPReader
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.
- Version:
- $Revision: 1.7 $
- Author:
- James Strachan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandler(String path, ElementHandler handler) Adds theElementHandlerto be called when the specified path is encounted.protected ReaderFactory method to create a Reader from the given InputStream.protected org.dom4j.io.DispatchHandlerDOCUMENT ME!org.gjt.xpp.XmlPullParserFactoryorg.gjt.xpp.XmlPullParserprotected Documentread(char[] text) Reads a Document from the given array of charactersReads a Document from the givenFileread(InputStream in) Reads a Document from the given streamread(InputStream in, String systemID) Reads a Document from the given streamReads a Document from the givenReaderReads a Document from the givenReaderReads a Document from the given URL or filename.Reads a Document from the givenURLvoidremoveHandler(String path) Removes theElementHandlerfrom the event based processor, for the specified path.voidsetDefaultHandler(ElementHandler handler) When multipleElementHandlerinstances have been registered, this will set a defaultElementHandlerto be called for any path which does NOT have a handler registered.protected voidsetDispatchHandler(org.dom4j.io.DispatchHandler dispatchHandler) voidsetDocumentFactory(DocumentFactory documentFactory) This sets theDocumentFactoryused to create new documents.voidsetXPPFactory(org.gjt.xpp.XmlPullParserFactory xPPFactory)
-
Constructor Details
-
XPPReader
public XPPReader() -
XPPReader
-
-
Method Details
-
read
public Document read(File file) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException Reads a Document from the given
File- Parameters:
file- is theFileto read from.- Returns:
- the newly created Document instance
- Throws:
DocumentException- if an error occurs during parsing.IOException- if a URL could not be made for the given Fileorg.gjt.xpp.XmlPullParserException- DOCUMENT ME!
-
read
public Document read(URL url) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException Reads a Document from the given
URL- Parameters:
url-URLto read from.- Returns:
- the newly created Document instance
- Throws:
DocumentException- if an error occurs during parsing.IOException- DOCUMENT ME!org.gjt.xpp.XmlPullParserException- DOCUMENT ME!
-
read
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 aURLor aFileinstance instead of aStringto denote the source of the document.- Parameters:
systemID- is a URL for a document or a file name.- Returns:
- the newly created Document instance
- Throws:
DocumentException- if an error occurs during parsing.IOException- if a URL could not be made for the given Fileorg.gjt.xpp.XmlPullParserException- DOCUMENT ME!
-
read
public Document read(InputStream in) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException Reads a Document from the given stream
- Parameters:
in-InputStreamto read from.- Returns:
- the newly created Document instance
- Throws:
DocumentException- if an error occurs during parsing.IOException- DOCUMENT ME!org.gjt.xpp.XmlPullParserException- DOCUMENT ME!
-
read
public Document read(Reader reader) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException Reads a Document from the given
Reader- Parameters:
reader- is the reader for the input- Returns:
- the newly created Document instance
- Throws:
DocumentException- if an error occurs during parsing.IOException- DOCUMENT ME!org.gjt.xpp.XmlPullParserException- DOCUMENT ME!
-
read
public Document read(char[] text) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException Reads a Document from the given array of characters
- Parameters:
text- is the text to parse- Returns:
- the newly created Document instance
- Throws:
DocumentException- if an error occurs during parsing.IOException- DOCUMENT ME!org.gjt.xpp.XmlPullParserException- DOCUMENT ME!
-
read
public Document read(InputStream in, String systemID) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException Reads a Document from the given stream
- Parameters:
in-InputStreamto read from.systemID- is the URI for the input- Returns:
- the newly created Document instance
- Throws:
DocumentException- if an error occurs during parsing.IOException- DOCUMENT ME!org.gjt.xpp.XmlPullParserException- DOCUMENT ME!
-
read
public Document read(Reader reader, String systemID) throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException Reads a Document from the given
Reader- Parameters:
reader- is the reader for the inputsystemID- is the URI for the input- Returns:
- the newly created Document instance
- Throws:
DocumentException- if an error occurs during parsing.IOException- DOCUMENT ME!org.gjt.xpp.XmlPullParserException- DOCUMENT ME!
-
getXPPParser
public org.gjt.xpp.XmlPullParser getXPPParser() throws org.gjt.xpp.XmlPullParserException- Throws:
org.gjt.xpp.XmlPullParserException
-
getXPPFactory
public org.gjt.xpp.XmlPullParserFactory getXPPFactory() throws org.gjt.xpp.XmlPullParserException- Throws:
org.gjt.xpp.XmlPullParserException
-
setXPPFactory
public void setXPPFactory(org.gjt.xpp.XmlPullParserFactory xPPFactory) -
getDocumentFactory
DOCUMENT ME!- Returns:
- the
DocumentFactoryused to create document objects
-
setDocumentFactory
This sets the
DocumentFactoryused to create new documents. This method allows the building of custom DOM4J tree objects to be implemented easily using a custom derivation ofDocumentFactory- Parameters:
documentFactory-DocumentFactoryused to create DOM4J objects
-
addHandler
Adds theElementHandlerto be called when the specified path is encounted.- Parameters:
path- is the path to be handledhandler- is theElementHandlerto be called by the event based processor.
-
removeHandler
Removes theElementHandlerfrom the event based processor, for the specified path.- Parameters:
path- is the path to remove theElementHandlerfor.
-
setDefaultHandler
When multipleElementHandlerinstances have been registered, this will set a defaultElementHandlerto be called for any path which does NOT have a handler registered.- Parameters:
handler- is theElementHandlerto be called by the event based processor.
-
parseDocument
protected Document parseDocument() throws DocumentException, IOException, org.gjt.xpp.XmlPullParserException- Throws:
DocumentExceptionIOExceptionorg.gjt.xpp.XmlPullParserException
-
getDispatchHandler
protected org.dom4j.io.DispatchHandler getDispatchHandler() -
setDispatchHandler
protected void setDispatchHandler(org.dom4j.io.DispatchHandler dispatchHandler) -
createReader
Factory method to create a Reader from the given InputStream.- Parameters:
in- DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Throws:
IOException- DOCUMENT ME!
-