protected synchronized Object initialValue() { return new Parser(new StringReader(";")); } };
protected synchronized Object initialValue() { return new Parser(new StringReader(";")); } };
protected synchronized Object initialValue() { return new Parser(new StringReader(";")); } };
/** * Static method to run a depth-first traversal over the AST * * @param query * JEXL query string */ public static Set<String> parseQuery(String query) throws ParseException { // Instantiate a parser and visitor Parser parser = new Parser(new StringReader(";")); // Parse the query return parseQuery(parser.parse(new StringReader(query), null)); }
/** * Static method to run a depth-first traversal over the AST * * @param query * JEXL query string */ public static void printQuery(String query) throws ParseException { // Instantiate a parser and visitor Parser parser = new Parser(new StringReader(";")); // Parse the query printQuery(parser.parse(new StringReader(query), null)); }
/** * Parse a query string using a JEXL parser and transform it into a parse tree of our RefactoredDatawaveTreeNodes. This also sets all convenience maps that * the analyzer provides. * * @param query * The query string in JEXL syntax to parse * @return Root node of the query parse tree. * @throws ParseException */ public static ASTJexlScript parseJexlQuery(String query) throws ParseException { // Instantiate a parser and visitor Parser parser = new Parser(new StringReader(";")); String caseFixQuery = query.replaceAll("\\s+[Aa][Nn][Dd]\\s+", " and "); caseFixQuery = caseFixQuery.replaceAll("\\s+[Oo][Rr]\\s+", " or "); caseFixQuery = caseFixQuery.replaceAll("\\s+[Nn][Oo][Tt]\\s+", " not "); // Parse the query return parser.parse(new StringReader(caseFixQuery), null); }
/** * Get a {@link java.lang.String} representation for this query string * * @param query * @param maxChildNodes * @return * @throws ParseException */ public static String formattedQueryString(String query, int maxChildNodes) throws ParseException { // Instantiate a parser and visitor Parser parser = new Parser(new StringReader(";")); // Parse the query return formattedQueryString(parser.parse(new StringReader(query), null), maxChildNodes); }
private Expression createNormalizedExpression(final String query) { try { Parser parser = new Parser(new StringReader(";")); ASTJexlScript script = parser.parse(new StringReader(query), null); Deque<SimpleNode> nodes = new LinkedList<>(); normalizeScript(script, nodes); return new NormalizedExpression(jEngine, query, script); } catch (org.apache.commons.jexl2.parser.ParseException pe) { throw new AssertionError(pe); } }
/** * Parses JEXL in query string to create ranges and column family filters * * @param queryString * jexl string for the query */ protected QueryData configureRanges(String queryString) throws ParseException { queryString = EdgeQueryLogic.fixQueryString(queryString); QueryData qData = new QueryData(); Parser parser = new Parser(new StringReader(";")); ASTJexlScript script; try { script = parser.parse(new StringReader(queryString), null); } catch (Exception e) { throw new IllegalArgumentException("Invalid jexl supplied. " + e.getMessage()); } EdgeTableRangeBuildingVisitor visitor = new EdgeTableRangeBuildingVisitor(config.includeStats(), dataTypes, config.getMaxQueryTerms(), regexDataTypes); visitationContext = (VisitationContext) script.jjtAccept(visitor, null); Set<Range> ranges = visitationContext.getRanges(); qData.setRanges(ranges); return qData; }