Пример #1
0
 /** Constructor, registering statically available XQuery functions. */
 private Functions() {
   for (final Function def : Function.values()) {
     final String dsc = def.desc;
     final byte[] ln = token(dsc.substring(0, dsc.indexOf(PAR1)));
     final int i = add(new QNm(ln, def.uri()).id());
     if (i < 0) Util.notexpected("Function defined twice:" + def);
     funcs[i] = def;
   }
 }
Пример #2
0
  /**
   * Returns the specified function.
   *
   * @param name function qname
   * @param args optional arguments
   * @param ii input info
   * @return function instance
   * @throws QueryException query exception
   */
  public StandardFunc get(final QNm name, final Expr[] args, final InputInfo ii)
      throws QueryException {

    final int id = id(name.id());
    if (id == 0) return null;

    // create function
    final Function fl = funcs[id];
    if (!eq(fl.uri(), name.uri())) return null;

    final StandardFunc f = fl.get(ii, args);
    // check number of arguments
    if (args.length < fl.min || args.length > fl.max) XPARGS.thrw(ii, fl);
    return f;
  }