Package net.sf.saxon.expr

## Class ConsumingOperand

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - net.sf.saxon.expr.UnaryExpression
    - - net.sf.saxon.expr.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.

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.expr.Expression

      `EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ConsumingOperand​(Expression subExpression)` | Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `computeCardinality()` | Get the static cardinality
    `Expression` | `copy​(RebindingMap rebindings)` | Copy an expression.
    `Sequence` | `evaluate​(XPathContext c)` | Get the value of this expression in a given context.
    `Item` | `evaluateItem​(XPathContext context)` | Evaluate an expression as a single item.
    `void` | `export​(ExpressionPresenter destination)` | Diagnostic print of expression structure.
    `java.lang.String` | `getExpressionName()` | Get a name identifying the kind of expression, in terms meaningful to a user.
    `int` | `getImplementationMethod()` | An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
    `int` | `getIntrinsicDependencies()` | Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.
    `ItemType` | `getItemType()` | Determine the data type of the expression, if possible.
    `protected OperandRole` | `getOperandRole()` | Get the usage (in terms of streamability analysis) of the single operand
    `SequenceIterator` | `iterate​(XPathContext context)` | Get the value of this expression in a given context.
    `java.lang.String` | `toShortString()` | Produce a short string identifying the expression for use in error messages
    `java.lang.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.

    - ### Methods inherited from class net.sf.saxon.expr.UnaryExpression

      `computeHashCode, computeSpecialProperties, displayOperator, emitExtraAttributes, equals, getBaseExpression, getOperand, operands, optimize, setBaseExpression, typeCheck`

    - ### Methods inherited from class net.sf.saxon.expr.Expression

      `addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.trace.Traceable

      `gatherProperties`

- - ### Constructor Detail

    - #### ConsumingOperand

          public ConsumingOperand​(Expression subExpression)

      Constructor
      Parameters:
        `subExpression` - identifies the expression for which this is a proxy.

  - ### Method Detail

    - #### 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

          public 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` -
      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 java.lang.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 java.lang.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 java.lang.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