@Test public void test5() throws ParseException { varStr = "'abc.a'|f1:\"a'b|c,\",b|f2"; parser = new FilterParser(varStr); parser.parse(); assertEquals("'abc.a'", parser.getVariable()); assertEquals(2, parser.getFilters().size()); assertEquals(2, parser.getArgss().get(0).length); }
@Test(expected = ParseException.class) public void test2() throws ParseException { varStr = "abc.a|f1:'abc\",b|f2"; parser = new FilterParser(varStr); parser.parse(); assertEquals("abc.a", parser.getVariable()); assertEquals(2, parser.getFilters().size()); assertEquals(2, parser.getArgss().get(0).length); }
@Test public void test1() throws ParseException { varStr = "abc.a|f1:abc,b|f2"; parser = new FilterParser(varStr); parser.parse(); assertEquals("abc.a", parser.getVariable()); assertEquals(2, parser.getFilters().size()); assertEquals(2, parser.getArgss().get(0).length); }
private static CommonTree runParser(CharStream charStream) throws Exception { FilterLexer lex = new FilterLexer(charStream); CommonTokenStream tokens = new CommonTokenStream(lex); FilterParser g = new FilterParser(tokens); try { filter_return fr = g.filter(); CommonTree tree = (CommonTree) fr.getTree(); return tree; } catch (RecognitionException e) { e.printStackTrace(); return null; } }
@Test public void test7() throws ParseException { varStr = "'abc.a'|f1:\"a'b|c,\",|f2:bec,xz|"; parser = new FilterParser(varStr); parser.parse(); assertEquals("'abc.a'", parser.getVariable()); assertEquals(2, parser.getFilters().size()); assertEquals("f1", parser.getFilters().get(0)); assertEquals("\"a'b|c,\"", parser.getArgss().get(0)[0]); assertEquals(1, parser.getArgss().get(0).length); assertEquals("bec", parser.getArgss().get(1)[0]); assertEquals("xz", parser.getArgss().get(1)[1]); assertEquals(2, parser.getArgss().get(1).length); }
/** * Parse a filter from its string representation. * * @param filterString The string representation of the filter expression. * @param defaultSchema The default schema that should be assumed when parsing attributes without * the schema explicitly defined in the URN. * @return The parsed filter. * @throws SCIMException If the filter string could not be parsed. */ public static SCIMFilter parse(final String filterString, final String defaultSchema) throws SCIMException { final FilterParser parser = new FilterParser(filterString, defaultSchema); return parser.parse(); }
/** * Parse a filter from its string representation. * * @param filterString The string representation of the filter expression. * @return The parsed filter. * @throws SCIMException If the filter string could not be parsed. */ public static SCIMFilter parse(final String filterString) throws SCIMException { final FilterParser parser = new FilterParser(filterString, SCIMConstants.SCHEMA_URI_CORE); return parser.parse(); }
public void setFilters(String filters) { this.filters = FilterParser.parse(filters); }