Class TupleExpression
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.flwor.TupleExpression
-
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
public class TupleExpression extends Expression
A tuple expression is an expression that returns a FLWOR tuple. Specifically, it is a list local variables references; it returns a Tuple item containing the current value of these variables.
-
-
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 TupleExpression()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
computeCardinality()
Get the cardinality of the expression.protected int
computeHashCode()
Hashcode supporting equals()Expression
copy(RebindingMap rebindings)
Copy an expression.boolean
equals(java.lang.Object other)
Is this expression the same as another expression?Tuple
evaluateItem(XPathContext context)
Evaluate an expression as a single item.void
export(ExpressionPresenter out)
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 static item type of the expression, as precisely possible.protected OperandArray
getOperanda()
Get the data structure holding the operands of this expression.int
getSize()
LocalVariableReference
getSlot(int i)
boolean
includesBinding(Binding binding)
java.lang.Iterable<Operand>
operands()
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.void
setCurrentTuple(XPathContext context, Tuple tuple)
Set the local variables in the current stack frame to values corresponding to a supplied tupleprotected void
setOperanda(OperandArray operanda)
Set the data structure for the operands of this expression.void
setSlot(int i, LocalVariableReference ref)
void
setVariables(java.util.List<LocalVariableReference> refs)
Expression
typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)
Perform type checking of an expression and its subexpressions.-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeSpecialProperties, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, evaluateAsString, explain, getCardinality, getConfiguration, getCost, getDependencies, getElaborator, getEvaluationMethod, getExtraProperty, getIntegerBounds, 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, iterate, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimize, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toShortString, toString, typeCheckChildren, typeError, unordered, verifyParentPointers, withLocation
-
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
-
-
-
-
Method Detail
-
setOperanda
protected void setOperanda(OperandArray operanda)
Set the data structure for the operands of this expression. This must be created during initialisation of the expression and must not be subsequently changed- Parameters:
operanda
- the data structure for expression operands
-
getOperanda
protected OperandArray getOperanda()
Get the data structure holding the operands of this expression.- Returns:
- the data structure holding expression operands
-
operands
public java.lang.Iterable<Operand> operands()
Description copied from class:Expression
Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.
- Overrides:
operands
in classExpression
- Returns:
- an iterator containing the sub-expressions of this expression
-
setVariables
public void setVariables(java.util.List<LocalVariableReference> refs)
-
getSize
public int getSize()
-
getSlot
public LocalVariableReference getSlot(int i)
-
setSlot
public void setSlot(int i, LocalVariableReference ref)
-
includesBinding
public boolean includesBinding(Binding binding)
-
getItemType
public ItemType getItemType()
Description copied from class:Expression
Determine the static item type of the expression, as precisely possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.This method should always return a result, though it may be the best approximation that is available at the time.
- Specified by:
getItemType
in classExpression
- Returns:
- a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
Description copied from class:Expression
Perform type checking of an expression and its subexpressions. This is the second phase of static optimization.This checks statically that the operands of the expression have the correct type; if necessary it generates code to do run-time type checking or type conversion. A static type error is reported only if execution cannot possibly succeed, that is, if a run-time type error is inevitable. The call may return a modified form of the expression.
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable. However, the types of such functions and variables may not be accurately known if they have not been explicitly declared.
- Overrides:
typeCheck
in classExpression
- Parameters:
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- Returns:
- the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
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 classExpression
- Returns:
- the implementation method, for example
Expression.ITERATE_METHOD
orExpression.EVALUATE_METHOD
orExpression.PROCESS_METHOD
-
equals
public boolean equals(java.lang.Object other)
Is this expression the same as another expression?- Overrides:
equals
in classExpression
- Parameters:
other
- the expression to be compared with this one- Returns:
- true if the two expressions are statically equivalent
-
computeHashCode
protected int computeHashCode()
Hashcode supporting equals()- Overrides:
computeHashCode
in classExpression
- Returns:
- a computed hash code
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
- the rebinding map- Returns:
- the copy of the original expression
-
export
public void export(ExpressionPresenter out) throws XPathException
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Specified by:
export
in classExpression
- Parameters:
out
- 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.
-
evaluateItem
public Tuple evaluateItem(XPathContext context) throws XPathException
Description copied from class:Expression
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 classExpression
- 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 classExpression
- 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.
-
setCurrentTuple
public void setCurrentTuple(XPathContext context, Tuple tuple) throws XPathException
Set the local variables in the current stack frame to values corresponding to a supplied tuple- Parameters:
context
- identifies the stack frame to be modifiedtuple
- the tuple containing the current values- Throws:
XPathException
- if any error occurs
-
computeCardinality
protected int computeCardinality()
Get the cardinality of the expression. This is exactly one, in the sense that evaluating the TupleExpression returns a single tuple.- Specified by:
computeCardinality
in classExpression
- Returns:
- the static cardinality - EXACTLY_ONE
-
getIntrinsicDependencies
public int getIntrinsicDependencies()
Description copied from class:Expression
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 classExpression
- Returns:
- an integer containing bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
-