Search in sources :

Example 1 with OpAssign

use of org.apache.jena.sparql.algebra.op.OpAssign in project jena by apache.

the class TransformExtendCombine method transform.

@Override
public Op transform(OpAssign opAssign, Op subOp) {
    if (subOp instanceof OpAssign) {
        // If a variable is assigned twice, don't do anything.
        // (assign (?x 2)  (assign (?x 1) op)) => leave alone.
        // This is the safest option in a rare case.
        // It would be OK if addAll does a replacement without checking
        // but having it check and complain about duplicates adds robustness.
        // In OpExtend, it's actually illegal.
        OpAssign x = (OpAssign) subOp;
        VarExprList outerVarExprList = opAssign.getVarExprList();
        // Copy
        VarExprList innerVarExprList = new VarExprList(x.getVarExprList());
        Op r = OpAssign.assign(x.getSubOp(), innerVarExprList);
        // This contains an "if already (assign)" test.
        r = OpAssign.assign(r, outerVarExprList);
        return r;
    }
    return super.transform(opAssign, subOp);
}
Also used : Op(org.apache.jena.sparql.algebra.Op) OpAssign(org.apache.jena.sparql.algebra.op.OpAssign) VarExprList(org.apache.jena.sparql.core.VarExprList)

Aggregations

Op (org.apache.jena.sparql.algebra.Op)1 OpAssign (org.apache.jena.sparql.algebra.op.OpAssign)1 VarExprList (org.apache.jena.sparql.core.VarExprList)1