|
From: <mrp...@us...> - 2014-06-03 00:31:33
|
Revision: 8439
http://sourceforge.net/p/bigdata/code/8439
Author: mrpersonick
Date: 2014-06-03 00:31:26 +0000 (Tue, 03 Jun 2014)
Log Message:
-----------
added a JSON parser and writer for construct.
Modified Paths:
--------------
branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/ServiceProviderHook.java
branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParser.java
branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriter.java
branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/SPARQLJSONWriterBase.java
Added Paths:
-----------
branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstruct.java
branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstructFactory.java
branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstruct.java
branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstructFactory.java
Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/ServiceProviderHook.java
===================================================================
--- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/ServiceProviderHook.java 2014-06-02 17:18:22 UTC (rev 8438)
+++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/ServiceProviderHook.java 2014-06-03 00:31:26 UTC (rev 8439)
@@ -40,7 +40,9 @@
import com.bigdata.rdf.model.StatementEnum;
import com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONParserFactory;
+import com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONParserForConstructFactory;
import com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONWriterFactory;
+import com.bigdata.rdf.rio.json.BigdataSPARQLResultsJSONWriterForConstructFactory;
import com.bigdata.rdf.rio.ntriples.BigdataNTriplesParserFactory;
import com.bigdata.rdf.rio.turtle.BigdataTurtleParserFactory;
import com.bigdata.rdf.rio.turtle.BigdataTurtleWriterFactory;
@@ -125,7 +127,7 @@
* Allows parsing of JSON SPARQL Results with an {s,p,o,[c]} header.
* RDR-enabled.
*/
-// r.add(new BigdataSPARQLResultsJSONParserFactory());
+ r.add(new BigdataSPARQLResultsJSONParserForConstructFactory());
}
@@ -157,7 +159,7 @@
r.add(new BigdataTurtleWriterFactory());
// RDR-enabled
-// r.add(new BigdataSPARQLResultsJSONWriterFactory());
+ r.add(new BigdataSPARQLResultsJSONWriterForConstructFactory());
}
Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParser.java
===================================================================
--- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParser.java 2014-06-02 17:18:22 UTC (rev 8438)
+++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParser.java 2014-06-03 00:31:26 UTC (rev 8439)
@@ -48,7 +48,7 @@
*/
public class BigdataSPARQLResultsJSONParser extends SPARQLJSONParserBase implements TupleQueryResultParser {
- public static final String STATEMENT = "statement";
+ public static final String SID = "sid";
public static final String SUBJECT = "subject";
@@ -156,7 +156,7 @@
}
// added for Sids support
- if (type.equals(STATEMENT)) {
+ if (type.equals(SID)) {
final Resource s = (Resource) sid.get(SUBJECT);
final URI p = (URI) sid.get(PREDICATE);
Added: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstruct.java
===================================================================
--- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstruct.java (rev 0)
+++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstruct.java 2014-06-03 00:31:26 UTC (rev 8439)
@@ -0,0 +1,147 @@
+/*
+ * Licensed to Aduna under one or more contributor license agreements.
+ * See the NOTICE.txt file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * Aduna licenses this file to you under the terms of the Aduna BSD
+ * License (the "License"); you may not use this file except in compliance
+ * with the License. See the LICENSE.txt file distributed with this work
+ * for the full License.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.bigdata.rdf.rio.json;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.List;
+
+import org.apache.commons.io.input.ReaderInputStream;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.QueryResultHandlerException;
+import org.openrdf.query.TupleQueryResultHandler;
+import org.openrdf.query.TupleQueryResultHandlerException;
+import org.openrdf.query.resultio.QueryResultParseException;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFHandlerException;
+import org.openrdf.rio.RDFParseException;
+import org.openrdf.rio.RDFParser;
+import org.openrdf.rio.helpers.RDFParserBase;
+
+/**
+ * Parser for SPARQL-1.1 JSON Results Format documents
+ *
+ * @see <a href="http://www.w3.org/TR/sparql11-results-json/">SPARQL 1.1 Query
+ * Results JSON Format</a>
+ * @author Peter Ansell
+ */
+public class BigdataSPARQLResultsJSONParserForConstruct extends RDFParserBase
+ implements RDFParser, TupleQueryResultHandler {
+
+ private final BigdataSPARQLResultsJSONParser parser;
+
+ public BigdataSPARQLResultsJSONParserForConstruct() {
+ this.parser = new BigdataSPARQLResultsJSONParser();
+ }
+
+ public BigdataSPARQLResultsJSONParserForConstruct(final ValueFactory vf) {
+ this.parser = new BigdataSPARQLResultsJSONParser(vf);
+ this.parser.setQueryResultHandler(this);
+ }
+
+ @Override
+ public RDFFormat getRDFFormat() {
+ return BigdataSPARQLResultsJSONWriterForConstructFactory.JSON;
+ }
+
+ @Override
+ public void parse(InputStream in, String baseURI) throws IOException,
+ RDFParseException, RDFHandlerException {
+ try {
+ parser.parseQueryResult(in);
+ } catch (QueryResultParseException e) {
+ throw new RDFParseException(e);
+ } catch (QueryResultHandlerException e) {
+ throw new RDFHandlerException(e);
+ }
+ }
+
+ @Override
+ public void parse(Reader reader, String baseURI) throws IOException,
+ RDFParseException, RDFHandlerException {
+ parse(new ReaderInputStream(reader), baseURI);
+ }
+
+ @Override
+ public void handleBoolean(boolean value) throws QueryResultHandlerException {
+ // do nothing
+ }
+
+ @Override
+ public void handleLinks(List<String> linkUrls)
+ throws QueryResultHandlerException {
+ // do nothing
+ }
+
+ @Override
+ public void startQueryResult(List<String> bindingNames)
+ throws TupleQueryResultHandlerException {
+ try {
+ getRDFHandler().startRDF();
+ } catch (RDFHandlerException e) {
+ throw new TupleQueryResultHandlerException(e);
+ }
+ }
+
+ @Override
+ public void endQueryResult() throws TupleQueryResultHandlerException {
+ try {
+ getRDFHandler().endRDF();
+ } catch (RDFHandlerException e) {
+ throw new TupleQueryResultHandlerException(e);
+ }
+ }
+
+ @Override
+ public void handleSolution(BindingSet bs)
+ throws TupleQueryResultHandlerException {
+
+ if (!bs.hasBinding("subject")) {
+ throw new TupleQueryResultHandlerException("no subject: " + bs);
+ }
+ if (!bs.hasBinding("predicate")) {
+ throw new TupleQueryResultHandlerException("no predicate: " + bs);
+ }
+ if (!bs.hasBinding("object")) {
+ throw new TupleQueryResultHandlerException("no object: " + bs);
+ }
+
+ final Resource s = (Resource) bs.getValue("subject");
+ final URI p = (URI) bs.getValue("predicate");
+ final Value o = (Value) bs.getValue("object");
+ final Resource c = bs.hasBinding("context") ?
+ (Resource) bs.getBinding("context") : null;
+
+ final Statement stmt = valueFactory.createStatement(s, p, o, c);
+
+ try {
+ getRDFHandler().handleStatement(stmt);
+ } catch (RDFHandlerException e) {
+ throw new TupleQueryResultHandlerException(e);
+ }
+
+ }
+
+
+
+}
Property changes on: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstruct.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstructFactory.java
===================================================================
--- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstructFactory.java (rev 0)
+++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstructFactory.java 2014-06-03 00:31:26 UTC (rev 8439)
@@ -0,0 +1,44 @@
+/*
+ * Licensed to Aduna under one or more contributor license agreements.
+ * See the NOTICE.txt file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * Aduna licenses this file to you under the terms of the Aduna BSD
+ * License (the "License"); you may not use this file except in compliance
+ * with the License. See the LICENSE.txt file distributed with this work
+ * for the full License.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.bigdata.rdf.rio.json;
+
+import org.openrdf.query.resultio.TupleQueryResultParserFactory;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFParser;
+import org.openrdf.rio.RDFParserFactory;
+
+/**
+ * A {@link TupleQueryResultParserFactory} for parsers of SPARQL-1.1 JSON Tuple
+ * Query Results.
+ *
+ * @author Peter Ansell
+ */
+public class BigdataSPARQLResultsJSONParserForConstructFactory implements RDFParserFactory {
+
+ public static final RDFFormat JSON = BigdataSPARQLResultsJSONWriterForConstructFactory.JSON;
+
+ @Override
+ public RDFParser getParser() {
+ return new BigdataSPARQLResultsJSONParserForConstruct();
+ }
+
+ @Override
+ public RDFFormat getRDFFormat() {
+ return JSON;
+ }
+
+}
Property changes on: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONParserForConstructFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriter.java
===================================================================
--- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriter.java 2014-06-02 17:18:22 UTC (rev 8438)
+++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriter.java 2014-06-03 00:31:26 UTC (rev 8439)
@@ -18,13 +18,10 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.io.Writer;
-import org.openrdf.model.BNode;
-import org.openrdf.model.Literal;
-import org.openrdf.model.URI;
import org.openrdf.model.Value;
import org.openrdf.query.QueryResultHandlerException;
-import org.openrdf.query.TupleQueryResultHandlerException;
import org.openrdf.query.resultio.TupleQueryResultFormat;
import org.openrdf.query.resultio.TupleQueryResultWriter;
@@ -42,6 +39,10 @@
* Constructors *
*--------------*/
+ public BigdataSPARQLResultsJSONWriter(Writer writer) {
+ super(writer);
+ }
+
public BigdataSPARQLResultsJSONWriter(OutputStream out) {
super(out);
}
@@ -82,21 +83,21 @@
jg.writeStartObject();
- jg.writeStringField("type", "statement");
+ jg.writeStringField("type", BigdataSPARQLResultsJSONParser.SID);
final BigdataStatement stmt = sid.getStatement();
- jg.writeFieldName("subject");
+ jg.writeFieldName(BigdataSPARQLResultsJSONParser.SUBJECT);
writeValue(stmt.getSubject());
- jg.writeFieldName("predicate");
- writeValue(stmt.getSubject());
+ jg.writeFieldName(BigdataSPARQLResultsJSONParser.PREDICATE);
+ writeValue(stmt.getPredicate());
- jg.writeFieldName("object");
- writeValue(stmt.getSubject());
+ jg.writeFieldName(BigdataSPARQLResultsJSONParser.OBJECT);
+ writeValue(stmt.getObject());
if (stmt.getContext() != null) {
- jg.writeFieldName("context");
+ jg.writeFieldName(BigdataSPARQLResultsJSONParser.CONTEXT);
writeValue(stmt.getContext());
}
Added: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstruct.java
===================================================================
--- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstruct.java (rev 0)
+++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstruct.java 2014-06-03 00:31:26 UTC (rev 8439)
@@ -0,0 +1,134 @@
+/*
+ * Licensed to Aduna under one or more contributor license agreements.
+ * See the NOTICE.txt file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * Aduna licenses this file to you under the terms of the Aduna BSD
+ * License (the "License"); you may not use this file except in compliance
+ * with the License. See the LICENSE.txt file distributed with this work
+ * for the full License.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.bigdata.rdf.rio.json;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.openrdf.model.Statement;
+import org.openrdf.query.QueryResultHandlerException;
+import org.openrdf.query.TupleQueryResultHandlerException;
+import org.openrdf.query.impl.MapBindingSet;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFHandlerException;
+import org.openrdf.rio.RDFWriter;
+import org.openrdf.rio.RioSetting;
+import org.openrdf.rio.WriterConfig;
+
+/**
+ * A TupleQueryResultWriter that writes query results in the <a
+ * href="http://www.w3.org/TR/rdf-sparql-json-res/">SPARQL Query Results JSON
+ * Format</a>.
+ */
+public class BigdataSPARQLResultsJSONWriterForConstruct implements RDFWriter {
+
+ private final BigdataSPARQLResultsJSONWriter writer;
+
+ /*--------------*
+ * Constructors *
+ *--------------*/
+
+ public BigdataSPARQLResultsJSONWriterForConstruct(final Writer writer) {
+ this.writer = new BigdataSPARQLResultsJSONWriter(writer);
+ }
+
+ public BigdataSPARQLResultsJSONWriterForConstruct(final OutputStream out) {
+ this.writer = new BigdataSPARQLResultsJSONWriter(out);
+ }
+
+ /*---------*
+ * Methods *
+ *---------*/
+
+ @Override
+ public RDFFormat getRDFFormat() {
+ return BigdataSPARQLResultsJSONWriterForConstructFactory.JSON;
+ }
+
+
+ @Override
+ public void startRDF() throws RDFHandlerException {
+ try {
+ writer.startDocument();
+ writer.startHeader();
+ writer.startQueryResult(Arrays.asList(new String[] {
+ "subject", "predicate", "object", "context"
+ }));
+ writer.endHeader();
+ } catch (QueryResultHandlerException e) {
+ throw new RDFHandlerException(e);
+ }
+ }
+
+ @Override
+ public void endRDF() throws RDFHandlerException {
+ try {
+ writer.endDocument();
+ } catch (IOException e) {
+ throw new RDFHandlerException(e);
+ }
+ }
+
+ @Override
+ public void handleNamespace(String prefix, String uri)
+ throws RDFHandlerException {
+ try {
+ writer.handleNamespace(prefix, uri);
+ } catch (QueryResultHandlerException e) {
+ throw new RDFHandlerException(e);
+ }
+ }
+
+ @Override
+ public void handleStatement(Statement st) throws RDFHandlerException {
+ final MapBindingSet bs = new MapBindingSet();
+ bs.addBinding("subject", st.getSubject());
+ bs.addBinding("predicate", st.getPredicate());
+ bs.addBinding("object", st.getObject());
+ if (st.getContext() != null)
+ bs.addBinding("context", st.getContext());
+ try {
+ writer.handleSolution(bs);
+ } catch (TupleQueryResultHandlerException e) {
+ throw new RDFHandlerException(e);
+ }
+ }
+
+ @Override
+ public void handleComment(String comment) throws RDFHandlerException {
+ // do nothing
+ }
+
+ @Override
+ public void setWriterConfig(WriterConfig config) {
+ writer.setWriterConfig(config);
+ }
+
+ @Override
+ public WriterConfig getWriterConfig() {
+ return writer.getWriterConfig();
+ }
+
+ @Override
+ public Collection<RioSetting<?>> getSupportedSettings() {
+ return writer.getSupportedSettings();
+ }
+
+}
Property changes on: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstruct.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstructFactory.java
===================================================================
--- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstructFactory.java (rev 0)
+++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstructFactory.java 2014-06-03 00:31:26 UTC (rev 8439)
@@ -0,0 +1,63 @@
+/*
+ * Licensed to Aduna under one or more contributor license agreements.
+ * See the NOTICE.txt file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * Aduna licenses this file to you under the terms of the Aduna BSD
+ * License (the "License"); you may not use this file except in compliance
+ * with the License. See the LICENSE.txt file distributed with this work
+ * for the full License.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+package com.bigdata.rdf.rio.json;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+
+import org.openrdf.query.resultio.TupleQueryResultWriterFactory;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFWriter;
+import org.openrdf.rio.RDFWriterFactory;
+
+
+/**
+ * A {@link TupleQueryResultWriterFactory} for writers of SPARQL/JSON query
+ * results.
+ *
+ * @author Arjohn Kampman
+ */
+public class BigdataSPARQLResultsJSONWriterForConstructFactory implements RDFWriterFactory {
+
+// public static final RDFFormat JSON = new RDFFormat("N-Triples", "text/plain",
+// Charset.forName("US-ASCII"), "nt", NO_NAMESPACES, NO_CONTEXTS);
+
+ /**
+ * SPARQL Query Results JSON Format.
+ */
+ public static final RDFFormat JSON = new RDFFormat("SPARQL/JSON", Arrays.asList(
+ "application/sparql-results+json", "application/json"), Charset.forName("UTF-8"), Arrays.asList(
+ "srj", "json"), RDFFormat.NO_NAMESPACES, RDFFormat.SUPPORTS_CONTEXTS);
+
+
+ @Override
+ public RDFFormat getRDFFormat() {
+ return JSON;
+ }
+
+ @Override
+ public RDFWriter getWriter(final Writer writer) {
+ return new BigdataSPARQLResultsJSONWriterForConstruct(writer);
+ }
+
+ @Override
+ public RDFWriter getWriter(final OutputStream out) {
+ return new BigdataSPARQLResultsJSONWriterForConstruct(out);
+ }
+}
Property changes on: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/BigdataSPARQLResultsJSONWriterForConstructFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/SPARQLJSONWriterBase.java
===================================================================
--- branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/SPARQLJSONWriterBase.java 2014-06-02 17:18:22 UTC (rev 8438)
+++ branches/SESAME_2_7/bigdata-rdf/src/java/com/bigdata/rdf/rio/json/SPARQLJSONWriterBase.java 2014-06-03 00:31:26 UTC (rev 8439)
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.HashSet;
@@ -26,9 +27,6 @@
import java.util.List;
import java.util.Set;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-
import org.openrdf.model.BNode;
import org.openrdf.model.Literal;
import org.openrdf.model.URI;
@@ -43,6 +41,9 @@
import org.openrdf.rio.RioSetting;
import org.openrdf.rio.helpers.BasicWriterSettings;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+
/**
* An abstract class to implement the base functionality for both
* SPARQLBooleanJSONWriter and SPARQLResultsJSONWriter.
@@ -86,6 +87,15 @@
protected final JsonGenerator jg;
+ public SPARQLJSONWriterBase(Writer writer) {
+ try {
+ jg = JSON_FACTORY.createJsonGenerator(writer);
+ }
+ catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
public SPARQLJSONWriterBase(OutputStream out) {
try {
jg = JSON_FACTORY.createJsonGenerator(new OutputStreamWriter(out, Charset.forName("UTF-8")));
@@ -413,7 +423,7 @@
// Ignored by SPARQLJSONWriterBase
}
- protected void endDocument()
+ public void endDocument()
throws IOException
{
jg.writeEndObject();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|