org.exist.xquery
Class InternalFunctionCall

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.InternalFunctionCall
All Implemented Interfaces:
CompiledXQuery, Expression, CompiledExpression

public class InternalFunctionCall
extends Function

Wrapper for internal modules in order to perform access control checks on internal module function calls. It delegates to the wrapped Function for everything, but checks permission before delegating eval


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
InternalFunctionCall(Function f)
           
 
Method Summary
 void accept(ExpressionVisitor visitor)
          Start traversing the expression tree using the specified ExpressionVisitor.
 void add(Expression s)
          Add an arbitrary expression to this object's list of child-expressions.
 void add(PathExpr path)
          Add all the child-expressions from another PathExpr to this object's child-expressions.
 void addPath(PathExpr path)
          Add another PathExpr to this object's expression list.
 void addPredicate(Predicate pred)
          Add a predicate expression to the list of expressions.
 void analyze(AnalyzeContextInfo contextInfo)
          Statically analyze the expression and its subexpressions.
 void dump(ExpressionDumper dumper)
          Write a diagnostic dump of the expression to the passed ExpressionDumper.
 void dump(Writer writer)
          Writes a diagnostic dump of the expression structure to the specified writer.
 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.
 XQueryContext getContext()
           
 DocumentSet getContextDocSet()
           
 int getDependencies()
          Returns Dependency.DEFAULT_DEPENDENCIES.
 DocumentSet getDocumentSet()
           
 Expression getExpression(int pos)
           
 Expression getLastExpression()
           
 int getLength()
           
 String getLiteralValue()
           
 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)
           
 boolean isValid()
          Is the compiled expression still valid? Returns false if, for example, the source code of one of the imported modules has changed.
 void replaceLastExpression(Expression s)
           
 void reset()
          Reset the compiled expression tree.
 void resetState(boolean postOptimization)
          Called to inform an expression that it should reset to its initial state.
 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 setContext(XQueryContext context)
           
 void setContextDocSet(DocumentSet contextSet)
           
 void setParent(Expression parent)
          Set the parent expression of this function, i.e.
 String toString()
           
 
Methods inherited from class org.exist.xquery.Function
createFunction, setPrimaryAxis
 
Methods inherited from class org.exist.xquery.PathExpr
getSource, replaceExpression, setSource
 
Methods inherited from class org.exist.xquery.AbstractExpression
eval, 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

InternalFunctionCall

public InternalFunctionCall(Function f)
Method Detail

eval

public Sequence eval(Sequence contextSequence,
                     Item contextItem)
              throws XPathException
Description copied from interface: Expression
Evaluate the expression represented by this object. Depending on the context in which this expression is executed, either the context sequence, the context item or both of them may be set. An implementing class should know how to handle this. The general contract is as follows: if the 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.

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

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

getName

public QName getName()
Description copied from class: Function
Return the name of this function.

Overrides:
getName in class Function
Returns:
name of this function

returnsType

public int returnsType()
Description copied from interface: Expression
The static return type of the expression. This method should return one of the type constants defined in class Type. If the return type cannot be determined statically, return Type.ITEM.

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

getCardinality

public int getCardinality()
Description copied from class: AbstractExpression
The default cardinality is Cardinality.EXACTLY_ONE.

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

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

setParent

public void setParent(Expression parent)
Description copied from class: Function
Set the parent expression of this function, i.e. the expression from which the function is called.

Overrides:
setParent in class Function

getParent

public Expression getParent()
Description copied from class: Function
Returns the expression from which this function gets called.

Overrides:
getParent in class Function

getContext

public XQueryContext getContext()
Specified by:
getContext in interface CompiledXQuery
Overrides:
getContext in class PathExpr
Returns:
the XQueryContext used to create this query

setASTNode

public void setASTNode(XQueryAST ast)
Specified by:
setASTNode in interface Expression
Overrides:
setASTNode in class Function

getASTNode

public XQueryAST getASTNode()
Description copied from interface: Expression
Returns the 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.

Specified by:
getASTNode in interface Expression
Overrides:
getASTNode in class Function
Returns:
XQueryAST node

add

public void add(Expression s)
Description copied from class: PathExpr
Add an arbitrary expression to this object's list of child-expressions.

Overrides:
add in class PathExpr

add

public void add(PathExpr path)
Description copied from class: PathExpr
Add all the child-expressions from another PathExpr to this object's child-expressions.

Overrides:
add in class PathExpr

addPath

public void addPath(PathExpr path)
Description copied from class: PathExpr
Add another PathExpr to this object's expression list.

Overrides:
addPath in class PathExpr

addPredicate

public void addPredicate(Predicate pred)
Description copied from class: PathExpr
Add a predicate expression to the list of expressions. The predicate is added to the last expression in the list.

Overrides:
addPredicate in class PathExpr

dump

public void dump(ExpressionDumper dumper)
Description copied from interface: Expression
Write a diagnostic dump of the expression to the passed ExpressionDumper.

Specified by:
dump in interface Expression
Overrides:
dump in class Function
Parameters:
dumper - the expression dumper to write to

dump

public void dump(Writer writer)
Description copied from interface: CompiledXQuery
Writes a diagnostic dump of the expression structure to the specified writer.

Specified by:
dump in interface CompiledXQuery
Overrides:
dump in class PathExpr

getArgument

public Expression getArgument(int pos)
Description copied from class: Function
Get an argument expression by its position in the argument list.

Overrides:
getArgument in class Function

getArguments

public Sequence[] getArguments(Sequence contextSequence,
                               Item contextItem)
                        throws XPathException
Overrides:
getArguments in class Function
Throws:
XPathException

getContextDocSet

public DocumentSet getContextDocSet()
Specified by:
getContextDocSet in interface Expression
Overrides:
getContextDocSet in class AbstractExpression

getDependencies

public int getDependencies()
Description copied from class: AbstractExpression
Returns Dependency.DEFAULT_DEPENDENCIES.

Specified by:
getDependencies in interface Expression
Overrides:
getDependencies in class Function
Returns:
set of bit-flags
See Also:
Expression.getDependencies()

getDocumentSet

public DocumentSet getDocumentSet()
Overrides:
getDocumentSet in class PathExpr

getExpression

public Expression getExpression(int pos)
Overrides:
getExpression in class PathExpr

getLastExpression

public Expression getLastExpression()
Overrides:
getLastExpression in class PathExpr

getLength

public int getLength()
Overrides:
getLength in class PathExpr

getLiteralValue

public String getLiteralValue()
Overrides:
getLiteralValue in class PathExpr

getSignature

public FunctionSignature getSignature()
Description copied from class: Function
Get the signature of this function.

Overrides:
getSignature in class Function
Returns:
signature of this function

isCalledAs

public boolean isCalledAs(String localName)
Overrides:
isCalledAs in class Function

isValid

public boolean isValid()
Description copied from interface: CompiledXQuery
Is the compiled expression still valid? Returns false if, for example, the source code of one of the imported modules has changed.

Specified by:
isValid in interface CompiledXQuery
Overrides:
isValid in class PathExpr

replaceLastExpression

public void replaceLastExpression(Expression s)
Overrides:
replaceLastExpression in class PathExpr

reset

public void reset()
Description copied from interface: CompiledXQuery
Reset the compiled expression tree. Discard all temporary expression results.

Specified by:
reset in interface CompiledXQuery
Specified by:
reset in interface CompiledExpression
Overrides:
reset in class PathExpr

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

setArguments

public void setArguments(List arguments)
                  throws XPathException
Description copied from class: Function
Set the (static) arguments for this function from a list of expressions. This will also check the type and cardinality of the passed argument expressions.

Overrides:
setArguments in class Function
Throws:
XPathException

setContext

public void setContext(XQueryContext context)
Specified by:
setContext in interface CompiledXQuery
Overrides:
setContext in class PathExpr

setContextDocSet

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

toString

public String toString()
Overrides:
toString in class Function

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.