Exemple #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;
  }
Exemple #2
0
  /**
   * 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);
  }