/** * Parses the RSQL expression and returns AST. * * @param query The query expression to parse. * @return A root of the parsed AST. * * @throws RSQLParserException If some exception occurred during parsing, i.e. the * {@code query} is syntactically invalid. * @throws IllegalArgumentException If the {@code query} is <tt>null</tt>. */ public Node parse(String query) throws RSQLParserException { if (query == null) { throw new IllegalArgumentException("query must not be null"); } InputStream is = new ByteArrayInputStream(query.getBytes(ENCODING)); Parser parser = new Parser(is, ENCODING.name(), nodesFactory); try { return parser.Input(); } catch (Exception | TokenMgrError ex) { throw new RSQLParserException(ex); } } }
/** * Parses the RSQL expression and returns AST. * * @param query The query expression to parse. * @return A root of the parsed AST. * * @throws RSQLParserException If some exception occurred during parsing, i.e. the * {@code query} is syntactically invalid. * @throws IllegalArgumentException If the {@code query} is <tt>null</tt>. */ public Node parse(String query) throws RSQLParserException { if (query == null) { throw new IllegalArgumentException("query must not be null"); } InputStream is = new ByteArrayInputStream(query.getBytes(ENCODING)); Parser parser = new Parser(is, ENCODING.name(), nodesFactory); try { return parser.Input(); } catch (Exception | TokenMgrError ex) { throw new RSQLParserException(ex); } } }