예제 #1
0
  @Override
  FItem evalFunc(final QueryContext ctx) throws QueryException {
    final int ar = expr.length - 1;
    final Item it = checkItem(expr[ar], ctx);
    if (!(it instanceof FItem)) throw INVFUNCITEM.get(info, it.type);
    final FItem fit = (FItem) it;
    if (fit.arity() != ar) throw INVARITY.get(info, fit, ar);
    if (!sc.mixUpdates && updating != fit.annotations().contains(Ann.Q_UPDATING))
      throw (updating ? UPFUNCNOTUP : UPFUNCUP).get(info);

    return fit;
  }
예제 #2
0
파일: FNUnit.java 프로젝트: nikhi/basex
  /**
   * Performs the test function.
   *
   * @param ctx query context
   * @return resulting value
   * @throws QueryException query exception
   */
  private Item test(final QueryContext ctx) throws QueryException {
    final Unit unit = new Unit(ctx, info);
    if (expr.length == 0) return unit.test(sc);

    final ArrayList<StaticFunc> funcs = new ArrayList<>();
    final Iter ir = ctx.iter(expr[0]);
    for (Item it; (it = ir.next()) != null; ) {
      final FItem fi = checkFunc(it, ctx);
      if (fi.funcName() != null) {
        final StaticFunc sf = ctx.funcs.get(fi.funcName(), fi.arity(), null, true);
        if (sf != null) funcs.add(sf);
      }
    }
    return unit.test(sc, funcs);
  }