redstone.xmlrpc.serializers
Class LongArraySerializer

java.lang.Object
  extended by redstone.xmlrpc.serializers.LongArraySerializer
All Implemented Interfaces:
XmlRpcCustomSerializer

public class LongArraySerializer
extends java.lang.Object
implements XmlRpcCustomSerializer

Serializes arrays of primitive longs. Note that unless setUseApacheExtension( true ) has been invoked, the longs are demoted to integers before being serialized into regular XML-RPC <i4>'s, possibly losing significant bits in the conversion.

Author:
Greger Olsson

Constructor Summary
LongArraySerializer()
           
 
Method Summary
 java.lang.Class getSupportedClass()
          Returns the class of objects this serializer knows how to handle.
 void serialize(java.lang.Object value, java.io.Writer writer, XmlRpcSerializer builtInSerializer)
          Asks the custom serializer to serialize the supplied value into the supplied writer.
 void setUseApacheExtension(boolean useApacheExtension)
          Sets whether or not to use the <i8> Apache extensions when serializing longs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongArraySerializer

public LongArraySerializer()
Method Detail

getSupportedClass

public java.lang.Class getSupportedClass()
Description copied from interface: XmlRpcCustomSerializer
Returns the class of objects this serializer knows how to handle.

Specified by:
getSupportedClass in interface XmlRpcCustomSerializer
Returns:
The class of objects interpretable to this serializer.

setUseApacheExtension

public void setUseApacheExtension(boolean useApacheExtension)
Sets whether or not to use the <i8> Apache extensions when serializing longs.

Parameters:
useApacheExtension - Flag for specifying the Apache extension to be used.

serialize

public void serialize(java.lang.Object value,
                      java.io.Writer writer,
                      XmlRpcSerializer builtInSerializer)
               throws XmlRpcException,
                      java.io.IOException
Description copied from interface: XmlRpcCustomSerializer
Asks the custom serializer to serialize the supplied value into the supplied writer. The supplied value will be of the type reported in getSupportedClass() or of a type extending therefrom.

Specified by:
serialize in interface XmlRpcCustomSerializer
Parameters:
value - The object to serialize.
writer - The writer to place the serialized data.
builtInSerializer - The built-in serializer used by the client or the server.
Throws:
XmlRpcException - if the value somehow could not be serialized. Many serializers rely on the built in serializer which also may throw this exception.
java.io.IOException - if there was an error serializing the value through the writer. The exception is the exception thrown by the writer, which in most cases will be a StringWriter, in which case this exception will never occurr. XmlRpcSerializer and custom serializers may, however, be used outside of the XML-RPC library to encode information in XML-RPC structs, in which case the writer potentially could be writing the information over a socket stream for instance.