|
||||||||
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
|
Fields inherited from interface org.exist.xquery.Expression |
DOT_TEST, EXPRESSION_ID_INVALID, IGNORE_CONTEXT, IN_PREDICATE, IN_UPDATE, IN_WHERE_CLAUSE, NO_CONTEXT_ID, SINGLE_STEP_EXECUTION |
Method Summary | |
void |
analyze(AnalyzeContextInfo contextInfo)
Statically analyze the expression and its subexpressions. |
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 |
accept, 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 |
equals, 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
Method Detail |
public int returnsType()
Expression
Type
. If the return type cannot be determined
statically, return Type.ITEM.
returnsType
in interface Expression
returnsType
in class PathExpr
public int getCardinality()
AbstractExpression
Cardinality.EXACTLY_ONE
.
getCardinality
in interface Expression
getCardinality
in class PathExpr
public static Function createFunction(XQueryContext context, XQueryAST ast, FunctionDef def) throws XPathException
XPathException
public void setParent(Expression parent)
parent
- public Expression getParent()
public void setArguments(java.util.List arguments) throws XPathException
arguments
-
XPathException
public void analyze(AnalyzeContextInfo contextInfo) throws XPathException
Expression
analyze
in interface Expression
analyze
in class PathExpr
XPathException
public abstract Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException
Expression
Dependency.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 Expression
eval
in class PathExpr
XPathException
public Sequence[] getArguments(Sequence contextSequence, Item contextItem) throws XPathException
XPathException
public Expression getArgument(int pos)
pos
- public int getArgumentCount()
public void setPrimaryAxis(int axis)
setPrimaryAxis
in interface Expression
setPrimaryAxis
in class PathExpr
public QName getName()
public FunctionSignature getSignature()
public boolean isCalledAs(java.lang.String localName)
public int getDependencies()
AbstractExpression
Dependency.DEFAULT_DEPENDENCIES
.
getDependencies
in interface Expression
getDependencies
in class PathExpr
public void dump(ExpressionDumper dumper)
Expression
ExpressionDumper
.
dump
in interface Expression
dump
in class PathExpr
public java.lang.String toString()
toString
in class PathExpr
public void setASTNode(XQueryAST ast)
setASTNode
in interface Expression
setASTNode
in class AbstractExpression
public XQueryAST getASTNode()
Expression
XQueryAST
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 Expression
getASTNode
in class PathExpr
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |