org.apache.muse.core.serializer
Class XmlSerializableSerializer

java.lang.Object
  extended by org.apache.muse.core.serializer.XmlSerializableSerializer
All Implemented Interfaces:
Serializer
Direct Known Subclasses:
MembershipContentRuleSerializer

public class XmlSerializableSerializer
extends Object
implements Serializer

XmlSerializableSerializer performs no transformation on its data - it simply casts objects to instances of XmlSerializable and calls their toXML() method to perform serialization. This class does not support the fromXML method, as there is no way for it to know what concrete class to use in order to instantiate the XML into POJO form. It is merely a way to serialize XmlSerializable objects into SOAP/XML without having to write custom serializers for those types.

Author:
Dan Jemiolo (danj)

Constructor Summary
XmlSerializableSerializer()
           
 
Method Summary
 Object fromXML(Element xml)
          Deserializes the DOM Element into a POJO whose type this Serializer is responsible for.
 Class getSerializableType()
           
 Element toXML(Object obj, QName qname)
          Serializes the given object into a DOM Element, the value wrapped inside a root element with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlSerializableSerializer

public XmlSerializableSerializer()
Method Detail

fromXML

public Object fromXML(Element xml)
Description copied from interface: Serializer
Deserializes the DOM Element into a POJO whose type this Serializer is responsible for.

Specified by:
fromXML in interface Serializer
Parameters:
xml - The XML representation of a Java object. If the type is primitive or simple (not a primitive, but serialized to a string), the value should be a DOM Text node inside the given Element.
Returns:
A POJO constructed from the given XML. If the Element is empty and the Serializer's type is a non-primitive, the method will return null.

getSerializableType

public Class getSerializableType()
Specified by:
getSerializableType in interface Serializer

toXML

public Element toXML(Object obj,
                     QName qname)
Description copied from interface: Serializer
Serializes the given object into a DOM Element, the value wrapped inside a root element with the given name.

Specified by:
toXML in interface Serializer
Parameters:
obj - The object to serialize into XML, or null.
qname - The name of the element which the XML representation will be wrapped in.
Returns:
An Element whose name is the one given, and whose child Nodes represent the object. If the object was null, an empty Element is returned.


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.