Search in sources :

Example 1 with ExprTransform

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

the class QueryTransformOps method transform.

/** Transform a query based on a mapping from {@link Var} variable to replacement {@link Node}. */
public static Query transform(Query query, Map<Var, ? extends Node> substitutions) {
    ElementTransform eltrans = new ElementTransformSubst(substitutions);
    NodeTransform nodeTransform = new NodeTransformSubst(substitutions);
    ExprTransform exprTrans = new ExprTransformNodeElement(nodeTransform, eltrans);
    return transform(query, eltrans, exprTrans);
}
Also used : NodeTransform(org.apache.jena.sparql.graph.NodeTransform) ExprTransform(org.apache.jena.sparql.expr.ExprTransform)

Example 2 with ExprTransform

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

the class Transformer method transformSkipService.

/** Transform an algebra expression except skip (leave alone) any OpService nodes */
public static Op transformSkipService(Transform opTransform, ExprTransform exprTransform, Op op, OpVisitor beforeVisitor, OpVisitor afterVisitor) {
    if (true) {
        // XXX XXX Better work with Walker.
        if (opTransform == null)
            opTransform = new TransformCopy();
        if (exprTransform == null)
            exprTransform = new ExprTransformCopy();
        Transform transform2 = new TransformSkipService(opTransform);
        transform2 = opTransform;
        ApplyTransformVisitor atv = new ApplyTransformVisitor(transform2, exprTransform, false, beforeVisitor, afterVisitor);
        return Walker.transformSkipService(op, atv, beforeVisitor, afterVisitor);
    }
    Transform transform = new TransformSkipService(opTransform);
    return Transformer.transform(transform, exprTransform, op, beforeVisitor, afterVisitor);
//        // OLD
//        // Simplest way but still walks the OpService subtree (and throws away the
//        // transformation).
//        Transform transform = new TransformSkipService(opTransform) ;
//        return Transformer.transform(transform, exprTransform, op, beforeVisitor, afterVisitor) ;
}
Also used : ExprTransformCopy(org.apache.jena.sparql.expr.ExprTransformCopy) ExprTransformCopy(org.apache.jena.sparql.expr.ExprTransformCopy) ApplyTransformVisitor(org.apache.jena.sparql.algebra.walker.ApplyTransformVisitor) ExprTransform(org.apache.jena.sparql.expr.ExprTransform)

Example 3 with ExprTransform

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

the class UpdateTransformOps method transform.

/** Transform an {@link Update} based on a mapping from {@link Var} variable to replacement {@link Node}. */
public static Update transform(Update update, Map<Var, Node> substitutions) {
    ElementTransform eltrans = new ElementTransformSubst(substitutions);
    NodeTransform nodeTransform = new NodeTransformSubst(substitutions);
    ExprTransform exprTrans = new ExprTransformNodeElement(nodeTransform, eltrans);
    return transform(update, eltrans, exprTrans);
}
Also used : NodeTransform(org.apache.jena.sparql.graph.NodeTransform) ExprTransform(org.apache.jena.sparql.expr.ExprTransform)

Example 4 with ExprTransform

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

the class UpdateTransformOps method transform.

/** Transform an {@link UpdateRequest} based on a mapping from {@link Var} variable to replacement {@link Node}. */
public static UpdateRequest transform(UpdateRequest update, Map<Var, Node> substitutions) {
    ElementTransform eltrans = new ElementTransformSubst(substitutions);
    NodeTransform nodeTransform = new NodeTransformSubst(substitutions);
    ExprTransform exprTrans = new ExprTransformNodeElement(nodeTransform, eltrans);
    return transform(update, eltrans, exprTrans);
}
Also used : NodeTransform(org.apache.jena.sparql.graph.NodeTransform) ExprTransform(org.apache.jena.sparql.expr.ExprTransform)

Example 5 with ExprTransform

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

the class NodeTransformLib method transform.

/** Do a node->node conversion of an Op - return original BGP for "no change" */
public static Op transform(NodeTransform nodeTransform, Op op) {
    Transform opTransform = new NodeTransformOp(nodeTransform);
    ExprTransform exprTransform = new NodeTransformExpr(nodeTransform);
    return Transformer.transform(opTransform, exprTransform, op);
}
Also used : Transform(org.apache.jena.sparql.algebra.Transform) ExprTransform(org.apache.jena.sparql.expr.ExprTransform) ExprTransform(org.apache.jena.sparql.expr.ExprTransform)

Aggregations

ExprTransform (org.apache.jena.sparql.expr.ExprTransform)5 NodeTransform (org.apache.jena.sparql.graph.NodeTransform)3 Transform (org.apache.jena.sparql.algebra.Transform)1 ApplyTransformVisitor (org.apache.jena.sparql.algebra.walker.ApplyTransformVisitor)1 ExprTransformCopy (org.apache.jena.sparql.expr.ExprTransformCopy)1