Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.coherence.rest.io
Class XmlJaxbMarshaller

java.lang.Object
  extended by com.tangosol.coherence.rest.io.AbstractMarshaller
      extended by com.tangosol.coherence.rest.io.XmlJaxbMarshaller

All Implemented Interfaces:
Marshaller

public class XmlJaxbMarshaller
extends AbstractMarshaller

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
XmlJaxbMarshaller(java.lang.Class clzRoot)
          Construct an XmlJaxbMarshaller instance.

 

Method Summary
protected  void configureJaxbMarshaller(javax.xml.bind.Marshaller marshaller)
          Configure a JAXB marshaller.
protected  void configureJaxbUnmarshaller(javax.xml.bind.Unmarshaller unmarshaller)
          Configure a JAXB unmarshaller.
 void marshal(java.lang.Object oValue, java.io.OutputStream out)
          Write the specified object into the given stream.
 void marshalAsFragment(java.lang.Object oValue, java.io.OutputStream out)
          Write the specified object into the given stream as a fragment.
 java.lang.Object unmarshal(java.io.InputStream in)
          Read an object from the specified stream.

 

Methods inherited from class com.tangosol.coherence.rest.io.AbstractMarshaller
getRootClass

 

Constructor Detail

XmlJaxbMarshaller

public XmlJaxbMarshaller(java.lang.Class clzRoot)
Construct an XmlJaxbMarshaller instance.
Parameters:
clzRoot - class of the root object this marshaller is for

Method Detail

marshal

public void marshal(java.lang.Object oValue,
                    java.io.OutputStream out)
             throws java.io.IOException
Write the specified object into the given stream.
Parameters:
oValue - object to marshall
out - stream to write to
Throws:
java.io.IOException - if an error occurs during marshalling

marshalAsFragment

public void marshalAsFragment(java.lang.Object oValue,
                              java.io.OutputStream out)
                       throws java.io.IOException
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).

Specified by:
marshalAsFragment in interface Marshaller
Overrides:
marshalAsFragment in class AbstractMarshaller
Parameters:
oValue - object to marshall
out - stream to write to
Throws:
java.io.IOException - if an error occurs during marshalling

unmarshal

public java.lang.Object unmarshal(java.io.InputStream in)
                           throws java.io.IOException
Read an object from the specified stream.
Parameters:
in - stream to read from
Returns:
unmarshalled object instance
Throws:
java.io.IOException - if an error occurs during unmarshalling

configureJaxbMarshaller

protected void configureJaxbMarshaller(javax.xml.bind.Marshaller marshaller)
                                throws javax.xml.bind.PropertyException
Configure a JAXB marshaller.
Parameters:
marshaller - marshaller to configure
Throws:
javax.xml.bind.PropertyException - when there is an error processing a property or value

configureJaxbUnmarshaller

protected void configureJaxbUnmarshaller(javax.xml.bind.Unmarshaller unmarshaller)
                                  throws javax.xml.bind.PropertyException
Configure a JAXB unmarshaller.
Parameters:
unmarshaller - unmarshaller to configure
Throws:
javax.xml.bind.PropertyException - when there is an error processing a property or value

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.