Search in sources :

Example 46 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestCastXSD method cast.

private NodeValue cast(String input$) {
    Expr input = ExprUtils.parse(input$);
    ARQ.getContext().set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime());
    FunctionEnv env = new ExecutionContext(ARQ.getContext(), null, null, null);
    return input.eval(null, env);
}
Also used : FunctionEnv(org.apache.jena.sparql.function.FunctionEnv) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) Expr(org.apache.jena.sparql.expr.Expr)

Example 47 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestExprLib method testSafeEquality.

private static void testSafeEquality(String string, boolean b, boolean graphString, boolean graphNumber) {
    Expr expr = ExprUtils.parse(string);
    Assert.assertEquals(string, b, ExprLib.isAssignmentSafeEquality(expr, graphString, graphNumber));
}
Also used : Expr(org.apache.jena.sparql.expr.Expr)

Example 48 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestExpressions method testVar.

private static void testVar(String string, String rightVarName) {
    Expr expr = parse(string);
    assertTrue("Not a NodeVar: " + expr, expr.isVariable());
    ExprVar v = (ExprVar) expr;
    assertEquals("Different variable names", rightVarName, v.getVarName());
}
Also used : ExprVar(org.apache.jena.sparql.expr.ExprVar) Expr(org.apache.jena.sparql.expr.Expr)

Example 49 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestExpressions method testNumeric.

private static void testNumeric(String string, int i) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(BindingFactory.binding(), new FunctionEnvBase());
    assertTrue(v.isInteger());
    assertEquals(i, v.getInteger().intValue());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 50 with Expr

use of org.apache.jena.sparql.expr.Expr in project jena by apache.

the class TestExpressions method testBoolean.

private static void testBoolean(String string, boolean b, Binding env) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(env, new FunctionEnvBase());
    assertTrue(v.isBoolean());
    assertEquals(b, v.getBoolean());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Aggregations

Expr (org.apache.jena.sparql.expr.Expr)83 Var (org.apache.jena.sparql.core.Var)28 ExprList (org.apache.jena.sparql.expr.ExprList)15 NodeValue (org.apache.jena.sparql.expr.NodeValue)15 Op (org.apache.jena.sparql.algebra.Op)13 ExprVar (org.apache.jena.sparql.expr.ExprVar)12 FunctionEnvBase (org.apache.jena.sparql.function.FunctionEnvBase)9 Test (org.junit.Test)9 VarExprList (org.apache.jena.sparql.core.VarExprList)8 Node (org.apache.jena.graph.Node)7 E_Random (org.apache.jena.sparql.expr.E_Random)7 ArrayList (java.util.ArrayList)6 Triple (org.apache.jena.graph.Triple)4 E_Multiply (org.apache.jena.sparql.expr.E_Multiply)4 E_Regex (org.apache.jena.sparql.expr.E_Regex)4 ContractTest (org.xenei.junit.contract.ContractTest)4 IndentedLineBuffer (org.apache.jena.atlas.io.IndentedLineBuffer)3 Query (org.apache.jena.query.Query)3 SortCondition (org.apache.jena.query.SortCondition)3 ExprAggregator (org.apache.jena.sparql.expr.ExprAggregator)3