Search in sources :

Example 11 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, BigInteger integer) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(BindingFactory.binding(), new FunctionEnvBase());
    assertTrue(v.isInteger());
    assertEquals(integer, v.getInteger());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 12 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, BigDecimal decimal) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(BindingFactory.binding(), new FunctionEnvBase());
    assertTrue(v.isDecimal());
    assertEquals(decimal, v.getDecimal());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 13 with Expr

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

the class TestExpressions method testURI.

private static void testURI(String string, String uri) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(env, new FunctionEnvBase());
    assertTrue(v.isIRI());
    assertEquals(uri, v.getNode().getURI());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 14 with Expr

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

the class TestExpressions method testString.

private static void testString(String string) {
    Expr expr = parse(string);
    NodeValue v = expr.eval(env, new FunctionEnvBase());
    assertTrue(v.isString());
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) FunctionEnvBase(org.apache.jena.sparql.function.FunctionEnvBase)

Example 15 with Expr

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

the class AggregationHandler method add.

/**
	 * Add and expression aggregator and variable to the mapping.
	 * 
	 * if the expr parameter is not an instance of ExprAggregator then no action is taken.
	 * 
	 * @param expr The expression to add.
	 * @param var The variable that it is bound to.
	 */
public void add(Expr expr, Var var) {
    if (expr instanceof ExprAggregator) {
        ExprAggregator eAgg = (ExprAggregator) expr;
        Expr expr2 = query.allocAggregate(eAgg.getAggregator());
        aggMap.put(var, (ExprAggregator) expr2);
    }
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) ExprAggregator(org.apache.jena.sparql.expr.ExprAggregator)

Aggregations

Expr (org.apache.jena.sparql.expr.Expr)82 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)5 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 ExprAggregator (org.apache.jena.sparql.expr.ExprAggregator)3 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)2 Query (org.apache.jena.query.Query)2