org.hamcrest.xml
Class HasXPath
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeDiagnosingMatcher<org.w3c.dom.Node>
org.hamcrest.xml.HasXPath
- All Implemented Interfaces:
- Matcher<org.w3c.dom.Node>, SelfDescribing
public class HasXPath
- extends TypeSafeDiagnosingMatcher<org.w3c.dom.Node>
Applies a Matcher to a given XML Node in an existing XML Node tree, specified by an XPath expression.
- Author:
- Joe Walnes
Constructor Summary |
HasXPath(java.lang.String xPathExpression,
Matcher<? super java.lang.String> valueMatcher)
|
HasXPath(java.lang.String xPathExpression,
javax.xml.namespace.NamespaceContext namespaceContext,
Matcher<? super java.lang.String> valueMatcher)
|
Method Summary |
void |
describeTo(Description description)
Generates a description of the object. |
static Matcher<org.w3c.dom.Node> |
hasXPath(java.lang.String xPath)
|
static Matcher<org.w3c.dom.Node> |
hasXPath(java.lang.String xPath,
Matcher<? super java.lang.String> valueMatcher)
|
static Matcher<org.w3c.dom.Node> |
hasXPath(java.lang.String xPath,
javax.xml.namespace.NamespaceContext namespaceContext)
|
static Matcher<org.w3c.dom.Node> |
hasXPath(java.lang.String xPath,
javax.xml.namespace.NamespaceContext namespaceContext,
Matcher<? super java.lang.String> valueMatcher)
|
boolean |
matchesSafely(org.w3c.dom.Node item,
Description mismatchDescription)
Subclasses should implement this. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
HasXPath
public HasXPath(java.lang.String xPathExpression,
Matcher<? super java.lang.String> valueMatcher)
- Parameters:
xPathExpression
- XPath expression.valueMatcher
- Matcher to use at given XPath.
May be null to specify that the XPath must exist but the value is irrelevant.
HasXPath
public HasXPath(java.lang.String xPathExpression,
javax.xml.namespace.NamespaceContext namespaceContext,
Matcher<? super java.lang.String> valueMatcher)
- Parameters:
xPathExpression
- XPath expression.namespaceContext
- Resolves XML namespace prefixes in the XPath expressionvalueMatcher
- Matcher to use at given XPath.
May be null to specify that the XPath must exist but the value is irrelevant.
matchesSafely
public boolean matchesSafely(org.w3c.dom.Node item,
Description mismatchDescription)
- Description copied from class:
TypeSafeDiagnosingMatcher
- Subclasses should implement this. The item will already have been checked
for the specific type and will never be null.
- Specified by:
matchesSafely
in class TypeSafeDiagnosingMatcher<org.w3c.dom.Node>
describeTo
public void describeTo(Description description)
- Description copied from interface:
SelfDescribing
- Generates a description of the object. The description may be part of a
a description of a larger object of which this is just a component, so it
should be worded appropriately.
- Parameters:
description
- The description to be built or appended to.
hasXPath
public static Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath,
Matcher<? super java.lang.String> valueMatcher)
hasXPath
public static Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath,
javax.xml.namespace.NamespaceContext namespaceContext,
Matcher<? super java.lang.String> valueMatcher)
hasXPath
public static Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath)
hasXPath
public static Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath,
javax.xml.namespace.NamespaceContext namespaceContext)