org.dom4j.io

Class XPP3Reader

public class XPP3Reader extends Object

XPP3Reader 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: 1.3 $

Author: Pelle Braendgaard James Strachan

Constructor Summary
XPP3Reader()
XPP3Reader(DocumentFactory factory)
Method Summary
voidaddHandler(String path, ElementHandler handler)
Adds the ElementHandler to be called when the specified path is encounted.
protected ReadercreateReader(InputStream in)
Factory method to create a Reader from the given InputStream.
protected DispatchHandlergetDispatchHandler()
DocumentFactorygetDocumentFactory()
DOCUMENT ME!
XmlPullParserFactorygetXPPFactory()
XmlPullParsergetXPPParser()
protected DocumentparseDocument()
Documentread(File file)

Reads a Document from the given File

Documentread(URL url)

Reads a Document from the given URL

Documentread(String systemID)

Reads a Document from the given URL or filename.

Documentread(InputStream in)

Reads a Document from the given stream

Documentread(Reader reader)

Reads a Document from the given Reader

Documentread(char[] text)

Reads a Document from the given array of characters

Documentread(InputStream in, String systemID)

Reads a Document from the given stream

Documentread(Reader reader, String systemID)

Reads a Document from the given Reader

voidremoveHandler(String path)
Removes the ElementHandler from the event based processor, for the specified path.
voidsetDefaultHandler(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 voidsetDispatchHandler(DispatchHandler dispatchHandler)
voidsetDocumentFactory(DocumentFactory documentFactory)

This sets the DocumentFactory used to create new documents.

voidsetXPPFactory(XmlPullParserFactory xPPfactory)

Constructor Detail

XPP3Reader

public XPP3Reader()

XPP3Reader

public XPP3Reader(DocumentFactory factory)

Method Detail

addHandler

public void addHandler(String path, ElementHandler handler)
Adds the ElementHandler to be called when the specified path is encounted.

Parameters: path is the path to be handled handler is the ElementHandler to be called by the event based processor.

createReader

protected Reader createReader(InputStream in)
Factory method to create a Reader from the given InputStream.

Parameters: in DOCUMENT ME!

Returns: DOCUMENT ME!

Throws: IOException DOCUMENT ME!

getDispatchHandler

protected DispatchHandler getDispatchHandler()

getDocumentFactory

public DocumentFactory getDocumentFactory()
DOCUMENT ME!

Returns: the DocumentFactory used to create document objects

getXPPFactory

public XmlPullParserFactory getXPPFactory()

getXPPParser

public XmlPullParser getXPPParser()

parseDocument

protected Document parseDocument()

read

public Document read(File file)

Reads a Document from the given File

Parameters: file is the File to 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 File XmlPullParserException DOCUMENT ME!

read

public Document read(URL url)

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. IOException DOCUMENT ME! XmlPullParserException DOCUMENT ME!

read

public Document read(String systemID)

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 {@link URL}or a {@link File}instance instead of a {@link String} 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. IOException if a URL could not be made for the given File XmlPullParserException DOCUMENT ME!

read

public Document read(InputStream in)

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. IOException DOCUMENT ME! XmlPullParserException DOCUMENT ME!

read

public Document read(Reader reader)

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! XmlPullParserException DOCUMENT ME!

read

public Document read(char[] text)

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! XmlPullParserException DOCUMENT ME!

read

public Document read(InputStream in, String systemID)

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. IOException DOCUMENT ME! XmlPullParserException DOCUMENT ME!

read

public Document read(Reader reader, String systemID)

Reads a Document from the given Reader

Parameters: reader is the reader for the input systemID is the URI for the input

Returns: the newly created Document instance

Throws: DocumentException if an error occurs during parsing. IOException DOCUMENT ME! XmlPullParserException DOCUMENT ME!

removeHandler

public void removeHandler(String path)
Removes the ElementHandler from the event based processor, for the specified path.

Parameters: path is the path to remove the ElementHandler for.

setDefaultHandler

public 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.

Parameters: handler is the ElementHandler to be called by the event based processor.

setDispatchHandler

protected void setDispatchHandler(DispatchHandler dispatchHandler)

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 of {@link DocumentFactory}

Parameters: documentFactory DocumentFactory used to create DOM4J objects

setXPPFactory

public void setXPPFactory(XmlPullParserFactory xPPfactory)
Copyright B) 2005 MetaStuff Ltd. All Rights Reserved. Hosted by

SourceForge