Package de.pangaea.metadataportal.utils
Class XMLToKeyValuePairs
- java.lang.Object
-
- de.pangaea.metadataportal.utils.XMLToKeyValuePairs
-
public final class XMLToKeyValuePairs extends Object
Used to serializeNodefrom a DOM tree to an Object (mainlyKeyValuePairs). 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 toKeyValuePairs, String only nodes with anxsi:typeattribute get deserialized to the given type,Stringotherwise. Empty nodes will returnnull.- Author:
- Uwe Schindler
- See Also:
Node.normalize()
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTRIBUTE_ELEMENT_PREFIXIf 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 ObjectconvertChilds(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 (usingNode.getTextContent().
-
-
-
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
-
-
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 (usingNode.getTextContent(). In all other cases its starts a new JSON object and converts every contained node. Empty nodes will be returned asnull.- Throws:
jakarta.xml.bind.JAXBException
-
-