Search in sources :

Example 16 with VarExprList

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

the class OpExtend method create.

/** Make a OpExtend - this does not aggregate (extend .. (extend ...)) */
public static Op create(Op op, Var var, Expr expr) {
    VarExprList x = new VarExprList();
    x.add(var, expr);
    return new OpExtend(op, x);
}
Also used : VarExprList(org.apache.jena.sparql.core.VarExprList)

Example 17 with VarExprList

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

the class PatternVarsVisitor method visit.

@Override
public void visit(ElementSubQuery el) {
    el.getQuery().setResultVars();
    VarExprList x = el.getQuery().getProject();
    acc.addAll(x.getVars());
}
Also used : VarExprList(org.apache.jena.sparql.core.VarExprList)

Example 18 with VarExprList

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

the class SelectClauseTest method testAddVarNode.

@ContractTest
public void testAddVarNode() throws Exception {
    Var v = Var.alloc("one");
    SelectClause<?> selectClause = getProducer().newInstance();
    selectClause.addVar("one");
    Query query = getQuery(selectClause.addVar(NodeFactory.createVariable("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 19 with VarExprList

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

the class SelectClauseTest method testAddStringVar.

@ContractTest
public void testAddStringVar() throws Exception {
    SelectClause<?> selectClause = getProducer().newInstance();
    AbstractQueryBuilder<?> aqb = selectClause.addVar("rand()", 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 20 with VarExprList

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

the class SelectClauseTest method testAddVarAsterisk.

@ContractTest
public void testAddVarAsterisk() throws Exception {
    SelectClause<?> selectClause = getProducer().newInstance();
    selectClause.addVar("*");
    Query query = getQuery(selectClause.addVar("*"));
    VarExprList expr = query.getProject();
    assertEquals(0, expr.size());
    assertTrue(query.isQueryResultStar());
}
Also used : Query(org.apache.jena.query.Query) VarExprList(org.apache.jena.sparql.core.VarExprList) ContractTest(org.xenei.junit.contract.ContractTest)

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