org.licas.parsers.types

## Class ElementParser

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

-     public class ElementParser
      extends java.lang.Object

  This parses an xml `Element` to or from a String.
  Author:
    Kieran Greer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ElementParser()` Creates a new instance of ElementParser

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.Object` | `convertToElementClass(org.licas_xml.abs.Element elemObj, java.lang.String className)` Convert an xml element into the format as specified by the class name.
    `static java.lang.String` | `getAttributeValue(java.lang.String attributeName, org.licas_xml.abs.Element elemObj)` Get an attribute value from the element with the specified name.
    `static java.lang.String` | `getParameterValue(org.licas_xml.abs.Element elemObj)` Get a value from a nested element with the `Const`.`PARAMETER` name and a `VALUE` element inside of that.
    `static java.lang.Object` | `parse(java.lang.String xmlStr)` Parse the xml String to return the xml element.
    `static java.lang.String` | `replaceElementSpecs(java.lang.String xmlStr)` Remove the element prefixes and return.
    `static java.lang.String` | `serialize(org.licas_xml.abs.Element nextObj)` Convert the object into an XML-based String.
    `protected static java.lang.String` | `serializeNextElement(org.licas_xml.abs.Node rootElem)` Convert an xml element and its subelements into String format.
    `static void` | `setAttribute(java.lang.String attributeName, java.lang.String attributeValue, org.licas_xml.abs.Element elemObj)` Add an attribute to the element with the specified values.

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

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

- - ### Constructor Detail

    - #### ElementParser

          public ElementParser()

      Creates a new instance of ElementParser

  - ### Method Detail

    - #### replaceElementSpecs

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

      Remove the element prefixes and return.
      Parameters:
        `xmlStr` - the string to remove prefixes from.
      Returns:
        the modified string.

    - #### setAttribute

          public static void setAttribute(java.lang.String attributeName,
                                          java.lang.String attributeValue,
                                          org.licas_xml.abs.Element elemObj)

      Add an attribute to the element with the specified values.
      Parameters:
        `attributeName` - the attribute name.
        `attributeValue` - the attribute value.
        `elemObj` - the xml element.

    - #### getAttributeValue

          public static java.lang.String getAttributeValue(java.lang.String attributeName,
                                                           org.licas_xml.abs.Element elemObj)

      Get an attribute value from the element with the specified name.
      Parameters:
        `attributeName` - the attribute name.
        `elemObj` - the xml element.
      Returns:
        the attribute value.

    - #### getParameterValue

          public static java.lang.String getParameterValue(org.licas_xml.abs.Element elemObj)
                                                    throws java.lang.Exception

      Get a value from a nested element with the `Const`.`PARAMETER` name and a `VALUE` element inside of that. If this is missing, then return null.
      Parameters:
        `elemObj` - the xml element with the nested parameter element.
      Returns:
        the value as a String.
      Throws:
        `java.lang.Exception` - any error.

    - #### convertToElementClass

          public static java.lang.Object convertToElementClass(org.licas_xml.abs.Element elemObj,
                                                               java.lang.String className)
                                                        throws java.lang.Exception

      Convert an xml element into the format as specified by the class name.
      Parameters:
        `elemObj` - an xml element to parse.
        `className` - the class name of the object to create.
      Returns:
        the converted xml element.
      Throws:
        `java.lang.Exception` - any error.

    - #### parse

          public static java.lang.Object parse(java.lang.String xmlStr)
                                        throws java.lang.Exception

      Parse the xml String to return the xml element.
      Parameters:
        `xmlStr` - a description of the data.
      Returns:
        the xml elements or the original String if not xml.
      Throws:
        `java.lang.Exception` - any error.

    - #### serialize

          public static java.lang.String serialize(org.licas_xml.abs.Element nextObj)
                                            throws java.lang.Exception

      Convert the object into an XML-based String.
      Parameters:
        `nextObj` - the xml element to convert.
      Returns:
        the xml element converted into a String.
      Throws:
        `java.lang.Exception` - any error.

    - #### serializeNextElement

          protected static java.lang.String serializeNextElement(org.licas_xml.abs.Node rootElem)
                                                          throws java.lang.Exception

      Convert an xml element and its subelements into String format.
      Parameters:
        `rootElem` - the root element.
      Returns:
        the root and subelements in String format.
      Throws:
        `java.lang.Exception` - any error.