@Test public void testParsesMultiCorrectly() { Evaluator<Object> eval = QueryParser.parse(".foo > ol, ol > li + li"); assertTrue(eval instanceof CombiningEvaluator.Or); CombiningEvaluator.Or<Object> or = (CombiningEvaluator.Or<Object>) eval; assertEquals(2, or.evaluators.size()); CombiningEvaluator.And<Object> andLeft = (CombiningEvaluator.And<Object>) or.evaluators.get(0); CombiningEvaluator.And<Object> andRight = (CombiningEvaluator.And<Object>) or.evaluators.get(1); assertEquals("ol :immediateParent(.foo)", andLeft.toString()); assertEquals(2, andLeft.evaluators.size()); assertEquals("li :prev(li :immediateParent(ol))", andRight.toString()); assertEquals(2, andLeft.evaluators.size()); }
public static <T> Evaluator<T> parse(String query) { try { QueryParser<T> p = new QueryParser<>(query); return p.parse(); } catch (IllegalArgumentException e) { throw new Selector.SelectorParseException(e.getMessage()); } }
QueryParser { public static <T> Evaluator<T> parse(String query) { try { QueryParser<T> p = new QueryParser<>(query); return p.parse(); } catch (IllegalArgumentException e) { throw new Selector.SelectorParseException(e.getMessage()); } } }
QueryParser { public static <T> Evaluator<T> parse(String query) { try { QueryParser<T> p = new QueryParser<>(query); return p.parse(); } catch (IllegalArgumentException e) { throw new Selector.SelectorParseException(e.getMessage()); } } private  QueryParser(String query); }
QueryParser { public static <T> Evaluator<T> parse(String query) { try { QueryParser<T> p = new QueryParser<>(query); return p.parse(); } catch (IllegalArgumentException e) { throw new Selector.SelectorParseException(e.getMessage()); } } private  QueryParser(String query); static Evaluator<T> parse(String query); }
QueryParser { public static <T> Evaluator<T> parse(String query) { try { QueryParser<T> p = new QueryParser<>(query); return p.parse(); } catch (IllegalArgumentException e) { throw new Selector.SelectorParseException(e.getMessage()); } } private  QueryParser(String query); static Evaluator<T> parse(String query);  }