org.basex.query.func
Class JavaMapping

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.expr.ParseExpr
              extended by org.basex.query.expr.Arr
                  extended by org.basex.query.func.JavaMapping
Direct Known Subclasses:
JavaFunc, JavaModuleFunc

public abstract class JavaMapping
extends Arr

This class contains common methods for executing Java code and mapping Java objects to XQuery values.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Flag
 
Field Summary
 
Fields inherited from class org.basex.query.expr.Arr
expr
 
Fields inherited from class org.basex.query.expr.ParseExpr
info, size, type
 
Method Summary
protected abstract  java.lang.Object eval(Value[] args, QueryContext ctx)
          Returns the result of the evaluated Java function.
protected static java.lang.String foundArgs(Value[] args)
          Returns a string representation of all found arguments.
 boolean has(Expr.Flag flag)
          Indicates if an expression has the specified compiler property.
 Iter iter(QueryContext ctx)
          Evaluates the expression and returns an iterator on the resulting items.
static Value toValue(java.lang.Object obj, QueryContext ctx)
          Converts the specified result to an XQuery value.
protected static Type type(java.lang.Class<?> type)
          Returns an appropriate XQuery data type for the specified Java class.
static Type type(java.lang.Object o)
          Returns an appropriate XQuery data type for the specified Java object.
 Value value(QueryContext ctx)
          Evaluates the expression and returns the resulting value.
 
Methods inherited from class org.basex.query.expr.Arr
accept, allAreValues, checkNoUp, checkUp, compile, copyAll, count, exprSize, indexEquivalent, inline, plan, removable, toString
 
Methods inherited from class org.basex.query.expr.ParseExpr
checkAdmin, checkAllUp, checkBinary, checkBln, checkColl, checkCreate, checkCtx, checkDbl, checkDBNode, checkEStr, checkEStr, checkFunc, checkItem, checkItr, checkItr, checkMap, checkNode, checkNode, checkNode, checkNoEmpty, checkNoneUp, checkNoUp, checkQNm, checkStr, checkStr, checkStrBin, checkType, checkWrite, compBln, copyType, ebv, item, optPre, preEval, size, test, type
 
Methods inherited from class org.basex.query.expr.Expr
addText, compEbv, copy, copy, hasFreeVars, indexAccessible, inlineAll, isEmpty, isFunction, isItem, isVacuous, isValue, iterable, markTailCalls, optimize, sameAs, uses, visitAll
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, description, info, planAttr, planElem, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

iter

public final Iter iter(QueryContext ctx)
                throws QueryException
Description copied from class: Expr
Evaluates the expression and returns an iterator on the resulting items. If this method is not overwritten, Expr.item(org.basex.query.QueryContext, org.basex.util.InputInfo) must be implemented by an expression, as it may be called by this method.

Overrides:
iter in class ParseExpr
Parameters:
ctx - query context
Returns:
resulting item
Throws:
QueryException - query exception

value

public final Value value(QueryContext ctx)
                  throws QueryException
Description copied from class: Expr
Evaluates the expression and returns the resulting value.

Overrides:
value in class ParseExpr
Parameters:
ctx - query context
Returns:
iterator
Throws:
QueryException - query exception

eval

protected abstract java.lang.Object eval(Value[] args,
                                         QueryContext ctx)
                                  throws QueryException
Returns the result of the evaluated Java function.

Parameters:
args - arguments
ctx - query context
Returns:
arguments
Throws:
QueryException - query exception

toValue

public static Value toValue(java.lang.Object obj,
                            QueryContext ctx)
                     throws QueryException
Converts the specified result to an XQuery value.

Parameters:
obj - result object
ctx - query context
Returns:
value
Throws:
QueryException - query exception

type

public static Type type(java.lang.Object o)
Returns an appropriate XQuery data type for the specified Java object.

Parameters:
o - object
Returns:
xquery type, or null if no appropriate type was found

type

protected static Type type(java.lang.Class<?> type)
Returns an appropriate XQuery data type for the specified Java class.

Parameters:
type - Java type
Returns:
xquery type

foundArgs

protected static java.lang.String foundArgs(Value[] args)
Returns a string representation of all found arguments.

Parameters:
args - array with arguments
Returns:
string representation

has

public boolean has(Expr.Flag flag)
Description copied from class: Expr
Indicates if an expression has the specified compiler property. This method is called by numerous Expr.compile(org.basex.query.QueryContext, org.basex.query.var.VarScope) methods to test properties of sub-expressions. It returns true if at least one test is successful.

Overrides:
has in class Arr
Parameters:
flag - flag to be found
Returns:
result of check