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 voiddetachChild()ExpressiongetChildExpression()Get the expression used as the actual operandOperandRolegetOperandRole()Get the operand roleExpressiongetParentExpression()Get the parent expression of this operandSequenceTypegetRequiredType()Get the required type of the operandOperandUsagegetUsage()Get the usage of the operandbooleanhasSameFocus()Ask whether the child expression is evaluated with the same focus as its parent expressionbooleanhasSpecialFocusRules()booleanisEvaluatedRepeatedly()Ask whether the operand is is evaluated repeatedly during a single evaluation of the parent expression.booleanisHigherOrder()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).booleanisInChoiceGroup()Ask whether the operand is a member of a choice groupjava.util.Iterator<Operand>iterator()Get a singleton iterator that returns this operand onlyvoidoptimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)voidsetChildExpression(Expression childExpression)Change the child expression used for this operand.voidsetOperandRole(OperandRole role)Set the operand rolebooleansetsNewFocus()Ask whether the child expression sets a new focus for evaluation of other operandsvoidsetUsage(OperandUsage usage)Set the usage of the operandvoidtypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)static OperandUsagetypeDeterminedUsage(ItemType type)
-
-
-
Constructor Detail
-
Operand
public Operand(Expression parentExpression, Expression childExpression, OperandRole role)
Create an operand object- Parameters:
parentExpression- the expression of which this is an operandchildExpression- the actual expression used as the operandrole- 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:
getChildExpressionin interfaceExpressionOwner- 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:
setChildExpressionin interfaceExpressionOwner- 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 theOperandRole.SINGLETONproperty.- 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:
iteratorin interfacejava.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)
-
-