use of org.eclipse.rdf4j.query.parser.sparql.ast.ASTProjectionElem in project rdf4j by eclipse.
the class WildcardProjectionProcessor method addQueryVars.
private static void addQueryVars(ASTWhereClause queryBody, Node wildcardNode) throws MalformedQueryException {
QueryVariableCollector visitor = new QueryVariableCollector();
try {
// Collect variable names from query
queryBody.jjtAccept(visitor, null);
// Adds ASTVar nodes to the ASTProjectionElem nodes and to the parent
for (String varName : visitor.getVariableNames()) {
ASTVar varNode = new ASTVar(SyntaxTreeBuilderTreeConstants.JJTVAR);
ASTProjectionElem projectionElemNode = new ASTProjectionElem(SyntaxTreeBuilderTreeConstants.JJTPROJECTIONELEM);
varNode.setName(varName);
projectionElemNode.jjtAppendChild(varNode);
varNode.jjtSetParent(projectionElemNode);
wildcardNode.jjtAppendChild(projectionElemNode);
projectionElemNode.jjtSetParent(wildcardNode);
}
} catch (VisitorException e) {
throw new MalformedQueryException(e);
}
}
Aggregations