org.basex.query.func
Class StaticFuncs

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.func.StaticFuncs

public final class StaticFuncs
extends ExprInfo

Container for a user-defined function.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Constructor Summary
StaticFuncs()
           
 
Method Summary
 void check(QueryContext qc)
          Checks if all functions have been correctly declared, and initializes all function calls.
 void checkUp()
          Checks if the functions perform updates.
 void compile(QueryContext ctx)
          Compiles the functions.
 StaticFunc declare(Ann ann, QNm nm, Var[] args, SeqType ret, Expr body, StaticContext sc, VarScope scp, java.lang.String xqdoc, InputInfo ii)
          Declares a new user-defined function.
 void errorIfSimilar(QNm name, InputInfo ii)
          Throws an error if the name of a function is similar to the specified function name.
 StaticFunc[] funcs()
          Returns all user-defined functions.
 StaticFunc get(QNm name, long arity, InputInfo ii)
          Returns the function with the given name and arity.
 TypedFunc getFuncRef(QNm name, Expr[] args, StaticContext sc, InputInfo ii)
          Returns a new reference to the function with the given name and arity.
 void plan(FElem plan)
          Creates an expression tree.
protected static byte[] sig(QNm name, long arity)
          returns the signature of the function with the given name and arity.
 java.lang.String toString()
           
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, description, info, planAttr, planElem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StaticFuncs

public StaticFuncs()
Method Detail

sig

protected static byte[] sig(QNm name,
                            long arity)
returns the signature of the function with the given name and arity.

Parameters:
name - function name
arity - function arity
Returns:
the function's signature

declare

public StaticFunc declare(Ann ann,
                          QNm nm,
                          Var[] args,
                          SeqType ret,
                          Expr body,
                          StaticContext sc,
                          VarScope scp,
                          java.lang.String xqdoc,
                          InputInfo ii)
                   throws QueryException
Declares a new user-defined function.

Parameters:
ann - annotations
nm - function name
args - formal parameters
ret - return type
body - function body
sc - static context
scp - variable scope
xqdoc - current xqdoc cache
ii - input info
Returns:
static function reference
Throws:
QueryException - query exception

getFuncRef

public TypedFunc getFuncRef(QNm name,
                            Expr[] args,
                            StaticContext sc,
                            InputInfo ii)
                     throws QueryException
Returns a new reference to the function with the given name and arity.

Parameters:
name - function name
args - argument expressions
sc - static context of the function call
ii - input info
Returns:
function call
Throws:
QueryException - query exception

check

public void check(QueryContext qc)
           throws QueryException
Checks if all functions have been correctly declared, and initializes all function calls.

Parameters:
qc - query context
Throws:
QueryException - query exception

checkUp

public void checkUp()
             throws QueryException
Checks if the functions perform updates.

Throws:
QueryException - query exception

compile

public void compile(QueryContext ctx)
             throws QueryException
Compiles the functions.

Parameters:
ctx - query context
Throws:
QueryException - query exception

get

public StaticFunc get(QNm name,
                      long arity,
                      InputInfo ii)
               throws QueryException
Returns the function with the given name and arity.

Parameters:
name - function name
arity - function arity
ii - input info
Returns:
function if found, null otherwise
Throws:
QueryException - query exception

errorIfSimilar

public void errorIfSimilar(QNm name,
                           InputInfo ii)
                    throws QueryException
Throws an error if the name of a function is similar to the specified function name.

Parameters:
name - function name
ii - input info
Throws:
QueryException - query exception

plan

public void plan(FElem plan)
Description copied from class: ExprInfo
Creates an expression tree.

Specified by:
plan in class ExprInfo
Parameters:
plan - root element

funcs

public StaticFunc[] funcs()
Returns all user-defined functions.

Returns:
functions

toString

public java.lang.String toString()
Specified by:
toString in class ExprInfo