/** * Add a binding to the where clause. * * @param expr * The expression to bind. * @param var * The variable to bind it to. */ public void addBind(Expr expr, Var var) { getClause().addElement(new ElementBind(var, expr)); }
/** * Add a binding to the where clause. * * @param expr * The expression to bind. * @param var * The variable to bind it to. */ public void addBind(Expr expr, Var var) { getClause().addElement(new ElementBind(var, expr)); }
@Override public Element transform(ElementBind el, Var v, Expr expr2) { if ( el.getVar() == v && el.getExpr() == expr2 ) return el ; return new ElementBind(v, expr2) ; }
/** * Add a binding to the where clause. * * @param expr * The expression to bind. * @param var * The variable to bind it to. */ public void addBind(Expr expr, Var var) { getClause().addElement(new ElementBind(var, expr)); }
/** * Add a binding to the where clause. * * @param expr * The expression to bind. * @param var * The variable to bind it to. */ public void addBind(Expr expr, Var var) { getClause().addElement(new ElementBind(var, expr)); }
/** * Add a binding to the where clause. * * @param expression * The expression to bind. * @param var * The variable to bind it to. * @throws ParseException */ public void addBind(String expression, Var var) throws ParseException { getClause().addElement(new ElementBind(var, parseExpr(expression))); }
/** * Add a binding to the where clause. * * @param expression * The expression to bind. * @param var * The variable to bind it to. * @throws ParseException */ public void addBind(String expression, Var var) throws ParseException { getClause().addElement(new ElementBind(var, ExprUtils.parse(query, expression, true))); }
/** * Add a binding to the where clause. * * @param expression * The expression to bind. * @param var * The variable to bind it to. * @throws ParseException */ public void addBind(String expression, Var var) throws ParseException { getClause().addElement(new ElementBind(var, ExprUtils.parse(query, expression, true))); }
/** * Add a binding to the where clause. * * @param expression * The expression to bind. * @param var * The variable to bind it to. * @throws ParseException */ public void addBind(String expression, Var var) throws ParseException { getClause().addElement(new ElementBind(var, parseExpr(expression))); }
/** * * @param p a concrete predicate * @param s * @param o * @param virtualPredicates */ public static Element createElementForConcretePredicate(Var pVar, Node pRef, Node s, Node o, BinaryRelation relation, Generator<Var> varGen) { //Relation relation = virtualProperties.get(pRef); Var sourceVar = relation.getSourceVar(); Var targetVar = relation.getTargetVar(); ElementBind bind = pVar == null ? null : new ElementBind(pVar, NodeValue.makeNode(pRef)); Set<Var> vars = relation.getVarsMentioned(); Map<Node, Node> nodeMap = new HashMap<Node, Node>(); List<Var> skip = Arrays.asList(sourceVar, targetVar); for(Var var : vars) { if(!skip.contains(var)) { Var freshVar = varGen.next(); nodeMap.put(var, freshVar); } } nodeMap.put(sourceVar, s); nodeMap.put(targetVar, o); Element fragment = ElementUtils.createRenamedElement(relation.getElement(), nodeMap); Element result = ElementUtils.groupIfNeeded(fragment, bind); return result; }
@Override public void visit(OpExtend opExtend) { Element e = asElement(opExtend.getSubOp()) ; // If (extend ... (table unit)), and first in group, don't add the empty group. insertIntoGroup(currentGroup(), e) ; processExtends(Arrays.asList(opExtend), (var,expr)->{ currentGroup().addElement(new ElementBind(var,expr)) ; }) ; }
final public Element Bind() throws ParseException { Var v ; Expr expr ; jj_consume_token(BIND); jj_consume_token(LPAREN); expr = Expression(); jj_consume_token(AS); v = Var(); jj_consume_token(RPAREN); {if (true) return new ElementBind(v, expr) ;} throw new Error("Missing return statement in function"); }
private void processQueryPattern(Op op, List<OpExtend> assignments) { op.visit(this) ; ElementGroup eg = this.currentGroup ; processExtends(assignments,(v,e)->eg.addElement(new ElementBind(v, e)) ) ; Element e = fixupGroupsOfOne(eg) ; query.setQueryPattern(e) ; query.setQuerySelectType() ; }
final public Element Bind() throws ParseException { Var v ; Expr expr ; jj_consume_token(BIND); jj_consume_token(LPAREN); expr = Expression(); jj_consume_token(AS); v = Var(); jj_consume_token(RPAREN); {if (true) return new ElementBind(v, expr) ;} throw new Error("Missing return statement in function"); }
@Override public PathFragment resolve(String propertyName) { PathFragment result = null; boolean isMatchingProperty = propertyOps.getName().equals(propertyName); if(isMatchingProperty) { BinaryRelation relation; if(typeConverter == null) { relation = RelationUtils.createRelation(predicate.asNode(), false); } else { ElementGroup group = new ElementGroup(); group.addElement(ElementUtils.createElement(new Triple(Vars.s, predicate.asNode(), Vars.x))); Expr expr = typeConverter.toJava(new ExprVar(Vars.x)); group.addElement(new ElementBind(Vars.o, expr)); relation = new BinaryRelationImpl(group, Vars.s, Vars.o); } result = new PathFragment(relation, propertyOps.getType(), targetRdfType, null); } return result; }
@Override public PathFragment resolve(String propertyName) { PathFragment result = null; boolean isMatchingProperty = propertyOps.getName().equals(propertyName); if(isMatchingProperty) { BinaryRelation relation; if(typeConverter == null) { relation = RelationUtils.createRelation(predicate.asNode(), false); } else { ElementGroup group = new ElementGroup(); group.addElement(ElementUtils.createElement(new Triple(Vars.s, predicate.asNode(), Vars.x))); Expr expr = typeConverter.toJava(new ExprVar(Vars.x)); group.addElement(new ElementBind(Vars.o, expr)); relation = new BinaryRelationImpl(group, Vars.s, Vars.o); } result = new PathFragment(relation, propertyOps.getType(), targetRdfType, null); } return result; }
@Override public void visit(ElementBind el) { Node n = changeNode(el.getVar()); if (n.equals(el.getVar())) { ExprRewriter exprRewriter = new ExprRewriter(values); el.getExpr().visit(exprRewriter); push(new ElementBind(el.getVar(), exprRewriter.getResult())); } else { // push( new ElementBind( el.getVar(), NodeValue.makeNode( n )) ); // no op push(new ElementTriplesBlock()); } }
@Override public PathFragment resolve(String propertyName) { PathFragment result = null; boolean isMatchingProperty = propertyOps.getName().equals(propertyName); if(isMatchingProperty) { BinaryRelation relation; if(typeConverter == null) { relation = RelationUtils.createRelation(predicate.asNode(), false); } else { ElementGroup group = new ElementGroup(); group.addElement(ElementUtils.createElement(new Triple(Vars.s, predicate.asNode(), Vars.x))); Expr expr = typeConverter.toJava(new ExprVar(Vars.x)); group.addElement(new ElementBind(Vars.o, expr)); relation = new BinaryRelationImpl(group, Vars.s, Vars.o); } result = new PathFragment(relation, propertyOps.getType(), targetRdfType, null); } return result; }
@Override public PathFragment resolve(String propertyName) { PathFragment result = null; boolean isMatchingProperty = propertyOps.getName().equals(propertyName); if(isMatchingProperty) { BinaryRelation relation; if(typeConverter == null) { relation = RelationUtils.createRelation(predicate.asNode(), false); } else { ElementGroup group = new ElementGroup(); group.addElement(ElementUtils.createElement(new Triple(Vars.s, predicate.asNode(), Vars.x))); Expr expr = typeConverter.toJava(new ExprVar(Vars.x)); group.addElement(new ElementBind(Vars.o, expr)); relation = new BinaryRelationImpl(group, Vars.s, Vars.o); } result = new PathFragment(relation, propertyOps.getType(), targetRdfType, null); } return result; }
@Override public void visit(ElementBind el) { Node n = changeNode(el.getVar()); if (n.equals(el.getVar())) { ExprRewriter exprRewriter = new ExprRewriter(values); el.getExpr().visit(exprRewriter); push(new ElementBind(el.getVar(), exprRewriter.getResult())); } else { // push( new ElementBind( el.getVar(), NodeValue.makeNode( n )) ); // no op push(new ElementTriplesBlock()); } }