use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class PropFuncArg method asExprList.
/** @deprecated To be removed - use {@link #asExprList()} */
@Deprecated
public ExprList asExprList(PropFuncArg pfArg) {
ExprList exprList = new ExprList();
if (pfArg.isNode()) {
Node n = pfArg.getArg();
Expr expr = ExprUtils.nodeToExpr(n);
exprList.add(expr);
return exprList;
}
for (Node n : pfArg.getArgList()) {
Expr expr = ExprUtils.nodeToExpr(n);
exprList.add(expr);
}
return exprList;
}
use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class TestSSE_Builder method testExprForms.
private static void testExprForms(String str1, String str2) {
Expr e1 = SSE.parseExpr(str1);
Expr e2 = SSE.parseExpr(str2);
assertEquals(str1 + " " + str2, e1, e2);
}
use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class TestSSE_Builder method testBuildExpr_02.
@Test
public void testBuildExpr_02() {
Expr e = SSE.parseExpr("(isNumeric ?x)");
assertTrue(e instanceof E_IsNumeric);
}
use of org.apache.jena.sparql.expr.Expr in project jena by apache.
the class FunctionBase method exec.
@Override
public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) {
if (args == null)
// The contract on the function interface is that this should not happen.
throw new ARQInternalErrorException("FunctionBase: Null args list");
List<NodeValue> evalArgs = new ArrayList<>();
for (Expr e : args) {
NodeValue x = e.eval(binding, env);
evalArgs.add(x);
}
NodeValue nv = exec(evalArgs);
return nv;
}
use of org.apache.jena.sparql.expr.Expr in project webofneeds by researchstudio-sat.
the class SparqlSelectFunction method apply.
@Override
public List<T> apply(Dataset dataset) {
boolean existingTransaction = dataset.isInTransaction();
if (!existingTransaction) {
dataset.begin(ReadWrite.READ);
}
Dataset result = DatasetFactory.createGeneral();
result.begin(ReadWrite.WRITE);
try {
Query theQuery = this.getQuery();
if (this.limit != null) {
theQuery.setLimit(this.limit);
}
if (this.offset != null) {
theQuery.setOffset(this.offset);
}
if (this.orderBy != null) {
for (SortCondition sortCondition : this.orderBy) {
theQuery.addOrderBy(sortCondition);
}
}
if (this.havingCondiditions != null) {
for (Expr havingCondition : this.havingCondiditions) {
theQuery.addHavingCondition(havingCondition);
}
}
QuerySolution binding = this.initialBinding;
if (binding == null) {
binding = new QuerySolutionMap();
}
List<T> ret = new ArrayList<>();
try (QueryExecution queryExecution = QueryExecutionFactory.create(theQuery, dataset, binding)) {
ResultSet resultSet = queryExecution.execSelect();
while (resultSet.hasNext()) {
ret.add(this.resultGenerator.apply(resultSet.next()));
}
}
return ret;
} finally {
if (!existingTransaction) {
dataset.end();
}
result.commit();
}
}
Aggregations