boolean filter(Map<String,Object> variables,List<Expression> expressions)
{
boolean ok = true;
for (Expression expr : expressions) {
if (expr instanceof RelationalExpression) {
RelationalExpression r = (RelationalExpression)expr;
Object leftSide = null;
Object rightSide = null;
if (r.getLeftSide() instanceof VariableRef) {
leftSide = variables.get(((VariableRef)r.getLeftSide()).getName());
} else {
leftSide = ((LiteralRef)r.getLeftSide()).getValue();
}
if (r.getRightSide() instanceof VariableRef) {
rightSide = variables.get(((VariableRef)r.getRightSide()).getName());
} else {
rightSide = ((LiteralRef)r.getRightSide()).getValue();
}
if (rightSide==null || leftSide==null) {
ok = false;
break;
} else {
switch (r.getOperator()) {
case EQUALS:
ok = leftSide.equals(rightSide);
break;
case NOT_EQUALS:
ok = !leftSide.equals(rightSide);