use of org.apache.jena.arq.querybuilder.rewriters.ElementRewriter in project jena by apache.
the class WhereHandler 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.query.getQueryPattern();
if (e != null) {
// clone the Element
ElementRewriter rewriter = new ElementRewriter(Collections.emptyMap());
e.visit(rewriter);
Element clone = rewriter.getResult();
Element mine = query.getQueryPattern();
if (mine == null) {
query.setQueryPattern(clone);
} else {
ElementGroup eg = null;
if (mine instanceof ElementGroup) {
eg = (ElementGroup) mine;
} else {
eg = new ElementGroup();
eg.addElement(mine);
}
if (clone instanceof ElementGroup) {
for (Element ele : ((ElementGroup) clone).getElements()) {
eg.addElement(ele);
}
} else {
eg.addElement(clone);
}
query.setQueryPattern(eg);
}
}
valuesHandler.addAll(whereHandler.valuesHandler);
}
Aggregations