Package com.github.oowekyala.ooxml
Class DomUtils
- java.lang.Object
-
- com.github.oowekyala.ooxml.DomUtils
-
public final class DomUtils extends Object
Simple utilities to work with theorg.w3c.domAPI.
-
-
Constructor Summary
Constructors Constructor Description DomUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<Node>asList(NamedNodeMap nodeList)Returns an unmodifiable view of the given nodemap as a list.static List<Node>asList(NodeList nodeList)Returns an unmodifiable view of the given nodelist as a list.static List<Element>children(Element element)Returns the list of children of the given element that are also elements.static List<Element>childrenNamed(Element element, String localName)Returns the list of children of the given element that are also elements.static Optional<String>getAttributeOpt(Element element, String attributeName)Returns the value of the attribute with the given name as an optional.static Map<String,Node>toMap(NamedNodeMap nodeList)Returns a new map of nodes built from the given node map.
-
-
-
Method Detail
-
children
public static List<Element> children(Element element)
Returns the list of children of the given element that are also elements.
-
childrenNamed
public static List<Element> childrenNamed(Element element, String localName)
Returns the list of children of the given element that are also elements.
-
getAttributeOpt
public static Optional<String> getAttributeOpt(Element element, String attributeName)
Returns the value of the attribute with the given name as an optional.- Parameters:
element- Element to get the attribute fromattributeName- Attribute name (local name, no NS)
-
asList
public static List<Node> asList(NodeList nodeList)
Returns an unmodifiable view of the given nodelist as a list.- Parameters:
nodeList- A node list- Returns:
- A list view
-
asList
public static List<Node> asList(NamedNodeMap nodeList)
Returns an unmodifiable view of the given nodemap as a list. Note that as per the specification ofNamedNodeMap, elements are in no particular order, but this allows to iterate over them easily.- Parameters:
nodeList- A node map- Returns:
- A list view
-
toMap
public static Map<String,Node> toMap(NamedNodeMap nodeList)
Returns a new map of nodes built from the given node map. This uses local names to index the nodes. The returned map is modifiable.- Parameters:
nodeList- A node map- Returns:
- A new, modifiable map
-
-