Package net.sf.saxon.expr

## Class Operand

- java.lang.Object
- - net.sf.saxon.expr.Operand

- All Implemented Interfaces:
    `java.lang.Iterable<Operand>`, `ExpressionOwner`

      public final class Operand
      extends java.lang.Object
      implements java.lang.Iterable<Operand>, ExpressionOwner

  Information about a sub-expression and its relationship to the parent expression

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Operand​(Expression parentExpression, Expression childExpression, OperandRole role)` | Create an operand object

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `detachChild()` |
    `Expression` | `getChildExpression()` | Get the expression used as the actual operand
    `OperandRole` | `getOperandRole()` | Get the operand role
    `Expression` | `getParentExpression()` | Get the parent expression of this operand
    `SequenceType` | `getRequiredType()` | Get the required type of the operand
    `OperandUsage` | `getUsage()` | Get the usage of the operand
    `boolean` | `hasSameFocus()` | Ask whether the child expression is evaluated with the same focus as its parent expression
    `boolean` | `hasSpecialFocusRules()` |
    `boolean` | `isEvaluatedRepeatedly()` | Ask whether the operand is is evaluated repeatedly during a single evaluation of the parent expression.
    `boolean` | `isHigherOrder()` | Ask whether the operand is a higher-order operand,: typically this means that the child expression is evaluated repeatedly during a single evaluation of the parent expression (but there are some cases like xsl:for-each select=".." where the operand is higher-order despite not being evaluated repeatedly).
    `boolean` | `isInChoiceGroup()` | Ask whether the operand is a member of a choice group
    `java.util.Iterator<Operand>` | `iterator()` | Get a singleton iterator that returns this operand only
    `void` | `optimize​(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)` |
    `void` | `setChildExpression​(Expression childExpression)` | Change the child expression used for this operand.
    `void` | `setOperandRole​(OperandRole role)` | Set the operand role
    `boolean` | `setsNewFocus()` | Ask whether the child expression sets a new focus for evaluation of other operands
    `void` | `setUsage​(OperandUsage usage)` | Set the usage of the operand
    `void` | `typeCheck​(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)` |
    `static OperandUsage` | `typeDeterminedUsage​(ItemType type)` |

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### Operand

          public Operand​(Expression parentExpression,
                         Expression childExpression,
                         OperandRole role)

      Create an operand object
      Parameters:
        `parentExpression` - the expression of which this is an operand
        `childExpression` - the actual expression used as the operand
        `role` - information about the role this operand plays within the parent expression

  - ### Method Detail

    - #### getParentExpression

          public Expression getParentExpression()

      Get the parent expression of this operand
      Returns:
        the parent expression

    - #### getChildExpression

          public Expression getChildExpression()

      Get the expression used as the actual operand
      Specified by:
        `getChildExpression` in interface `ExpressionOwner`
      Returns:
        the child expression

    - #### setChildExpression

          public void setChildExpression​(Expression childExpression)

      Change the child expression used for this operand. This is the only approved way of making structural changes to the expression tree, and the implementation of this method is responsible for maintaining the consistency of the tree
      Specified by:
        `setChildExpression` in interface `ExpressionOwner`
      Parameters:
        `childExpression` - the new child expression

    - #### detachChild

          public void detachChild()

    - #### getOperandRole

          public OperandRole getOperandRole()

      Get the operand role
      Returns:
        the operand role

    - #### setOperandRole

          public void setOperandRole​(OperandRole role)

      Set the operand role
      Parameters:
        `role` - the operand role

    - #### setsNewFocus

          public boolean setsNewFocus()

      Ask whether the child expression sets a new focus for evaluation of other operands
      Returns:
        true if the child expression is evaluated with the same focus as its parent expression

    - #### hasSpecialFocusRules

          public boolean hasSpecialFocusRules()

    - #### hasSameFocus

          public boolean hasSameFocus()

      Ask whether the child expression is evaluated with the same focus as its parent expression
      Returns:
        true if the child expression is evaluated with the same focus as its parent expression

    - #### isHigherOrder

          public boolean isHigherOrder()

      Ask whether the operand is a higher-order operand,: typically this means that the child expression is evaluated repeatedly during a single evaluation of the parent expression (but there are some cases like xsl:for-each select=".." where the operand is higher-order despite not being evaluated repeatedly).
      Returns:
        true if the operand is higher-order

    - #### isEvaluatedRepeatedly

          public boolean isEvaluatedRepeatedly()

      Ask whether the operand is is evaluated repeatedly during a single evaluation of the parent expression. This is true if the operand is higher-order and the operand does not have the `OperandRole.SINGLETON` property.
      Returns:
        true if the operand is higher-order

    - #### getUsage

          public OperandUsage getUsage()

      Get the usage of the operand
      Returns:
        the usage

    - #### setUsage

          public void setUsage​(OperandUsage usage)

      Set the usage of the operand
      Parameters:
        `usage` - the operand usage

    - #### getRequiredType

          public SequenceType getRequiredType()

      Get the required type of the operand
      Returns:
        the required type

    - #### isInChoiceGroup

          public boolean isInChoiceGroup()

      Ask whether the operand is a member of a choice group
      Returns:
        true if the operand is in a choice group

    - #### iterator

          public java.util.Iterator<Operand> iterator()

      Get a singleton iterator that returns this operand only
      Specified by:
        `iterator` in interface `java.lang.Iterable<Operand>`
      Returns:
        a singleton iterator

    - #### typeCheck

          public void typeCheck​(ExpressionVisitor visitor,
                                ContextItemStaticInfo contextInfo)
                         throws XPathException

      Throws:
        `XPathException`

    - #### optimize

          public void optimize​(ExpressionVisitor visitor,
                               ContextItemStaticInfo contextInfo)
                        throws XPathException

      Throws:
        `XPathException`

    - #### typeDeterminedUsage

          public static OperandUsage typeDeterminedUsage​(ItemType type)