Search in sources :

Example 11 with ExprList

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

the class PropFuncArg method asExprList.

/** @deprecated To be removed - use {@link #asExprList()} */
@Deprecated
public ExprList asExprList(PropFuncArg pfArg) {
    ExprList exprList = new ExprList();
    if (pfArg.isNode()) {
        Node n = pfArg.getArg();
        Expr expr = ExprUtils.nodeToExpr(n);
        exprList.add(expr);
        return exprList;
    }
    for (Node n : pfArg.getArgList()) {
        Expr expr = ExprUtils.nodeToExpr(n);
        exprList.add(expr);
    }
    return exprList;
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) ExprList(org.apache.jena.sparql.expr.ExprList) Node(org.apache.jena.graph.Node)

Example 12 with ExprList

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

the class PropFuncArg method asExprList.

public ExprList asExprList() {
    ExprList exprList = new ExprList();
    if (isNode()) {
        Node n = getArg();
        Expr expr = ExprUtils.nodeToExpr(n);
        exprList.add(expr);
        return exprList;
    }
    for (Node n : getArgList()) {
        Expr expr = ExprUtils.nodeToExpr(n);
        exprList.add(expr);
    }
    return exprList;
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) ExprList(org.apache.jena.sparql.expr.ExprList) Node(org.apache.jena.graph.Node)

Example 13 with ExprList

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

the class NodeTransformLib method transform.

public static ExprList transform(NodeTransform nodeTransform, ExprList exprList) {
    ExprList exprList2 = new ExprList();
    boolean changed = false;
    for (Expr expr : exprList) {
        Expr expr2 = transform(nodeTransform, expr);
        if (expr != expr2)
            changed = true;
        exprList2.add(expr2);
    }
    if (!changed)
        return exprList;
    return exprList2;
}
Also used : Expr(org.apache.jena.sparql.expr.Expr) ExprList(org.apache.jena.sparql.expr.ExprList)

Example 14 with ExprList

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

the class OpRewriterTest method testBGP.

@Test
public void testBGP() {
    SecurityEvaluator securityEvaluator = new MockSecurityEvaluator(true, true, true, true, true, true);
    rewriter = new OpRewriter(securityEvaluator, "http://example.com/dummy");
    rewriter.visit(new OpBGP(BasicPattern.wrap(Arrays.asList(triples))));
    Op op = rewriter.getResult();
    Assert.assertTrue("Should have been an OpFilter", op instanceof OpFilter);
    OpFilter filter = (OpFilter) op;
    ExprList eLst = filter.getExprs();
    Assert.assertEquals(1, eLst.size());
    Assert.assertTrue("Should have been a SecuredFunction", eLst.get(0) instanceof SecuredFunction);
    op = filter.getSubOp();
    Assert.assertTrue("Should have been a OpBGP", op instanceof OpBGP);
    BasicPattern basicPattern = ((OpBGP) op).getPattern();
    Assert.assertEquals(3, basicPattern.size());
    Triple t = basicPattern.get(0);
    Assert.assertEquals(NodeFactory.createVariable("foo"), t.getSubject());
    Assert.assertEquals(RDF.type.asNode(), t.getPredicate());
    Assert.assertEquals(NodeFactory.createURI("http://example.com/class"), t.getObject());
    t = basicPattern.get(1);
    Assert.assertEquals(NodeFactory.createVariable("foo"), t.getSubject());
    Assert.assertTrue("Should have been blank", t.getPredicate().isBlank());
    Assert.assertEquals(NodeFactory.createVariable("bar"), t.getObject());
    t = basicPattern.get(2);
    Assert.assertEquals(NodeFactory.createVariable("bar"), t.getSubject());
    Assert.assertTrue("Should have been blank", t.getPredicate().isBlank());
    Assert.assertEquals(NodeFactory.createVariable("baz"), t.getObject());
}
Also used : Triple(org.apache.jena.graph.Triple) Op(org.apache.jena.sparql.algebra.Op) SecuredFunction(org.apache.jena.permissions.query.rewriter.SecuredFunction) ExprList(org.apache.jena.sparql.expr.ExprList) MockSecurityEvaluator(org.apache.jena.permissions.MockSecurityEvaluator) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) SecurityEvaluator(org.apache.jena.permissions.SecurityEvaluator) MockSecurityEvaluator(org.apache.jena.permissions.MockSecurityEvaluator) BasicPattern(org.apache.jena.sparql.core.BasicPattern) OpFilter(org.apache.jena.sparql.algebra.op.OpFilter) OpRewriter(org.apache.jena.permissions.query.rewriter.OpRewriter) Test(org.junit.Test)

Example 15 with ExprList

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

the class AbstractTestLeftJoin method leftjoin_condition_03.

@Test
public void leftjoin_condition_03() {
    // Never match 
    ExprList exprs = SSE.parseExprList("((= ?b 99))");
    testJoin("a", table1(), tableD1(), "((= ?b 99))", table1());
}
Also used : ExprList(org.apache.jena.sparql.expr.ExprList) Test(org.junit.Test)

Aggregations

ExprList (org.apache.jena.sparql.expr.ExprList)27 Op (org.apache.jena.sparql.algebra.Op)17 Expr (org.apache.jena.sparql.expr.Expr)15 Var (org.apache.jena.sparql.core.Var)11 Node (org.apache.jena.graph.Node)3 Triple (org.apache.jena.graph.Triple)3 HashSet (java.util.HashSet)2 OpFilter (org.apache.jena.sparql.algebra.op.OpFilter)2 BasicPattern (org.apache.jena.sparql.core.BasicPattern)2 Test (org.junit.Test)2 ExprRewriter (org.apache.jena.arq.querybuilder.rewriters.ExprRewriter)1 MockSecurityEvaluator (org.apache.jena.permissions.MockSecurityEvaluator)1 SecurityEvaluator (org.apache.jena.permissions.SecurityEvaluator)1 OpRewriter (org.apache.jena.permissions.query.rewriter.OpRewriter)1 SecuredFunction (org.apache.jena.permissions.query.rewriter.SecuredFunction)1 SortCondition (org.apache.jena.query.SortCondition)1 OpBGP (org.apache.jena.sparql.algebra.op.OpBGP)1 VarExprList (org.apache.jena.sparql.core.VarExprList)1 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)1 NodeValue (org.apache.jena.sparql.expr.NodeValue)1