Package net.sf.saxon.functions.hof
Class CoercedFunction
java.lang.Object
net.sf.saxon.functions.AbstractFunction
net.sf.saxon.functions.hof.CoercedFunction
- All Implemented Interfaces:
Callable
,FunctionItem
,GroundedValue
,Item
,Sequence
A function item obtained by coercing a supplied function; this adds a wrapper to perform dynamic
type checking of the arguments in any call, and type checking of the result.
-
Constructor Summary
ConstructorsConstructorDescriptionCoercedFunction
(FunctionItem targetFunction, SpecificFunctionType requiredType, boolean allowReducedArity) Create a CoercedFunction as a wrapper around a target functionCoercedFunction
(SpecificFunctionType requiredType) Create a CoercedFunction whose target function is not yet known (happens during package re-loading) -
Method Summary
Modifier and TypeMethodDescriptioncall
(XPathContext context, Sequence[] args) Invoke the functionvoid
Export information about this function item to the SEF fileGet the function annotations.int
getArity()
Get the arity of the functionGet a description of this function for use in error messages.Get the item type of the function itemGet the name of the function, or null if it is anonymousvoid
setTargetFunction
(FunctionItem targetFunction) Set the target functionvoid
typeCheck
(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) Type check the function (may modify it by adding code for converting the arguments)Methods inherited from class net.sf.saxon.functions.AbstractFunction
atomize, deepEqual40, deepEquals, effectiveBooleanValue, getOperandRoles, getUnicodeStringValue, isArray, isMap, isTrustedResultType, makeNewContext, simplify, toShortString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.FunctionItem
getGenre, isSequenceVariadic
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize
Methods inherited from interface net.sf.saxon.om.Item
getLength, getStringValue, head, isStreamed, itemAt, iterate, reduce, subsequence
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
CoercedFunction
public CoercedFunction(FunctionItem targetFunction, SpecificFunctionType requiredType, boolean allowReducedArity) throws XPathException Create a CoercedFunction as a wrapper around a target function- Parameters:
targetFunction
- the function to be wrapped by a type-checking layerrequiredType
- the type of the coerced function, that is the type required by the context in which the target function is being usedallowReducedArity
- true if the 4.0 rules apply: the supplied function may have lower arity than the required type- Throws:
XPathException
- if the arity of the supplied function does not match the arity of the required type
-
CoercedFunction
Create a CoercedFunction whose target function is not yet known (happens during package re-loading)- Parameters:
requiredType
- the type of the coerced function, that is the type required by the context in which the target function is being used
-
-
Method Details
-
setTargetFunction
Set the target function- Parameters:
targetFunction
- the function to be wrapped by a type-checking layer- Throws:
XPathException
- if the arity of the supplied function does not match the arity of the required type
-
typeCheck
public void typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException Type check the function (may modify it by adding code for converting the arguments)- Overrides:
typeCheck
in classAbstractFunction
- Parameters:
visitor
- the expression visitor, supplies context informationcontextItemType
- the context item type at the point where the function definition appears- Throws:
XPathException
- if type checking of the target function fails
-
getFunctionItemType
Get the item type of the function item- Returns:
- the function item's type
-
getFunctionName
Get the name of the function, or null if it is anonymous- Returns:
- null indicating that this is an anonymous inline function
-
getDescription
Get a description of this function for use in error messages. For named functions, the description is the function name (as a lexical QName). For others, it might be, for example, "inline function", or "partially-applied ends-with function".- Returns:
- a description of the function for use in error messages
-
getArity
public int getArity()Get the arity of the function- Returns:
- the number of arguments in the function signature
-
getAnnotations
Get the function annotations. These are the same as the annotations of the base function- Specified by:
getAnnotations
in interfaceFunctionItem
- Overrides:
getAnnotations
in classAbstractFunction
- Returns:
- the annotations of the base function
-
call
Invoke the function- Parameters:
context
- the XPath dynamic evaluation contextargs
- the actual arguments to be supplied- Returns:
- the result of invoking the function
- Throws:
XPathException
- if execution of the function fails
-
export
Export information about this function item to the SEF file- Specified by:
export
in interfaceFunctionItem
- Overrides:
export
in classAbstractFunction
- Parameters:
out
- the SEF output destination- Throws:
XPathException
- if things go wrong
-