Example #1
0
 @Override
 public final void plan(final Serializer ser) throws IOException {
   ser.openElement(this);
   root.plan(ser);
   super.plan(ser);
   ser.closeElement();
 }
Example #2
0
  /** Saves the displayed text. */
  private void save() {
    final BaseXFileChooser fc =
        new BaseXFileChooser(SAVE_AS, gui.gopts.get(GUIOptions.WORKPATH), gui).suffix(IO.XMLSUFFIX);

    final IO file = fc.select(Mode.FSAVE);
    if (file == null) return;
    gui.gopts.set(GUIOptions.WORKPATH, file.path());

    gui.cursor(CURSORWAIT, true);
    final MainOptions opts = gui.context.options;
    final int mh = opts.get(MainOptions.MAXHITS);
    opts.set(MainOptions.MAXHITS, -1);
    opts.set(MainOptions.CACHEQUERY, false);

    try (final PrintOutput out = new PrintOutput(file.toString())) {
      if (cmd != null) {
        cmd.execute(gui.context, out);
      } else if (ns != null) {
        ns.serialize(Serializer.get(out));
      } else {
        final byte[] txt = text.getText();
        for (final byte t : txt) if (t < 0 || t > ' ' || ws(t)) out.write(t);
      }
    } catch (final IOException ex) {
      BaseXDialog.error(gui, Util.info(FILE_NOT_SAVED_X, file));
    } finally {
      opts.set(MainOptions.MAXHITS, mh);
      opts.set(MainOptions.CACHEQUERY, true);
      gui.cursor(CURSORARROW, true);
    }
  }
Example #3
0
 /**
  * Returns a serializer for the given output stream. Optional output declarations within the query
  * will be included in the serializer instance.
  *
  * @param os output stream
  * @return serializer instance
  * @throws IOException query exception
  * @throws QueryException query exception
  */
 public Serializer getSerializer(final OutputStream os) throws IOException, QueryException {
   compile();
   try {
     return Serializer.get(os, qc.serParams());
   } catch (final QueryIOException ex) {
     throw ex.getCause();
   }
 }
Example #4
0
 @Override
 public void plan(final Serializer ser) throws IOException {
   ser.emptyElement(
       this,
       DATA,
       token(ictx.data.meta.name),
       MIN,
       token(ind.min),
       MAX,
       token(ind.max),
       TYP,
       token(ind.type.toString()));
 }
Example #5
0
 /**
  * Serializes the specified nodes.
  *
  * @param n nodes to display
  */
 private void setText(final DBNodes n) {
   if (visible()) {
     try {
       final ArrayOutput ao = new ArrayOutput();
       ao.setLimit(gui.gopts.get(GUIOptions.MAXTEXT));
       if (n != null) n.serialize(Serializer.get(ao));
       setText(ao);
       cmd = null;
       ns = ao.finished() ? n : null;
     } catch (final IOException ex) {
       Util.debug(ex);
     }
   } else {
     home.setEnabled(gui.context.data() != null);
   }
 }
Example #6
0
 @Override
 public void plan(final Serializer ser) throws IOException {
   ser.openElement(this, token(same ? SAME : DIFFERENT), token(unit.toString()));
   super.plan(ser);
 }
Example #7
0
 @Override
 public void plan(final Serializer ser) throws IOException {
   ser.openElement(this, TYP, Token.token(type.toString()));
   expr.plan(ser);
   ser.closeElement();
 }