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
,Function
,GroundedValue
,Item
,Sequence
- Direct Known Subclasses:
ContextItemAccessorFunction.Number_0
,ContextItemAccessorFunction.StringAccessor
public class ContextItemAccessorFunction extends ContextAccessorFunction
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 Classes Modifier and Type Class Description static class
ContextItemAccessorFunction.Number_0
Subclass of ContextItemAccessorFunction to handle number().static class
ContextItemAccessorFunction.StringAccessor
Subclass of ContextItemAccessorFunction to handle string-length() and normalize-space().
-
Constructor Summary
Constructors Constructor Description ContextItemAccessorFunction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Function
bindContext(XPathContext context)
Bind a context item to appear as part of the function's closure.Sequence
call(XPathContext context, Sequence[] arguments)
Evaluate the expression.GroundedValue
evaluate(Item item, XPathContext context)
Evaluate the function.Expression
makeContextItemExplicit()
Create a system function call on this function in which the context item is supplied as an explicit argumentExpression
makeFunctionCall(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, getCompilerName, getContextNode, getDescription, getDetails, getErrorCodeForTypeErrors, getFunctionItemType, getFunctionName, getIntegerBounds, getNetCost, getOperandRoles, getRequiredType, getResultItemType, getResultItemType, getRetainedStaticContext, getSpecialProperties, getStaticBaseUriString, getStreamerName, getUniStringArg, hashCode, importAttributes, isSequenceVariadic, isTrustedResultType, makeCall, makeFunction, makeOptimizedFunctionCall, resultIfEmpty, setArity, setDetails, setRetainedStaticContext, supplyTypeInformation, toShortString, toString, typeCheckCaller
-
Methods inherited from class net.sf.saxon.functions.AbstractFunction
atomize, deepEquals, effectiveBooleanValue, getAnnotations, getSerialNumber, 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.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
-
-
-
-
Method Detail
-
bindContext
public Function bindContext(XPathContext context) throws XPathException
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
public GroundedValue evaluate(Item item, XPathContext context) throws XPathException
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
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
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
public Expression makeFunctionCall(Expression[] arguments)
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
public Expression 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.
-
-