org.licas.parsers.types

## Class DomParser

- java.lang.Object
- - org.licas.parsers.types.DomParser

-     public class DomParser
      extends java.lang.Object

  This class serialises and parses a `Document` object to or from XML. https://www.journaldev.com/1237/java-convert-string-to-xml-document-and-xml-document-to-string
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `W3CDOM` Codes a string as a w3c dom document

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DomParser()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `addW3cSpec(java.lang.String xmlStr)` Add the special characters indicating a string of `org.wc3.dom XML` format that should not be converted into anything else.
    `static boolean` | `isW3cDom(java.lang.Object xmlElem)` Return true if the object is a w3c `Document` type.
    `static boolean` | `isW3cDom(java.lang.String xmlElem)` Return true if the object is a w3c `Document` type.
    `static org.w3c.dom.Document` | `parse(java.lang.String toParse)` Parse a String description of a `Document` object back into a Java object.
    `static java.lang.String` | `prettyFormatXml(org.w3c.dom.Document doc, boolean keepDeclaration)` Pretty format the w3c document and return the string representation.
    `static java.lang.String` | `removeW3cSpec(java.lang.String xmlStr)` Remove the special characters indicating a string of `org.wc3.dom XML` format that should not be converted into anything else.
    `static java.lang.String` | `serialize(org.w3c.dom.Document toSerialize)` Serialize a `Document` object to XML.

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

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

- - ### Field Detail

    - #### W3CDOM

          public static final java.lang.String W3CDOM

      Codes a string as a w3c dom document
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DomParser

          public DomParser()

  - ### Method Detail

    - #### isW3cDom

          public static boolean isW3cDom(java.lang.String xmlElem)

      Return true if the object is a w3c `Document` type.
      Parameters:
        `xmlElem` - the string parameter.
      Returns:
        true if not null and w3c Document type, false otherwise.

    - #### isW3cDom

          public static boolean isW3cDom(java.lang.Object xmlElem)

      Return true if the object is a w3c `Document` type.
      Parameters:
        `xmlElem` - the element parameter.
      Returns:
        true if not null and w3c Document type, false otherwise.

    - #### serialize

          public static java.lang.String serialize(org.w3c.dom.Document toSerialize)
                                            throws java.lang.Exception

      Serialize a `Document` object to XML.
      Parameters:
        `toSerialize` - the ByteArray object to serialize.
      Returns:
        an XML description of the object.
      Throws:
        `java.lang.Exception` - any error.

    - #### parse

          public static org.w3c.dom.Document parse(java.lang.String toParse)
                                            throws java.lang.Exception

      Parse a String description of a `Document` object back into a Java object.
      Parameters:
        `toParse` - the XML description to parse.
      Returns:
        the Document object that is created.
      Throws:
        `java.lang.Exception` - any error.

    - #### addW3cSpec

          public static java.lang.String addW3cSpec(java.lang.String xmlStr)

      Add the special characters indicating a string of `org.wc3.dom XML` format that should not be converted into anything else. The Parsers however will automatically try to remove this coding as part of a final parsing event.
      Parameters:
        `xmlStr` - the original String.
      Returns:
        the String with the special characters included.

    - #### removeW3cSpec

          public static java.lang.String removeW3cSpec(java.lang.String xmlStr)

      Remove the special characters indicating a string of `org.wc3.dom XML` format that should not be converted into anything else.
      Parameters:
        `xmlStr` - the original String with the special characters included.
      Returns:
        the String with the special characters removed.

    - #### prettyFormatXml

          public static java.lang.String prettyFormatXml(org.w3c.dom.Document doc,
                                                         boolean keepDeclaration)
                                                  throws java.lang.Exception

      Pretty format the w3c document and return the string representation.
      Parameters:
        `doc` - the w3c document.
        `keepDeclaration` - true if keep the header declaration.
      Returns:
        the text where the XML is appropriately formatted wrt indentation.
      Throws:
        `java.lang.Exception` - any error.