Package org.springframework.oxm.xmlbeans
Class XmlBeansMarshaller
- java.lang.Object
- org.springframework.oxm.support.AbstractMarshaller
- org.springframework.oxm.xmlbeans.XmlBeansMarshaller
- All Implemented Interfaces:
Marshaller
,Unmarshaller
@Deprecated public class XmlBeansMarshaller extends AbstractMarshaller
Deprecated.as of Spring 4.2, following the XMLBeans retirement at ApacheImplementation of theMarshaller
interface for Apache XMLBeans.Options can be set by setting the
xmlOptions
property. TheXmlOptionsFactoryBean
is provided to easily set up anXmlOptions
instance.Unmarshalled objects can be validated by setting the
validating
property, or by calling thevalidate(XmlObject)
method directly. Invalid objects will result in anValidationFailureException
.NOTE: Due to the nature of XMLBeans, this marshaller requires all passed objects to be of type
XmlObject
.- Since:
- 3.0
- Author:
- Arjen Poutsma
- See Also:
setValidating(boolean)
,setXmlOptions(org.apache.xmlbeans.XmlOptions)
,XmlOptionsFactoryBean
Field Summary
Fields inherited from class org.springframework.oxm.support.AbstractMarshaller
logger
Constructor Summary
Constructors Constructor Description XmlBeansMarshaller()
Deprecated.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected XmlMappingException
convertXmlBeansException(Exception ex, boolean marshalling)
Deprecated.Convert the given XMLBeans exception to an appropriate exception from theorg.springframework.oxm
hierarchy.org.apache.xmlbeans.XmlOptions
getXmlOptions()
Deprecated.Return theXmlOptions
.boolean
isValidating()
Deprecated.Return whether this marshaller should validate in- and outgoing documents.protected void
marshalDomNode(Object graph, Node node)
Deprecated.Abstract template method for marshalling the given object graph to a DOMNode
.protected void
marshalOutputStream(Object graph, OutputStream outputStream)
Deprecated.Abstract template method for marshalling the given object graph to aOutputStream
.protected void
marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
Deprecated.Abstract template method for marshalling the given object graph to a SAXContentHandler
.protected void
marshalWriter(Object graph, Writer writer)
Deprecated.Abstract template method for marshalling the given object graph to aWriter
.protected void
marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter)
Deprecated.Abstract template method for marshalling the given object to a StAXXMLEventWriter
.protected void
marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter)
Deprecated.Abstract template method for marshalling the given object to a StAXXMLStreamWriter
.void
setValidating(boolean validating)
Deprecated.Set whether this marshaller should validate in- and outgoing documents.void
setXmlOptions(org.apache.xmlbeans.XmlOptions xmlOptions)
Deprecated.Set theXmlOptions
.boolean
supports(Class<?> clazz)
Deprecated.This implementation returns true if the given class is an implementation ofXmlObject
.protected Object
unmarshalDomNode(Node node)
Deprecated.Abstract template method for unmarshalling from a given DOMNode
.protected Object
unmarshalInputStream(InputStream inputStream)
Deprecated.Abstract template method for unmarshalling from a givenInputStream
.protected Object
unmarshalReader(Reader reader)
Deprecated.Abstract template method for unmarshalling from a givenReader
.protected Object
unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
Deprecated.Abstract template method for unmarshalling using a given SAXXMLReader
andInputSource
.protected Object
unmarshalXmlEventReader(XMLEventReader eventReader)
Deprecated.Abstract template method for unmarshalling from a given StaxXMLEventReader
.protected Object
unmarshalXmlStreamReader(XMLStreamReader streamReader)
Deprecated.Abstract template method for unmarshalling from a given StaxXMLStreamReader
.protected void
validate(org.apache.xmlbeans.XmlObject object)
Deprecated.Validate the givenXmlObject
.Methods inherited from class org.springframework.oxm.support.AbstractMarshaller
buildDocument, createDocumentBuilder, createDocumentBuilderFactory, createXmlReader, getDefaultEncoding, isProcessExternalEntities, isSupportDtd, marshal, marshalDomResult, marshalSaxResult, marshalStaxResult, marshalStreamResult, setProcessExternalEntities, setSupportDtd, unmarshal, unmarshalDomSource, unmarshalSaxSource, unmarshalStaxSource, unmarshalStreamSource
Constructor Detail
XmlBeansMarshaller
public XmlBeansMarshaller()
Deprecated.
Method Detail
setXmlOptions
public void setXmlOptions(org.apache.xmlbeans.XmlOptions xmlOptions)
Deprecated.Set theXmlOptions
.- See Also:
XmlOptionsFactoryBean
getXmlOptions
public org.apache.xmlbeans.XmlOptions getXmlOptions()
Deprecated.Return theXmlOptions
.
setValidating
public void setValidating(boolean validating)
Deprecated.Set whether this marshaller should validate in- and outgoing documents. Default isfalse
.
isValidating
public boolean isValidating()
Deprecated.Return whether this marshaller should validate in- and outgoing documents.
supports
public boolean supports(Class<?> clazz)
Deprecated.This implementation returns true if the given class is an implementation ofXmlObject
.- Parameters:
clazz
- the class that this marshaller is being asked if it can marshal- Returns:
true
if this marshaller can indeed marshal instances of the supplied class;false
otherwise
marshalDomNode
protected void marshalDomNode(Object graph, Node node) throws XmlMappingException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for marshalling the given object graph to a DOMNode
.In practice, node is be a
Document
node, aDocumentFragment
node, or aElement
node. In other words, a node that accepts children.- Specified by:
marshalDomNode
in classAbstractMarshaller
- Parameters:
graph
- the root of the object graph to marshalnode
- the DOM node that will contain the result tree- Throws:
XmlMappingException
- if the given object cannot be marshalled to the DOM node- See Also:
Document
,DocumentFragment
,Element
marshalXmlEventWriter
protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter)
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for marshalling the given object to a StAXXMLEventWriter
.- Specified by:
marshalXmlEventWriter
in classAbstractMarshaller
- Parameters:
graph
- the root of the object graph to marshaleventWriter
- theXMLEventWriter
to write to
marshalXmlStreamWriter
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for marshalling the given object to a StAXXMLStreamWriter
.- Specified by:
marshalXmlStreamWriter
in classAbstractMarshaller
- Parameters:
graph
- the root of the object graph to marshalstreamWriter
- theXMLStreamWriter
to write to- Throws:
XmlMappingException
- if the given object cannot be marshalled to the DOM node
marshalSaxHandlers
protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler) throws XmlMappingException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for marshalling the given object graph to a SAXContentHandler
.- Specified by:
marshalSaxHandlers
in classAbstractMarshaller
- Parameters:
graph
- the root of the object graph to marshalcontentHandler
- the SAXContentHandler
lexicalHandler
- the SAX2LexicalHandler
. Can benull
.- Throws:
XmlMappingException
- if the given object cannot be marshalled to the handlers
marshalOutputStream
protected void marshalOutputStream(Object graph, OutputStream outputStream) throws XmlMappingException, IOException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for marshalling the given object graph to aOutputStream
.- Specified by:
marshalOutputStream
in classAbstractMarshaller
- Parameters:
graph
- the root of the object graph to marshaloutputStream
- theOutputStream
to write to- Throws:
XmlMappingException
- if the given object cannot be marshalled to the writerIOException
- if an I/O exception occurs
marshalWriter
protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for marshalling the given object graph to aWriter
.- Specified by:
marshalWriter
in classAbstractMarshaller
- Parameters:
graph
- the root of the object graph to marshalwriter
- theWriter
to write to- Throws:
XmlMappingException
- if the given object cannot be marshalled to the writerIOException
- if an I/O exception occurs
unmarshalDomNode
protected Object unmarshalDomNode(Node node) throws XmlMappingException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for unmarshalling from a given DOMNode
.- Specified by:
unmarshalDomNode
in classAbstractMarshaller
- Parameters:
node
- the DOM node that contains the objects to be unmarshalled- Returns:
- the object graph
- Throws:
XmlMappingException
- if the given DOM node cannot be mapped to an object
unmarshalXmlEventReader
protected Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for unmarshalling from a given StaxXMLEventReader
.- Specified by:
unmarshalXmlEventReader
in classAbstractMarshaller
- Parameters:
eventReader
- theXMLEventReader
to read from- Returns:
- the object graph
- Throws:
XmlMappingException
- if the given event reader cannot be converted to an object
unmarshalXmlStreamReader
protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) throws XmlMappingException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for unmarshalling from a given StaxXMLStreamReader
.- Specified by:
unmarshalXmlStreamReader
in classAbstractMarshaller
- Parameters:
streamReader
- theXMLStreamReader
to read from- Returns:
- the object graph
- Throws:
XmlMappingException
- if the given stream reader cannot be converted to an object
unmarshalSaxReader
protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource) throws XmlMappingException, IOException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for unmarshalling using a given SAXXMLReader
andInputSource
.- Specified by:
unmarshalSaxReader
in classAbstractMarshaller
- Parameters:
xmlReader
- the SAXXMLReader
to parse withinputSource
- the input source to parse from- Returns:
- the object graph
- Throws:
XmlMappingException
- if the given reader and input source cannot be converted to an objectIOException
- if an I/O exception occurs
unmarshalInputStream
protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for unmarshalling from a givenInputStream
.- Specified by:
unmarshalInputStream
in classAbstractMarshaller
- Parameters:
inputStream
- theInputStreamStream
to read from- Returns:
- the object graph
- Throws:
XmlMappingException
- if the given stream cannot be converted to an objectIOException
- if an I/O exception occurs
unmarshalReader
protected Object unmarshalReader(Reader reader) throws XmlMappingException, IOException
Deprecated.Description copied from class:AbstractMarshaller
Abstract template method for unmarshalling from a givenReader
.- Specified by:
unmarshalReader
in classAbstractMarshaller
- Parameters:
reader
- theReader
to read from- Returns:
- the object graph
- Throws:
XmlMappingException
- if the given reader cannot be converted to an objectIOException
- if an I/O exception occurs
validate
protected void validate(org.apache.xmlbeans.XmlObject object) throws ValidationFailureException
Deprecated.Validate the givenXmlObject
.- Parameters:
object
- the xml object to validate- Throws:
ValidationFailureException
- if the given object is not valid
convertXmlBeansException
protected XmlMappingException convertXmlBeansException(Exception ex, boolean marshalling)
Deprecated.Convert the given XMLBeans exception to an appropriate exception from theorg.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 occuredmarshalling
- indicates whether the exception occurs during marshalling (true
), or unmarshalling (false
)- Returns:
- the corresponding
XmlMappingException