Package com.adaptris.tester.runtime
Class XpathCommon
- java.lang.Object
-
- com.adaptris.tester.runtime.XpathCommon
-
- Direct Known Subclasses:
AssertXpathBoolean
,AssertXpathEquals
,RemoveNodePreprocessor
,XpathPreprocessor
public class XpathCommon extends java.lang.Object
Abstract class providing common functionality and configuration to its extenders.
-
-
Constructor Summary
Constructors Constructor Description XpathCommon()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyValuePairSet
getNamespaceContext()
java.lang.String
getXpath()
Returns the xpath to use.java.lang.String
nodeToString(org.w3c.dom.Node node)
Utility class that returns a String of a Nodeprotected boolean
selectSingleBoolean(java.lang.String input)
Returns boolean result ofgetXpath()
against input param.org.w3c.dom.Node
selectSingleNode(java.lang.String input)
Convenience method that callsselectSingleNode(Node)
after turning string into node.protected org.w3c.dom.Node
selectSingleNode(org.w3c.dom.Node document)
Returns result ofgetXpath()
from input parameter.void
setNamespaceContext(KeyValuePairSet kvps)
Set the namespace context for resolving namespaces.void
setXpath(java.lang.String xpath)
Sets the xpath to use.
-
-
-
Method Detail
-
selectSingleNode
protected final org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node document) throws XpathCommonException
Returns result ofgetXpath()
from input parameter.Example:
Payload:
<root><key>value</key></root>
Xpath:
/root/key
Node:
value
- Parameters:
document
- Xml to run xpath against- Returns:
- resulting node from xpath query
- Throws:
XpathCommonException
- wraps thrown exceptions
-
selectSingleNode
public final org.w3c.dom.Node selectSingleNode(java.lang.String input) throws XpathCommonException
Convenience method that callsselectSingleNode(Node)
after turning string into node.- Parameters:
input
- Xml to run xpath against- Returns:
- resulting node from xpath query
- Throws:
XpathCommonException
- wraps thrown exceptions
-
nodeToString
public final java.lang.String nodeToString(org.w3c.dom.Node node) throws XpathCommonException
Utility class that returns a String of a Node- Parameters:
node
- node to transform- Returns:
- string of node
- Throws:
XpathCommonException
- wraps thrown exceptions
-
selectSingleBoolean
protected final boolean selectSingleBoolean(java.lang.String input) throws XpathCommonException
Returns boolean result ofgetXpath()
against input param.Example:
Payload:
<root><key>value</key></root>
Xpath:
count(/root/key) = 1
- Parameters:
input
- Xml to run xpath against- Returns:
- Boolean result of xpath
- Throws:
XpathCommonException
- wraps thrown exceptions
-
getXpath
public java.lang.String getXpath()
Returns the xpath to use.- Returns:
- the xpath
-
setXpath
public void setXpath(java.lang.String xpath)
Sets the xpath to use.- Parameters:
xpath
- the xpath
-
getNamespaceContext
public KeyValuePairSet getNamespaceContext()
- Returns:
- the namespaceContext
-
setNamespaceContext
public void setNamespaceContext(KeyValuePairSet kvps)
Set the namespace context for resolving namespaces.- The key is the namespace prefix
- The value is the namespace uri
- Parameters:
kvps
- the namespace context- See Also:
SimpleNamespaceContext.create(KeyValuePairSet)
-
-