use of org.apache.jena.arq.querybuilder.rewriters.ElementRewriter in project jena by apache.
the class WhereProcessor method setVars.
/**
* replace the vars in the expressions with the nodes in the values map.
* Vars not listed in the values map are not changed.
*
* Will return null if the whereClause is null.
*
* @param values
* the value map to use
* @return A new Element instance with the values changed.
*/
public Element setVars(Map<Var, Node> values) {
if (values.isEmpty() || whereClause == null) {
return whereClause;
}
ElementRewriter r = new ElementRewriter(values);
whereClause.visit(r);
return r.getResult();
}
use of org.apache.jena.arq.querybuilder.rewriters.ElementRewriter in project jena by apache.
the class WhereHandler method setVars.
@Override
public void setVars(Map<Var, Node> values) {
if (values.isEmpty()) {
return;
}
Element e = query.getQueryPattern();
if (e != null) {
ElementRewriter r = new ElementRewriter(values);
e.visit(r);
query.setQueryPattern(r.getResult());
}
valuesHandler.setVars(values);
}
use of org.apache.jena.arq.querybuilder.rewriters.ElementRewriter in project jena by apache.
the class WhereQuadHolder method setVars.
/**
* replace the vars in the expressions with the nodes in the values map. Vars
* not listed in the values map are not changed.
*
* Will return null if the whereClause is null.
*
* @param values the value map to use
* @return A new Element instance with the values changed.
*/
public WhereQuadHolder setVars(Map<Var, Node> values) {
if (whereClause != null) {
/* process when values are empty as rewriter handles Node_Variable to Var translation.
*
*/
ElementRewriter r = new ElementRewriter(values);
whereClause.visit(r);
whereClause = r.getResult();
}
return this;
}
use of org.apache.jena.arq.querybuilder.rewriters.ElementRewriter in project jena by apache.
the class WhereQuadHolder method addAll.
/**
* Add all where attributes from the Where Handler argument.
*
* @param whereHandler The Where Handler to copy from.
*/
public void addAll(WhereHandler whereHandler) {
Element e = whereHandler.getQueryPattern();
if (e != null) {
// clone the Element
ElementRewriter rewriter = new ElementRewriter(Collections.emptyMap());
e.visit(rewriter);
Element clone = rewriter.getResult();
if (whereClause == null) {
whereClause = clone;
} else {
ElementGroup eg = null;
if (whereClause instanceof ElementGroup) {
eg = (ElementGroup) whereClause;
} else {
eg = new ElementGroup();
eg.addElement(whereClause);
}
if (clone instanceof ElementGroup) {
for (Element ele : ((ElementGroup) clone).getElements()) {
eg.addElement(ele);
}
} else {
eg.addElement(clone);
}
whereClause = eg;
}
}
}
use of org.apache.jena.arq.querybuilder.rewriters.ElementRewriter in project jena by apache.
the class WhereProcessor method addAll.
/**
* Add all where attributes from the Where Handler argument.
*
* @param whereHandler
* The Where Handler to copy from.
*/
public void addAll(WhereHandler whereHandler) {
Element e = whereHandler.getQueryPattern();
if (e != null) {
// clone the Element
ElementRewriter rewriter = new ElementRewriter(Collections.emptyMap());
e.visit(rewriter);
Element clone = rewriter.getResult();
if (whereClause == null) {
whereClause = clone;
} else {
ElementGroup eg = null;
if (whereClause instanceof ElementGroup) {
eg = (ElementGroup) whereClause;
} else {
eg = new ElementGroup();
eg.addElement(whereClause);
}
if (clone instanceof ElementGroup) {
for (Element ele : ((ElementGroup) clone).getElements()) {
eg.addElement(ele);
}
} else {
eg.addElement(clone);
}
whereClause = eg;
}
}
}
Aggregations