private void printTabularQueryResults() {
// number of distinct bindings
int count = 0;
NodeFormatter formatter = new NodeFormatter( loader.getModel() );
// variables used in select
List<?> resultVars = query.getResultVars();
List<List<String>> data = new ArrayList<List<String>>();
while( queryResults.hasNext() ) {
QuerySolution binding = queryResults.nextSolution();
List<String> formattedBinding = new ArrayList<String>();
for( int i = 0; i < resultVars.size(); i++ ) {
String var = (String) resultVars.get( i );
RDFNode result = binding.get( var );
// format the result
formattedBinding.add( formatter.format( result ) );
}
if( data.add( formattedBinding ) )
count++;
}