Class AbstractXPathAction<T>
- java.lang.Object
-
- gov.nist.secauto.decima.xml.templating.document.post.template.AbstractXPathAction<T>
-
- Type Parameters:
T
- The generic type of the results of the XPath query after being processed by the JDOMFilter<T>
- All Implemented Interfaces:
Action
,XPathAction<T>
- Direct Known Subclasses:
AddAttributeAction
,DeleteAction
,InsertChildAction
,InsertSiblingAction
,ModifyAttributeAction
,ReplaceAction
public abstract class AbstractXPathAction<T> extends Object implements XPathAction<T>
This abstract implementation provides basic XPath query support forAction
implementations that handle specific action operations.
-
-
Constructor Summary
Constructors Constructor Description AbstractXPathAction(org.jdom2.xpath.XPathFactory xpathFactory, String xpath, org.jdom2.filter.Filter<T> filter, Map<String,String> prefixToNamespaceMap)
Construct a new AbstractXPathAction based on an XPath string, a JDOMFilter<T>
using the provided namespace map to map XML prefixes to namespaces.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
execute(org.jdom2.Document document)
Apply the action to an XML document, making the required modifications.org.jdom2.xpath.XPathExpression<T>
getXpath()
Retrieves the compiled XPath expression.protected abstract void
process(List<T> results)
Perform the implemented action on the provided XPath results.protected List<T>
resolveXpath(org.jdom2.Document document)
Resolves the XPath expression against the provided document, returning the nodeset.
-
-
-
Constructor Detail
-
AbstractXPathAction
public AbstractXPathAction(org.jdom2.xpath.XPathFactory xpathFactory, String xpath, org.jdom2.filter.Filter<T> filter, Map<String,String> prefixToNamespaceMap)
Construct a new AbstractXPathAction based on an XPath string, a JDOMFilter<T>
using the provided namespace map to map XML prefixes to namespaces.- Parameters:
xpathFactory
- the XPath implementation to usexpath
- the XPath stringfilter
- a filter to determine the types of nodes to returnprefixToNamespaceMap
- a map of XML prefixes to namespaces used in the provided XPath
-
-
Method Detail
-
getXpath
public org.jdom2.xpath.XPathExpression<T> getXpath()
Description copied from interface:XPathAction
Retrieves the compiled XPath expression.- Specified by:
getXpath
in interfaceXPathAction<T>
- Returns:
- a compiled XPath expression
-
resolveXpath
protected List<T> resolveXpath(org.jdom2.Document document) throws ActionException
Resolves the XPath expression against the provided document, returning the nodeset.- Parameters:
document
- the document to query against- Returns:
- a list of matching nodes
- Throws:
ActionException
- if an error occurs while resolving the XPath expression
-
execute
public void execute(org.jdom2.Document document) throws ActionException
Description copied from interface:Action
Apply the action to an XML document, making the required modifications.- Specified by:
execute
in interfaceAction
- Parameters:
document
- the document to apply the action to- Throws:
ActionException
- if an error occurs while applying the action to the document
-
process
protected abstract void process(List<T> results) throws ActionException
Perform the implemented action on the provided XPath results.- Parameters:
results
- a list of XPath results guaranteed to be non-empty- Throws:
ActionException
- if an error occurs while processing the implemented action
-
-