|
|||||||
| 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
public abstract class 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 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, NEED_INDEX_INFO, NO_CONTEXT_ID, SINGLE_STEP_EXECUTION |
| 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. |
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(String localName)
|
int |
returnsType()
The static return type of the expression. |
void |
setArguments(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)
|
String |
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, 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 String BUILTIN_FUNCTION_NS
| 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 PathExpr
public static Function createFunction(XQueryContext context,
XQueryAST ast,
FunctionDef def)
throws XPathException
XPathExceptionpublic void setParent(Expression parent)
parent - public Expression getParent()
getParent in class PathExpr
public void setArguments(List arguments)
throws XPathException
arguments -
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 PathExprcontextSequence - the current context sequence.contextItem - a single item, taken from context. This defines the item,
the expression should work on.
XPathException
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(String localName)
public int getDependencies()
AbstractExpressionDependency.DEFAULT_DEPENDENCIES.
getDependencies in interface ExpressiongetDependencies in class PathExprExpression.getDependencies()public void dump(ExpressionDumper dumper)
ExpressionExpressionDumper.
dump in interface Expressiondump in class PathExprdumper - the expression dumper to write topublic 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 PathExprpublic void accept(ExpressionVisitor visitor)
ExpressionExpressionVisitor.
accept in interface Expressionaccept in class PathExpr
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||