@Override
public QueryResult getQueryResult(final InputStream inputStream, final BindingsFactory bindingsFactory) {
final QueryResult result = QueryResult.createInstance();
try {
final SimpleNode root = CSVParser.parse(inputStream);
if(root == null){
return null;
}
final LinkedList<Variable> vars = new LinkedList<Variable>();
for(int i=0; i<root.jjtGetNumChildren(); i++){
final Node child = root.jjtGetChild(i);
if(child instanceof ASTVars){
for(int j=0; j<child.jjtGetNumChildren(); j++){
final Node childchild = child.jjtGetChild(j);
if(childchild instanceof ASTVar){
vars.add(new Variable(((ASTVar)childchild).getName()));
}
}
}
}
for(int i=0; i<root.jjtGetNumChildren(); i++){
final Node child = root.jjtGetChild(i);
if(child instanceof ASTOneResult){
final Bindings bindings = bindingsFactory.createInstance();
final Iterator<Variable> varIt = vars.iterator();
for(int j=0; j<child.jjtGetNumChildren() && varIt.hasNext(); j++){
final Variable var = varIt.next();