com.echomine.xmlrpc
Class DoubleSerializer
java.lang.Object
com.echomine.xmlrpc.DoubleSerializer
- All Implemented Interfaces:
- Deserializer, Serializer
public class DoubleSerializer
- extends java.lang.Object
- implements Serializer, Deserializer
Serializer for the double value. This will deal with the XMLRPC's <double> element.
Example:
<double>-12.214<double>
Field Summary |
static java.lang.String |
NAME
|
Method Summary |
java.lang.Object |
deserialize(Element elem)
Deserializes the xml data into a Double object. |
Element |
serialize(java.lang.Object data,
Namespace ns)
Serializes the object into its XML representation
The object can be any Number-based instance. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
DoubleSerializer
public DoubleSerializer()
serialize
public Element serialize(java.lang.Object data,
Namespace ns)
- Serializes the object into its XML representation
The object can be any Number-based instance. It will be
transformed to a double value before writing out the string
representation.
NOTE: The serialization may not serialize the exact value that you specified, but it will be close.
For instance, if you have -12.222, the serialized value may be -12.22200000100023. There is nothing
that can be done in regards to the current situation.
- Specified by:
serialize
in interface Serializer
- Parameters:
data
- a Number instancens
- optional namespace, null if no namespace
- Returns:
- the element data
- Throws:
java.lang.IllegalArgumentException
- when the data is not an accepted format
deserialize
public java.lang.Object deserialize(Element elem)
- Deserializes the xml data into a Double object.
NOTE: The deserialized double value may not be the exact value that the data specified.
However, you can round it off to your nearest precision if you'd like afterwards.
- Specified by:
deserialize
in interface Deserializer
- Parameters:
elem
- the element containing the data
- Returns:
- the Double instance of the deserialized object
- Throws:
java.lang.NumberFormatException
- if the data cannot be parsed properly
Copyright © 2001-2005 Echomine. All Rights Reserved.