|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dom4j.jaxb.JAXBSupport org.dom4j.jaxb.JAXBReader
Reads an XML document and creates a DOM4J tree from SAX parsing events.
JAXBObjectHandler
objects can be registered to automatically receive
unmarshalled XML fragments. Registered
implementations are notified when a certain element path is encountered
SAXReader
,
JAXBContext
Constructor Summary | |
JAXBReader(String contextPath)
Creates a new JAXBReader for the given JAXB context path. |
|
JAXBReader(String contextPath,
ClassLoader classloader)
Creates a new JAXBReader for the given JAXB context path, using the specified Classloader . |
Method Summary | |
void |
addHandler(String path,
ElementHandler handler)
Adds the ElementHandler to be called when the specified
path is encounted. |
void |
addObjectHandler(String path,
JAXBObjectHandler handler)
Registers a JAXBObjectHandler that will be supplied with the
unmarshalled representation of the xml fragment whenever the specified
path is encounted. |
boolean |
isPruneElements()
When 'true', the DOM4J document will not be kept in memory while parsing. |
protected Element |
marshal(javax.xml.bind.Element element)
Marshals the given Element in to its DOM4J
counterpart. |
Document |
read(File source)
Parses the specified File |
Document |
read(File file,
java.nio.charset.Charset charset)
Parses the specified File , using the given Charset . |
Document |
read(InputSource source)
Parses the specified InputSource |
Document |
read(InputStream source)
Parses the specified InputStream |
Document |
read(InputStream source,
String systemId)
Parses the specified InputStream |
Document |
read(Reader source)
Parses the specified Reader |
Document |
read(Reader source,
String systemId)
Parses the specified Reader |
Document |
read(String source)
Parses the the given URL or filename. |
Document |
read(URL source)
Parses the the given URL. |
void |
removeHandler(String path)
Removes the ElementHandler from the event based processor,
for the specified path. |
void |
removeObjectHandler(String path)
Removes the JAXBObjectHandler from the event based processor, for
the specified element path. |
void |
resetHandlers()
Removes all registered JAXBObjectHandler and ElementHandler instances from the event based processor. |
void |
setPruneElements(boolean pruneElements)
Set to true when DOM4J elements must immediately be pruned from the tree. |
protected javax.xml.bind.Element |
unmarshal(Element element)
Unmarshalls the specified DOM4J Element into a Element |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JAXBReader(String contextPath)
contextPath
- context path to be usedJAXBContext
public JAXBReader(String contextPath, ClassLoader classloader)
Classloader
. This is the Java package where
JAXB can find the generated XML classes. This package MUST contain
jaxb.properties!
contextPath
- to be usedclassloader
- to be usedJAXBContext
Method Detail |
public Document read(File source) throws DocumentException
File
source
- the file to parse
DocumentException
- when an error occurs while parsingpublic Document read(File file, java.nio.charset.Charset charset) throws DocumentException
File
, using the given Charset
.
file
- the file to parsecharset
- the charset to be used
DocumentException
- when an error occurs while parsingpublic Document read(InputSource source) throws DocumentException
InputSource
source
- the source to parse
DocumentException
- when an error occurs while parsingpublic Document read(InputStream source) throws DocumentException
InputStream
source
- the input stream to parse
DocumentException
- when an error occurs while parsingpublic Document read(InputStream source, String systemId) throws DocumentException
InputStream
source
- the input stream to parsesystemId
- is the URI for the input
DocumentException
- when an error occurs while parsingpublic Document read(Reader source) throws DocumentException
Reader
source
- the input reader to use
DocumentException
- when an error occurs while parsingpublic Document read(Reader source, String systemId) throws DocumentException
Reader
source
- the input reader to parsesystemId
- is the URI for the input
DocumentException
- when an error occurs while parsingpublic Document read(String source) throws DocumentException
source
- the location to parse
DocumentException
- when an error occurs while parsingpublic Document read(URL source) throws DocumentException
source
- the URL to parse
DocumentException
- when an error occurs while parsingpublic void addObjectHandler(String path, JAXBObjectHandler handler)
JAXBObjectHandler
that will be supplied with the
unmarshalled representation of the xml fragment whenever the specified
path is encounted.
path
- the path to listen forhandler
- the handler to be notifiedpublic void removeObjectHandler(String path)
JAXBObjectHandler
from the event based processor, for
the specified element path.
path
- The path to remove the JAXBObjectHandler
forpublic 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 resetHandlers()
JAXBObjectHandler
and ElementHandler
instances from the event based processor.
public boolean isPruneElements()
public void setPruneElements(boolean pruneElements)
Document
will not be available afterwards!
pruneElements
- protected Element marshal(javax.xml.bind.Element element) throws javax.xml.bind.JAXBException
Element
in to its DOM4J
counterpart.
element
- JAXB Element to be marshalled
Element
javax.xml.bind.JAXBException
- when an error occursprotected javax.xml.bind.Element unmarshal(Element element) throws javax.xml.bind.JAXBException
Element
into a Element
element
- the DOM4J element to unmarshall
javax.xml.bind.JAXBException
- when an error occurs
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |