Interface XMLSerializable

    • Field Detail

      • ROOT_ELEMENT_NAME

        static final java.lang.String ROOT_ELEMENT_NAME
        The default root element name. See toXML()
        See Also:
        Constant Field Values
    • Method Detail

      • toXML

        org.jdom.Element toXML()
        Convert object to a JDOM element. The representation should be complete so that fromXML(org.jdom.Element) can completely restore the object's representation.

        It is recommended that the returned element use ROOT_ELEMENT_NAME as its name, in which case it must not define an attribute called "type". In this case, fromXML, will be called with an element whose name may differ from the element return from this function. This recommendation allows a more compact representation of the XML can be stored.

        This method generally should not be called directly. Instead, you should usually call XMLSerializer.classToXML(String, XMLSerializable) which calls this method internally.

        PluginDocument implementations of this method may choose to throw an XMLSerializationException, enclosed in a RuntimeException.

        Returns:
        object encoded as a JDOM element
        Throws:
        java.lang.RuntimeException - whose cause is a XMLSerializationException if either the serializable class is a PluginDocument and it is unable to serialize to a temporary file using PluginDocument.FILE_DATA_ATTRIBUTE_NAME. or the serializable class is an AnnotatedPluginDocument which can't load its internal PluginDocument because for example there is insufficient memory or it is in a shared database that encounters an IOException
      • fromXML

        void fromXML​(org.jdom.Element element)
              throws XMLSerializationException
        Restore the object from the JDOM Element returned by toXML().

        This method generally should not be called directly. Instead, you should usually call XMLSerializer.classFromXML(org.jdom.Element) or XMLSerializer.classFromXML(org.jdom.Element, Class) which calls this method internally.

        It is optional to implement this method. Instead of implementing an empty constructor and implementing this method properly, the implementation may instead throw an UnsupportedOperationException and implement a constructor that takes a single Element as a parameter. This allows for cleaner code such as support for final fields in the XMLSerializable class.

        The element parameter should not be modified since it may be reused. If you need a modified version of it, take a copy with Element.clone().

        Parameters:
        element - representation from a previous call to toXML()
        Throws:
        XMLSerializationException - if the Element can't be converted into this type of object
        java.lang.UnsupportedOperationException - if this class instead implements a constructor that takes a single Element as a parameter. PluginDocuments must not throw this exception.