public class

XmlBeansMarshaller

extends AbstractMarshaller
java.lang.Object
   ↳ org.springframework.oxm.support.AbstractMarshaller
     ↳ org.springframework.oxm.xmlbeans.XmlBeansMarshaller

Class Overview

Implementation of the Marshaller interface for Apache XMLBeans.

Options can be set by setting the xmlOptions property. The XmlOptionsFactoryBean is provided to easily set up an XmlOptions instance.

Unmarshalled objects can be validated by setting the validating property, or by calling the validate(XmlObject) method directly. Invalid objects will result in an ValidationFailureException.

NOTE: Due to the nature of XMLBeans, this marshaller requires all passed objects to be of type XmlObject.

Summary

[Expand]
Inherited Fields
From class org.springframework.oxm.support.AbstractMarshaller
Public Constructors
XmlBeansMarshaller()
Public Methods
XmlOptions getXmlOptions()
Return the XmlOptions.
boolean isValidating()
Return whether this marshaller should validate in- and outgoing documents.
void setValidating(boolean validating)
Set whether this marshaller should validate in- and outgoing documents.
void setXmlOptions(XmlOptions xmlOptions)
Set the XmlOptions.
boolean supports(Class<?> clazz)
This implementation returns true if the given class is an implementation of XmlObject.
Protected Methods
XmlMappingException convertXmlBeansException(Exception ex, boolean marshalling)
Convert the given XMLBeans exception to an appropriate exception from the org.springframework.oxm hierarchy.
final void marshalDomNode(Object graph, Node node)
Abstract template method for marshalling the given object graph to a DOM Node.
final void marshalOutputStream(Object graph, OutputStream outputStream)
Abstract template method for marshalling the given object graph to a OutputStream.
final void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
Abstract template method for marshalling the given object graph to a SAX ContentHandler.
final void marshalWriter(Object graph, Writer writer)
Abstract template method for marshalling the given object graph to a Writer.
final void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter)
Abstract template method for marshalling the given object to a StAX XMLEventWriter.
final void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter)
Abstract template method for marshalling the given object to a StAX XMLStreamWriter.
final Object unmarshalDomNode(Node node)
Abstract template method for unmarshalling from a given DOM Node.
final Object unmarshalInputStream(InputStream inputStream)
Abstract template method for unmarshalling from a given InputStream.
final Object unmarshalReader(Reader reader)
Abstract template method for unmarshalling from a given Reader.
final Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
Abstract template method for unmarshalling using a given SAX XMLReader and InputSource.
final Object unmarshalXmlEventReader(XMLEventReader eventReader)
Abstract template method for unmarshalling from a given Stax XMLEventReader.
final Object unmarshalXmlStreamReader(XMLStreamReader streamReader)
Abstract template method for unmarshalling from a given Stax XMLStreamReader.
void validate(XmlObject object)
Validate the given XmlObject.
[Expand]
Inherited Methods
From class org.springframework.oxm.support.AbstractMarshaller
From class java.lang.Object
From interface org.springframework.oxm.Marshaller
From interface org.springframework.oxm.Unmarshaller

Public Constructors

public XmlBeansMarshaller ()

Public Methods

public XmlOptions getXmlOptions ()

Return the XmlOptions.

public boolean isValidating ()

Return whether this marshaller should validate in- and outgoing documents.

public void setValidating (boolean validating)

Set whether this marshaller should validate in- and outgoing documents. Default is false.

public void setXmlOptions (XmlOptions xmlOptions)

Set the XmlOptions.

public boolean supports (Class<?> clazz)

This implementation returns true if the given class is an implementation of XmlObject.

Protected Methods

protected XmlMappingException convertXmlBeansException (Exception ex, boolean marshalling)

Convert the given XMLBeans exception to an appropriate exception from the org.springframework.oxm hierarchy.

A boolean flag is used to indicate whether this exception occurs during marshalling or unmarshalling, since XMLBeans itself does not make this distinction in its exception hierarchy.

Parameters
ex XMLBeans Exception that occured
marshalling indicates whether the exception occurs during marshalling (true), or unmarshalling (false)
Returns
  • the corresponding XmlMappingException

protected final void marshalDomNode (Object graph, Node node)

Abstract template method for marshalling the given object graph to a DOM Node.

In practice, node is be a Document node, a DocumentFragment node, or a Element node. In other words, a node that accepts children.

Parameters
graph the root of the object graph to marshal
node the DOM node that will contain the result tree

protected final void marshalOutputStream (Object graph, OutputStream outputStream)

Abstract template method for marshalling the given object graph to a OutputStream.

Parameters
graph the root of the object graph to marshal
outputStream the OutputStream to write to

protected final void marshalSaxHandlers (Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)

Abstract template method for marshalling the given object graph to a SAX ContentHandler.

Parameters
graph the root of the object graph to marshal
contentHandler the SAX ContentHandler
lexicalHandler the SAX2 LexicalHandler. Can be null.

protected final void marshalWriter (Object graph, Writer writer)

Abstract template method for marshalling the given object graph to a Writer.

Parameters
graph the root of the object graph to marshal
writer the Writer to write to

protected final void marshalXmlEventWriter (Object graph, XMLEventWriter eventWriter)

Abstract template method for marshalling the given object to a StAX XMLEventWriter.

Parameters
graph the root of the object graph to marshal
eventWriter the XMLEventWriter to write to

protected final void marshalXmlStreamWriter (Object graph, XMLStreamWriter streamWriter)

Abstract template method for marshalling the given object to a StAX XMLStreamWriter.

Parameters
graph the root of the object graph to marshal
streamWriter the XMLStreamWriter to write to

protected final Object unmarshalDomNode (Node node)

Abstract template method for unmarshalling from a given DOM Node.

Parameters
node the DOM node that contains the objects to be unmarshalled
Returns
  • the object graph

protected final Object unmarshalInputStream (InputStream inputStream)

Abstract template method for unmarshalling from a given InputStream.

Parameters
inputStream the InputStreamStream to read from
Returns
  • the object graph

protected final Object unmarshalReader (Reader reader)

Abstract template method for unmarshalling from a given Reader.

Parameters
reader the Reader to read from
Returns
  • the object graph

protected final Object unmarshalSaxReader (XMLReader xmlReader, InputSource inputSource)

Abstract template method for unmarshalling using a given SAX XMLReader and InputSource.

Parameters
xmlReader the SAX XMLReader to parse with
inputSource the input source to parse from
Returns
  • the object graph

protected final Object unmarshalXmlEventReader (XMLEventReader eventReader)

Abstract template method for unmarshalling from a given Stax XMLEventReader.

Parameters
eventReader the XMLEventReader to read from
Returns
  • the object graph

protected final Object unmarshalXmlStreamReader (XMLStreamReader streamReader)

Abstract template method for unmarshalling from a given Stax XMLStreamReader.

Parameters
streamReader the XMLStreamReader to read from
Returns
  • the object graph

protected void validate (XmlObject object)

Validate the given XmlObject.

Parameters
object the xml object to validate
Throws
ValidationFailureException if the given object is not valid