コード例 #1
0
ファイル: RESTCmd.java プロジェクト: LukasK/basex
 /**
  * Lists the table contents.
  *
  * @param table table reference
  * @param root root node
  * @param header table header
  * @param skip number of columns to skip
  */
 static void list(final Table table, final FElem root, final QNm header, final int skip) {
   for (final TokenList list : table.contents) {
     final FElem el = new FElem(header);
     // don't show last attribute (input path)
     final int ll = list.size() - skip;
     for (int l = 1; l < ll; l++) {
       el.add(new QNm(lc(table.header.get(l))), list.get(l));
     }
     el.add(list.get(0));
     root.add(el);
   }
 }
コード例 #2
0
ファイル: Find.java プロジェクト: phspaelti/basex
  /**
   * Creates an XQuery representation for the specified table query.
   *
   * @param filter filter terms
   * @param cols filter columns
   * @param elem element flag
   * @param name name of root element
   * @param root root flag
   * @return query
   */
  public static String findTable(
      final StringList filter,
      final TokenList cols,
      final BoolList elem,
      final byte[] name,
      final boolean root) {

    final TokenBuilder tb = new TokenBuilder();
    final int is = filter.size();
    for (int i = 0; i < is; ++i) {
      final String[] spl = split(filter.get(i));
      for (final String s : spl) {
        final byte[] term = trim(replace(token(s), '"', ' '));
        if (term.length == 0) continue;
        tb.add('[');

        final boolean elm = elem.get(i);
        tb.add(elm ? ".//" : "@");
        tb.add("*:");
        tb.add(cols.get(i));

        if (term[0] == '<' || term[0] == '>') {
          tb.add(term[0]);
          tb.addLong(calcNum(substring(term, 1)));
        } else {
          tb.add(" contains text \"");
          tb.add(term);
          tb.add('"');
        }
        tb.add(']');
      }
    }
    return tb.isEmpty() ? "/" : (root ? "/" : "") + Axis.DESCORSELF + "::*:" + string(name) + tb;
  }