Search in sources :

Example 1 with ListMemberOperator

use of org.eclipse.rdf4j.query.algebra.ListMemberOperator 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)1 ListMemberOperator (org.eclipse.rdf4j.query.algebra.ListMemberOperator)1 ValueConstant (org.eclipse.rdf4j.query.algebra.ValueConstant)1 ValueExpr (org.eclipse.rdf4j.query.algebra.ValueExpr)1