use of org.eclipse.rdf4j.query.algebra.ValueConstant 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;
}
use of org.eclipse.rdf4j.query.algebra.ValueConstant in project rdf4j by eclipse.
the class QueryBuilderFactory method describe.
/**
* Create a QueryBuilder for creating a describe query
*
* @param theVars
* the variables to be described
* @param theValues
* the specific bound URI values to be described
* @return a describe query builder
*/
public static QueryBuilder<ParsedGraphQuery> describe(String[] theVars, Resource... theValues) {
QueryBuilder<ParsedGraphQuery> aBuilder = new AbstractQueryBuilder<ParsedGraphQuery>(new ParsedDescribeQuery());
aBuilder.reduced();
aBuilder.addProjectionVar("descr_subj", "descr_pred", "descr_obj");
GroupBuilder<?, ?> aGroup = aBuilder.group();
if (theVars != null) {
for (String aVar : theVars) {
Var aVarObj = new Var(aVar);
aVarObj.setAnonymous(true);
aGroup.filter().or(new SameTerm(aVarObj, new Var("descr_subj")), new SameTerm(aVarObj, new Var("descr_obj")));
}
}
if (theValues != null) {
for (Resource aVar : theValues) {
Var aSubjVar = new Var("descr_subj");
aSubjVar.setAnonymous(true);
Var aObjVar = new Var("descr_obj");
aObjVar.setAnonymous(true);
aGroup.filter().or(new SameTerm(new ValueConstant(aVar), aSubjVar), new SameTerm(new ValueConstant(aVar), aObjVar));
}
}
aGroup.atom("descr_subj", "descr_pred", "descr_obj");
return aBuilder;
}
use of org.eclipse.rdf4j.query.algebra.ValueConstant in project rdf4j by eclipse.
the class TupleExprBuilder method visit.
@Override
public PropertySetElem visit(ASTPathOneInPropertySet node, Object data) throws VisitorException {
PropertySetElem result = new PropertySetElem();
result.setInverse(node.isInverse());
ValueConstant predicate = (ValueConstant) node.jjtGetChild(0).jjtAccept(this, data);
result.setPredicate(predicate);
return result;
}
Aggregations