Exemplo n.º 1
0
  @Override
  public Sequence execute(StaticContext sctx, QueryContext ctx, final Sequence[] args)
      throws QueryException {
    if (args[1] == null) {
      return Int32.ZERO;
    }
    try {
      IntNumeric count = Int32.ZERO;
      String uri = ((Atomic) args[0]).stringValue();
      BufferedWriter out =
          new BufferedWriter(new OutputStreamWriter(URIHandler.getOutputStream(uri, true)));
      Iter it = args[1].iterate();
      try {
        Item item;
        while ((item = it.next()) != null) {
          out.write(item.toString());
          count = count.inc();
        }
      } finally {
        it.close();
      }
      out.close();

      return count;
    } catch (IOException e) {
      throw new QueryException(e, IOFun.IO_WRITEFILE_INT_ERROR);
    }
  }
Exemplo n.º 2
0
 @Override
 public SubtreeParser next() throws DocumentException {
   try {
     final Item i = it.next();
     if (i == null) {
       return null;
     }
     if (i instanceof Node<?>) {
       final Node<?> n = (Node<?>) i;
       return new StoreParser(n);
     } else {
       throw new QueryException(
           ErrorCode.ERR_TYPE_INAPPROPRIATE_TYPE,
           "Cannot create subtree parser for item of type: %s",
           i.itemType());
     }
   } catch (QueryException e) {
     throw new DocumentException(e);
   }
 }
Exemplo n.º 3
0
 @Override
 public void close() {
   it.close();
 }