use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TestUserDefinedFunctionFactory method test_user_defined_function_factory_add_02.
@Test
public void test_user_defined_function_factory_add_02() {
Expr e1 = new E_Multiply(new ExprVar("x"), new ExprVar("x"));
Expr e2 = new E_Multiply(new ExprVar("y"), new ExprVar("y"));
UserDefinedFunctionFactory.getFactory().add("http://example/square", e1, new ArrayList<>(e1.getVarsMentioned()));
Assert.assertTrue(UserDefinedFunctionFactory.getFactory().isRegistered("http://example/square"));
Assert.assertEquals(e1, UserDefinedFunctionFactory.getFactory().get("http://example/square").getBaseExpr());
UserDefinedFunctionFactory.getFactory().add("http://example/square", e2, new ArrayList<>(e2.getVarsMentioned()));
Assert.assertTrue(UserDefinedFunctionFactory.getFactory().isRegistered("http://example/square"));
Assert.assertEquals(e2, UserDefinedFunctionFactory.getFactory().get("http://example/square").getBaseExpr());
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TestUserFunctionsInSparql method setup.
@BeforeClass
public static void setup() {
UserDefinedFunctionFactory.getFactory().clear();
// Define a square function
Expr square = new E_Multiply(new ExprVar("x"), new ExprVar("x"));
UserDefinedFunctionFactory.getFactory().add("http://example/square", square, new ArrayList<>(square.getVarsMentioned()));
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TestOptimizer method combine_extend_02.
@Test
public void combine_extend_02() {
Op extend = OpExtend.create(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
extend = OpExtend.create(extend, new VarExprList(Var.alloc("y"), new ExprVar("x")));
String opExpectedString = StrUtils.strjoinNL("(extend ((?x 1) (?y ?x))", " (table unit))");
check(extend, new TransformExtendCombine(), opExpectedString);
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TestOptimizer method combine_assign_02.
@Test
public void combine_assign_02() {
Op assign = OpAssign.create(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
assign = OpAssign.create(assign, new VarExprList(Var.alloc("y"), new ExprVar("x")));
String opExpectedString = StrUtils.strjoinNL("(assign ((?x 1) (?y ?x))", " (table unit))");
check(assign, new TransformExtendCombine(), opExpectedString);
}
use of org.apache.jena.sparql.expr.ExprVar in project webofneeds by researchstudio-sat.
the class SparqlSelectFunction method addOrderBy.
/**
* Use Query.ORDER_* for the direction value.
*
* @param varName
* @param direction
*/
public SparqlSelectFunction<T> addOrderBy(String varName, int direction) {
varName = Var.canonical(varName);
SortCondition sc = new SortCondition(new ExprVar(varName), direction);
addOrderBy(sc);
return this;
}
Aggregations