Package com.tangosol.coherence.rest.io
Class JaxbXmlMarshaller<T>
java.lang.Object
com.tangosol.coherence.rest.io.AbstractMarshaller<T>
com.tangosol.coherence.rest.io.JaxbXmlMarshaller<T>
- All Implemented Interfaces:
Marshaller<T>
- Direct Known Subclasses:
XmlJaxbMarshaller
JAXB-based marshaller that marshals object to/from XML.
- Author:
- as 2011.07.10
-
Field Summary
Fields inherited from interface com.tangosol.coherence.rest.io.Marshaller
FORMAT_OUTPUT
-
Constructor Summary
ConstructorDescriptionJaxbXmlMarshaller
(Class<T> clzRoot) Construct an JaxbXmlMarshaller instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureJaxbMarshaller
(jakarta.xml.bind.Marshaller marshaller) Configure a JAXB marshaller.protected void
configureJaxbUnmarshaller
(jakarta.xml.bind.Unmarshaller unmarshaller) Configure a JAXB unmarshaller.void
marshal
(T value, OutputStream out, jakarta.ws.rs.core.MultivaluedMap<String, Object> httpHeaders) Write the specified object into the given stream.void
marshalAsFragment
(T value, OutputStream out, jakarta.ws.rs.core.MultivaluedMap<String, Object> httpHeaders) Write the specified object into the given stream as a fragment.unmarshal
(InputStream in, jakarta.ws.rs.core.MediaType mediaType) Read an object from the specified stream.Methods inherited from class com.tangosol.coherence.rest.io.AbstractMarshaller
getRootClass
-
Constructor Details
-
JaxbXmlMarshaller
Construct an JaxbXmlMarshaller instance.- Parameters:
clzRoot
- class of the root object this marshaller is for
-
-
Method Details
-
marshal
public void marshal(T value, OutputStream out, jakarta.ws.rs.core.MultivaluedMap<String, Object> httpHeaders) throws IOExceptionDescription copied from interface:Marshaller
Write the specified object into the given stream.- Parameters:
value
- object to marshallout
- theOutputStream
for the HTTP entity. The implementation should not close the output stream.httpHeaders
- a mutable map of the HTTP message headers.- Throws:
IOException
- if an error occurs during marshalling
-
marshalAsFragment
public void marshalAsFragment(T value, OutputStream out, jakarta.ws.rs.core.MultivaluedMap<String, Object> httpHeaders) throws IOExceptionDescription copied from interface:Marshaller
Write the specified object into the given stream as a fragment.This method is called when marshalling collections of objects, as marshalling behavior might differ when an object is serialized directly or as element of a collection.
For example, when marshalling a collection of objects into XML, you need to ensure that the XML declaration is emmitted only once, not for each object in the collection.
In cases where there is no difference in output between fragments and full objects (JSON, for example), this method could simply delegate to
Marshaller.marshal(Object, OutputStream, MultivaluedMap)
.- Parameters:
value
- object to marshallout
- theOutputStream
for the HTTP entity. The implementation should not close the output stream.httpHeaders
- a mutable map of the HTTP message headers.- Throws:
IOException
- if an error occurs during marshalling
-
unmarshal
Description copied from interface:Marshaller
Read an object from the specified stream.- Parameters:
in
- stream to read frommediaType
- the media type of the object to read- Returns:
- unmarshalled object instance
- Throws:
IOException
- if an error occurs during unmarshalling
-
configureJaxbMarshaller
protected void configureJaxbMarshaller(jakarta.xml.bind.Marshaller marshaller) throws jakarta.xml.bind.PropertyException Configure a JAXB marshaller.- Parameters:
marshaller
- marshaller to configure- Throws:
jakarta.xml.bind.PropertyException
- when there is an error processing a property or value
-
configureJaxbUnmarshaller
protected void configureJaxbUnmarshaller(jakarta.xml.bind.Unmarshaller unmarshaller) throws jakarta.xml.bind.PropertyException Configure a JAXB unmarshaller.- Parameters:
unmarshaller
- unmarshaller to configure- Throws:
jakarta.xml.bind.PropertyException
- when there is an error processing a property or value
-