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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations