Package net.sf.saxon.expr
Class DraftFunctionCall
java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.expr.DraftExpression
net.sf.saxon.expr.DraftFunctionCall
- All Implemented Interfaces:
ExportAgent,Locatable,IdentityComparable,Traceable
This class represents a call to a function in its raw lexical form, before it has been resolved to an
actual function. Used in XQuery only, where function references can be forwards references to functions not
yet declared.
-
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, UPDATE_METHOD, WATCH_METHOD -
Constructor Summary
ConstructorsConstructorDescriptionDraftFunctionCall(String lexicalName, QueryModule queryModule, Expression[] arguments, Map<StructuredQName, Integer> keywordArgs) Create a function call to a user-written function in a query -
Method Summary
Modifier and TypeMethodDescriptionprotected intDetermine the cardinality of the resultcopy(RebindingMap rebindings) Copy an expression.Call the function, returning the value as an item.voidDiagnostic print of expression structure.Make an elaborator for this expressionGet a name identifying the kind of expression, in terms meaningful to a user.intAn implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().intDetermine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.booleanDetermine whether this is an updating expression as defined in the XQuery update specificationCall the function, returning an iterator over the results.operands()Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.voidprocess(Outputter output, XPathContext context) Process the function call in push modesimplify()Thesimplifymethod applied to a DraftFunctionCall when the entire query has been parsed, so all user-defined functions are now known, enabling the name to be resolved.Methods inherited from class net.sf.saxon.expr.DraftExpression
computeSpecialProperties, getItemType, getStaticType, getStaticUTypeMethods inherited from class net.sf.saxon.expr.Expression
adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeHashCode, computeStaticProperties, dispatchTailCall, dynamicError, effectiveBooleanValue, equals, evaluateAsString, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isVacuousExpression, makeElaborator, markTailFunctionCalls, operandList, operandSparseList, optimize, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, supportsLazyEvaluation, suppressValidation, toPattern, toShortString, toString, typeCheck, typeCheckChildren, typeError, unordered, verifyParentPointers, warning, withLocationMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
Constructor Details
-
DraftFunctionCall
public DraftFunctionCall(String lexicalName, QueryModule queryModule, Expression[] arguments, Map<StructuredQName, Integer> keywordArgs) Create a function call to a user-written function in a query- Parameters:
lexicalName- The name of the function as written in the source queryqueryModule- The query module containing the function definitionarguments- The argument expressions, in order, representing any "?" place marker by a PlaceHolder pseudo-expressionkeywordArgs- Mapping from argument keywords (where used) to the zero-based position where the keyword is used
-
-
Method Details
-
operands
Description copied from class:ExpressionGet 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:
operandsin classExpression- Returns:
- an iterator containing the sub-expressions of this expression
-
getIntrinsicDependencies
public int getIntrinsicDependencies()Description copied from class:ExpressionDetermine 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:
getIntrinsicDependenciesin classExpression- Returns:
- an integer containing bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
isUpdatingExpression
public boolean isUpdatingExpression()Determine whether this is an updating expression as defined in the XQuery update specification- Overrides:
isUpdatingExpressionin classExpression- Returns:
- true if this is an updating expression
-
copy
Copy an expression. This makes a deep copy.- Specified by:
copyin classExpression- Parameters:
rebindings- variable bindings that need to be changed- Returns:
- the copy of the original expression
-
computeCardinality
protected int computeCardinality()Determine the cardinality of the result- Specified by:
computeCardinalityin classExpression- Returns:
- the computed cardinality, as one of the values
StaticProperty.ALLOWS_ZERO_OR_ONE,StaticProperty.EXACTLY_ONE,StaticProperty.ALLOWS_ONE_OR_MORE,StaticProperty.ALLOWS_ZERO_OR_MORE. May also returnStaticProperty.ALLOWS_ZEROif the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANYif if is known to return a sequence of length two or more.
-
evaluateItem
Call the function, returning the value as an item. This method will be used only when the cardinality is zero or one. If the function is tail recursive, it returns an Object representing the arguments to the next (recursive) call- Overrides:
evaluateItemin classExpression- Parameters:
c- 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
-
iterate
Call the function, returning an iterator over the results. (But if the function is tail recursive, it returns an iterator over the arguments of the recursive call)- Overrides:
iteratein classExpression- Parameters:
c- supplies the context for evaluation- Returns:
- a SequenceIterator that can be used to iterate over the result of the expression
- Throws:
XPathException- if any dynamic error occurs evaluating the expression
-
process
Process the function call in push mode- Overrides:
processin classExpression- Parameters:
output- the destination for the resultcontext- the XPath dynamic context- Throws:
XPathException- if a dynamic error occurs
-
export
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
exportin interfaceExportAgent- Specified by:
exportin 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.
-
getExpressionName
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionNamein 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 explain() output displaying the expression.
-
getImplementationMethod
public int getImplementationMethod()Description copied from class:ExpressionAn 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:
getImplementationMethodin classExpression- Returns:
- the implementation method, for example
Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
-
getElaborator
Description copied from class:ExpressionMake an elaborator for this expression- Overrides:
getElaboratorin classExpression- Returns:
- an appropriate
Elaborator
-
simplify
Thesimplifymethod applied to a DraftFunctionCall when the entire query has been parsed, so all user-defined functions are now known, enabling the name to be resolved. As well as locating the target function, keyword arguments can be resolved to positional arguments.- Overrides:
simplifyin classExpression- Returns:
- either a FunctionCall or a CurriedFunction
- Throws:
XPathException- if resolution fails
-