Class 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 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
      • 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
        Perform type-checking on the child expression. This may cause the child expression to be replaced with a different child expression.
        Parameters:
        visitor - the expression visitor
        contextInfo - information about the static context
        Throws:
        XPathException - if type checking fails
      • optimize

        public void optimize​(ExpressionVisitor visitor,
                             ContextItemStaticInfo contextInfo)
                      throws XPathException
        Perform optimization on the child expression. This may cause the child expression to be replaced with a different child expression.
        Parameters:
        visitor - the expression visitor
        contextInfo - information about the static context
        Throws:
        XPathException - if optimization fails
      • typeDeterminedUsage

        public static OperandUsage typeDeterminedUsage​(ItemType type)
        Get the type-determined usage of the operand, as defined in the XSLT 3.0 streaming spec
        Parameters:
        type - the type required by the context in which the expression appears
        Returns:
        the type-determined usage