Class ConsumingOperand

All Implemented Interfaces:
ExportAgent, Locatable, IdentityComparable, Traceable

public class ConsumingOperand extends UnaryExpression
This expression is used as a proxy for the consuming operand of an expression such as an arithmetic expression for which there is no explicit streaming support. The actual subexpression is retained, so that it is accessible to compile time operations that walk the expression tree; but at evaluation time, the subexpression is not evaluated in the conventional (pull) way, rather its value is pushed up the tree as a consequence of template inversion. Previously (until 9.6) a SuppliedParameterReference was used for the purpose; but this caused problems with allocation of local variable slots: see bug 2320.
  • Constructor Details

    • ConsumingOperand

      public ConsumingOperand(Expression subExpression)
      Constructor
      Parameters:
      subExpression - identifies the expression for which this is a proxy.
  • Method Details

    • getOperandRole

      protected OperandRole getOperandRole()
      Get the usage (in terms of streamability analysis) of the single operand
      Specified by:
      getOperandRole in class UnaryExpression
      Returns:
      the operand usage
    • getItemType

      public ItemType getItemType()
      Determine the data type of the expression, if possible.
      Overrides:
      getItemType in class UnaryExpression
      Returns:
      Type.ITEM, because we don't know the type of the supplied value in advance.
    • getIntrinsicDependencies

      public int getIntrinsicDependencies()
      Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".
      Overrides:
      getIntrinsicDependencies in class Expression
      Returns:
      a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
    • computeCardinality

      protected int computeCardinality()
      Get the static cardinality
      Overrides:
      computeCardinality in class UnaryExpression
      Returns:
      ZERO_OR_MORE, unless we know the type of the supplied value in advance.
    • copy

      public Expression copy(RebindingMap rebindings)
      Copy an expression. This makes a deep copy.
      Specified by:
      copy in class Expression
      Parameters:
      rebindings - variables that must be re-bound
      Returns:
      the copy of the original expression
    • getImplementationMethod

      public int getImplementationMethod()
      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
    • evaluate

      public Sequence evaluate(XPathContext c) throws XPathException
      Get the value of this expression in a given context.
      Parameters:
      c - the XPathContext which contains the relevant variable bindings
      Returns:
      the value of the variable, if it is defined
      Throws:
      XPathException - if the variable is undefined
    • iterate

      public SequenceIterator iterate(XPathContext context) throws XPathException
      Get the value of this expression in a given context.
      Overrides:
      iterate in class Expression
      Parameters:
      context - the XPathContext which contains the relevant variable bindings
      Returns:
      the value of the variable, if it is defined
      Throws:
      XPathException - if the variable is undefined
    • evaluateItem

      public Item evaluateItem(XPathContext context) throws XPathException
      Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.
      Overrides:
      evaluateItem in class Expression
      Parameters:
      context - The context in which the expression is to be evaluated
      Returns:
      the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
      Throws:
      XPathException - if any dynamic error occurs evaluating the expression
    • 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 export() output displaying the expression.
    • 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
      Overrides:
      export in class UnaryExpression
      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.
    • 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 UnaryExpression
      Returns:
      a representation of the expression as a string
    • toShortString

      public String toShortString()
      Description copied from class: Expression
      Produce a short string identifying the expression for use in error messages
      Overrides:
      toShortString in class UnaryExpression
      Returns:
      a short string, sufficient to identify the expression
    • getElaborator

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