Class JAXPVariableReference

java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.xpath.JAXPVariableReference
All Implemented Interfaces:
Callable, ExportAgent, Locatable, IdentityComparable, Traceable

public class JAXPVariableReference extends Expression implements Callable
This class represents a variable in an XPath expression compiled using the JAXP XPath API. Although the class name suggests otherwise, the expression is not in fact a VariableReference; it's a custom expression which, on evaluation, calls the JAXP XPathVariableResolver to get the value of the variable.
  • Constructor Details

    • JAXPVariableReference

      public JAXPVariableReference(StructuredQName name, XPathVariableResolver resolver)
      Create the expression
      Parameters:
      name - the name of the expression
      resolver - the JAXP XPathVariableResolver
  • Method Details

    • getExpressionName

      public String getExpressionName()
      Get a name identifying the kind of expression, in terms meaningful to a user.
      Overrides:
      getExpressionName in class Expression
      Returns:
      a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.
    • copy

      public Expression copy(RebindingMap rebindings)
      Create a clone copy of this expression
      Specified by:
      copy in class Expression
      Parameters:
      rebindings - the rebinding map
      Returns:
      a copy of this expression
    • getItemType

      public ItemType getItemType()
      Determine the item type
      Specified by:
      getItemType in class Expression
      Returns:
      a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
    • computeCardinality

      protected int computeCardinality()
      Get the static cardinality
      Specified by:
      computeCardinality in class Expression
      Returns:
      the computed cardinality, as one of the values StaticProperty.ALLOWS_ZERO_OR_ONE, StaticProperty.EXACTLY_ONE, StaticProperty.ALLOWS_ONE_OR_MORE, StaticProperty.ALLOWS_ZERO_OR_MORE. May also return StaticProperty.ALLOWS_ZERO if the result is known to be an empty sequence, or StaticProperty.ALLOWS_MANY if if is known to return a sequence of length two or more.
    • computeSpecialProperties

      protected int computeSpecialProperties()
      Determine the special properties of this expression
      Overrides:
      computeSpecialProperties in class Expression
      Returns:
      the value StaticProperty.NO_NODES_NEWLY_CREATED
    • getImplementationMethod

      public int getImplementationMethod()
      Description copied from class: Expression
      An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.
      Specified by:
      getImplementationMethod in class Expression
      Returns:
      the implementation method, for example Expression.ITERATE_METHOD or Expression.EVALUATE_METHOD or Expression.PROCESS_METHOD
    • equals

      public boolean equals(Object other)
      Is this expression the same as another expression?
      Overrides:
      equals in class Expression
      Parameters:
      other - the other operand; the result is false if this is not an Expression
      Returns:
      true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.
    • computeHashCode

      protected int computeHashCode()
      get HashCode for comparing two expressions
      Overrides:
      computeHashCode in class Expression
      Returns:
      a computed hash code
    • call

      public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
      Description copied from interface: Callable
      Call the Callable.
      Specified by:
      call in interface Callable
      Parameters:
      context - the dynamic evaluation context
      arguments - the values of the arguments, supplied as Sequences.

      Generally it is advisable, if calling iterate() to process a supplied sequence, to call it only once; if the value is required more than once, it should first be converted to a GroundedValue by calling the utility method SequenceTool.toGroundedValue().

      If the expected value is a single item, the item should be obtained by calling Sequence.head(): it cannot be assumed that the item will be passed as an instance of Item or AtomicValue.

      It is the caller's responsibility to perform any type conversions required to convert arguments to the type expected by the callee. An exception is where this Callable is explicitly an argument-converting wrapper around the original Callable.

      Returns:
      the result of the evaluation, in the form of a Sequence. It is the responsibility of the callee to ensure that the type of result conforms to the expected result type.
      Throws:
      XPathException - if a dynamic error occurs during the evaluation of the expression
    • iterate

      public SequenceIterator iterate(XPathContext context) throws XPathException
      Iterate over the value of the expression
      Overrides:
      iterate in class Expression
      Parameters:
      context - supplies the context for evaluation
      Returns:
      a SequenceIterator that can be used to iterate over the result of the expression
      Throws:
      XPathException - if any dynamic error occurs evaluating the expression
    • toString

      public String toString()
      The toString() method for an expression attempts to give a representation of the expression in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath. In the case of XSLT instructions, the toString() method gives an abstracted view of the syntax
      Overrides:
      toString in class Expression
      Returns:
      a representation of the expression as a string
    • export

      public void export(ExpressionPresenter destination) throws XPathException
      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
      export in interface ExportAgent
      Specified by:
      export in class Expression
      Parameters:
      destination - the expression presenter used to display the structure
      Throws:
      XPathException - if the export fails, for example if an expression is found that won't work in the target environment.
    • getElaborator

      public Elaborator getElaborator()
      Make an elaborator for this expression
      Overrides:
      getElaborator in class Expression
      Returns:
      an appropriate Elaborator