Class IntegratedFunctionCall
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.FunctionCall
-
- net.sf.saxon.functions.IntegratedFunctionCall
-
- All Implemented Interfaces:
Callable
,ExportAgent
,Locatable
,IdentityComparable
,Traceable
public class IntegratedFunctionCall extends FunctionCall implements Callable
Expression representing a call to a user-written extension function implemented as a subtype ofExtensionFunctionCall
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IntegratedFunctionCall.ConfigurationCheckingFunction
This class checks that NodeInfo objects returned by an extension function were created under the right Configuration
-
Field Summary
-
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD
-
-
Constructor Summary
Constructors Constructor Description IntegratedFunctionCall(StructuredQName name, ExtensionFunctionCall function)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Sequence
call(XPathContext context, Sequence[] arguments)
Call the Callable.void
checkArguments(ExpressionVisitor visitor)
Method supplied by each class of function to check arguments during parsing, when all the argument expressions have been read.protected int
computeCardinality()
Compute the static cardinality of this expressionprotected int
computeSpecialProperties()
Compute the special properties of this expression.Expression
copy(RebindingMap rebindings)
Copy an expression.boolean
effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression.void
export(ExpressionPresenter out)
Diagnostic print of expression structure.ExtensionFunctionCall
getFunction()
Get the ExtensionFunctionCall object supplied by the applicationStructuredQName
getFunctionName()
Get the qualified of the function being calledint
getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.ItemType
getItemType()
Determine the data type of the expression, if possible.Function
getTargetFunction(XPathContext context)
Get the target function to be calledSequenceIterator
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence.Expression
preEvaluate(ExpressionVisitor visitor)
Pre-evaluate a function at compile time.void
setResultType(SequenceType resultType)
Set the result type of the functionExpression
typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)
Type-check the expression.-
Methods inherited from class net.sf.saxon.expr.FunctionCall
addExternalFunctionCallToPathMap, adjustRequiredType, checkArgumentCount, checkFunctionCall, computeHashCode, equals, evaluateArguments, getArg, getArguments, getArity, getDisplayName, getExpressionName, getImplementationMethod, getNetCost, getOperanda, operands, optimize, pluralArguments, preEvaluateIfConstant, setArg, setArguments, setOperanda, setOperanda, simplifyArguments, toShortString, toString
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheckChildren, typeError, unordered, verifyParentPointers
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.trace.Traceable
gatherProperties
-
-
-
-
Constructor Detail
-
IntegratedFunctionCall
public IntegratedFunctionCall(StructuredQName name, ExtensionFunctionCall function)
-
-
Method Detail
-
setResultType
public void setResultType(SequenceType resultType)
Set the result type of the function- Parameters:
resultType
- the result type
-
getFunctionName
public StructuredQName getFunctionName()
Get the qualified of the function being called- Specified by:
getFunctionName
in classFunctionCall
- Returns:
- the qualified name
-
getTargetFunction
public Function getTargetFunction(XPathContext context)
Get the target function to be called- Specified by:
getTargetFunction
in classFunctionCall
- Parameters:
context
- the dynamic evaluation context- Returns:
- the target function, or null if unknown
-
getFunction
public ExtensionFunctionCall getFunction()
Get the ExtensionFunctionCall object supplied by the application- Returns:
- the ExtensionFunctionCall object
-
checkArguments
public void checkArguments(ExpressionVisitor visitor) throws XPathException
Method supplied by each class of function to check arguments during parsing, when all the argument expressions have been read. This implementation of the method checks the arguments of the supplied function call against the argument types declared as part of the extension function definition, and generates code to do the conversion if necessary.- Overrides:
checkArguments
in classFunctionCall
- Parameters:
visitor
- the expression visitor- Throws:
XPathException
- if the arguments are statically determined to be incompatible with the declared argument types of the function.
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
Type-check the expression.- Overrides:
typeCheck
in classFunctionCall
- Parameters:
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- Returns:
- the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
preEvaluate
public Expression preEvaluate(ExpressionVisitor visitor)
Pre-evaluate a function at compile time. This function does not allow pre-evaluation, so the method returns null.- Overrides:
preEvaluate
in classFunctionCall
- Parameters:
visitor
- an expression visitor- Returns:
- for this class: always null
-
getItemType
public ItemType getItemType()
Determine the data type of the expression, if possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.This method should always return a result, though it may be the best approximation that is available at the time.
- Specified by:
getItemType
in classExpression
- Returns:
- a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
-
computeCardinality
protected int computeCardinality()
Compute the static cardinality of this expression- Specified by:
computeCardinality
in classExpression
- Returns:
- the computed cardinality, as one of the values
StaticProperty.ALLOWS_ZERO_OR_ONE
,StaticProperty.EXACTLY_ONE
,StaticProperty.ALLOWS_ONE_OR_MORE
,StaticProperty.ALLOWS_ZERO_OR_MORE
-
getIntrinsicDependencies
public int getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".- Overrides:
getIntrinsicDependencies
in classExpression
- Returns:
- a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
-
computeSpecialProperties
protected int computeSpecialProperties()
Compute the special properties of this expression. These properties are denoted by a bit-significant integer, possible values are in classStaticProperty
. The "special" properties are properties other than cardinality and dependencies, and most of them relate to properties of node sequences, for example whether the nodes are in document order.- Overrides:
computeSpecialProperties
in classExpression
- Returns:
- the special properties, as a bit-significant integer
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Specified by:
copy
in classExpression
- Parameters:
rebindings
- Variables that need to be re-bound- Returns:
- the copy of the original expression
-
export
public void export(ExpressionPresenter out) throws XPathException
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Overrides:
export
in classFunctionCall
- Parameters:
out
- the expression presenter used to display the structure- Throws:
XPathException
- if the export fails, for example if an expression is found that won't work in the target environment.
-
iterate
public SequenceIterator iterate(XPathContext context) throws XPathException
Return an Iterator to iterate over the values of a sequence. The value of every expression can be regarded as a sequence, so this method is supported for all expressions. This default implementation handles iteration for expressions that return singleton values: for non-singleton expressions, the subclass must provide its own implementation.- Overrides:
iterate
in classFunctionCall
- Parameters:
context
- supplies the context for evaluation- Returns:
- a SequenceIterator that can be used to iterate over the result of the expression
- Throws:
XPathException
- if any dynamic error occurs evaluating the expression
-
effectiveBooleanValue
public boolean effectiveBooleanValue(XPathContext context) throws XPathException
Get the effective boolean value of the expression. This returns false if the value is the empty sequence, a zero-length string, a number equal to zero, or the boolean false. Otherwise it returns true.- Overrides:
effectiveBooleanValue
in classExpression
- Parameters:
context
- The context in which the expression is to be evaluated- Returns:
- the effective boolean value
- Throws:
XPathException
- if any dynamic error occurs evaluating the expression
-
call
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
Description copied from interface:Callable
Call the Callable.- Specified by:
call
in interfaceCallable
- Parameters:
context
- the dynamic evaluation contextarguments
- the values of the arguments, supplied as Sequences.Generally it is advisable, if calling iterate() to process a supplied sequence, to call it only once; if the value is required more than once, it should first be converted to a
GroundedValue
by calling the utility method SequenceTool.toGroundedValue().If the expected value is a single item, the item should be obtained by calling Sequence.head(): it cannot be assumed that the item will be passed as an instance of
Item
orAtomicValue
.It is the caller's responsibility to perform any type conversions required to convert arguments to the type expected by the callee. An exception is where this Callable is explicitly an argument-converting wrapper around the original Callable.
- Returns:
- the result of the evaluation, in the form of a Sequence. It is the responsibility of the callee to ensure that the type of result conforms to the expected result type.
- Throws:
XPathException
- if a dynamic error occurs during the evaluation of the expression
-
-