org.apache.qpid.management.wsdm.muse.serializer
Class ObjectSerializer

java.lang.Object
  extended by org.apache.qpid.management.wsdm.muse.serializer.ObjectSerializer
All Implemented Interfaces:
org.apache.muse.core.serializer.Serializer

public class ObjectSerializer
extends Object
implements org.apache.muse.core.serializer.Serializer

Generic Serializer for objects. It is a general-purpose serializer used for encoding Object values.


Constructor Summary
ObjectSerializer()
           
 
Method Summary
 Object fromXML(Element elementData)
          Converts the incoming element into the appropriate Java type.
 Class<?> getSerializableType()
          As this serializer is supposed to deal with generic object types, this method returns Object.class.
 String getXmlType(Class<?> clazz)
          Returns the xml type associated with the given class.
 Element toXML(Object obj, QName qname)
          Converts the given object (with the given qname) in XML format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectSerializer

public ObjectSerializer()
Method Detail

fromXML

public Object fromXML(Element elementData)
               throws org.apache.muse.ws.addressing.soap.SoapFault
Converts the incoming element into the appropriate Java type. The method will fail if :
1) The element has no xsi:type attribute;
2) The xsi:type attribute has no corresponding java type on this serializer mappings.

Specified by:
fromXML in interface org.apache.muse.core.serializer.Serializer
Parameters:
elementData - the xml element containing data to be unmarshalled.l
Returns:
the java object as result of xml element unmarshalling.
Throws:
org.apache.muse.ws.addressing.soap.SoapFault - when the marshalling fails.

getSerializableType

public Class<?> getSerializableType()
As this serializer is supposed to deal with generic object types, this method returns Object.class.

Specified by:
getSerializableType in interface org.apache.muse.core.serializer.Serializer
Returns:
Object.class

toXML

public Element toXML(Object obj,
                     QName qname)
              throws org.apache.muse.ws.addressing.soap.SoapFault
Converts the given object (with the given qname) in XML format. This method fails if there's no corresponding xml type for the given runtime type of the input object.

Specified by:
toXML in interface org.apache.muse.core.serializer.Serializer
Parameters:
obj - the object to be marshalled.
qname - the qualified name that will be used in encoding.
Throws:
org.apache.muse.ws.addressing.soap.SoapFault

getXmlType

public String getXmlType(Class<?> clazz)
Returns the xml type associated with the given class.

Parameters:
clazz - the class.
Returns:
the xml type associated with the given class.


Licensed to the Apache Software Foundation