Package net.sf.saxon.functions
Class ContextItemAccessorFunction
java.lang.Object
net.sf.saxon.functions.AbstractFunction
net.sf.saxon.functions.SystemFunction
net.sf.saxon.functions.ContextAccessorFunction
net.sf.saxon.functions.ContextItemAccessorFunction
- All Implemented Interfaces:
Callable
,FunctionItem
,GroundedValue
,Item
,Sequence
- Direct Known Subclasses:
ContextItemAccessorFunction.Number_0
,ContextItemAccessorFunction.StringAccessor
A ContextItemAccessorFunction is a function that takes no arguments, but operates implicitly on the
context item. In the case of a dynamic call, the context item that is used is the one at the point
where the function item is created.
Because these functions depend on the context only, with no additional arguments, the function can
be evaluated as soon as the context is bound. The function is therefore replaced at this stage with a
constant function, that is, one that always returns the same value.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Subclass of ContextItemAccessorFunction to handle number().static class
Subclass of ContextItemAccessorFunction to handle string-length() and normalize-space(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbindContext
(XPathContext context) Bind a context item to appear as part of the function's closure.call
(XPathContext context, Sequence[] arguments) Evaluate the expression.evaluate
(Item item, XPathContext context) Evaluate the function.Create a system function call on this function in which the context item is supplied as an explicit argumentmakeFunctionCall
(Expression[] arguments) Make a static call on this function, with specified arguments.Methods inherited from class net.sf.saxon.functions.SystemFunction
dependsOnContextItem, dynamicCall, equals, export, exportAdditionalArguments, exportAttributes, fixArguments, getArity, getCardinality, getContextNode, getDescription, getDetails, getElaborator, getErrorCodeForTypeErrors, getFunctionItemType, getFunctionName, getIntegerBounds, getNetCost, getOperandRoles, getRequiredType, getResultItemType, getResultItemType, getRetainedStaticContext, getSpecialProperties, getStaticBaseUriString, getStreamerName, getUniStringArg, hashCode, importAttributes, isSequenceVariadic, isTrustedResultType, makeCall, makeFunction, makeFunction40, makeOptimizedFunctionCall, resultIfEmpty, setArity, setDetails, setRetainedStaticContext, supplyTypeInformation, toShortString, toString, typeCheckCaller
Methods inherited from class net.sf.saxon.functions.AbstractFunction
atomize, deepEqual40, deepEquals, effectiveBooleanValue, getAnnotations, getUnicodeStringValue, isArray, isMap, makeNewContext, simplify, typeCheck
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.FunctionItem
getGenre
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
-
ContextItemAccessorFunction
public ContextItemAccessorFunction()
-
-
Method Details
-
bindContext
Bind a context item to appear as part of the function's closure. If this method has been called, the supplied context item will be used in preference to the context item at the point where the function is actually called.- Specified by:
bindContext
in classContextAccessorFunction
- Parameters:
context
- the context to which the function applies. Must not be null.- Throws:
XPathException
-
evaluate
Evaluate the function. This is done by creating a function of the same name, with the context item as an explicit argument, and evaluating that.- Parameters:
item
- the context itemcontext
- XPath dynamic context (not normally used)- Returns:
- the result of the function
- Throws:
XPathException
- in the event of a dynamic error
-
call
Evaluate the expression. This method is not normally used, but is provided to satisfy the interface.- Specified by:
call
in interfaceCallable
- Overrides:
call
in classContextAccessorFunction
- Parameters:
context
- the dynamic evaluation contextarguments
- the values of the arguments, supplied as Sequences- Returns:
- the result of the evaluation, in the form of a Sequence
- Throws:
XPathException
- if a dynamic error occurs during the evaluation of the expression
-
makeFunctionCall
Make a static call on this function, with specified arguments.- Overrides:
makeFunctionCall
in classSystemFunction
- Parameters:
arguments
- the supplied arguments to the function call. This will always be an empty array, since this is a zero-arity function.- Returns:
- This implementation returns a call on the equivalent arity-1 version of the function, supplying "." as an explicit argument.
-
makeContextItemExplicit
Create a system function call on this function in which the context item is supplied as an explicit argument- Returns:
- an equivalent function call in which the context item is supplied explicitly.
-