net.sf.saxon.functions
Class IntegratedFunctionCall

java.lang.Object
  extended by net.sf.saxon.expr.Expression
      extended by net.sf.saxon.expr.FunctionCall
          extended by net.sf.saxon.functions.IntegratedFunctionCall
All Implemented Interfaces:
Serializable, SourceLocator, LocationProvider, SaxonLocator, CallableExpression, InstructionInfo, Locator

public class IntegratedFunctionCall
extends FunctionCall
implements CallableExpression

Expression representing a call to a user-written extension function implemented as a subtype of ExtensionFunctionCall

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.expr.FunctionCall
argument
 
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, EVENT_FEED_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, PUSH_SELECTION, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, WATCH_METHOD
 
Constructor Summary
IntegratedFunctionCall(ExtensionFunctionCall function)
           
 
Method Summary
 SequenceIterator<? extends Item> call(SequenceIterator<? extends Item>[] arguments, XPathContext context)
          Evaluate the expression
 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 expression
protected  int computeSpecialProperties()
          Compute the special properties of this expression.
 Expression copy()
          Copy an expression.
 boolean effectiveBooleanValue(XPathContext context)
          Get the effective boolean value of the expression.
 ExtensionFunctionCall getFunction()
          Get the ExtensionFunctionCall object supplied by the application
 int getIntrinsicDependencies()
          Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.
 ItemType getItemType(TypeHierarchy th)
          Determine the data type of the expression, if possible.
 SequenceIterator 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 setContainer(Container container)
          Mark an expression as being in a given Container.
 Expression typeCheck(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)
          Type-check the expression.
 
Methods inherited from class net.sf.saxon.expr.FunctionCall
addExternalFunctionCallToPathMap, checkArgumentCount, equals, explain, getArguments, getDisplayName, getExpressionName, getFunctionName, getNumberOfArguments, hashCode, iterateSubExpressions, optimize, promote, replaceSubExpression, setArguments, setFunctionName, simplify, simplifyArguments, toString
 
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getDependencies, getEvaluationMethod, getExecutable, getHostLanguage, getImplementationMethod, getIntegerBounds, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasLoopingSubexpression, hasVariableBinding, implementsStaticTypeCheck, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterateEvents, iterateSameFocusSubExpressions, markTailFunctionCalls, process, resetLocalStaticProperties, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, typeError
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.expr.CallableExpression
getArguments
 

Constructor Detail

IntegratedFunctionCall

public IntegratedFunctionCall(ExtensionFunctionCall function)
Method Detail

getFunction

public ExtensionFunctionCall getFunction()
Get the ExtensionFunctionCall object supplied by the application

Returns:
the ExtensionFunctionCall object

setContainer

public void setContainer(Container container)
Mark an expression as being in a given Container. This link is used primarily for diagnostics: the container links to the location map held in the executable.

This affects the expression and all its subexpressions. Any subexpressions that are not in the same container are marked with the new container, and this proceeds recursively. However, any subexpression that is already in the correct container is not modified.

Overrides:
setContainer in class Expression
Parameters:
container - The container of this expression.

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.

Specified by:
checkArguments in class FunctionCall
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,
                            ExpressionVisitor.ContextItemType contextItemType)
                     throws XPathException
Type-check the expression.

Overrides:
typeCheck in class FunctionCall
Parameters:
visitor - an expression visitor
contextItemType - the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set to Type.ITEM_TYPE
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)
                       throws XPathException
Pre-evaluate a function at compile time. Functions that do not allow pre-evaluation, or that need access to context information, can override this method.

Overrides:
preEvaluate in class FunctionCall
Parameters:
visitor - an expression visitor
Returns:
the result of the early evaluation, or the original expression, or potentially a simplified expression
Throws:
XPathException - if evaluation fails

getItemType

public ItemType getItemType(TypeHierarchy th)
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 class Expression
Parameters:
th - the type hierarchy cache
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 class Expression
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 class Expression
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 class StaticProperty. 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 class Expression
Returns:
the special properties, as a bit-significant integer

copy

public Expression copy()
Copy an expression. This makes a deep copy.

Specified by:
copy in class Expression
Returns:
the copy of the original expression

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 class Expression
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 class Expression
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 SequenceIterator<? extends Item> call(SequenceIterator<? extends Item>[] arguments,
                                             XPathContext context)
                                      throws XPathException
Description copied from interface: CallableExpression
Evaluate the expression

Specified by:
call in interface CallableExpression
Parameters:
arguments - the values of the arguments, supplied as SequenceIterators
context - the dynamic evaluation context
Returns:
the result of the evaluation, in the form of a SequenceIterator
Throws:
XPathException - if a dynamic error occurs during the evaluation of the expression


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.