public class JAXBWriter extends JAXBSupport
Element
objects to an XML stream. Element
instances can be created using the ObjectFactory that
is generated by the JAXB compiler.XMLWriter
,
JAXBContext
Modifier and Type | Field and Description |
---|---|
private OutputFormat |
outputFormat |
private XMLWriter |
xmlWriter |
Constructor and Description |
---|
JAXBWriter(java.lang.String contextPath)
Creates a new JAXBWriter for the given JAXB context path.
|
JAXBWriter(java.lang.String contextPath,
java.lang.ClassLoader classloader)
Creates a new JAXBWriter for the given JAXB context path, using the
specified
ClassLoader . |
JAXBWriter(java.lang.String contextPath,
java.lang.ClassLoader classloader,
OutputFormat outputFormat)
Creates a new JAXBWriter for the given JAXB context path, using the
specified
ClassLoader . |
JAXBWriter(java.lang.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.
|
private XMLWriter |
getWriter() |
void |
setOutput(java.io.File file)
Defines to write the resulting output to the specified
File . |
void |
setOutput(java.io.OutputStream outputStream)
Defines to write the resulting output to the specified
OutputStream |
void |
setOutput(java.io.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.
|
void |
write(javax.xml.bind.Element jaxbObject)
Writes the specified
Element to the document. |
void |
writeClose(javax.xml.bind.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(javax.xml.bind.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. |
marshal, unmarshal
private XMLWriter xmlWriter
private OutputFormat outputFormat
public JAXBWriter(java.lang.String contextPath)
contextPath
- JAXB context path to be usedJAXBContext
public JAXBWriter(java.lang.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(java.lang.String contextPath, java.lang.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(java.lang.String contextPath, java.lang.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(java.io.File file) throws java.io.IOException
File
.file
- file to write tojava.io.IOException
- when the file cannot be foundpublic void setOutput(java.io.OutputStream outputStream) throws java.io.IOException
OutputStream
outputStream
- outputStream to write to.java.io.IOException
- DOCUMENT ME!public void setOutput(java.io.Writer writer) throws java.io.IOException
Writer
.writer
- writer to write tojava.io.IOException
- DOCUMENT ME!public void startDocument() throws java.io.IOException, org.xml.sax.SAXException
java.io.IOException
- if an error occured while writing the outputorg.xml.sax.SAXException
- thrown by the underlying SAX driverpublic void endDocument() throws java.io.IOException, org.xml.sax.SAXException
java.io.IOException
- if an error occured while writing the outputorg.xml.sax.SAXException
- thrown by the underlying SAX driverpublic void write(javax.xml.bind.Element jaxbObject) throws java.io.IOException, javax.xml.bind.JAXBException
Element
to the document.
Element
instances can be created using the
ObjectFactory that is generated by the JAXB compiler.jaxbObject
- DOCUMENT ME!java.io.IOException
- if an error occured while writing the outputjavax.xml.bind.JAXBException
- when an error occured while marshalling the jaxbObjectpublic void writeClose(javax.xml.bind.Element jaxbObject) throws java.io.IOException, javax.xml.bind.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 writejava.io.IOException
- if an error occured while writing the outputjavax.xml.bind.JAXBException
- when an error occured while marshalling the jaxbObjectpublic void writeOpen(javax.xml.bind.Element jaxbObject) throws java.io.IOException, javax.xml.bind.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 writejava.io.IOException
- if an error occured while writing the outputjavax.xml.bind.JAXBException
- when an error occured while marshalling the jaxbObjectpublic void writeElement(Element element) throws java.io.IOException
Element
to the document.element
- the Element
to writejava.io.IOException
- if an error occured while writing the outputpublic void writeCloseElement(Element element) throws java.io.IOException
Element
to the
document.element
- the Element
to writejava.io.IOException
- if an error occured while writing the outputpublic void writeOpenElement(Element element) throws java.io.IOException
Element
to the
document.element
- the Element
to writejava.io.IOException
- if an error occured while writing the outputprivate XMLWriter getWriter() throws java.io.IOException
java.io.IOException