@Test public void testParse_simple() throws Exception { List<Token> listTokens = new ArrayList<Token>(); listTokens.add(new Token(Token.TYPE.RELATIONAL_OPERATOR, "=")); listTokens.add(new Token(Token.TYPE.PROPERTY_OPERAND, "a")); listTokens.add(new Token(Token.TYPE.VALUE_OPERAND, "b")); QueryParser parser = new QueryParser(); Predicate p = parser.parse(listTokens.toArray(new Token[listTokens.size()])); assertEquals(new EqualsPredicate<String>("a", "b"), p); }
public Predicate parse(Token[] tokens) throws InvalidQueryException { ParseContext ctx = parseExpressions(tokens); List<Expression> listExpressions = ctx.getExpressions(); changeHostNameToLowerCase(listExpressions); List<Expression> listMergedExpressions = mergeExpressions(listExpressions, ctx.getMaxPrecedence()); return listMergedExpressions.isEmpty() ? null : listMergedExpressions.get(0).toPredicate(); }
QueryParser { public Predicate parse(Token[] tokens) throws InvalidQueryException { ParseContext ctx = parseExpressions(tokens); List<Expression> listExpressions = ctx.getExpressions(); changeHostNameToLowerCase(listExpressions); List<Expression> listMergedExpressions = mergeExpressions(listExpressions, ctx.getMaxPrecedence()); return listMergedExpressions.isEmpty() ? null : listMergedExpressions.get(0).toPredicate(); } }
QueryParser { public Predicate parse(Token[] tokens) throws InvalidQueryException { ParseContext ctx = parseExpressions(tokens); List<Expression> listExpressions = ctx.getExpressions(); changeHostNameToLowerCase(listExpressions); List<Expression> listMergedExpressions = mergeExpressions(listExpressions, ctx.getMaxPrecedence()); return listMergedExpressions.isEmpty() ? null : listMergedExpressions.get(0).toPredicate(); } QueryParser(); }
QueryParser { public Predicate parse(Token[] tokens) throws InvalidQueryException { ParseContext ctx = parseExpressions(tokens); List<Expression> listExpressions = ctx.getExpressions(); changeHostNameToLowerCase(listExpressions); List<Expression> listMergedExpressions = mergeExpressions(listExpressions, ctx.getMaxPrecedence()); return listMergedExpressions.isEmpty() ? null : listMergedExpressions.get(0).toPredicate(); } QueryParser(); Predicate parse(Token[] tokens); }
QueryParser { public Predicate parse(Token[] tokens) throws InvalidQueryException { ParseContext ctx = parseExpressions(tokens); List<Expression> listExpressions = ctx.getExpressions(); changeHostNameToLowerCase(listExpressions); List<Expression> listMergedExpressions = mergeExpressions(listExpressions, ctx.getMaxPrecedence()); return listMergedExpressions.isEmpty() ? null : listMergedExpressions.get(0).toPredicate(); } QueryParser(); Predicate parse(Token[] tokens);  }