@Test public void testParser01() throws Exception { String query = "Compute[@fqdns=\"aaaa.ebay.com\"]{*}." + "( <VPool>parentCluster[@_oid=\"CLguf6sdle-invalid\"] " + "&& activeManifestRef[@_oid=\"B-N-D-1.20111108154904.0\"]" + "|| activeManifestCur[@_oid=\"Black-Pearl-1.20111103221326.0\"])"; ParseBaseNode baseNode = stratusParser.parse(query); Assert.assertTrue(baseNode.getType() == ParseNodeTypeEnum.QUERY); Assert.assertTrue(baseNode.getNextNodes().size() == 1); ParseBaseNode joinNode = baseNode.getNextNodes().get(0); Assert.assertTrue(joinNode.getType() == ParseNodeTypeEnum.INNERJOIN); Assert.assertTrue(joinNode.getNextNodes().size() == 1); ParseBaseNode unionNode = joinNode.getNextNodes().get(0); Assert.assertTrue(unionNode.getType() == ParseNodeTypeEnum.UNION); Assert.assertTrue(unionNode.getNextNodes().size() == 2); ParseBaseNode intersectNode = unionNode.getNextNodes().get(0); Assert.assertTrue(intersectNode.getType() == ParseNodeTypeEnum.INTERSECTION); Assert.assertTrue(intersectNode.getNextNodes().size() == 2); ParseBaseNode manifestCurNode = unionNode.getNextNodes().get(1); Assert.assertTrue(manifestCurNode.getType() == ParseNodeTypeEnum.QUERY); }
public ParseBaseNode parse(String query) { CommonTree queryTree = parseAST(query); try { ParseBaseNode rootNode = parseQuery(queryTree, query); rootNode.validate(parseContext); postValidate(rootNode); return rootNode; } catch (QueryParseException e) { logger.error(e.getMessage()); throw e; } catch (Throwable t) { throw new QueryParseException(QueryErrCodeEnum.SYNTAX_ERROR, MessageFormat.format("{0}!Syntax Error: {1}", query, t.getMessage()), t); } }
QueryParser { public ParseBaseNode parse(String query) { CommonTree queryTree = parseAST(query); try { ParseBaseNode rootNode = parseQuery(queryTree, query); rootNode.validate(parseContext); postValidate(rootNode); return rootNode; } catch (QueryParseException e) { logger.error(e.getMessage()); throw e; } catch (Throwable t) { throw new QueryParseException(QueryErrCodeEnum.SYNTAX_ERROR, MessageFormat.format("{0}!Syntax Error: {1}", query, t.getMessage()), t); } } }
QueryParser { public ParseBaseNode parse(String query) { CommonTree queryTree = parseAST(query); try { ParseBaseNode rootNode = parseQuery(queryTree, query); rootNode.validate(parseContext); postValidate(rootNode); return rootNode; } catch (QueryParseException e) { logger.error(e.getMessage()); throw e; } catch (Throwable t) { throw new QueryParseException(QueryErrCodeEnum.SYNTAX_ERROR, MessageFormat.format("{0}!Syntax Error: {1}", query, t.getMessage()), t); } } QueryParser(QueryContext queryContext); }
QueryParser { public ParseBaseNode parse(String query) { CommonTree queryTree = parseAST(query); try { ParseBaseNode rootNode = parseQuery(queryTree, query); rootNode.validate(parseContext); postValidate(rootNode); return rootNode; } catch (QueryParseException e) { logger.error(e.getMessage()); throw e; } catch (Throwable t) { throw new QueryParseException(QueryErrCodeEnum.SYNTAX_ERROR, MessageFormat.format("{0}!Syntax Error: {1}", query, t.getMessage()), t); } } QueryParser(QueryContext queryContext); ParseBaseNode parse(String query); }
QueryParser { public ParseBaseNode parse(String query) { CommonTree queryTree = parseAST(query); try { ParseBaseNode rootNode = parseQuery(queryTree, query); rootNode.validate(parseContext); postValidate(rootNode); return rootNode; } catch (QueryParseException e) { logger.error(e.getMessage()); throw e; } catch (Throwable t) { throw new QueryParseException(QueryErrCodeEnum.SYNTAX_ERROR, MessageFormat.format("{0}!Syntax Error: {1}", query, t.getMessage()), t); } } QueryParser(QueryContext queryContext); ParseBaseNode parse(String query);  }