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

public class JaxbXmlMarshaller<T> extends AbstractMarshaller<T>
JAXB-based marshaller that marshals object to/from XML.
Author:
as 2011.07.10
  • Constructor Details

    • JaxbXmlMarshaller

      public JaxbXmlMarshaller(Class<T> clzRoot)
      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 IOException
      Description copied from interface: Marshaller
      Write the specified object into the given stream.
      Parameters:
      value - object to marshall
      out - the OutputStream 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 IOException
      Description 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 marshall
      out - the OutputStream 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

      public T unmarshal(InputStream in, jakarta.ws.rs.core.MediaType mediaType) throws IOException
      Description copied from interface: Marshaller
      Read an object from the specified stream.
      Parameters:
      in - stream to read from
      mediaType - 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