@Override protected boolean run() { final String query = find(args[0], context, root); final boolean ok = query(query); final StringBuilder sb = new StringBuilder(); if (prop.is(Prop.QUERYINFO)) { sb.append(NL).append(QUERY_CC).append(NL).append(query).append(NL); } sb.append(info()); error(sb.toString()); return ok; }
/** * Splits the string and returns an array. * * @param str string to be split * @return array */ private static String[] split(final String str) { final int l = str.length(); final String[] split = new String[l]; int s = 0; char delim = 0; final StringBuilder sb = new StringBuilder(); for (int i = 0; i < l; ++i) { final char c = str.charAt(i); if (delim == 0) { if (c == '\'' || c == '"') { delim = c; } else if (!XMLToken.isChar(c) && c != '@' && c != '=' && c != '<' && c != '>' && c != '~') { if (sb.length() != 0) { split[s++] = sb.toString(); sb.setLength(0); } } else { sb.append(c); } } else { if (c == delim) { delim = 0; if (sb.length() != 0) { split[s++] = sb.toString(); sb.setLength(0); } } else { if (c != '\'' && c != '"') sb.append(c); } } } if (sb.length() != 0) split[s++] = sb.toString(); return Array.copyOf(split, s); }