com.echomine.xmlrpc
Class IntSerializer

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

public class IntSerializer
extends java.lang.Object
implements Serializer, Deserializer

A serializer for integer types. It can be used to serialize both the <int> and the <i4> elements. Each one should be registered by the caller just in case either one is used. Example:

 <int>64</int>
 <i4>128</i4>
 


Constructor Summary
IntSerializer(java.lang.String name)
          accepts the name of the element to use (ie.
 
Method Summary
 java.lang.Object deserialize(Element elem)
          Deserializes the element into an Integer value.
 java.lang.String getName()
           
 Element serialize(java.lang.Object data, Namespace ns)
          serializes the data which can be a Number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntSerializer

public IntSerializer(java.lang.String name)
accepts the name of the element to use (ie. i4 or int)

Method Detail

serialize

public Element serialize(java.lang.Object data,
                         Namespace ns)
serializes the data which can be a Number. If you pass in an object that is more than what an integer can handle, the number will be rounded or truncated (ie. if a large double value is used, it will be truncated/rounded). Preferably this should only accept Integer.

Specified by:
serialize in interface Serializer
Parameters:
data - an object of type Number
ns - optional namespace, null if there is no namespace
Returns:
the element of the serialized data
Throws:
java.lang.IllegalArgumentException - when the data is not an accepted format

deserialize

public java.lang.Object deserialize(Element elem)
Deserializes the element into an Integer value.

Specified by:
deserialize in interface Deserializer
Parameters:
elem - the element containing the data
Returns:
the parsed integer
Throws:
java.lang.NumberFormatException - if the contained data does not contain a parsable integer value

getName

public java.lang.String getName()
Returns:
the name of the element used


Copyright © 2001-2005 Echomine. All Rights Reserved.