public class JAXBWriter extends Object
Element
objects to an XML stream. Element
instances can be created using the ObjectFactory that
is generated by the JAXB compiler.XMLWriter
,
JAXBContext
Constructor and Description |
---|
JAXBWriter(String contextPath)
Creates a new JAXBWriter for the given JAXB context path.
|
JAXBWriter(String contextPath,
ClassLoader classloader)
Creates a new JAXBWriter for the given JAXB context path, using the
specified
Classloader . |
JAXBWriter(String contextPath,
ClassLoader classloader,
OutputFormat outputFormat)
Creates a new JAXBWriter for the given JAXB context path, using the
specified
Classloader . |
JAXBWriter(String contextPath,
OutputFormat outputFormat)
Creates a new JAXBWriter for the given JAXB context path.
|
Modifier and Type | Method and Description |
---|---|
void |
endDocument()
Stop writing the document to the output.
|
OutputFormat |
getOutputFormat()
Returns the OutputFormat that will be used when writing the XML stream.
|
protected Element |
marshal(Element element)
Marshals the given
Element in to its DOM4J
counterpart. |
void |
setOutput(File file)
Defines to write the resulting output to the specified
File . |
void |
setOutput(OutputStream outputStream)
Defines to write the resulting output to the specified
OutputStream |
void |
setOutput(Writer writer)
Defines to write the resulting output to the specified
Writer . |
void |
startDocument()
Start a document by writing the initial XML declaration to the output.
|
protected Element |
unmarshal(Element element)
|
void |
write(Element jaxbObject)
Writes the specified
Element to the document. |
void |
writeClose(Element jaxbObject)
Writes the closing tag of the specified
Element to
the document. |
void |
writeCloseElement(Element element)
Writes the closing tag of the specified
Element to the
document. |
void |
writeElement(Element element)
Writes the specified
Element to the document. |
void |
writeOpen(Element jaxbObject)
Writes the opening tag of the specified
Element to
the document. |
void |
writeOpenElement(Element element)
Writes the opening tag of the specified
Element to the
document. |
public JAXBWriter(String contextPath)
contextPath
- JAXB context path to be usedJAXBContext
public JAXBWriter(String contextPath, OutputFormat outputFormat)
OutputFormat
will be used for writing the XML
stream.contextPath
- JAXB context path to be usedoutputFormat
- the DOM4J OutputFormat
to be usedJAXBContext
public JAXBWriter(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
- JAXB context path to be usedclassloader
- the classloader to be used for loading JAXBJAXBContext
public JAXBWriter(String contextPath, ClassLoader classloader, OutputFormat outputFormat)
Classloader
. The specied OutputFormat
will be used while writing the XML stream.contextPath
- JAXB context path to be usedclassloader
- the class loader to be used to load JAXBoutputFormat
- the DOM4J OutputFormat
to be usedJAXBContext
public OutputFormat getOutputFormat()
public void setOutput(File file) throws IOException
File
.file
- file to write toIOException
- when the file cannot be foundpublic void setOutput(OutputStream outputStream) throws IOException
OutputStream
outputStream
- outputStream to write to.IOException
- DOCUMENT ME!public void setOutput(Writer writer) throws IOException
Writer
.writer
- writer to write toIOException
public void startDocument() throws IOException, SAXException
IOException
- if an error occured while writing the outputSAXException
- thrown by the underlying SAX driverpublic void endDocument() throws IOException, SAXException
IOException
- if an error occured while writing the outputSAXException
- thrown by the underlying SAX driverpublic void write(Element jaxbObject) throws IOException, JAXBException
Element
to the document.
Element
instances can be created using the
ObjectFactory that is generated by the JAXB compiler.jaxbObject
- IOException
- if an error occured while writing the outputJAXBException
- when an error occured while marshalling the jaxbObjectpublic void writeClose(Element jaxbObject) throws IOException, JAXBException
Element
to
the document. This method can be used for writing Element
instances can be created using the ObjectFactory
that is generated by the JAXB compiler.jaxbObject
- the JAXB element to writeIOException
- if an error occured while writing the outputJAXBException
- when an error occured while marshalling the jaxbObjectpublic void writeOpen(Element jaxbObject) throws IOException, JAXBException
Element
to
the document. Element
instances can be created
using the ObjectFactory that is generated by the JAXB compiler.jaxbObject
- the JAXB element to writeIOException
- if an error occured while writing the outputJAXBException
- when an error occured while marshalling the jaxbObjectpublic void writeElement(Element element) throws IOException
Element
to the document.element
- the Element
to writeIOException
- if an error occured while writing the outputpublic void writeCloseElement(Element element) throws IOException
Element
to the
document.element
- the Element
to writeIOException
- if an error occured while writing the outputpublic void writeOpenElement(Element element) throws IOException
Element
to the
document.element
- the Element
to writeIOException
- if an error occured while writing the outputprotected Element marshal(Element element) throws JAXBException
Element
in to its DOM4J
counterpart.element
- JAXB Element to be marshalledElement
JAXBException
- when an error occursprotected Element unmarshal(Element element) throws JAXBException
element
- the DOM4J element to unmarshallJAXBException
- when an error occursCopyright © 2012 JBoss by Red Hat. All Rights Reserved.