Beispiel #1
0
  @Override
  protected boolean run() throws IOException {
    // get arguments
    final String start = args.length > 0 ? args[0] : null;
    final String end = args.length > 1 ? args[1] : null;

    // evaluate input as number range or xquery
    if (start != null && toInt(start) == Integer.MIN_VALUE) {
      queryNodes();
      if (result == null) return false;
    }

    final Data data = context.data();
    if (result != null) {
      final Table table = th();
      for (final int n : ((Nodes) result).list) table(table, data, n);
      out.print(table.finish());
      result = null;
    } else {
      int ps = 0;
      int pe = 1000;

      if (start != null) {
        if (end != null) {
          ps = toInt(start);
          pe = toInt(end) + 1;
        } else {
          ps = toInt(start);
          pe = ps + 1;
        }
      }
      out.print(table(data, ps, pe));
    }
    return true;
  }
Beispiel #2
0
  /**
   * Prints the specified range of the table.
   *
   * @param data data reference
   * @param s first node to be printed
   * @param e last node to be printed
   * @return table
   */
  public static byte[] table(final Data data, final int s, final int e) {
    final TokenBuilder tb = new TokenBuilder();
    final int ps = Math.max(0, s);
    final int pe = Math.min(data.meta.size, e);
    final Table table = th();
    for (int p = ps; p < pe; ++p) table(table, data, p);
    tb.add(table.finish());

    final byte[] ns = data.ns.table(ps, pe);
    if (ns.length != 0) tb.add(NL).add(ns).add(data.ns.toString(ps, pe)).add(NL);
    return tb.finish();
  }
Beispiel #3
0
 /**
  * Returns a string representation of the specified table range. Can be called for debugging.
  *
  * @param start start pre value
  * @param end end pre value
  * @return table
  */
 final String toString(final int start, final int end) {
   return string(InfoStorage.table(this, start, end));
 }