Creates a query for the specified table search. @param filter filter terms @param cols filter columns @param elem element flag @param name name of root element @param root root flag @return query
(final StringList filter, final TokenList cols,
final BoolList elem, final String name, final boolean root)
| 71 | * @return query |
| 72 | */ |
| 73 | public static String tableQuery(final StringList filter, final TokenList cols, |
| 74 | final BoolList elem, final String name, final boolean root) { |
| 75 | |
| 76 | final TokenBuilder tb = new TokenBuilder(); |
| 77 | final int is = filter.size(); |
| 78 | for(int i = 0; i < is; ++i) { |
| 79 | final String[] spl = split(filter.get(i)); |
| 80 | for(final String s : spl) { |
| 81 | final byte[] term = trim(replace(token(s), '"', ' ')); |
| 82 | if(term.length == 0) continue; |
| 83 | final boolean elm = elem.get(i); |
| 84 | tb.add('[').add(elm ? ".//" : "@").add("*:").add(cols.get(i)); |
| 85 | |
| 86 | if(term[0] == '<' || term[0] == '>') { |
| 87 | tb.add(term[0]).addLong(sizeToLong(substring(term, 1))); |
| 88 | } else { |
| 89 | tb.add(" contains text \"").add(term).add('"'); |
| 90 | } |
| 91 | tb.add(']'); |
| 92 | } |
| 93 | } |
| 94 | return tb.isEmpty() ? "/" : (root ? "/" : "") + Axis.DESCENDANT_OR_SELF + "::*:" + name + tb; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Converts the token with a size unit suffix to a numeric value. |