/* $This file is distributed under the terms of the license in LICENSE$ */

package edu.cornell.mannlib.vitro.webapp.rdfservice.filter;

import java.util.Iterator;
import java.util.List;

import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.sparql.engine.binding.Binding;

public class FilteredResultSet implements ResultSet {

    protected Iterator<QuerySolution> solutIt;
    protected ResultSet originalResultSet;
    protected int rowNum = -1;

    public FilteredResultSet (List<QuerySolution> solutions, ResultSet originalResultSet) {
        this.solutIt = solutions.iterator();
        this.originalResultSet = originalResultSet;
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("Attempt to remove an element");
    }

    @Override
    public Model getResourceModel() {
        return originalResultSet.getResourceModel();
    }

    @Override
    public List<String> getResultVars() {
        return originalResultSet.getResultVars();
    }

    @Override
    public int getRowNumber() {
        return rowNum;
    }

    @Override
    public boolean hasNext() {
        return solutIt.hasNext();
    }

    @Override
    public QuerySolution next() {
        return nextSolution();
    }

    @Override
    public Binding nextBinding() {
        throw new UnsupportedOperationException("Can we ignore this?");
    }

    @Override
    public QuerySolution nextSolution() {
        rowNum++;
        return solutIt.next();
    }

}

@@ -358,16 +358,75 @@
 Binding;
+%0Aimport org.apache.jena.sparql.engine.binding.BindingUtils;
 %0A%0Apublic
@@ -1455,69 +1455,52 @@
     
-throw new UnsupportedOperationException(%22Can we ignore this?%22
+return BindingUtils.asBinding(nextSolution()
 );%0A 

Implement nextBinding() method in FIlteredResultSet. (#215)