Search in sources :

Example 6 with Compare

use of org.eclipse.rdf4j.query.algebra.Compare in project rdf4j by eclipse.

the class TupleExprBuilder method visit.

@Override
public ValueExpr visit(ASTIn node, Object data) throws VisitorException {
    ValueExpr result = null;
    ValueExpr leftArg = (ValueExpr) data;
    int listItemCount = node.jjtGetNumChildren();
    if (listItemCount == 0) {
        result = new ValueConstant(BooleanLiteral.FALSE);
    } else if (listItemCount == 1) {
        ValueExpr arg = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, null);
        result = new Compare(leftArg, arg, CompareOp.EQ);
    } else {
        ListMemberOperator listMemberOperator = new ListMemberOperator();
        listMemberOperator.addArgument(leftArg);
        for (int i = 0; i < listItemCount; i++) {
            ValueExpr arg = (ValueExpr) node.jjtGetChild(i).jjtAccept(this, null);
            listMemberOperator.addArgument(arg);
        }
        result = listMemberOperator;
    }
    return result;
}
Also used : ListMemberOperator(org.eclipse.rdf4j.query.algebra.ListMemberOperator) ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) ValueConstant(org.eclipse.rdf4j.query.algebra.ValueConstant) Compare(org.eclipse.rdf4j.query.algebra.Compare)

Aggregations

Compare (org.eclipse.rdf4j.query.algebra.Compare)6 ValueExpr (org.eclipse.rdf4j.query.algebra.ValueExpr)5 ValueConstant (org.eclipse.rdf4j.query.algebra.ValueConstant)4 And (org.eclipse.rdf4j.query.algebra.And)2 Var (org.eclipse.rdf4j.query.algebra.Var)2 CompareOp (org.eclipse.rdf4j.query.algebra.Compare.CompareOp)1 Filter (org.eclipse.rdf4j.query.algebra.Filter)1 Join (org.eclipse.rdf4j.query.algebra.Join)1 ListMemberOperator (org.eclipse.rdf4j.query.algebra.ListMemberOperator)1 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)1 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)1 Union (org.eclipse.rdf4j.query.algebra.Union)1 ASTCompare (org.eclipse.rdf4j.query.parser.serql.ast.ASTCompare)1 ASTValueExpr (org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr)1