use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public ValueExpr visit(ASTInList node, Object data) throws VisitorException {
ValueExpr leftArg = (ValueExpr) node.getValueExpr().jjtAccept(this, null);
ValueExpr result = null;
for (ASTValueExpr argExpr : node.getArgList().getElements()) {
ValueExpr rightArg = (ValueExpr) argExpr.jjtAccept(this, null);
if (result == null) {
// First argument
result = new SameTerm(leftArg, rightArg);
} else {
SameTerm sameTerm = new SameTerm(leftArg.clone(), rightArg);
result = new Or(result, sameTerm);
}
}
assert result != null;
return result;
}
use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public ValueExpr visit(ASTOr node, Object data) throws VisitorException {
Iterator<ASTBooleanExpr> iter = node.getOperandList().iterator();
ValueExpr result = (ValueExpr) iter.next().jjtAccept(this, null);
while (iter.hasNext()) {
ValueExpr operand = (ValueExpr) iter.next().jjtAccept(this, null);
result = new Or(result, operand);
}
return result;
}
use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public Regex visit(ASTRegex node, Object data) throws VisitorException {
ValueExpr text = (ValueExpr) node.getText().jjtAccept(this, null);
ValueExpr pattern = (ValueExpr) node.getPattern().jjtAccept(this, null);
ValueExpr flags = null;
if (node.hasFlags()) {
flags = (ValueExpr) node.getFlags().jjtAccept(this, null);
}
return new Regex(text, pattern, flags);
}
use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public TupleExpr visit(ASTSelect node, Object data) throws VisitorException {
TupleExpr result = (TupleExpr) data;
Extension extension = new Extension();
ProjectionElemList projElemList = new ProjectionElemList();
for (ASTProjectionElem projElemNode : node.getProjectionElemList()) {
ValueExpr valueExpr = (ValueExpr) projElemNode.getValueExpr().jjtAccept(this, null);
String alias = projElemNode.getAlias();
if (alias != null) {
// aliased projection element
extension.addElement(new ExtensionElem(valueExpr, alias));
projElemList.addElement(new ProjectionElem(alias));
} else if (valueExpr instanceof Var) {
// unaliased variable
Var projVar = (Var) valueExpr;
projElemList.addElement(new ProjectionElem(projVar.getName()));
} else {
throw new IllegalStateException("required alias for non-Var projection elements not found");
}
}
if (!extension.getElements().isEmpty()) {
extension.setArg(result);
result = extension;
}
result = new Projection(result, projElemList);
if (node.isDistinct()) {
result = new Distinct(result);
} else if (node.isReduced()) {
result = new Reduced(result);
}
return result;
}
use of org.eclipse.rdf4j.query.algebra.ValueExpr in project rdf4j by eclipse.
the class BasicGroup method filtersAsAnd.
private ValueExpr filtersAsAnd() {
ValueExpr aExpr = null;
for (ValueExpr aValEx : mFilters) {
if (aExpr == null) {
aExpr = aValEx;
} else {
And aAnd = new And();
aAnd.setLeftArg(aValEx);
aAnd.setRightArg(aExpr);
aExpr = aAnd;
}
}
return aExpr;
}
Aggregations