redstone.xmlrpc
Class XmlRpcSerializer

java.lang.Object
  extended by redstone.xmlrpc.XmlRpcSerializer
Direct Known Subclasses:
XmlRpcJsonSerializer

public class XmlRpcSerializer
extends java.lang.Object

The XmlRpcSerializer class converts Java objects to their XML-RPC counterparts according to the XML-RPC specification. It inherently supports basic object types like String, Integer, Double, Float, Boolean, Date, and byte arrays. For other types of objects, custom serializers need to be registered. The Redstone XML-RPC library comes with a set of useful serializers for collections and other types of objects. @see the redstone.xmlrpc.serializers . TODO Change synchronization of global dateFormatter to prevent bottleneck.

Author:
Greger Olsson

Constructor Summary
XmlRpcSerializer()
          Constructor adding all core custom serializers.
XmlRpcSerializer(boolean addCustomSerializers)
          Constructor that may add all the custom serializers in the library (which is almost always what you want).
 
Method Summary
 void addCustomSerializer(XmlRpcCustomSerializer customSerializer)
          Registers a custom serializer.
 void removeCustomSerializer(XmlRpcCustomSerializer customSerializer)
          Unregisters a previously registered custom serializer.
 void serialize(java.lang.Object value, java.io.Writer writer)
          Converts the supplied Java object to its XML-RPC counterpart according to the XML-RPC specification.
 void writeEnvelopeFooter(java.lang.Object value, java.io.Writer writer)
          
 void writeEnvelopeHeader(java.lang.Object value, java.io.Writer writer)
          
 void writeError(java.lang.String message, java.io.Writer writer)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRpcSerializer

public XmlRpcSerializer()
Constructor adding all core custom serializers.


XmlRpcSerializer

public XmlRpcSerializer(boolean addCustomSerializers)
Constructor that may add all the custom serializers in the library (which is almost always what you want).

Parameters:
addCustomSerializers - Indicates if the core custom serializers should be added.
Method Detail

writeEnvelopeHeader

public void writeEnvelopeHeader(java.lang.Object value,
                                java.io.Writer writer)
                         throws java.io.IOException

Parameters:
writer -
Throws:
java.io.IOException

writeEnvelopeFooter

public void writeEnvelopeFooter(java.lang.Object value,
                                java.io.Writer writer)
                         throws java.io.IOException

Parameters:
value -
writer -
Throws:
java.io.IOException

writeError

public void writeError(java.lang.String message,
                       java.io.Writer writer)
                throws java.io.IOException

Parameters:
message -
writer -
Throws:
java.io.IOException

serialize

public void serialize(java.lang.Object value,
                      java.io.Writer writer)
               throws XmlRpcException,
                      java.io.IOException
Converts the supplied Java object to its XML-RPC counterpart according to the XML-RPC specification.

Throws:
XmlRpcException
java.io.IOException

addCustomSerializer

public void addCustomSerializer(XmlRpcCustomSerializer customSerializer)
Registers a custom serializer. The serializer is placed the list of serializers before more general serializers from the same inheritance tree. That is, adding a serializer supporting serialization of java.util.Vector will be placed before a serializer for java.util.Collection. In other words, when serializing an object of type Vector, the java.util.Vector serializer will override a more general java.util.Collection serializer.


removeCustomSerializer

public void removeCustomSerializer(XmlRpcCustomSerializer customSerializer)
Unregisters a previously registered custom serializer.