dsto.dfc.databeans.io
Class XmlUtil

java.lang.Object
  extended by dsto.dfc.databeans.io.XmlUtil

public final class XmlUtil
extends Object

General utility methods for use with serialized data object XML documents.

Author:
phillipm

Method Summary
static org.jdom.Element findElement(Collection elements, String attr, String value)
           
static org.jdom.Element findElement(List elements, String elementType)
          Finds the first Elements of the given type (elementType) in the list of Elements provided, and returns it.
static List findElements(List elements, String elementType)
          Finds all the Elements of the given type (elementType) in the list of Elements provided, and returns them in a list in order of discovery.
static org.jdom.Element followNamePath(org.jdom.Element root, String path)
           
static String getAttribute(org.jdom.Element element, String name)
          Get the value of a required attribute.
static boolean getAttribute(org.jdom.Element element, String name, boolean defValue)
           
static int getAttribute(org.jdom.Element element, String name, int defValue)
           
static Map getAttributesAsMap(org.jdom.Element element)
          Turn the attributes of an element into a java.util.Map.
static boolean getBooleanAttribute(org.jdom.Element element, String name)
          Get the value of a required boolean attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

followNamePath

public static org.jdom.Element followNamePath(org.jdom.Element root,
                                              String path)

findElement

public static org.jdom.Element findElement(Collection elements,
                                           String attr,
                                           String value)

findElement

public static org.jdom.Element findElement(List elements,
                                           String elementType)
Finds the first Elements of the given type (elementType) in the list of Elements provided, and returns it.

Parameters:
elements - The list of Elements to check.
elementType - The type of Elements to look for.
Returns:
The first elementType typed Element found in elements.

findElements

public static List findElements(List elements,
                                String elementType)
Finds all the Elements of the given type (elementType) in the list of Elements provided, and returns them in a list in order of discovery.

Parameters:
elements - The list of Elements to check.
elementType - The type of Elements to look for.
Returns:
A list of elementType typed Elements.

getAttribute

public static int getAttribute(org.jdom.Element element,
                               String name,
                               int defValue)

getAttribute

public static boolean getAttribute(org.jdom.Element element,
                                   String name,
                                   boolean defValue)

getBooleanAttribute

public static boolean getBooleanAttribute(org.jdom.Element element,
                                          String name)
                                   throws IllegalArgumentException
Get the value of a required boolean attribute.

Parameters:
element - The element to read from.
name - The attribute name.
Returns:
The boolean attribute value.
Throws:
IllegalArgumentException - if attribute is missing or not a boolean.

getAttribute

public static String getAttribute(org.jdom.Element element,
                                  String name)
                           throws IllegalArgumentException
Get the value of a required attribute.

Parameters:
element - The element to read from.
name - The attribute name.
Returns:
The attribute value.
Throws:
IllegalArgumentException - if attribute is missing.

getAttributesAsMap

public static Map getAttributesAsMap(org.jdom.Element element)
Turn the attributes of an element into a java.util.Map.



Copyright © 2008 Commonwealth of Australia