Top Description Inners Fields Constructors Methods
org.opentest4j.reporting.tooling.core.util

public Class DomUtils

extends Object
Class Inheritance
Annotations
@API
status:INTERNAL
since:0.2.0
Imports
org.apiguardian.api.API, org.opentest4j.reporting.schema.Namespace, .QualifiedName, org.w3c.dom.NamedNodeMap, .Node, .NodeList, java.util.Arrays, .Optional, java.util.function.IntFunction, java.util.regex.Matcher, .Pattern, java.util.stream.IntStream, .Stream

Internal utils to work with DOM types
Since
0.2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
DomUtils.NamespaceVersion

Represents a namespace version.

public static class
DomUtils.VersionedNamespace

A namespace base URI and version.

Field Summary

Modifier and TypeField and Description
private static final Pattern

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Stream<Node>

Returns:

a stream of the children of the node
children
(Node
the parent node
parent
)

Stream the children of the supplied node.

public static Optional<Node>

Returns:

the first child node with the supplied element name
findChild
(Node
the parent node
parent
,
QualifiedName
the element name to find
elementName
)

Find the first child of the supplied parent node with the supplied element name.

public static Stream<Node>

Returns:

the children nodes with the supplied element name
findChildren
(Node
the parent node
parent
,
QualifiedName
the element name to find
elementName
)

Find the children of the supplied parent node with the supplied element name.

public static Optional<Node>

Returns:

the attribute
getAttribute
(Node
the node
node
,
QualifiedName
the element name of the attribute
elementName
)

Get the attribute with the supplied element name of the supplied node.

public static Optional<String>

Returns:

the value of the attribute
getAttributeValue
(Node
the node
node
,
QualifiedName
the element name of the attribute
elementName
)

Get the value of the attribute with the supplied element name of the supplied node.

private static boolean
public static boolean

Returns:

true if the node matches the qualified name
matches
(QualifiedName
the qualified name to match
qualifiedName
,
Node
the node to check
node
)

Check whether the simple name of the supplied node matches the supplied qualified name and the namespace of the node is compatible with the namespace of the qualified name (same base URI and version less than or equal to the version of the qualified name).

public static Optional<DomUtils.VersionedNamespace>

Returns:

the versioned namespace
parseNamespace
(String
the namespace URI to parse
namespaceUri
)

Parse the supplied namespace URI into a base URI and a version.

public static Stream<Node>

Returns:

a stream of the nodes in the node list
stream
(NodeList
the node list to stream
nodeList
)

Stream the nodes of the supplied node list.

public static Stream<Node>

Returns:

a stream of the nodes in the named node map
stream
(NamedNodeMap
the named node map to stream
namedNodeMap
)

Stream the nodes of the supplied named node map.

private static Stream<Node>
stream(int length, IntFunction<Node> item)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NAMESPACE_VERSION_PATTERNback to summary
private static final Pattern NAMESPACE_VERSION_PATTERN

Constructor Detail

DomUtilsback to summary
private DomUtils()

Method Detail

childrenback to summary
public static Stream<Node> children(Node parent)

Stream the children of the supplied node.

Parameters
parent:Node

the parent node

Returns:Stream<Node>

a stream of the children of the node

findChildback to summary
public static Optional<Node> findChild(Node parent, QualifiedName elementName)

Find the first child of the supplied parent node with the supplied element name.

Parameters
parent:Node

the parent node

elementName:QualifiedName

the element name to find

Returns:Optional<Node>

the first child node with the supplied element name

findChildrenback to summary
public static Stream<Node> findChildren(Node parent, QualifiedName elementName)

Find the children of the supplied parent node with the supplied element name.

Parameters
parent:Node

the parent node

elementName:QualifiedName

the element name to find

Returns:Stream<Node>

the children nodes with the supplied element name

getAttributeback to summary
public static Optional<Node> getAttribute(Node node, QualifiedName elementName)

Get the attribute with the supplied element name of the supplied node.

Parameters
node:Node

the node

elementName:QualifiedName

the element name of the attribute

Returns:Optional<Node>

the attribute

getAttributeValueback to summary
public static Optional<String> getAttributeValue(Node node, QualifiedName elementName)

Get the value of the attribute with the supplied element name of the supplied node.

Parameters
node:Node

the node

elementName:QualifiedName

the element name of the attribute

Returns:Optional<String>

the value of the attribute

isNamespaceCompatibleback to summary
private static boolean isNamespaceCompatible(QualifiedName qualifiedName, Node node)
matchesback to summary
public static boolean matches(QualifiedName qualifiedName, Node node)

Check whether the simple name of the supplied node matches the supplied qualified name and the namespace of the node is compatible with the namespace of the qualified name (same base URI and version less than or equal to the version of the qualified name).

Parameters
qualifiedName:QualifiedName

the qualified name to match

node:Node

the node to check

Returns:boolean

true if the node matches the qualified name

parseNamespaceback to summary
public static Optional<DomUtils.VersionedNamespace> parseNamespace(String namespaceUri)

Parse the supplied namespace URI into a base URI and a version.

Parameters
namespaceUri:String

the namespace URI to parse

Returns:Optional<DomUtils.VersionedNamespace>

the versioned namespace

streamback to summary
public static Stream<Node> stream(NodeList nodeList)

Stream the nodes of the supplied node list.

Parameters
nodeList:NodeList

the node list to stream

Returns:Stream<Node>

a stream of the nodes in the node list

streamback to summary
public static Stream<Node> stream(NamedNodeMap namedNodeMap)

Stream the nodes of the supplied named node map.

Parameters
namedNodeMap:NamedNodeMap

the named node map to stream

Returns:Stream<Node>

a stream of the nodes in the named node map

streamback to summary
private static Stream<Node> stream(int length, IntFunction<Node> item)
org.opentest4j.reporting.tooling.core.util back to summary

public Class DomUtils.NamespaceVersion

extends Object
implements Comparable<DomUtils.NamespaceVersion>
Class Inheritance
  • java.lang.Object
  • org.opentest4j.reporting.tooling.core.util.DomUtils.NamespaceVersion
All Implemented Interfaces
java.lang.Comparable

Represents a namespace version.

Field Summary

Modifier and TypeField and Description
private final int[]
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
NamespaceVersion(String stringValue, int[] parts)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(DomUtils.NamespaceVersion
the object to be compared.
that
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public static DomUtils.NamespaceVersion

Returns:

the parsed version
parse
(String
the version string to parse
version
)

Parse the supplied version string.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

partsback to summary
private final int[] parts
stringValueback to summary
private final String stringValue

Constructor Detail

NamespaceVersionback to summary
pack-priv NamespaceVersion(String stringValue, int[] parts)

Method Detail

compareToback to summary
public int compareTo(DomUtils.NamespaceVersion that)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
that:DomUtils.NamespaceVersion

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
parseback to summary
public static DomUtils.NamespaceVersion parse(String version)

Parse the supplied version string.

Parameters
version:String

the version string to parse

Returns:DomUtils.NamespaceVersion

the parsed version

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.opentest4j.reporting.tooling.core.util back to summary

public Class DomUtils.VersionedNamespace

extends Object
Class Inheritance
  • java.lang.Object
  • org.opentest4j.reporting.tooling.core.util.DomUtils.VersionedNamespace

A namespace base URI and version.

Field Summary

Modifier and TypeField and Description
private final String
private final DomUtils.NamespaceVersion

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the base URI
getBaseUri
()

Returns the base URI.

public DomUtils.NamespaceVersion

Returns:

the version
getVersion
()

Returns the version.

pack-priv boolean
public Namespace

Returns:

the namespace
toNamespace
()

Convert this versioned namespace to a namespace.

public DomUtils.VersionedNamespace

Returns:

the new versioned namespace
withVersion
(DomUtils.NamespaceVersion
the version
version
)

Create a new versioned namespace with the supplied version.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseUriback to summary
private final String baseUri
versionback to summary
private final DomUtils.NamespaceVersion version

Constructor Detail

VersionedNamespaceback to summary
pack-priv VersionedNamespace(String baseUri, DomUtils.NamespaceVersion version)

Method Detail

getBaseUriback to summary
public String getBaseUri()

Returns the base URI.

Returns:String

the base URI

getVersionback to summary
public DomUtils.NamespaceVersion getVersion()

Returns the version.

Returns:DomUtils.NamespaceVersion

the version

isCompatibleback to summary
pack-priv boolean isCompatible(DomUtils.VersionedNamespace that)
toNamespaceback to summary
public Namespace toNamespace()

Convert this versioned namespace to a namespace.

Returns:Namespace

the namespace

withVersionback to summary
public DomUtils.VersionedNamespace withVersion(DomUtils.NamespaceVersion version)

Create a new versioned namespace with the supplied version.

Parameters
version:DomUtils.NamespaceVersion

the version

Returns:DomUtils.VersionedNamespace

the new versioned namespace