public class FLWORExpression extends Expression
Modifier and Type | Field and Description |
---|---|
List<Clause> |
clauses |
Expression |
returnClause |
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, WATCH_METHOD
Constructor and Description |
---|
FLWORExpression(List<Clause> clauses,
Expression returnClause) |
Modifier and Type | Method and Description |
---|---|
void |
checkForUpdatingSubexpressions()
Check to ensure that this expression does not contain any inappropriate updating subexpressions.
|
protected int |
computeCardinality()
Compute the static cardinality of this expression
|
Expression |
copy()
Copy an expression.
|
void |
evaluatePendingUpdates(XPathContext context,
PendingUpdateList pul)
Evaluate an updating expression, adding the results to a Pending Update List.
|
void |
explain(ExpressionPresenter out)
Diagnostic print of expression structure.
|
List<Clause> |
getClauseList()
Get the list of clauses of the FLWOR expression, in the order they are written.
|
int |
getEvaluationMethod() |
ExpressionCompiler |
getExpressionCompiler()
Return the compiler of the FLWOR expression
|
ItemType |
getItemType()
Determine the data type of the items returned by the expression.
|
Expression |
getReturnClause()
Get the return clause of the FLWOR expression
|
boolean |
hasLoopingVariableReference(Binding binding)
Determine whether a variable reference found within a clause of a FLWOR expression is a looping
reference, that is, whether the variable is used more than once
|
boolean |
hasVariableBinding(Binding binding)
Determine whether a given variable binding belongs to this FLWOR expression
|
boolean |
implementsStaticTypeCheck()
Determine whether this expression implements its own method for static type checking
|
boolean |
isUpdatingExpression()
Determine whether this is an updating expression as defined in the XQuery update specification
|
SequenceIterator |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence.
|
Iterable<Operand> |
operands()
Get the immediate sub-expressions of this expression, with information about the relationship
of each expression to its parent expression.
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Perform optimisation of an expression and its subexpressions.
|
void |
process(XPathContext context)
Process the instruction, without returning any tail calls
|
Expression |
promote(PromotionOffer offer,
Expression parent)
Promote this expression if possible
|
boolean |
replaceOperand(Expression original,
Expression replacement)
Replace one subexpression by a replacement subexpression
|
Expression |
simplify(ExpressionVisitor visitor)
Simplify an expression.
|
Expression |
staticTypeCheck(SequenceType req,
boolean backwardsCompatible,
RoleLocator role,
TypeCheckerEnvironment visitor)
Static type checking for let expressions is delegated to the expression itself,
and is performed on the "return" expression, to allow further delegation to the branches
of a conditional
|
String |
toString()
Display the expression as a string
|
Expression |
typeCheck(ExpressionVisitor visitor,
ContextItemStaticInfo contextInfo)
Perform type checking of an expression and its subexpressions.
|
Expression |
unordered(boolean retainAllNodes,
boolean forStreaming)
Replace this expression by a simpler expression that delivers the results without regard
to order.
|
addToPathMap, adoptChildExpression, checkPermittedContents, clearStreamabilityData, computeDependencies, computeSpecialProperties, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, getCardinality, getColumnNumber, getConfiguration, getConstructType, getContainer, getDependencies, getExpressionName, getHostLanguage, getImplementationMethod, getIntegerBounds, getIntrinsicDependencies, getLineNumber, getLocationId, getObjectName, getPosture, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getStreamability, getStreamingAdjunct, getSweep, getSystemId, identityHashCode, isIdentical, isSubtreeExpression, isVacuousExpression, iterateEvents, makeStreamingAdjunct, markTailFunctionCalls, operandList, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, setPostureAndSweep, suppressValidation, toPattern, toShortString, toStreamingPattern, typeError
public Expression returnClause
public FLWORExpression(List<Clause> clauses, Expression returnClause)
public List<Clause> getClauseList()
public Expression getReturnClause()
public boolean hasVariableBinding(Binding binding)
hasVariableBinding
in class Expression
binding
- the binding being soughtpublic Expression simplify(ExpressionVisitor visitor) throws XPathException
simplify
in class Expression
visitor
- an expression visitorXPathException
- if an error is discovered during expression
rewritingpublic Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
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.
If the implementation returns a value other than "this", then it is required to ensure that the location information in the returned expression have been set up correctly. It should not rely on the caller to do this, although for historical reasons many callers do so.
param visitor an expression visitortypeCheck
in class Expression
contextInfo
- visitor
- an expression visitorXPathException
- if an error is discovered during this phase
(typically a type error)public boolean implementsStaticTypeCheck()
implementsStaticTypeCheck
in class Expression
public Expression staticTypeCheck(SequenceType req, boolean backwardsCompatible, RoleLocator role, TypeCheckerEnvironment visitor) throws XPathException
staticTypeCheck
in class Expression
req
- the required typebackwardsCompatible
- true if backwards compatibility mode appliesrole
- the role of the expression in relation to the required typevisitor
- an expression visitorXPathException
- if failures occur, for example if the static type of one branch of the conditional
is incompatible with the required typepublic ItemType getItemType()
getItemType
in class Expression
protected int computeCardinality()
computeCardinality
in class Expression
StaticProperty.ALLOWS_ZERO_OR_ONE
,
StaticProperty.EXACTLY_ONE
, StaticProperty.ALLOWS_ONE_OR_MORE
,
StaticProperty.ALLOWS_ZERO_OR_MORE
public Iterable<Operand> operands()
operands
in class Expression
public void checkForUpdatingSubexpressions() throws XPathException
checkForUpdatingSubexpressions
in class Expression
XPathException
- if the expression has a non-permitted updateing subexpressionpublic boolean isUpdatingExpression()
isUpdatingExpression
in class Expression
public boolean replaceOperand(Expression original, Expression replacement)
replaceOperand
in class Expression
original
- the original subexpressionreplacement
- the replacement subexpressionpublic void explain(ExpressionPresenter out)
explain
in class Expression
out
- the expression presenter used to display the structurepublic Expression copy()
copy
in class Expression
public Expression promote(PromotionOffer offer, Expression parent) throws XPathException
promote
in class Expression
offer
- details of the offer, for example the offer to move
expressions that don't depend on the context to an outer level in
the containing expressionparent
- the containing expression in the expression treeXPathException
- if any error is detectedpublic Expression unordered(boolean retainAllNodes, boolean forStreaming) throws XPathException
unordered
in class Expression
retainAllNodes
- set to true if the result must contain exactly the same nodes as the
original; set to false if the result can eliminate (or introduce) duplicates.forStreaming
- set to true if optimizing for streamingXPathException
- if the rewrite failspublic int getEvaluationMethod()
getEvaluationMethod
in class Expression
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
Expression
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
optimize
in class Expression
visitor
- an expression visitorcontextItemType
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public SequenceIterator iterate(XPathContext context) throws XPathException
iterate
in class Expression
context
- supplies the context for evaluationXPathException
- if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext context) throws XPathException
process
in class Expression
context
- The dynamic context, giving access to the current node,
the current variables, etc.XPathException
- if a dynamic error occurspublic void evaluatePendingUpdates(XPathContext context, PendingUpdateList pul) throws XPathException
evaluatePendingUpdates
in class Expression
context
- the XPath dynamic evaluation contextpul
- the pending update list to which the results should be writtenXPathException
- if evaluation failsUnsupportedOperationException
- if the expression is not an updating expressionpublic String toString()
toString
in class Expression
public boolean hasLoopingVariableReference(Binding binding)
binding
- the variable binding, which may be bound in a clause of the same FLWOR expression,
or in some containing expressionpublic ExpressionCompiler getExpressionCompiler()
getExpressionCompiler
in class Expression
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.