org.basex.query.func
Class StaticFunc

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.StaticScope
          extended by org.basex.query.StaticDecl
              extended by org.basex.query.func.StaticFunc
All Implemented Interfaces:
XQFunction, Scope

public final class StaticFunc
extends StaticDecl
implements XQFunction

A static user-defined function.

Author:
BaseX Team 2005-12, BSD License, Leo Woerteler

Field Summary
 Var[] args
          Arguments.
 boolean updating
          Updating flag.
 
Fields inherited from class org.basex.query.StaticDecl
ann, declType, dontEnter, name, sc
 
Fields inherited from class org.basex.query.StaticScope
compiled, expr, info, scope
 
Constructor Summary
StaticFunc(Ann a, QNm n, Var[] v, SeqType r, Expr e, StaticContext stc, VarScope scp, java.lang.String xqdoc, InputInfo ii)
          Function constructor.
 
Method Summary
 int arity()
          Number of arguments this function takes.
 void checkUp()
          Checks if all updating expressions in the function are correctly declared and placed.
 void compile(QueryContext ctx)
          Compiles the expression contained in this scope.
 QNm fName()
          Name of this function, null means anonymous function.
 FuncType funcType()
          Type of this function.
 boolean has(Expr.Flag flag)
          Indicates if an expression has the specified compiler property.
 byte[] id()
          Returns a unique identifier for this declaration.
 Item invItem(QueryContext ctx, InputInfo ii, Value... arg)
          Invokes this function with the given arguments.
 Value invValue(QueryContext ctx, InputInfo ii, Value... arg)
          Invokes this function with the given arguments.
 boolean isVacuous()
          Checks if this function returns vacuous results (see Expr.isVacuous()).
 void plan(FElem plan)
          Creates an expression tree.
 boolean selfRecursive()
          Checks if this function calls itself recursively.
 java.lang.String toString()
           
 boolean visit(ASTVisitor visitor)
          Traverses this scope with the given ASTVisitor.
 
Methods inherited from class org.basex.query.StaticDecl
type
 
Methods inherited from class org.basex.query.StaticScope
compiled, doc
 
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
 

Field Detail

args

public final Var[] args
Arguments.


updating

public final boolean updating
Updating flag.

Constructor Detail

StaticFunc

public StaticFunc(Ann a,
                  QNm n,
                  Var[] v,
                  SeqType r,
                  Expr e,
                  StaticContext stc,
                  VarScope scp,
                  java.lang.String xqdoc,
                  InputInfo ii)
Function constructor.

Parameters:
a - annotations
n - function name
v - arguments
r - return type
e - function body
stc - static context
scp - variable scope
xqdoc - current xqdoc cache
ii - input info
Method Detail

compile

public void compile(QueryContext ctx)
             throws QueryException
Description copied from interface: Scope
Compiles the expression contained in this scope.

Specified by:
compile in interface Scope
Parameters:
ctx - query context
Throws:
QueryException - compilation errors

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

toString

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

selfRecursive

public boolean selfRecursive()
Checks if this function calls itself recursively.

Returns:
result of check

arity

public int arity()
Description copied from interface: XQFunction
Number of arguments this function takes.

Specified by:
arity in interface XQFunction
Returns:
function arity

fName

public QNm fName()
Description copied from interface: XQFunction
Name of this function, null means anonymous function.

Specified by:
fName in interface XQFunction
Returns:
name or null

funcType

public FuncType funcType()
Description copied from interface: XQFunction
Type of this function.

Specified by:
funcType in interface XQFunction
Returns:
this function's type

invItem

public Item invItem(QueryContext ctx,
                    InputInfo ii,
                    Value... arg)
             throws QueryException
Description copied from interface: XQFunction
Invokes this function with the given arguments.

Specified by:
invItem in interface XQFunction
Parameters:
ctx - query context
ii - input info
arg - arguments
Returns:
resulting item
Throws:
QueryException - query exception

invValue

public Value invValue(QueryContext ctx,
                      InputInfo ii,
                      Value... arg)
               throws QueryException
Description copied from interface: XQFunction
Invokes this function with the given arguments.

Specified by:
invValue in interface XQFunction
Parameters:
ctx - query context
ii - input info
arg - arguments
Returns:
resulting iterator
Throws:
QueryException - query exception

checkUp

public void checkUp()
             throws QueryException
Checks if all updating expressions in the function are correctly declared and placed.

Throws:
QueryException - query exception

isVacuous

public boolean isVacuous()
Checks if this function returns vacuous results (see Expr.isVacuous()).

Returns:
result of check

has

public boolean has(Expr.Flag flag)
Indicates if an expression has the specified compiler property.

Parameters:
flag - feature
Returns:
result of check
See Also:
Expr.has(Flag)

visit

public boolean visit(ASTVisitor visitor)
Description copied from interface: Scope
Traverses this scope with the given ASTVisitor.

Specified by:
visit in interface Scope
Parameters:
visitor - visitor
Returns:
continue flag

id

public byte[] id()
Description copied from class: StaticDecl
Returns a unique identifier for this declaration.

Specified by:
id in class StaticDecl
Returns:
a byte sequence that uniquely identifies this declaration