org.dom4j.jaxb

Class JAXBWriter

public class JAXBWriter extends JAXBSupport

Writes {@link javax.xml.bind.Element}objects to an XML stream. {@link javax.xml.bind.Element} instances can be created using the ObjectFactory that is generated by the JAXB compiler.

Author: Wonne Keysers (Realsoftware.be)

See Also: XMLWriter javax.xml.bind.JAXBContext

Constructor Summary
JAXBWriter(String contextPath)
Creates a new JAXBWriter for the given JAXB context path.
JAXBWriter(String contextPath, OutputFormat outputFormat)
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 {@link java.lang.Classloader}.
JAXBWriter(String contextPath, ClassLoader classloader, OutputFormat outputFormat)
Creates a new JAXBWriter for the given JAXB context path, using the specified {@link java.lang.Classloader}.
Method Summary
voidendDocument()
Stop writing the document to the output.
OutputFormatgetOutputFormat()
Returns the OutputFormat that will be used when writing the XML stream.
voidsetOutput(File file)
Defines to write the resulting output to the specified {@link java.io.File}.
voidsetOutput(OutputStream outputStream)
Defines to write the resulting output to the specified {@link java.io.OutputStream}
voidsetOutput(Writer writer)
Defines to write the resulting output to the specified {@link Writer}.
voidstartDocument()
Start a document by writing the initial XML declaration to the output.
voidwrite(Element jaxbObject)
Writes the specified {@link javax.xml.bind.Element}to the document.
voidwriteClose(Element jaxbObject)
Writes the closing tag of the specified {@link javax.xml.bind.Element}to the document.
voidwriteCloseElement(Element element)
Writes the closing tag of the specified {@link org.dom4j.Element}to the document.
voidwriteElement(Element element)
Writes the specified {@link org.dom4j.Element}to the document.
voidwriteOpen(Element jaxbObject)
Writes the opening tag of the specified {@link javax.xml.bind.Element}to the document.
voidwriteOpenElement(Element element)
Writes the opening tag of the specified {@link org.dom4j.Element}to the document.

Constructor Detail

JAXBWriter

public JAXBWriter(String contextPath)
Creates a new JAXBWriter for the given JAXB context path. This is the Java package where JAXB can find the generated XML classes. This package MUST contain jaxb.properties!

Parameters: contextPath JAXB context path to be used

See Also: javax.xml.bind.JAXBContext

JAXBWriter

public JAXBWriter(String contextPath, OutputFormat outputFormat)
Creates a new JAXBWriter for the given JAXB context path. The specied {@link org.dom4j.io.OutputFormat}will be used for writing the XML stream.

Parameters: contextPath JAXB context path to be used outputFormat the DOM4J {@link org.dom4j.io.OutputFormat}to be used

See Also: javax.xml.bind.JAXBContext

JAXBWriter

public JAXBWriter(String contextPath, ClassLoader classloader)
Creates a new JAXBWriter for the given JAXB context path, using the specified {@link java.lang.Classloader}. (This is the Java package where JAXB can find the generated XML classes. This package MUST contain jaxb.properties!)

Parameters: contextPath JAXB context path to be used classloader the classloader to be used for loading JAXB

See Also: javax.xml.bind.JAXBContext

JAXBWriter

public JAXBWriter(String contextPath, ClassLoader classloader, OutputFormat outputFormat)
Creates a new JAXBWriter for the given JAXB context path, using the specified {@link java.lang.Classloader}. The specied {@link org.dom4j.io.OutputFormat} will be used while writing the XML stream.

Parameters: contextPath JAXB context path to be used classloader the class loader to be used to load JAXB outputFormat the DOM4J {@link org.dom4j.io.OutputFormat}to be used

See Also: javax.xml.bind.JAXBContext

Method Detail

endDocument

public void endDocument()
Stop writing the document to the output. This must be done when all other elements are finished.

Throws: IOException if an error occured while writing the output SAXException thrown by the underlying SAX driver

getOutputFormat

public OutputFormat getOutputFormat()
Returns the OutputFormat that will be used when writing the XML stream.

Returns: Returns the output format.

setOutput

public void setOutput(File file)
Defines to write the resulting output to the specified {@link java.io.File}.

Parameters: file file to write to

Throws: IOException when the file cannot be found

setOutput

public void setOutput(OutputStream outputStream)
Defines to write the resulting output to the specified {@link java.io.OutputStream}

Parameters: outputStream outputStream to write to.

Throws: IOException DOCUMENT ME!

setOutput

public void setOutput(Writer writer)
Defines to write the resulting output to the specified {@link Writer}.

Parameters: writer writer to write to

Throws: IOException

startDocument

public void startDocument()
Start a document by writing the initial XML declaration to the output. This must be done prior to writing any other elements.

Throws: IOException if an error occured while writing the output SAXException thrown by the underlying SAX driver

write

public void write(Element jaxbObject)
Writes the specified {@link javax.xml.bind.Element}to the document. {@link javax.xml.bind.Element}instances can be created using the ObjectFactory that is generated by the JAXB compiler.

Parameters: jaxbObject

Throws: IOException if an error occured while writing the output JAXBException when an error occured while marshalling the jaxbObject

writeClose

public void writeClose(Element jaxbObject)
Writes the closing tag of the specified {@link javax.xml.bind.Element}to the document. This method can be used for writing {@link javax.xml.bind.Element} instances can be created using the ObjectFactory that is generated by the JAXB compiler.

Parameters: jaxbObject the JAXB element to write

Throws: IOException if an error occured while writing the output JAXBException when an error occured while marshalling the jaxbObject

writeCloseElement

public void writeCloseElement(Element element)
Writes the closing tag of the specified {@link org.dom4j.Element}to the document.

Parameters: element the {@link org.dom4j.Element}to write

Throws: IOException if an error occured while writing the output

writeElement

public void writeElement(Element element)
Writes the specified {@link org.dom4j.Element}to the document.

Parameters: element the {@link org.dom4j.Element}to write

Throws: IOException if an error occured while writing the output

writeOpen

public void writeOpen(Element jaxbObject)
Writes the opening tag of the specified {@link javax.xml.bind.Element}to the document. {@link javax.xml.bind.Element}instances can be created using the ObjectFactory that is generated by the JAXB compiler.

Parameters: jaxbObject the JAXB element to write

Throws: IOException if an error occured while writing the output JAXBException when an error occured while marshalling the jaxbObject

writeOpenElement

public void writeOpenElement(Element element)
Writes the opening tag of the specified {@link org.dom4j.Element}to the document.

Parameters: element the {@link org.dom4j.Element}to write

Throws: IOException if an error occured while writing the output

Copyright B) 2005 MetaStuff Ltd. All Rights Reserved. Hosted by

SourceForge