org.exist.xquery
Class FunctionCall

java.lang.Object
  extended by org.exist.xquery.AbstractExpression
      extended by org.exist.xquery.PathExpr
          extended by org.exist.xquery.Function
              extended by org.exist.xquery.FunctionCall
All Implemented Interfaces:
CompiledXQuery, Expression, CompiledExpression

public class FunctionCall
extends Function

Represents a call to a user-defined function UserDefinedFunction. FunctionCall wraps around a user-defined function. It makes sure that all function parameters are checked against the signature of the function.

Author:
wolf

Field Summary
 
Fields inherited from class org.exist.xquery.Function
BUILTIN_FUNCTION_NS
 
Fields inherited from interface org.exist.xquery.Expression
DOT_TEST, EXPRESSION_ID_INVALID, IGNORE_CONTEXT, IN_NODE_CONSTRUCTOR, IN_PREDICATE, IN_UPDATE, IN_WHERE_CLAUSE, NEED_INDEX_INFO, NO_CONTEXT_ID, SINGLE_STEP_EXECUTION, USE_TREE_TRAVERSAL
 
Constructor Summary
FunctionCall(XQueryContext context, QName name, List arguments)
           
FunctionCall(XQueryContext context, UserDefinedFunction functionDef)
           
 
Method Summary
 void accept(ExpressionVisitor visitor)
          Start traversing the expression tree using the specified ExpressionVisitor.
 void analyze(AnalyzeContextInfo contextInfo)
          Statically analyze the expression and its subexpressions.
 Sequence eval(Sequence contextSequence, Item contextItem)
          Evaluates all arguments, then forwards them to the user-defined function.
 Sequence evalFunction(Sequence contextSequence, Item contextItem, Sequence[] seq)
           
 Sequence evalFunction(Sequence contextSequence, Item contextItem, Sequence[] seq, DocumentSet[] contextDocs)
           
 int getArgumentCount()
          Get the number of arguments passed to this function.
 QName getQName()
           
 void resetState(boolean postOptimization)
          Called to inform an expression that it should reset to its initial state.
 void resolveForwardReference(UserDefinedFunction functionDef)
          Called by XQueryContext to resolve a call to a function that has not yet been declared.
 void setContextDocSet(DocumentSet contextSet)
           
 
Methods inherited from class org.exist.xquery.Function
createFunction, dump, getArgument, getArguments, getASTNode, getCardinality, getDependencies, getName, getParent, getSignature, isCalledAs, returnsType, setArguments, setASTNode, setParent, setPrimaryAxis, toString
 
Methods inherited from class org.exist.xquery.PathExpr
add, add, addPath, addPredicate, dump, getContext, getDocumentSet, getExpression, getLastExpression, getLength, getLiteralValue, getSource, isValid, replaceExpression, replaceLastExpression, reset, setContext, setSource
 
Methods inherited from class org.exist.xquery.AbstractExpression
eval, getContextDocSet, getContextId, getExpressionId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.exist.xquery.CompiledXQuery
eval
 

Constructor Detail

FunctionCall

public FunctionCall(XQueryContext context,
                    QName name,
                    List arguments)

FunctionCall

public FunctionCall(XQueryContext context,
                    UserDefinedFunction functionDef)
Method Detail

analyze

public void analyze(AnalyzeContextInfo contextInfo)
             throws XPathException
Description copied from interface: Expression
Statically analyze the expression and its subexpressions. During the static analysis phase, the query engine can detect unknown variables and some type errors.

Specified by:
analyze in interface Expression
Overrides:
analyze in class Function
Throws:
XPathException

resolveForwardReference

public void resolveForwardReference(UserDefinedFunction functionDef)
                             throws XPathException
Called by XQueryContext to resolve a call to a function that has not yet been declared. XQueryContext remembers all calls to undeclared functions and tries to resolve them after parsing has completed.

Parameters:
functionDef -
Throws:
XPathException

getArgumentCount

public int getArgumentCount()
Description copied from class: Function
Get the number of arguments passed to this function.

Overrides:
getArgumentCount in class Function
Returns:
number of arguments

getQName

public QName getQName()

eval

public Sequence eval(Sequence contextSequence,
                     Item contextItem)
              throws XPathException
Evaluates all arguments, then forwards them to the user-defined function. The return value of the user-defined function will be checked against the provided function signature.

Specified by:
eval in interface Expression
Specified by:
eval in class Function
Parameters:
contextSequence - the current context sequence.
contextItem - a single item, taken from context. This defines the item, the expression should work on.
Throws:
XPathException
See Also:
Expression.eval(Sequence, Item)

evalFunction

public Sequence evalFunction(Sequence contextSequence,
                             Item contextItem,
                             Sequence[] seq)
                      throws XPathException
Parameters:
contextSequence -
contextItem -
seq -
Throws:
XPathException

evalFunction

public Sequence evalFunction(Sequence contextSequence,
                             Item contextItem,
                             Sequence[] seq,
                             DocumentSet[] contextDocs)
                      throws XPathException
Throws:
XPathException

resetState

public void resetState(boolean postOptimization)
Description copied from interface: Expression
Called to inform an expression that it should reset to its initial state. All cached data in the expression object should be dropped. For example, the xmldb:document() function calls this method whenever the input document set has changed.

Specified by:
resetState in interface Expression
Overrides:
resetState in class PathExpr

setContextDocSet

public void setContextDocSet(DocumentSet contextSet)
Specified by:
setContextDocSet in interface Expression
Overrides:
setContextDocSet in class AbstractExpression

accept

public void accept(ExpressionVisitor visitor)
Description copied from interface: Expression
Start traversing the expression tree using the specified ExpressionVisitor.

Specified by:
accept in interface Expression
Overrides:
accept in class Function


Copyright (C) Wolfgang Meier. All rights reserved.