Class SerializerHandler


  • public class SerializerHandler
    extends java.lang.Object
    The serializer handler serializes and deserialized objects. It takes an object, determine its type and let the responsible handler serialize it. For deserialization it looks at the xml tag around the element. The class is designed as a kind of singleton, so it can be accessed from anywhere in the library.
    Author:
    Tim Roes
    • Method Detail

      • initialize

        public static void initialize​(int flags)
        Initialize the serialization handler. This method must be called before the get method returns any object.
        Parameters:
        flags - The flags that has been set in the XMLRPCClient.
        See Also:
        XMLRPCClient
      • getDefault

        public static SerializerHandler getDefault()
        Return the instance of the SerializerHandler. It must have been initialized with initialize() before.
        Returns:
        The instance of the SerializerHandler.
      • deserialize

        public java.lang.Object deserialize​(org.w3c.dom.Element element)
                                     throws XMLRPCException
        Deserializes an incoming xml element to an java object. The xml element must be the value element around the type element. The type of the returning object depends on the type tag.
        Parameters:
        element - An type element from within a value tag.
        Returns:
        The deserialized object.
        Throws:
        XMLRPCException - Will be thrown whenever an error occurs.
      • serialize

        public XmlElement serialize​(java.lang.Object object)
                             throws XMLRPCException
        Serialize an object to its representation as an xml element. The xml element will be the type element for the use within a value tag.
        Parameters:
        object - The object that should be serialized.
        Returns:
        The xml representation of this object.
        Throws:
        XMLRPCException - Will be thrown, if an error occurs (e.g. the object cannot be serialized to an xml element.