Package org.dom4j.io
Class XPPPacketReader
java.lang.Object
org.dom4j.io.XPPPacketReader
XPPPacketReader is a Reader of DOM4J documents that
uses the fast
XML Pull Parser 3.x.
It is very fast for use in SOAP style environments.
- Version:
- $Revision$
- Author:
- Pelle Braendgaard, James Strachan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandler(String path, org.dom4j.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.DispatchHandlerorg.dom4j.DocumentFactoryorg.xmlpull.v1.XmlPullParserFactoryorg.xmlpull.v1.XmlPullParserorg.dom4j.Documentorg.dom4j.Documentread(char[] text) Reads a Document from the given array of charactersorg.dom4j.DocumentReads a Document from the givenFileorg.dom4j.Documentread(InputStream in) Reads a Document from the given streamorg.dom4j.Documentread(InputStream in, String systemID) Reads a Document from the given streamorg.dom4j.DocumentReads a Document from the givenReaderorg.dom4j.DocumentReads a Document from the givenReaderorg.dom4j.DocumentReads a Document from the given URL or filename.org.dom4j.DocumentReads a Document from the givenURLvoidremoveHandler(String path) Removes theElementHandlerfrom the event based processor, for the specified path.voidsetDefaultHandler(org.dom4j.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(org.dom4j.DocumentFactory factory) This sets theDocumentFactoryused to create new documents.voidsetXPPFactory(org.xmlpull.v1.XmlPullParserFactory xppFactory)
-
Constructor Details
-
XPPPacketReader
public XPPPacketReader() -
XPPPacketReader
public XPPPacketReader(org.dom4j.DocumentFactory factory)
-
-
Method Details
-
read
public org.dom4j.Document read(File file) throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.XmlPullParserException Reads a Document from the given
File- Parameters:
file- is theFileto read from.- Returns:
- the newly created Document instance
- Throws:
org.dom4j.DocumentException- if an error occurs during parsing.MalformedURLException- if a URL could not be made for the given FileIOExceptionorg.xmlpull.v1.XmlPullParserException
-
read
public org.dom4j.Document read(URL url) throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.XmlPullParserException Reads a Document from the given
URL- Parameters:
url-URLto read from.- Returns:
- the newly created Document instance
- Throws:
org.dom4j.DocumentException- if an error occurs during parsing.IOExceptionorg.xmlpull.v1.XmlPullParserException
-
read
public org.dom4j.Document read(String systemID) throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.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:
org.dom4j.DocumentException- if an error occurs during parsing.MalformedURLException- if a URL could not be made for the given FileIOExceptionorg.xmlpull.v1.XmlPullParserException
-
read
public org.dom4j.Document read(InputStream in) throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.XmlPullParserException Reads a Document from the given stream
- Parameters:
in-InputStreamto read from.- Returns:
- the newly created Document instance
- Throws:
org.dom4j.DocumentException- if an error occurs during parsing.IOExceptionorg.xmlpull.v1.XmlPullParserException
-
read
public org.dom4j.Document read(Reader reader) throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.XmlPullParserException Reads a Document from the given
Reader- Parameters:
reader- is the reader for the input- Returns:
- the newly created Document instance
- Throws:
org.dom4j.DocumentException- if an error occurs during parsing.IOExceptionorg.xmlpull.v1.XmlPullParserException
-
read
public org.dom4j.Document read(char[] text) throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.XmlPullParserException Reads a Document from the given array of characters
- Parameters:
text- is the text to parse- Returns:
- the newly created Document instance
- Throws:
org.dom4j.DocumentException- if an error occurs during parsing.IOExceptionorg.xmlpull.v1.XmlPullParserException
-
read
public org.dom4j.Document read(InputStream in, String systemID) throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.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:
org.dom4j.DocumentException- if an error occurs during parsing.IOExceptionorg.xmlpull.v1.XmlPullParserException
-
read
public org.dom4j.Document read(Reader reader, String systemID) throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.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:
org.dom4j.DocumentException- if an error occurs during parsing.IOExceptionorg.xmlpull.v1.XmlPullParserException
-
getXPPParser
public org.xmlpull.v1.XmlPullParser getXPPParser() throws org.xmlpull.v1.XmlPullParserException- Throws:
org.xmlpull.v1.XmlPullParserException
-
getXPPFactory
public org.xmlpull.v1.XmlPullParserFactory getXPPFactory() throws org.xmlpull.v1.XmlPullParserException- Throws:
org.xmlpull.v1.XmlPullParserException
-
setXPPFactory
public void setXPPFactory(org.xmlpull.v1.XmlPullParserFactory xppFactory) -
getDocumentFactory
public org.dom4j.DocumentFactory getDocumentFactory()- Returns:
- the
DocumentFactoryused to create document objects
-
setDocumentFactory
public void setDocumentFactory(org.dom4j.DocumentFactory factory) 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:
factory-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
public void setDefaultHandler(org.dom4j.ElementHandler handler) 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
public org.dom4j.Document parseDocument() throws org.dom4j.DocumentException, IOException, org.xmlpull.v1.XmlPullParserException- Throws:
org.dom4j.DocumentExceptionIOExceptionorg.xmlpull.v1.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.- Throws:
IOException
-