Esempio n. 1
0
  @Override
  public Value value(final QueryContext ctx) throws QueryException {
    final int o = (int) ctx.resources.output.size();
    final Updates updates = ctx.resources.updates();
    final ContextModifier tmp = updates.mod;
    final TransformModifier pu = new TransformModifier();
    updates.mod = pu;

    try {
      for (final Let fo : copies) {
        final Iter ir = ctx.iter(fo.expr);
        Item i = ir.next();
        if (!(i instanceof ANode) || ir.next() != null) throw UPCOPYMULT.get(fo.info, fo.var.name);

        // copy node to main memory data instance
        i = ((ANode) i).dbCopy(ctx.context.options);
        // add resulting node to variable
        ctx.set(fo.var, i, info);
        pu.addData(i.data());
      }
      final Value v = ctx.value(expr[0]);
      if (!v.isEmpty()) throw BASEX_MOD.get(info);

      updates.prepare();
      updates.apply();
      return ctx.value(expr[1]);
    } finally {
      ctx.resources.output.size(o);
      updates.mod = tmp;
    }
  }
Esempio n. 2
0
 @Override
 public Value value(final QueryContext qc) throws QueryException {
   if (seqType().zeroOrOne()) {
     final Value v = item(qc, info);
     return v == null ? Empty.SEQ : v;
   }
   return qc.iter(this).value();
 }
Esempio n. 3
0
 /**
  * Returns all tokens of the query.
  *
  * @param qc query context
  * @return token list
  * @throws QueryException query exception
  */
 private TokenList tokens(final QueryContext qc) throws QueryException {
   final TokenList tl = new TokenList();
   final Iter ir = qc.iter(query);
   for (byte[] qu; (qu = nextToken(ir)) != null; ) {
     // skip empty tokens if not all results are needed
     if (qu.length != 0 || mode == FTMode.ALL || mode == FTMode.ALL_WORDS) tl.add(qu);
   }
   return tl;
 }
Esempio n. 4
0
 /**
  * Returns a result value.
  *
  * @return result value
  * @throws QueryException query exception
  */
 public Value value() throws QueryException {
   parse();
   return qc.iter().value();
 }
Esempio n. 5
0
 /**
  * Returns a result iterator.
  *
  * @return result iterator
  * @throws QueryException query exception
  */
 public Iter iter() throws QueryException {
   parse();
   return qc.iter();
 }