org.faktorips.runtime.internal
Class XmlUtil

java.lang.Object
  extended by org.faktorips.runtime.internal.XmlUtil

public class XmlUtil
extends Object

A collection of utility methods for xml handling.

Author:
Jan Ortmann

Method Summary
static String getCDATAorTextContent(Node node)
          Returns the node's first CDATA section if the node has one.
static Element getElement(Node parent, String tagName, int index)
          Returns the child element with the given tag name and index.
static List<Element> getElementsFromNode(Element elem, String nodeName, String attributeName, String attributeValue)
          Returns a list of element's with the following criteria: the node name must be equals to the given node name the node must contain an attribute with the attribute name the value of the attribute (with the given name) must be equal to the given value
static CDATASection getFirstCDataSection(Node node)
          Returns the node's first CDATA section or null if the node hasn't got one.
static Element getFirstElement(Node parent)
          Returns the first Element node
static Element getFirstElement(Node parent, String tagName)
           
static Text getTextNode(Node node)
          Returns the node's text child node or null if the node hasn't got a text node.
static String getValueFromNode(Element elem, String nodeName)
          Returns the value of the first element with the given node name, starts searching by the given Element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFirstElement

public static final Element getFirstElement(Node parent,
                                            String tagName)

getFirstElement

public static final Element getFirstElement(Node parent)
Returns the first Element node


getElement

public static final Element getElement(Node parent,
                                       String tagName,
                                       int index)
Returns the child element with the given tag name and index. The index is the position of the element considering all child elements with the given tag name.

Parameters:
parent - The parent node.
tagName - the element tag name.
index - The 0 based position of the child.
Returns:
The element at the specified index
Throws:
IndexOutOfBoundsException - if no element exists at the specified index.

getTextNode

public static final Text getTextNode(Node node)
Returns the node's text child node or null if the node hasn't got a text node.


getFirstCDataSection

public static final CDATASection getFirstCDataSection(Node node)
Returns the node's first CDATA section or null if the node hasn't got one.


getCDATAorTextContent

public static final String getCDATAorTextContent(Node node)
Returns the node's first CDATA section if the node has one. If not, this returns the node's text child node or null if the node hasn't got a text node.


getValueFromNode

public static final String getValueFromNode(Element elem,
                                            String nodeName)
Returns the value of the first element with the given node name, starts searching by the given Element

Parameters:
elem - The first element (root or parent) element the search begins
nodeName - The name searching for

getElementsFromNode

public static final List<Element> getElementsFromNode(Element elem,
                                                      String nodeName,
                                                      String attributeName,
                                                      String attributeValue)
Returns a list of element's with the following criteria:



Copyright © 2015. All rights reserved.