Top Description Fields Constructors Methods
org.dom4j.jaxb

public Class JAXBWriter

extends JAXBSupport
Class Inheritance
Imports
java.io.File, .FileOutputStream, .IOException, .OutputStream, .Writer, javax.xml.bind.JAXBException, org.dom4j.Element, org.dom4j.io.OutputFormat, .XMLWriter, org.xml.sax.SAXException

Writes javax.xml.bind.Elementobjects to an XML stream. 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
org.dom4j.io.XMLWriter, javax.xml.bind.JAXBContext

Field Summary

Modifier and TypeField and Description
private OutputFormat
private XMLWriter

Constructor Summary

AccessConstructor and Description
public
JAXBWriter(String
JAXB context path to be used
contextPath
)

Creates a new JAXBWriter for the given JAXB context path.

public
JAXBWriter(String
JAXB context path to be used
contextPath
,
OutputFormat
the DOM4J org.dom4j.io.OutputFormatto be used
outputFormat
)

Creates a new JAXBWriter for the given JAXB context path.

public
JAXBWriter(String
JAXB context path to be used
contextPath
,
ClassLoader
the classloader to be used for loading JAXB
classloader
)

Creates a new JAXBWriter for the given JAXB context path, using the specified java.lang.ClassLoader.

public
JAXBWriter(String
JAXB context path to be used
contextPath
,
ClassLoader
the class loader to be used to load JAXB
classloader
,
OutputFormat
the DOM4J org.dom4j.io.OutputFormatto be used
outputFormat
)

Creates a new JAXBWriter for the given JAXB context path, using the specified java.lang.ClassLoader.

Method Summary

Modifier and TypeMethod and Description
public void
endDocument()

Stop writing the document to the output.

public OutputFormat

Returns:

Returns the output format.
getOutputFormat
()

Returns the OutputFormat that will be used when writing the XML stream.

private XMLWriter
public void
setOutput(File
file to write to
file
)

Defines to write the resulting output to the specified java.io.File.

public void
setOutput(OutputStream
outputStream to write to.
outputStream
)

Defines to write the resulting output to the specified java.io.OutputStream

public void
setOutput(Writer
writer to write to
writer
)

Defines to write the resulting output to the specified Writer.

public void
startDocument()

Start a document by writing the initial XML declaration to the output.

public void
write(Element
DOCUMENT ME!
jaxbObject
)

Writes the specified javax.xml.bind.Elementto the document.

public void
writeClose(Element
the JAXB element to write
jaxbObject
)

Writes the closing tag of the specified javax.xml.bind.Elementto the document.

public void
writeCloseElement(Element
the org.dom4j.Elementto write
element
)

Writes the closing tag of the specified org.dom4j.Elementto the document.

public void
writeElement(Element
the org.dom4j.Elementto write
element
)

Writes the specified org.dom4j.Elementto the document.

public void
writeOpen(Element
the JAXB element to write
jaxbObject
)

Writes the opening tag of the specified javax.xml.bind.Elementto the document.

public void
writeOpenElement(Element
the org.dom4j.Elementto write
element
)

Writes the opening tag of the specified org.dom4j.Elementto the document.

Inherited from org.dom4j.jaxb.JAXBSupport:
marshalunmarshal

Field Detail

outputFormatback to summary
private OutputFormat outputFormat
xmlWriterback to summary
private XMLWriter xmlWriter

Constructor Detail

JAXBWriterback to summary
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:String

JAXB context path to be used

See Also
javax.xml.bind.JAXBContext
JAXBWriterback to summary
public JAXBWriter(String contextPath, OutputFormat outputFormat)

Creates a new JAXBWriter for the given JAXB context path. The specied org.dom4j.io.OutputFormatwill be used for writing the XML stream.

Parameters
contextPath:String

JAXB context path to be used

outputFormat:OutputFormat

the DOM4J org.dom4j.io.OutputFormatto be used

See Also
javax.xml.bind.JAXBContext
JAXBWriterback to summary
public JAXBWriter(String contextPath, ClassLoader classloader)

Creates a new JAXBWriter for the given JAXB context path, using the specified java.lang.ClassLoader. (This is the Java package where JAXB can find the generated XML classes. This package MUST contain jaxb.properties!)

Parameters
contextPath:String

JAXB context path to be used

classloader:ClassLoader

the classloader to be used for loading JAXB

See Also
javax.xml.bind.JAXBContext
JAXBWriterback to summary
public JAXBWriter(String contextPath, ClassLoader classloader, OutputFormat outputFormat)

Creates a new JAXBWriter for the given JAXB context path, using the specified java.lang.ClassLoader. The specied org.dom4j.io.OutputFormat will be used while writing the XML stream.

Parameters
contextPath:String

JAXB context path to be used

classloader:ClassLoader

the class loader to be used to load JAXB

outputFormat:OutputFormat

the DOM4J org.dom4j.io.OutputFormatto be used

See Also
javax.xml.bind.JAXBContext

Method Detail

endDocumentback to summary
public void endDocument() throws IOException, SAXException

Stop writing the document to the output. This must be done when all other elements are finished.

Exceptions
IOException:
if an error occured while writing the output
SAXException:
thrown by the underlying SAX driver
getOutputFormatback to summary
public OutputFormat getOutputFormat()

Returns the OutputFormat that will be used when writing the XML stream.

Returns:OutputFormat

Returns the output format.

getWriterback to summary
private XMLWriter getWriter() throws IOException
setOutputback to summary
public void setOutput(File file) throws IOException

Defines to write the resulting output to the specified java.io.File.

Parameters
file:File

file to write to

Exceptions
IOException:
when the file cannot be found
setOutputback to summary
public void setOutput(OutputStream outputStream) throws IOException

Defines to write the resulting output to the specified java.io.OutputStream

Parameters
outputStream:OutputStream

outputStream to write to.

Exceptions
IOException:
DOCUMENT ME!
setOutputback to summary
public void setOutput(Writer writer) throws IOException

Defines to write the resulting output to the specified Writer.

Parameters
writer:Writer

writer to write to

Exceptions
IOException:
DOCUMENT ME!
startDocumentback to summary
public void startDocument() throws IOException, SAXException

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

Exceptions
IOException:
if an error occured while writing the output
SAXException:
thrown by the underlying SAX driver
writeback to summary
public void write(Element jaxbObject) throws IOException, JAXBException

Writes the specified javax.xml.bind.Elementto the document. javax.xml.bind.Elementinstances can be created using the ObjectFactory that is generated by the JAXB compiler.

Parameters
jaxbObject:Element

DOCUMENT ME!

Exceptions
IOException:
if an error occured while writing the output
JAXBException:
when an error occured while marshalling the jaxbObject
writeCloseback to summary
public void writeClose(Element jaxbObject) throws IOException, JAXBException

Writes the closing tag of the specified javax.xml.bind.Elementto the document. This method can be used for writing javax.xml.bind.Element instances can be created using the ObjectFactory that is generated by the JAXB compiler.

Parameters
jaxbObject:Element

the JAXB element to write

Exceptions
IOException:
if an error occured while writing the output
JAXBException:
when an error occured while marshalling the jaxbObject
writeCloseElementback to summary
public void writeCloseElement(Element element) throws IOException

Writes the closing tag of the specified org.dom4j.Elementto the document.

Parameters
element:Element

the org.dom4j.Elementto write

Exceptions
IOException:
if an error occured while writing the output
writeElementback to summary
public void writeElement(Element element) throws IOException

Writes the specified org.dom4j.Elementto the document.

Parameters
element:Element

the org.dom4j.Elementto write

Exceptions
IOException:
if an error occured while writing the output
writeOpenback to summary
public void writeOpen(Element jaxbObject) throws IOException, JAXBException

Writes the opening tag of the specified javax.xml.bind.Elementto the document. javax.xml.bind.Elementinstances can be created using the ObjectFactory that is generated by the JAXB compiler.

Parameters
jaxbObject:Element

the JAXB element to write

Exceptions
IOException:
if an error occured while writing the output
JAXBException:
when an error occured while marshalling the jaxbObject
writeOpenElementback to summary
public void writeOpenElement(Element element) throws IOException

Writes the opening tag of the specified org.dom4j.Elementto the document.

Parameters
element:Element

the org.dom4j.Elementto write

Exceptions
IOException:
if an error occured while writing the output