net.sf.saxon.instruct
public class UserFunction extends Procedure
It is assumed that type-checking, of both the arguments and the results, has been handled at compile time. That is, the expression supplied as the body of the function must be wrapped in code to check or convert the result to the required type, and calls on the function must be wrapped at compile time to check or convert the supplied arguments.
Field Summary | |
---|---|
protected int | evaluationMode |
Constructor Summary | |
---|---|
UserFunction()
Create a user-defined function (the body must be added later) |
Method Summary | |
---|---|
ValueRepresentation | call(ValueRepresentation[] actualArgs, XPathContextMajor context)
Call this function to return a value. |
ValueRepresentation | call(ValueRepresentation[] actualArgs, Controller controller)
Call this function. |
void | callUpdating(ValueRepresentation[] actualArgs, XPathContextMajor context, PendingUpdateList pul)
Call an updating function. |
void | computeEvaluationMode()
Determine the preferred evaluation mode for this function |
boolean | containsTailCalls()
Determine whether the function contains tail calls (on this or other functions) |
void | gatherDirectContributingCallees(Set result)
Gather the direct contributing callees of this function. |
SequenceType | getArgumentType(int n)
Get the required types of an argument to this function |
int | getConstructType()
Get the type of construct. |
SequenceType | getDeclaredResultType()
Get the declared result type |
int | getEvaluationMode()
Get the evaluation mode. |
StructuredQName | getFunctionName()
Get the function name |
int | getNumberOfArguments()
Get the arity of this function |
StructuredQName | getObjectName()
Get a name identifying the object of the expression, for example a function name, template name,
variable name, key name, element name, etc. |
UserFunctionParameter[] | getParameterDefinitions()
Get the definitions of the declared parameters for this function |
SequenceType | getResultType(TypeHierarchy th)
Get the type of value returned by this function |
boolean | isMemoFunction()
Ask whether this function is a memo function |
boolean | isTailRecursive()
Determine whether the function contains a tail call, calling itself |
boolean | isUpdating()
Ask whether this is an updating function (as defined in XQuery Update) |
EventIterator | iterateEvents(ValueRepresentation[] actualArgs, XPathContextMajor context)
Call this function in "pull" mode, returning the results as a sequence of PullEvents. |
void | process(ValueRepresentation[] actualArgs, XPathContextMajor context)
Call this function in "push" mode, writing the results to the current output destination. |
void | setFunctionName(StructuredQName name)
Set the function name |
void | setParameterDefinitions(UserFunctionParameter[] params)
Set the definitions of the declared parameters for this function |
void | setResultType(SequenceType resultType)
Set the declared result type of the function |
void | setTailRecursive(boolean tailCalls, boolean recursiveTailCalls)
Indicate whether the function contains a tail call |
void | setUpdating(boolean isUpdating)
Set whether this is an updating function (as defined in XQuery Update) |
Parameters: actualArgs the arguments supplied to the function. These must have the correct types required by the function signature (it is the caller's responsibility to check this). It is acceptable to supply a Closure to represent a value whose evaluation will be delayed until it is needed. The array must be the correct size to match the number of arguments: again, it is the caller's responsibility to check this. context This provides the run-time context for evaluating the function. It is the caller's responsibility to allocate a "clean" context for the function to use; the context that is provided will be overwritten by the function.
Returns: a Value representing the result of the function.
Parameters: actualArgs the arguments supplied to the function. These must have the correct types required by the function signature (it is the caller's responsibility to check this). It is acceptable to supply a Closure to represent a value whose evaluation will be delayed until it is needed. The array must be the correct size to match the number of arguments: again, it is the caller's responsibility to check this. controller This provides the run-time context for evaluating the function. A Controller may be obtained by calling XQueryExpression. This may be used for a series of calls on functions defined in the same module as the XQueryExpression.
Returns: a Value representing the result of the function.
Parameters: actualArgs the arguments supplied to the function. These must have the correct types required by the function signature (it is the caller's responsibility to check this). It is acceptable to supply a Closure to represent a value whose evaluation will be delayed until it is needed. The array must be the correct size to match the number of arguments: again, it is the caller's responsibility to check this. context the dynamic evaluation context pul the pending updates list, to which the function's update actions are to be added.
Returns: true if the function contains tail calls
Parameters: result the list into which the callees are gathered.
Parameters: n identifies the argument in question, starting at 0
Returns: a SequenceType object, indicating the required type of the argument
Returns: the declared result type
Returns: the computed evaluation mode
Returns: the function name, as a StructuredQName
Returns: the number of arguments
Returns: an array of parameter definitions
Parameters: th the type hierarchy cache
Returns: the declared result type, or the inferred result type if this is more precise
Returns: false (overridden in a subclass)
Returns: true if the function contains a directly-recursive tail call
Returns: true if this is an updating function
Parameters: actualArgs the arguments supplied to the function. These must have the correct types required by the function signature (it is the caller's responsibility to check this). It is acceptable to supply a Closure to represent a value whose evaluation will be delayed until it is needed. The array must be the correct size to match the number of arguments: again, it is the caller's responsibility to check this. context This provides the run-time context for evaluating the function. It is the caller's responsibility to allocate a "clean" context for the function to use; the context that is provided will be overwritten by the function.
Returns: an iterator over the results of the function call
Parameters: actualArgs the arguments supplied to the function. These must have the correct types required by the function signature (it is the caller's responsibility to check this). It is acceptable to supply a Closure to represent a value whose evaluation will be delayed until it is needed. The array must be the correct size to match the number of arguments: again, it is the caller's responsibility to check this. context This provides the run-time context for evaluating the function. It is the caller's responsibility to allocate a "clean" context for the function to use; the context that is provided will be overwritten by the function.
Parameters: name the function name
Parameters: params an array of parameter definitions
Parameters: resultType the declared return type
Parameters: tailCalls true if the function contains a tail call (on any function) recursiveTailCalls true if the function contains a tail call (on itself)
Parameters: isUpdating true if this is an updating function