You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/06/13 17:18:35 UTC
svn commit: r1135137 -
/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/CSVOutput.java
Author: andy
Date: Mon Jun 13 15:18:35 2011
New Revision: 1135137
URL: http://svn.apache.org/viewvc?rev=1135137&view=rev
Log:
Add blank node label abbreviation in CSV output
Modified:
incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/CSVOutput.java
Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/CSVOutput.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/CSVOutput.java?rev=1135137&r1=1135136&r2=1135137&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/CSVOutput.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/resultset/CSVOutput.java Mon Jun 13 15:18:35 2011
@@ -21,6 +21,7 @@ import com.hp.hpl.jena.query.ResultSet ;
import com.hp.hpl.jena.sparql.ARQException ;
import com.hp.hpl.jena.sparql.core.Var ;
import com.hp.hpl.jena.sparql.engine.binding.Binding ;
+import com.hp.hpl.jena.sparql.util.NodeToLabelMap ;
import com.hp.hpl.jena.util.FileUtils ;
/** Convenient comma separated values - see also TSV (tab separated values)
@@ -45,8 +46,8 @@ public class CSVOutput extends OutputBas
public void format(OutputStream out, ResultSet resultSet)
{
try {
-
Writer w = FileUtils.asUTF8(out) ;
+ NodeToLabelMap bnodes = new NodeToLabelMap() ;
w = new BufferedWriter(w) ;
String sep = null ;
@@ -79,7 +80,7 @@ public class CSVOutput extends OutputBas
Node n = b.get(v) ;
if ( n != null )
- output(w, n) ;
+ output(w, n, bnodes) ;
}
w.write(NL) ;
}
@@ -90,13 +91,14 @@ public class CSVOutput extends OutputBas
}
}
- private void output(Writer w, Node n) throws IOException
+ private void output(Writer w, Node n, NodeToLabelMap bnodes) throws IOException
{
//String str = FmtUtils.stringForNode(n) ;
String str = "?" ;
if ( n.isLiteral() ) str = n.getLiteralLexicalForm() ;
else if ( n.isURI() ) str = n.getURI() ;
- else if ( n.isBlank() ) str = n.getBlankNodeLabel() ;
+ else if ( n.isBlank() )
+ str = bnodes.asString(n) ;
str = csvSafe(str) ;
w.write(str) ;