|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.exist.xquery.AbstractExpression
org.exist.xquery.PathExpr
org.exist.xquery.Function
Abstract base class for all built-in and user-defined functions.
Built-in functions just extend this class. A new function instance
will be created for each function call. Subclasses have to
provide a function signature to the constructor.
User-defined functions extend class UserDefinedFunction,
which is again a subclass of Function. They will not be called directly, but through a
FunctionCall object, which checks the type and cardinality of
all arguments and takes care that the current execution context is saved properly.
| Field Summary | |
static java.lang.String |
BUILTIN_FUNCTION_NS
|
protected FunctionSignature |
mySignature
|
| Fields inherited from class org.exist.xquery.PathExpr |
inPredicate, keepVirtual, LOG, source, steps |
| Fields inherited from class org.exist.xquery.AbstractExpression |
context, contextDocSet, contextId |
| Fields inherited from interface org.exist.xquery.Expression |
EXPRESSION_ID_INVALID, IGNORE_CONTEXT, IN_PREDICATE, IN_UPDATE, IN_WHERE_CLAUSE, NO_CONTEXT_ID, SINGLE_STEP_EXECUTION |
| Constructor Summary | |
protected |
Function(XQueryContext context)
|
protected |
Function(XQueryContext context,
FunctionSignature signature)
Internal constructor. |
| Method Summary | |
void |
analyze(AnalyzeContextInfo contextInfo)
Statically analyze the expression and its subexpressions. |
protected Expression |
checkArgument(Expression expr,
SequenceType type,
int argPosition)
Statically check an argument against the sequence type specified in the signature. |
protected void |
checkArguments()
|
static Function |
createFunction(XQueryContext context,
XQueryAST ast,
FunctionDef def)
Create a built-in function from the specified class. |
void |
dump(ExpressionDumper dumper)
Write a diagnostic dump of the expression to the passed ExpressionDumper. |
abstract Sequence |
eval(Sequence contextSequence,
Item contextItem)
Evaluate the expression represented by this object. |
Expression |
getArgument(int pos)
Get an argument expression by its position in the argument list. |
int |
getArgumentCount()
Get the number of arguments passed to this function. |
Sequence[] |
getArguments(Sequence contextSequence,
Item contextItem)
|
XQueryAST |
getASTNode()
Returns the XQueryAST node from which this expression
has been constructed by the parser. |
int |
getCardinality()
The default cardinality is Cardinality.EXACTLY_ONE. |
int |
getDependencies()
Returns Dependency.DEFAULT_DEPENDENCIES. |
QName |
getName()
Return the name of this function. |
Expression |
getParent()
Returns the expression from which this function gets called. |
FunctionSignature |
getSignature()
Get the signature of this function. |
boolean |
isCalledAs(java.lang.String localName)
|
int |
returnsType()
The static return type of the expression. |
void |
setArguments(java.util.List arguments)
Set the (static) arguments for this function from a list of expressions. |
void |
setASTNode(XQueryAST ast)
|
void |
setParent(Expression parent)
Set the parent expression of this function, i.e. |
void |
setPrimaryAxis(int axis)
|
java.lang.String |
toString()
|
| Methods inherited from class org.exist.xquery.PathExpr |
add, add, addPath, addPredicate, dump, getContext, getDocumentSet, getExpression, getLastExpression, getLength, getLiteralValue, getSource, isValid, replaceLastExpression, reset, resetState, setContext, setSource |
| Methods inherited from class org.exist.xquery.AbstractExpression |
eval, getContextDocSet, getContextId, getExpressionId, setContextDocSet |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.exist.xquery.CompiledXQuery |
eval |
| Field Detail |
public static final java.lang.String BUILTIN_FUNCTION_NS
protected FunctionSignature mySignature
| Constructor Detail |
protected Function(XQueryContext context,
FunctionSignature signature)
context - signature - protected Function(XQueryContext context)
| Method Detail |
public int returnsType()
ExpressionType. If the return type cannot be determined
statically, return Type.ITEM.
returnsType in interface ExpressionreturnsType in class PathExprpublic int getCardinality()
AbstractExpressionCardinality.EXACTLY_ONE.
getCardinality in interface ExpressiongetCardinality in class AbstractExpression
public static Function createFunction(XQueryContext context,
XQueryAST ast,
FunctionDef def)
throws XPathException
context -
XPathExceptionpublic void setParent(Expression parent)
parent - public Expression getParent()
public void setArguments(java.util.List arguments)
throws XPathException
arguments -
XPathException
protected void checkArguments()
throws XPathException
XPathException
protected Expression checkArgument(Expression expr,
SequenceType type,
int argPosition)
throws XPathException
expr - type -
XPathException
public void analyze(AnalyzeContextInfo contextInfo)
throws XPathException
Expression
analyze in interface Expressionanalyze in class PathExprXPathException
public abstract Sequence eval(Sequence contextSequence,
Item contextItem)
throws XPathException
ExpressionDependency.CONTEXT_ITEM
bit is set in the bit field returned by Expression.getDependencies(), the eval method will
be called once for every item in the context sequence. The contextItem
parameter will be set to the current item. Otherwise, the eval method will only be called
once for the whole context sequence and contextItem will be null.
eXist tries to process the entire context set in one, single step whenever
possible. Thus, most classes only expect context to contain a list of
nodes which represents the current context of the expression.
The position() function in XPath is an example for an expression,
which requires both, context sequence and context item to be set.
The context sequence might be a node set, a sequence of atomic values or a single
node or atomic value.
eval in interface Expressioneval in class PathExprXPathException
public Sequence[] getArguments(Sequence contextSequence,
Item contextItem)
throws XPathException
XPathExceptionpublic Expression getArgument(int pos)
pos -
public int getArgumentCount()
public void setPrimaryAxis(int axis)
setPrimaryAxis in interface ExpressionsetPrimaryAxis in class PathExprpublic QName getName()
public FunctionSignature getSignature()
public boolean isCalledAs(java.lang.String localName)
public int getDependencies()
AbstractExpressionDependency.DEFAULT_DEPENDENCIES.
getDependencies in interface ExpressiongetDependencies in class PathExprpublic void dump(ExpressionDumper dumper)
ExpressionExpressionDumper.
dump in interface Expressiondump in class PathExprpublic java.lang.String toString()
toString in class PathExprpublic void setASTNode(XQueryAST ast)
setASTNode in interface ExpressionsetASTNode in class AbstractExpressionpublic XQueryAST getASTNode()
ExpressionXQueryAST node from which this expression
has been constructed by the parser. This node contains location information
(line number and column) important for error reports.
getASTNode in interface ExpressiongetASTNode in class PathExpr
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||