/** Tokenizes the value and delegates to {@link #parseToken(String)} to parse each token. */ public final Object parse(String value) throws Exception { List tokens = KvpUtils.readFlat(value, delimiter); List parsed = new ArrayList(tokens.size()); final int size = tokens.size(); for (int i = 0; i < size; i++) { String token = (String) tokens.get(i); parsed.add(parseToken(token)); } return parse(parsed); }
public Object parse(String value) throws Exception { // create the parser final Configuration configuration = getParserConfiguration(); final Parser parser = new Parser(configuration); parser.setEntityResolver(entityResolverProvider.getEntityResolver()); // seperate the individual filter strings List unparsed = KvpUtils.readFlat(value, KvpUtils.OUTER_DELIMETER); List filters = new ArrayList(); Iterator i = unparsed.listIterator(); while (i.hasNext()) { String string = (String) i.next(); if ("".equals(string.trim())) { filters.add(Filter.INCLUDE); } else { InputStream input = new ByteArrayInputStream(string.getBytes()); try { Filter filter = (Filter) parser.parse(input); if (filter == null) { throw new NullPointerException(); } filters.add(filter); } catch (Exception e) { // parsing failed, fall back to old parser String msg = "Unable to parse filter: " + string; LOGGER.log(Level.WARNING, msg, e); Filter filter = parseXMLFilterWithOldParser(new StringReader(string)); if (filter != null) { filters.add(filter); } } } } return filters; }