Package org.faktorips.runtime.internal
Enum XmlUtil
- All Implemented Interfaces:
Serializable,Comparable<XmlUtil>,java.lang.constant.Constable
A collection of utility methods for xml handling.
- Author:
- Jan Ortmann
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Method Summary
Modifier and TypeMethodDescriptionfindFirstElement(Node parent) Returns the first Element nodefindFirstElement(Node parent, String tagName) static final StringgetCDATAorTextContent(Node node) Returns the node's first CDATA section if the node has one.static final ElementgetElement(Node parent, String tagName, int index) Returns the child element with the given tag name and index.getElements(Node parent, String tagName) Returns all child elements with the given tag name.getElementsFromNode(Element elem, String nodeName, String attributeName, String attributeValue) Returns a list of element's with the following criteria: the node name must be equal 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 valuestatic final CDATASectiongetFirstCDataSection(Node node) Returns the node's first CDATA section ornullif the node hasn't got one.static final ElementgetFirstElement(Node parent) Returns the first Element nodestatic final ElementgetFirstElement(Node parent, String tagName) static final TextgetTextNode(Node node) Returns the node's text child node ornullif the node hasn't got a text node.static final StringgetValueFromNode(Element elem, String nodeName) Returns the value of the first element with the given node name, starts searching by the given Elementstatic XmlUtilReturns the enum constant of this type with the specified name.static XmlUtil[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getFirstElement
-
findFirstElement
-
getFirstElement
Returns the first Element node -
findFirstElement
Returns the first Element node -
getElement
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.
-
getElements
Returns all child elements with the given tag name. Considers only direct children. UseElement.getElementsByTagName(String)to search all descendants.- Parameters:
parent- The parent node.tagName- the element tag name.- Returns:
- all child elements with the matching tag name
-
getTextNode
Returns the node's text child node ornullif the node hasn't got a text node. -
getFirstCDataSection
Returns the node's first CDATA section ornullif the node hasn't got one. -
getCDATAorTextContent
Returns the node's first CDATA section if the node has one. If not, this returns the node's text child node ornullif the node hasn't got a text node. -
getValueFromNode
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 beginsnodeName- 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:- the node name must be equal 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
-