## net.dontdrinkandroot.utils.xml
Class DomUtils

    java.lang.Object
      net.dontdrinkandroot.utils.xml.DomUtils

    public class DomUtils

extends java.lang.Object

Field Summary
`static org.slf4j.Logger` `LOGGER`

Constructor Summary
`protected` `DomUtils()` Disabled constructor, utility class.

Method Summary
`protected static boolean` `checkPreconditions(org.w3c.dom.Element element)` Checks if the element is null or does only contain whitespace text.
`static java.lang.String` `getAttributeText(org.w3c.dom.Element element, java.lang.String tagName, java.lang.String attrName)` Get the attribute text of a single child of an element by its tag name.
`static org.w3c.dom.Element` `getChildByTagName(org.w3c.dom.Element element, java.lang.String name)` Get a single child of an element by its tag name.
`static java.util.List<org.w3c.dom.Element>` `getChildrenByTagName(org.w3c.dom.Element element, java.lang.String name)` Get the children of an element with a specified tag name.
`static java.lang.String` `getElementText(org.w3c.dom.Element element, java.lang.String name)` Get the element text of a single child of an element by its tag name.
`static java.lang.Boolean` `toBoolean(org.w3c.dom.Element element)`
`static java.lang.Boolean` `toBoolean(org.w3c.dom.Element element, java.lang.String attributeName)`
`static ISO_3166_1_alpha2` `toCountry(org.w3c.dom.Element element)`
`static java.util.Date` `toDateFromSecondsTimestamp(org.w3c.dom.Element element, java.lang.String attName)`
`static java.lang.Double` `toDouble(org.w3c.dom.Element element)`
`static java.lang.Double` `toDouble(org.w3c.dom.Element element, java.lang.String attributeName)`
`static java.lang.Float` `toFloat(org.w3c.dom.Element element)`
`static java.lang.Float` `toFloat(org.w3c.dom.Element element, java.lang.String attributeName)`
`static java.net.URL` `toHttpURL(org.w3c.dom.Element element)`
`static java.lang.Integer` `toInteger(org.w3c.dom.Element element)`
`static java.lang.Integer` `toInteger(org.w3c.dom.Element element, java.lang.String attributeName)`
`static java.lang.Long` `toLong(org.w3c.dom.Element element)`
`static java.lang.Long` `toLong(org.w3c.dom.Element element, java.lang.String attributeName)`
`static java.lang.String` `toNonEmptyString(org.w3c.dom.Element element)` Retrieve the element body as a string.
`static java.lang.String` `toNonEmptyString(org.w3c.dom.Element element, java.lang.String attributeName)`
`static java.net.URI` `toURI(org.w3c.dom.Element element)`
`static java.net.URL` `toURL(org.w3c.dom.Element element)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOGGER

    public static final org.slf4j.Logger LOGGER

Constructor Detail

### DomUtils

    protected DomUtils()

  Disabled constructor, utility class.

Method Detail

### toNonEmptyString

    public static java.lang.String toNonEmptyString(org.w3c.dom.Element element)

  Retrieve the element body as a string.

  Parameters:
    `element` - The element to process.
  Returns:
    The element body as string or null.

### toNonEmptyString

    public static java.lang.String toNonEmptyString(org.w3c.dom.Element element,
                                                    java.lang.String attributeName)

### toInteger

    public static java.lang.Integer toInteger(org.w3c.dom.Element element)

### toInteger

    public static java.lang.Integer toInteger(org.w3c.dom.Element element,
                                              java.lang.String attributeName)

### toLong

    public static java.lang.Long toLong(org.w3c.dom.Element element)

### toLong

    public static java.lang.Long toLong(org.w3c.dom.Element element,
                                        java.lang.String attributeName)

### toFloat

    public static java.lang.Float toFloat(org.w3c.dom.Element element)

### toFloat

    public static java.lang.Float toFloat(org.w3c.dom.Element element,
                                          java.lang.String attributeName)

### toDouble

    public static java.lang.Double toDouble(org.w3c.dom.Element element)

### toDouble

    public static java.lang.Double toDouble(org.w3c.dom.Element element,
                                            java.lang.String attributeName)

### toBoolean

    public static java.lang.Boolean toBoolean(org.w3c.dom.Element element)

### toBoolean

    public static java.lang.Boolean toBoolean(org.w3c.dom.Element element,
                                              java.lang.String attributeName)

### toURL

    public static java.net.URL toURL(org.w3c.dom.Element element)

### toHttpURL

    public static java.net.URL toHttpURL(org.w3c.dom.Element element)

### toCountry

    public static ISO_3166_1_alpha2 toCountry(org.w3c.dom.Element element)

### toDateFromSecondsTimestamp

    public static java.util.Date toDateFromSecondsTimestamp(org.w3c.dom.Element element,
                                                            java.lang.String attName)

### toURI

    public static java.net.URI toURI(org.w3c.dom.Element element)

### getChildByTagName

    public static org.w3c.dom.Element getChildByTagName(org.w3c.dom.Element element,
                                                        java.lang.String name)

  Get a single child of an element by its tag name.

  Parameters:
    `element` - The element to search the child for.
    `name` - The tag name of the child to search.
  Returns:
    The child if found or null.

### getElementText

    public static java.lang.String getElementText(org.w3c.dom.Element element,
                                                  java.lang.String name)

  Get the element text of a single child of an element by its tag name.

  Parameters:
    `element` - The element to search the child for.
    `name` - The tag name of the child to search.
  Returns:
    The element text of the child if found or null if not found or the text is empty.

### getAttributeText

    public static java.lang.String getAttributeText(org.w3c.dom.Element element,
                                                    java.lang.String tagName,
                                                    java.lang.String attrName)

  Get the attribute text of a single child of an element by its tag name.

  Parameters:
    `element` - The element to search the child for.
    `name` - The tag name of the child to search.
    `attrName` - The name of the attribute.
  Returns:
    The attribute text of the child if found or null.

### getChildrenByTagName

    public static java.util.List<org.w3c.dom.Element> getChildrenByTagName(org.w3c.dom.Element element,
                                                                           java.lang.String name)

  Get the children of an element with a specified tag name.

  Parameters:
    `element` - The element to search the children for.
    `name` - The tag name of the children to search for.
  Returns:
    A List of the matching children (can be empty of no children found).

### checkPreconditions

    protected static boolean checkPreconditions(org.w3c.dom.Element element)

  Checks if the element is null or does only contain whitespace text.

  Parameters:
    `element` - The element to check.
  Returns:
    True if the element can be processed.

Copyright © 2013 dontdrinkandroot. All Rights Reserved.