@Test public void testParse_NotOp() 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, "1")); listTokens.add(new Token(Token.TYPE.LOGICAL_OPERATOR, "&")); listTokens.add(new Token(Token.TYPE.LOGICAL_UNARY_OPERATOR, "!")); listTokens.add(new Token(Token.TYPE.RELATIONAL_OPERATOR, "=")); listTokens.add(new Token(Token.TYPE.PROPERTY_OPERAND, "b")); listTokens.add(new Token(Token.TYPE.VALUE_OPERAND, "2")); QueryParser parser = new QueryParser(); Predicate p = parser.parse(listTokens.toArray(new Token[listTokens.size()])); EqualsPredicate aPred = new EqualsPredicate<String>("a", "1"); EqualsPredicate bPred = new EqualsPredicate<String>("b", "2"); NotPredicate notPred = new NotPredicate(bPred); AndPredicate andPred = new AndPredicate(aPred, notPred); assertEquals(andPred, 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);  }