Class XPathMatcher
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<IXPathNodeMatcher>,Collection<IXPathNodeMatcher>,List<IXPathNodeMatcher>,RandomAccess
XPath matcher is used to match if a DOM Node match a XPath expression. It is
initialized with an XPath expression :
- static expression like //element, //element/@attr, //element/text()
- expression with wildcard like //element[@id='$0']
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionXPathMatcher(String xpathExpression) Constructor of XPath Matcher with a XPath expression. -
Method Summary
Modifier and TypeMethodDescriptionprotected XPathElementMatcherCreate XPath any element matcher.protected XPathAttributeMatchercreateAttributeMatcher(XPathElementMatcher elementmatcher, String attrName, String attrValue) Create the XPath attribute matcher.intReturns the number of wilcard used in the XPath expression and -1 if there is no wildcard.Returns the type (element, attribute, text) of the node to select.getWildcardValues(Node selectedNode) Returns list of wildcard values of the given DOM Node.booleanReturns true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise.booleanmatch(Node node, Collection<String> wildcardValues) Returns true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Constructor Details
-
XPathMatcher
Constructor of XPath Matcher with a XPath expression.- Parameters:
xpathExpression-
-
-
Method Details
-
match
Returns true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise.- Parameters:
node- the DOM Node to match.- Returns:
- true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise.
-
match
Returns true if the given DOM Node match the XPath expression of this XPath matcher and false otherwise. This method use wilcard values if XPath expression contains wildcard (like [@id='$0'].- Parameters:
node- the DOM Node to match.wildcardValues- the list of wildcard values and null otherwise.- Returns:
-
getWildcardValues
Returns list of wildcard values of the given DOM Node.- Parameters:
selectedNode-- Returns:
-
getNbWildCard
public int getNbWildCard()Returns the number of wilcard used in the XPath expression and -1 if there is no wildcard.- Returns:
-
createAnyElementMatcher
Create XPath any element matcher.- Returns:
- the XPath any element matcher.
-
createAttributeMatcher
protected XPathAttributeMatcher createAttributeMatcher(XPathElementMatcher elementmatcher, String attrName, String attrValue) Create the XPath attribute matcher.- Parameters:
elementmatcher- the parent element matcher.attrName- the attribute name to match.attrValue- the attribute value to match.- Returns:
- the XPath attribute matcher.
-
getNodeSelectorType
Returns the type (element, attribute, text) of the node to select.- Returns:
- the type (element, attribute, text) of the node to select.o
-