com.echomine.xmlrpc
Class StructSerializer

java.lang.Object
  extended by com.echomine.xmlrpc.StructSerializer
All Implemented Interfaces:
Deserializer, Serializer, SerializerFactoryAware

public class StructSerializer
extends java.lang.Object
implements Serializer, Deserializer, SerializerFactoryAware

serializer for parsing a struct element into a hashmap or any Map-based class into an JDOM element. The Element should start with the <struct> tag. The struct XML example structure is as follows:

 <struct>
    <member>
       <name>lowerBound</name>
       <value><i4>18</i4></value>
    </member>
    <member>
       <name>upperBound</name>
       <value><i4>139</i4></value>
    </member>
 </struct>
 


Field Summary
static java.lang.String NAME
           
 
Constructor Summary
StructSerializer()
           
 
Method Summary
 java.lang.Object deserialize(Element elem)
          Deserializes the element into a HashMap instance
 Element serialize(java.lang.Object data, Namespace ns)
          Serializes a Map-based object into a struct.
 void setSerializerFactory(SerializerFactory factory)
          sets the serializer factory instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values
Constructor Detail

StructSerializer

public StructSerializer()
Method Detail

setSerializerFactory

public void setSerializerFactory(SerializerFactory factory)
sets the serializer factory instance

Specified by:
setSerializerFactory in interface SerializerFactoryAware

serialize

public Element serialize(java.lang.Object data,
                         Namespace ns)
Serializes a Map-based object into a struct. This includes Hashmaps, sorted maps, tree maps, etc.

Specified by:
serialize in interface Serializer
Parameters:
data - any object that implements the Map interface
ns - optional namespace, null if there is none
Returns:
the Element object of the serialized data, null if there were any problems
Throws:
java.lang.IllegalArgumentException - when the data is not an accepted format

deserialize

public java.lang.Object deserialize(Element elem)
Deserializes the element into a HashMap instance

Specified by:
deserialize in interface Deserializer
Parameters:
elem - the element containing the struct xml
Returns:
a HashMap instance


Copyright © 2001-2005 Echomine. All Rights Reserved.