Class XPPReader
- java.lang.Object
-
- org.dom4j.io.XPPReader
-
public class XPPReader extends java.lang.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.
-
-
Constructor Summary
Constructors Constructor Description XPPReader()
XPPReader(DocumentFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHandler(java.lang.String path, ElementHandler handler)
Adds theElementHandler
to be called when the specified path is encounted.protected java.io.Reader
createReader(java.io.InputStream in)
Factory method to create a Reader from the given InputStream.protected org.dom4j.io.DispatchHandler
getDispatchHandler()
DocumentFactory
getDocumentFactory()
DOCUMENT ME!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 charactersDocument
read(java.io.File file)
Reads a Document from the givenFile
Document
read(java.io.InputStream in)
Reads a Document from the given streamDocument
read(java.io.InputStream in, java.lang.String systemID)
Reads a Document from the given streamDocument
read(java.io.Reader reader)
Reads a Document from the givenReader
Document
read(java.io.Reader reader, java.lang.String systemID)
Reads a Document from the givenReader
Document
read(java.lang.String systemID)
Reads a Document from the given URL or filename.Document
read(java.net.URL url)
Reads a Document from the givenURL
void
removeHandler(java.lang.String path)
Removes theElementHandler
from the event based processor, for the specified path.void
setDefaultHandler(ElementHandler handler)
When multipleElementHandler
instances have been registered, this will set a defaultElementHandler
to be called for any path which does NOT have a handler registered.protected void
setDispatchHandler(org.dom4j.io.DispatchHandler dispatchHandler)
void
setDocumentFactory(DocumentFactory documentFactory)
This sets theDocumentFactory
used to create new documents.void
setXPPFactory(org.gjt.xpp.XmlPullParserFactory xPPFactory)
-
-
-
Constructor Detail
-
XPPReader
public XPPReader()
-
XPPReader
public XPPReader(DocumentFactory factory)
-
-
Method Detail
-
read
public Document read(java.io.File file) throws DocumentException, java.io.IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given
File
- Parameters:
file
- is theFile
to read from.- Returns:
- the newly created Document instance
- Throws:
DocumentException
- if an error occurs during parsing.java.io.IOException
- if a URL could not be made for the given Fileorg.gjt.xpp.XmlPullParserException
- DOCUMENT ME!
-
read
public Document read(java.net.URL url) throws DocumentException, java.io.IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given
URL
- Parameters:
url
-URL
to read from.- Returns:
- the newly created Document instance
- Throws:
DocumentException
- if an error occurs during parsing.java.io.IOException
- DOCUMENT ME!org.gjt.xpp.XmlPullParserException
- DOCUMENT ME!
-
read
public Document read(java.lang.String systemID) throws DocumentException, java.io.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 aURL
or aFile
instance instead of aString
to 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.java.io.IOException
- if a URL could not be made for the given Fileorg.gjt.xpp.XmlPullParserException
- DOCUMENT ME!
-
read
public Document read(java.io.InputStream in) throws DocumentException, java.io.IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given stream
- Parameters:
in
-InputStream
to read from.- Returns:
- the newly created Document instance
- Throws:
DocumentException
- if an error occurs during parsing.java.io.IOException
- DOCUMENT ME!org.gjt.xpp.XmlPullParserException
- DOCUMENT ME!
-
read
public Document read(java.io.Reader reader) throws DocumentException, java.io.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.java.io.IOException
- DOCUMENT ME!org.gjt.xpp.XmlPullParserException
- DOCUMENT ME!
-
read
public Document read(char[] text) throws DocumentException, java.io.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.java.io.IOException
- DOCUMENT ME!org.gjt.xpp.XmlPullParserException
- DOCUMENT ME!
-
read
public Document read(java.io.InputStream in, java.lang.String systemID) throws DocumentException, java.io.IOException, org.gjt.xpp.XmlPullParserException
Reads a Document from the given stream
- Parameters:
in
-InputStream
to read from.systemID
- is the URI for the input- Returns:
- the newly created Document instance
- Throws:
DocumentException
- if an error occurs during parsing.java.io.IOException
- DOCUMENT ME!org.gjt.xpp.XmlPullParserException
- DOCUMENT ME!
-
read
public Document read(java.io.Reader reader, java.lang.String systemID) throws DocumentException, java.io.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.java.io.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
public DocumentFactory getDocumentFactory()
DOCUMENT ME!- Returns:
- the
DocumentFactory
used to create document objects
-
setDocumentFactory
public void setDocumentFactory(DocumentFactory documentFactory)
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 ofDocumentFactory
- Parameters:
documentFactory
-DocumentFactory
used to create DOM4J objects
-
addHandler
public void addHandler(java.lang.String path, ElementHandler handler)
Adds theElementHandler
to be called when the specified path is encounted.- Parameters:
path
- is the path to be handledhandler
- is theElementHandler
to be called by the event based processor.
-
removeHandler
public void removeHandler(java.lang.String path)
Removes theElementHandler
from the event based processor, for the specified path.- Parameters:
path
- is the path to remove theElementHandler
for.
-
setDefaultHandler
public void setDefaultHandler(ElementHandler handler)
When multipleElementHandler
instances have been registered, this will set a defaultElementHandler
to be called for any path which does NOT have a handler registered.- Parameters:
handler
- is theElementHandler
to be called by the event based processor.
-
parseDocument
protected Document parseDocument() throws DocumentException, java.io.IOException, org.gjt.xpp.XmlPullParserException
- Throws:
DocumentException
java.io.IOException
org.gjt.xpp.XmlPullParserException
-
getDispatchHandler
protected org.dom4j.io.DispatchHandler getDispatchHandler()
-
setDispatchHandler
protected void setDispatchHandler(org.dom4j.io.DispatchHandler dispatchHandler)
-
createReader
protected java.io.Reader createReader(java.io.InputStream in) throws java.io.IOException
Factory method to create a Reader from the given InputStream.- Parameters:
in
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Throws:
java.io.IOException
- DOCUMENT ME!
-
-