Package de.pangaea.metadataportal.utils

## Class XMLToKeyValuePairs

- java.lang.Object
- - de.pangaea.metadataportal.utils.XMLToKeyValuePairs

-     public final class XMLToKeyValuePairs
      extends Object

  Used to serialize `Node` from a DOM tree to an Object (mainly `KeyValuePairs`). This class cannot handle adjacent text nodes, so the DOM tree should be normalized first. Nodes that have child elements or mixed content with get transformed to `KeyValuePairs`, String only nodes with an `xsi:type` attribute get deserialized to the given type, `String` otherwise. Empty nodes will return `null`.
  Author:
    Uwe Schindler
  See Also:
    `Node.normalize()`

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `ATTRIBUTE_ELEMENT_PREFIX` | If an element has a local name with this prefix, it is converted to a JSON attribute, prefixed by `@`.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `XMLToKeyValuePairs​(boolean serializeAttributes)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Object` | `convertChilds​(Node parentNode)` | Convert all children of a node: It first checks if all child nodes are text-only, in that case the whole node is returned as String (using `Node.getTextContent()`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ATTRIBUTE_ELEMENT_PREFIX

          public static final String ATTRIBUTE_ELEMENT_PREFIX

      If an element has a local name with this prefix, it is converted to a JSON attribute, prefixed by `@`.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XMLToKeyValuePairs

          public XMLToKeyValuePairs​(boolean serializeAttributes)
                             throws jakarta.xml.bind.JAXBException

      Throws:
        `jakarta.xml.bind.JAXBException`

  - ### Method Detail

    - #### convertChilds

          public Object convertChilds​(Node parentNode)
                               throws jakarta.xml.bind.JAXBException

      Convert all children of a node: It first checks if all child nodes are text-only, in that case the whole node is returned as String (using `Node.getTextContent()`. In all other cases its starts a new JSON object and converts every contained node. Empty nodes will be returned as `null`.
      Throws:
        `jakarta.xml.bind.JAXBException`