de.caff.io.xml

## Interface XmlDispatchedStorable

- All Superinterfaces:
    XmlStorable

      public interface XmlDispatchedStorable
      extends XmlStorable

  Interface for objects of varying classes which can be stored to XML.
  Since:
    June 15, 2023
  Author:
    Rammi

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `XML_ATTR_READ_METHOD`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> T` | `fromXmlElement(org.w3c.dom.Element element, java.lang.String xmlTag, java.lang.Class<T> type)` Recreate an object of the given class from its stored XML representation.
    `java.lang.String` | `getXmlReaderMethod()` Get the method used to reread an object of this kind from XML.
    `void` | `storeInnerXml(SimpleXmlWriter xml)` Store the individual XML
    `default void` | `storeOuterXml(SimpleXmlWriter xml, java.lang.String xmlTag)` Write this dispatched storable to XML using the given XML tag.

    - ### Methods inherited from interface de.caff.io.xml.XmlStorable

      `storeXml, toXmlText`

- - ### Field Detail

    - #### XML_ATTR_READ_METHOD

          @NotNull
          static final java.lang.String XML_ATTR_READ_METHOD

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### storeOuterXml

          default void storeOuterXml(@NotNull
                                     SimpleXmlWriter xml,
                                     @NotNull
                                     java.lang.String xmlTag)

      Write this dispatched storable to XML using the given XML tag. This writes out an outer element with the given tag and version and reader attributes, which contains whatever `storeInnerXml(SimpleXmlWriter)` is creating.

      This method is assumed to be called from parent class/interfaces implementations.

      Parameters:
        `xml` - XML writer
        `xmlTag` - XML tag

    - #### storeInnerXml

          void storeInnerXml(@NotNull
                             SimpleXmlWriter xml)

      Store the individual XML
      Parameters:
        `xml` - XML writer

    - #### getXmlReaderMethod

          @NotNull
          java.lang.String getXmlReaderMethod()

      Get the method used to reread an object of this kind from XML. The method is expected to have one `Element` argument and return an object of the stored kind.

      The reader is expected to ignore the exact element and restore the object from the children of the given element. This is the reverse of what has happened during storeInnerXml(SimpleXmlWriter).

      Returns:
        XML restore method in the form `"full.class.name#methodName"`

    - #### fromXmlElement

          @NotNull
          static <T> T fromXmlElement(@NotNull
                                               org.w3c.dom.Element element,
                                               @NotNull
                                               java.lang.String xmlTag,
                                               @NotNull
                                               java.lang.Class<T> type)
                                        throws org.xml.sax.SAXException

      Recreate an object of the given class from its stored XML representation.
      Type Parameters:
        `T` - type of object
      Parameters:
        `element` - outer XML element as created by `storeOuterXml(SimpleXmlWriter, String)`
        `xmlTag` - outer XML tag used for storage
        `type` - type of stored object
      Returns:
        recreated object of the given type
      Throws:
        `org.xml.sax.SAXException` - on read, access or format errors