Class XPathVariableProvider

java.lang.Object
de.aristaflow.adept2.model.common.xml.XPathVariableProvider
Direct Known Subclasses:
XPathSystemDataProvider

public abstract class XPathVariableProvider extends Object
This class handles variables that can be used in XPath expressions. The variables need to be declared in the XPathCompiler and the corresponding values need to be set in the XPathSelector. Subclasses provide their supported variables (and optionally their type and their occurrence indicator) in the constructor. The value will be requested as needed.
The corresponding variables in XPath have to start with $.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Map<net.sf.saxon.s9api.QName,Pair<net.sf.saxon.s9api.ItemType,net.sf.saxon.s9api.OccurrenceIndicator>>
    All variables to be replaced by this provider.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new variable provider.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.sf.saxon.s9api.XPathCompiler
    declareVariables(net.sf.saxon.s9api.XPathCompiler compiler)
    Declares all variables in the designated XPathCompiler.
    protected abstract Map<net.sf.saxon.s9api.QName,Pair<net.sf.saxon.s9api.ItemType,net.sf.saxon.s9api.OccurrenceIndicator>>
    Gets all variables provided by this class.
    protected abstract net.sf.saxon.s9api.XdmValue
    getVariableValue(net.sf.saxon.s9api.QName variable)
    Gets the value of the designated variable.
    net.sf.saxon.s9api.XPathSelector
    setVariables(net.sf.saxon.s9api.XPathSelector selector)
    Sets all values of all variables of this provider in the designated XPathSelector.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • variables

      protected Map<net.sf.saxon.s9api.QName,Pair<net.sf.saxon.s9api.ItemType,net.sf.saxon.s9api.OccurrenceIndicator>> variables
      All variables to be replaced by this provider. The values within this map are optional. The map will be initialised when declaring variables.
  • Constructor Details

    • XPathVariableProvider

      protected XPathVariableProvider()
      Creates a new variable provider.
  • Method Details

    • declareVariables

      public net.sf.saxon.s9api.XPathCompiler declareVariables(net.sf.saxon.s9api.XPathCompiler compiler)
      Declares all variables in the designated XPathCompiler.
      Parameters:
      compiler - The XPathCompiler in which to declare all variables of this provider.
      Returns:
      The designated XPathCompiler.
    • setVariables

      public net.sf.saxon.s9api.XPathSelector setVariables(net.sf.saxon.s9api.XPathSelector selector) throws net.sf.saxon.s9api.SaxonApiException
      Sets all values of all variables of this provider in the designated XPathSelector. The variables have to be declared in the corresponding XPathCompiler previously.
      Parameters:
      selector - The XPathSelector in which to set the values of all variables of this provider.
      Returns:
      The designated XPathSelector.
      Throws:
      net.sf.saxon.s9api.SaxonApiException - If the type of the value supplied does not conform to its declared type, a SaxonApiException will be thrown.
    • getVariables

      protected abstract Map<net.sf.saxon.s9api.QName,Pair<net.sf.saxon.s9api.ItemType,net.sf.saxon.s9api.OccurrenceIndicator>> getVariables()
      Gets all variables provided by this class. The type and occurrence indicator are optional. If not provided, defaults will be used.
      Returns:
      The variables to be replaced within an XPath. The variable name is required, the map values are optional. If a variable has no value in the map it will be declared with default type and occurrence indicator.
      See Also:
      • XPathCompiler.declareVariable(QName)
    • getVariableValue

      protected abstract net.sf.saxon.s9api.XdmValue getVariableValue(net.sf.saxon.s9api.QName variable)
      Gets the value of the designated variable.
      Parameters:
      variable - The variable for which to get the value.
      Returns:
      The value of the designated variable.