Package org.mustangproject.util
Class NodeMap
- java.lang.Object
-
- org.mustangproject.util.NodeMap
-
public class NodeMap extends java.lang.ObjectTheNodeMapcontains aMaprepresentation of DOM object It can be constructed either from the children of a singleNodeor aNodeList.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.stream.Stream<org.w3c.dom.Node>getAllNodes(java.lang.String... localNames)Get all matching nodesjava.util.Optional<java.math.BigDecimal>getAsBigDecimal(java.lang.String... localNames)Get the text content of a matching node In case more than one node matches, it is not guaranteed that the first match is selectedjava.util.Optional<NodeMap>getAsNodeMap(java.lang.String... localNames)Get aNodeMapof the child of a matching node byLocalNameIn case more than one node matches, it is not guaranteed that the first match is selectedjava.util.Optional<java.lang.String>getAsString(java.lang.String... localNames)Get the text content of a matching node In case more than one node matches, it is not guaranteed that the first match is selectedjava.lang.StringgetAsStringOrNull(java.lang.String... localNames)Get the text content of a matching node In case more than one node matches, it is not guaranteed that the first match is selectedjava.util.Optional<org.w3c.dom.Node>getNode(java.lang.String... localNames)Get matching node byLocalNameIn case more than one node matches, it is not guaranteed that the first match is selectedjava.lang.StringtoString()
-
-
-
Constructor Detail
-
NodeMap
public NodeMap(org.w3c.dom.Node node)
Create a newNodeMapTheNodethat is passed to the constructor must not be null. TheNodeMapwill be empty when no child nodes are present.- Parameters:
node- the node that shall be represented by thisNodeMap- Throws:
java.lang.IllegalArgumentException- when argument is null
-
NodeMap
public NodeMap(org.w3c.dom.NodeList nodeList)
-
-
Method Detail
-
getNode
public java.util.Optional<org.w3c.dom.Node> getNode(java.lang.String... localNames)
Get matching node byLocalNameIn case more than one node matches, it is not guaranteed that the first match is selected- Parameters:
localNames- one or moreLocalNames- Returns:
- the matching node
-
getAsNodeMap
public java.util.Optional<NodeMap> getAsNodeMap(java.lang.String... localNames)
Get aNodeMapof the child of a matching node byLocalNameIn case more than one node matches, it is not guaranteed that the first match is selected- Parameters:
localNames- one or moreLocalNames- Returns:
- the
NodeMaprepresentation of the matching node
-
getAsString
public java.util.Optional<java.lang.String> getAsString(java.lang.String... localNames)
Get the text content of a matching node In case more than one node matches, it is not guaranteed that the first match is selected- Parameters:
localNames- one or moreLocalNames- Returns:
- the text content of the matching node
-
getAsBigDecimal
public java.util.Optional<java.math.BigDecimal> getAsBigDecimal(java.lang.String... localNames)
Get the text content of a matching node In case more than one node matches, it is not guaranteed that the first match is selected- Parameters:
localNames- one or moreLocalNames- Returns:
- the text content of the matching node, converted to BigDecimal
-
getAsStringOrNull
public java.lang.String getAsStringOrNull(java.lang.String... localNames)
Get the text content of a matching node In case more than one node matches, it is not guaranteed that the first match is selected- Parameters:
localNames- one or moreLocalNames- Returns:
- the text content of the matching node or
nullwhen no matching node could be found
-
getAllNodes
public java.util.stream.Stream<org.w3c.dom.Node> getAllNodes(java.lang.String... localNames)
Get all matching nodes- Parameters:
localNames- one or moreLocalNames- Returns:
- a
Streamthat contains all matching nodes (can be empty if nothing matches)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-