Search in sources :

Example 21 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class SelectClauseTest method testAddVarString.

@ContractTest
public void testAddVarString() throws Exception {
    Var v = Var.alloc("one");
    SelectClause<?> selectClause = getProducer().newInstance();
    selectClause.addVar("one");
    Query query = getQuery(selectClause.addVar("one"));
    VarExprList expr = query.getProject();
    assertEquals(1, expr.size());
    assertTrue(expr.contains(v));
}
Also used : Query(org.apache.jena.query.Query) Var(org.apache.jena.sparql.core.Var) VarExprList(org.apache.jena.sparql.core.VarExprList) ContractTest(org.xenei.junit.contract.ContractTest)

Example 22 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class SelectClauseTest method testAddExprVar.

@ContractTest
public void testAddExprVar() throws Exception {
    SelectClause<?> selectClause = getProducer().newInstance();
    AbstractQueryBuilder<?> aqb = selectClause.addVar(new E_Random(), Var.alloc("foo"));
    Query query = getQuery(aqb);
    VarExprList expr = query.getProject();
    assertEquals(1, expr.size());
    Expr e = expr.getExpr(Var.alloc("foo"));
    assertNotNull("expression should not be null", e);
    assertTrue("Should be an E_Random", e instanceof E_Random);
}
Also used : Query(org.apache.jena.query.Query) Expr(org.apache.jena.sparql.expr.Expr) E_Random(org.apache.jena.sparql.expr.E_Random) VarExprList(org.apache.jena.sparql.core.VarExprList) ContractTest(org.xenei.junit.contract.ContractTest)

Example 23 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class SelectHandlerTest method testAddVar.

@Test
public void testAddVar() {
    Var v = Var.alloc("one");
    handler.addVar(v);
    VarExprList expr = query.getProject();
    assertEquals(1, expr.size());
    assertTrue(expr.contains(v));
}
Also used : Var(org.apache.jena.sparql.core.Var) VarExprList(org.apache.jena.sparql.core.VarExprList) Test(org.junit.Test)

Example 24 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class SelectHandlerTest method testAddStringVar.

@Test
public void testAddStringVar() {
    Var v = Var.alloc("foo");
    handler.addVar("rand()", v);
    VarExprList expr = query.getProject();
    assertEquals(1, expr.size());
    Expr e = expr.getExpr(Var.alloc("foo"));
    assertNotNull("expression should not be null", e);
    assertTrue("Should be an E_Random", e instanceof E_Random);
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) E_Random(org.apache.jena.sparql.expr.E_Random) Var(org.apache.jena.sparql.core.Var) VarExprList(org.apache.jena.sparql.core.VarExprList) Test(org.junit.Test)

Example 25 with VarExprList

use of org.apache.jena.sparql.core.VarExprList in project jena by apache.

the class ApplyTransformVisitor method visit.

@Override
public void visit(OpExtend opExtend) {
    VarExprList varExpr = opExtend.getVarExprList();
    VarExprList varExpr2 = collect(varExpr);
    OpExtend opExtend2 = opExtend;
    if (varExpr != varExpr2)
        opExtend2 = OpExtend.create(opExtend.getSubOp(), varExpr2);
    visit1(opExtend2);
}
Also used : VarExprList(org.apache.jena.sparql.core.VarExprList)

Aggregations

VarExprList (org.apache.jena.sparql.core.VarExprList)49 Var (org.apache.jena.sparql.core.Var)21 Test (org.junit.Test)15 Op (org.apache.jena.sparql.algebra.Op)12 Expr (org.apache.jena.sparql.expr.Expr)8 Query (org.apache.jena.query.Query)7 NodeValueInteger (org.apache.jena.sparql.expr.nodevalue.NodeValueInteger)7 ContractTest (org.xenei.junit.contract.ContractTest)6 E_Random (org.apache.jena.sparql.expr.E_Random)4 QueryParseException (org.apache.jena.query.QueryParseException)3 ExprAggregator (org.apache.jena.sparql.expr.ExprAggregator)2 ExprVar (org.apache.jena.sparql.expr.ExprVar)2 StringReader (java.io.StringReader)1 Map (java.util.Map)1 ExprRewriter (org.apache.jena.arq.querybuilder.rewriters.ExprRewriter)1 Node (org.apache.jena.graph.Node)1 SortCondition (org.apache.jena.query.SortCondition)1 OpAssign (org.apache.jena.sparql.algebra.op.OpAssign)1 OpExtend (org.apache.jena.sparql.algebra.op.OpExtend)1 BindingHashMap (org.apache.jena.sparql.engine.binding.BindingHashMap)1