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.
Modifier and Type | Field and Description |
---|---|
protected int |
evaluationMode |
Constructor and Description |
---|
UserFunction()
Create a user-defined function (the body must be added later)
|
Modifier and Type | Method and Description |
---|---|
Callable |
asCallable() |
Sequence |
call(Sequence[] actualArgs,
Controller controller)
Call this function.
|
Sequence |
call(XPathContextMajor context,
Sequence[] actualArgs)
Call this function to return a value.
|
void |
callUpdating(Sequence[] 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)
|
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
|
FunctionItemType |
getFunctionType()
Get the type of the function
|
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 |
isInlineable()
Ask whether the function can be inlined
|
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(Sequence[] actualArgs,
XPathContextMajor context)
Call this function in "pull" mode, returning the results as a sequence of PullEvents.
|
void |
process(Sequence[] actualArgs,
XPathContextMajor context)
Call this function in "push" mode, writing the results to the current output destination.
|
void |
setAnnotationMap(Map<StructuredQName,Annotation> map)
Supply a set of annotations
|
void |
setFunctionName(StructuredQName name)
Set the function name
|
void |
setInlineable(boolean inlineable)
Say whether this function can be inlined
|
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)
|
getBody, getColumnNumber, getColumnNumber, getContainerGranularity, getExecutable, getHostLanguage, getLineNumber, getLineNumber, getLocationProvider, getProperties, getProperty, getPublicId, getStackFrameMap, getSystemId, getSystemId, setBody, setExecutable, setHostLanguage, setLineNumber, setStackFrameMap, setSystemId
public UserFunction()
public void setFunctionName(StructuredQName name)
name
- the function namepublic StructuredQName getFunctionName()
public StructuredQName getObjectName()
public FunctionItemType getFunctionType()
public Callable asCallable()
public void setAnnotationMap(Map<StructuredQName,Annotation> map)
map
- the new set of annotations, which will replace any previous annotations on the functionpublic void computeEvaluationMode()
public Boolean isInlineable()
public void setInlineable(boolean inlineable)
inlineable
- true or falsepublic void setParameterDefinitions(UserFunctionParameter[] params)
params
- an array of parameter definitionspublic UserFunctionParameter[] getParameterDefinitions()
public void setResultType(SequenceType resultType)
resultType
- the declared return typepublic void setTailRecursive(boolean tailCalls, boolean recursiveTailCalls)
tailCalls
- true if the function contains a tail call (on any function)recursiveTailCalls
- true if the function contains a tail call (on itself)public boolean containsTailCalls()
public boolean isTailRecursive()
public void setUpdating(boolean isUpdating)
isUpdating
- true if this is an updating functionpublic boolean isUpdating()
public SequenceType getResultType(TypeHierarchy th)
th
- the type hierarchy cachepublic SequenceType getDeclaredResultType()
public SequenceType getArgumentType(int n)
n
- identifies the argument in question, starting at 0public int getEvaluationMode()
public int getNumberOfArguments()
public boolean isMemoFunction()
public Sequence call(XPathContextMajor context, Sequence[] actualArgs) throws XPathException
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.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.XPathException
- if a dynamic error occurs while evaluating the functionpublic void process(Sequence[] actualArgs, XPathContextMajor context) throws XPathException
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.XPathException
- if a dynamic error occurs while evaluating the functionpublic EventIterator iterateEvents(Sequence[] actualArgs, XPathContextMajor context) throws XPathException
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.XPathException
- if a dynamic error occurs while evaluating the functionpublic Sequence call(Sequence[] actualArgs, Controller controller) throws XPathException
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.newController()
. This may
be used for a series of calls on functions defined in the same module as the XQueryExpression.XPathException
- if a dynamic error occurs while evaluating the function.public void callUpdating(Sequence[] actualArgs, XPathContextMajor context, PendingUpdateList pul) throws XPathException
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 contextpul
- the pending updates list, to which the function's update actions are to be added.XPathException
- if a dynamic error occurs while evaluating the function.public int getConstructType()
StandardNames
: all less than 1024)
or it will be a constant in class Location
.Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.