Search in sources :

Example 6 with ValueExpr

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

the class QueryModelBuilder method visit.

@Override
public LangMatches visit(ASTLangMatches node, Object data) throws VisitorException {
    ValueExpr tag = (ValueExpr) node.getLanguageTag().jjtAccept(this, null);
    ValueExpr range = (ValueExpr) node.getLanguageRange().jjtAccept(this, null);
    return new LangMatches(tag, range);
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) ASTValueExpr(org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr) ASTLangMatches(org.eclipse.rdf4j.query.parser.serql.ast.ASTLangMatches) LangMatches(org.eclipse.rdf4j.query.algebra.LangMatches)

Example 7 with ValueExpr

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

the class QueryModelBuilder method visit.

@Override
public Object visit(ASTWhere node, Object data) throws VisitorException {
    ValueExpr valueExpr = (ValueExpr) node.getCondition().jjtAccept(this, null);
    graphPattern.addConstraint(valueExpr);
    return null;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) ASTValueExpr(org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr)

Example 8 with ValueExpr

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

the class TupleExprBuilder method visit.

@Override
public If visit(ASTIf node, Object data) throws VisitorException {
    If result = null;
    if (node.jjtGetNumChildren() < 3) {
        throw new VisitorException("IF construction missing required number of arguments");
    }
    ValueExpr condition = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, null);
    ValueExpr resultExpr = (ValueExpr) node.jjtGetChild(1).jjtAccept(this, null);
    ValueExpr alternative = (ValueExpr) node.jjtGetChild(2).jjtAccept(this, null);
    result = new If(condition, resultExpr, alternative);
    return result;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) If(org.eclipse.rdf4j.query.algebra.If)

Example 9 with ValueExpr

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

the class TupleExprBuilder method visit.

@Override
public BindingSet visit(ASTBindingSet node, Object data) throws VisitorException {
    @SuppressWarnings("unchecked") List<Var> vars = (List<Var>) data;
    List<String> names = new ArrayList<String>(vars.size());
    for (Var var : vars) {
        names.add(var.getName());
    }
    int numberOfBindingValues = node.jjtGetNumChildren();
    if (numberOfBindingValues != vars.size()) {
        throw new VisitorException("number of values in bindingset does not match variables in BINDINGS clause");
    }
    Value[] values = new Value[numberOfBindingValues];
    for (int i = 0; i < numberOfBindingValues; i++) {
        ValueExpr ve = (ValueExpr) node.jjtGetChild(i).jjtAccept(this, null);
        if (ve != null) {
            Value v = getValueForExpr(ve);
            values[i] = v;
        }
    }
    BindingSet result = new ListBindingSet(names, values);
    return result;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) BindingSet(org.eclipse.rdf4j.query.BindingSet) ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) Var(org.eclipse.rdf4j.query.algebra.Var) ArrayList(java.util.ArrayList) Value(org.eclipse.rdf4j.model.Value) List(java.util.List) ArrayList(java.util.ArrayList) ProjectionElemList(org.eclipse.rdf4j.query.algebra.ProjectionElemList)

Example 10 with ValueExpr

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

the class TupleExprBuilder method visit.

@Override
public String visit(ASTGroupCondition node, Object data) throws VisitorException {
    Group group = (Group) data;
    TupleExpr arg = group.getArg();
    Extension extension = null;
    if (arg instanceof Extension) {
        extension = (Extension) arg;
    } else {
        extension = new Extension();
    }
    String name = null;
    ValueExpr ve = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, data);
    boolean aliased = false;
    if (node.jjtGetNumChildren() > 1) {
        aliased = true;
        Var v = (Var) node.jjtGetChild(1).jjtAccept(this, data);
        name = v.getName();
    } else {
        if (ve instanceof Var) {
            name = ((Var) ve).getName();
        } else {
            aliased = true;
            Var v = createAnonVar();
            name = v.getName();
        }
    }
    if (aliased) {
        ExtensionElem elem = new ExtensionElem(ve, name);
        extension.addElement(elem);
    }
    if (extension.getElements().size() > 0 && !(arg instanceof Extension)) {
        extension.setArg(arg);
        group.setArg(extension);
    }
    return name;
}
Also used : Extension(org.eclipse.rdf4j.query.algebra.Extension) Group(org.eclipse.rdf4j.query.algebra.Group) ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) Var(org.eclipse.rdf4j.query.algebra.Var) ExtensionElem(org.eclipse.rdf4j.query.algebra.ExtensionElem) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr)

Aggregations

ValueExpr (org.eclipse.rdf4j.query.algebra.ValueExpr)55 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)19 Var (org.eclipse.rdf4j.query.algebra.Var)19 ASTValueExpr (org.eclipse.rdf4j.query.parser.serql.ast.ASTValueExpr)14 ProjectionElemList (org.eclipse.rdf4j.query.algebra.ProjectionElemList)10 ArrayList (java.util.ArrayList)9 Extension (org.eclipse.rdf4j.query.algebra.Extension)9 ExtensionElem (org.eclipse.rdf4j.query.algebra.ExtensionElem)9 And (org.eclipse.rdf4j.query.algebra.And)7 ValueConstant (org.eclipse.rdf4j.query.algebra.ValueConstant)7 Filter (org.eclipse.rdf4j.query.algebra.Filter)6 Projection (org.eclipse.rdf4j.query.algebra.Projection)6 ProjectionElem (org.eclipse.rdf4j.query.algebra.ProjectionElem)6 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)6 List (java.util.List)5 Compare (org.eclipse.rdf4j.query.algebra.Compare)5 MultiProjection (org.eclipse.rdf4j.query.algebra.MultiProjection)5 Reduced (org.eclipse.rdf4j.query.algebra.Reduced)5 BNodeGenerator (org.eclipse.rdf4j.query.algebra.BNodeGenerator)4 Distinct (org.eclipse.rdf4j.query.algebra.Distinct)4