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 2021/02/15 08:45:30 UTC
[jena] branch main updated: JENA-2045: Remove deprecated functions
in RDFDataMgr
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push:
new 1fa35ca JENA-2045: Remove deprecated functions in RDFDataMgr
new 57fe27e Merge pull request #924 from afs/deprecations
1fa35ca is described below
commit 1fa35ca2b3ceeb6a899f34cce72fe6a0c1fd3623
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Sun Feb 14 11:13:20 2021 +0000
JENA-2045: Remove deprecated functions in RDFDataMgr
---
.../main/java/org/apache/jena/riot/RDFDataMgr.java | 906 ++++++++-------------
.../main/java/org/apache/jena/riot/RDFParser.java | 8 +-
.../main/java/org/apache/jena/riot/RDFWriter.java | 36 +-
.../org/apache/jena/riot/RDFWriterBuilder.java | 54 +-
.../main/java/org/apache/jena/riot/SysRIOT.java | 2 +-
.../java/org/apache/jena/riot/TestRDFWriter.java | 2 +-
.../apache/jena/riot/stream/TestStreamManager.java | 36 +-
.../apache/jena/riot/writer/TestJsonLDWriter.java | 2 +-
jena-cmds/src/main/java/riotcmd/infer.java | 21 +-
.../apache/jena/tdb2/loader/base/LoaderOps.java | 9 +-
.../jena/tdb2/loader/AbstractTestLoader.java | 3 +-
.../jena/shacl/compact/TestReadShaclCompact.java | 4 +-
.../jena/shacl/compact/TestWriteShaclCompact.java | 4 +-
.../jena/tdb/store/bulkloader/BulkLoader.java | 10 +-
.../store/bulkloader2/ProcNodeTableBuilder.java | 4 +-
15 files changed, 450 insertions(+), 651 deletions(-)
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/RDFDataMgr.java b/jena-arq/src/main/java/org/apache/jena/riot/RDFDataMgr.java
index ff6a0e8..8fdcb17 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/RDFDataMgr.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/RDFDataMgr.java
@@ -18,36 +18,37 @@
package org.apache.jena.riot;
-import java.io.* ;
-import java.util.Iterator ;
-import java.util.Objects ;
-
-import org.apache.jena.atlas.iterator.IteratorResourceClosing ;
-import org.apache.jena.atlas.web.ContentType ;
-import org.apache.jena.atlas.web.TypedInputStream ;
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.DatasetFactory ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.riot.lang.PipedQuadsStream ;
-import org.apache.jena.riot.lang.PipedRDFIterator ;
-import org.apache.jena.riot.lang.PipedTriplesStream ;
+import java.io.*;
+import java.util.Iterator;
+import java.util.Objects;
+
+import org.apache.jena.atlas.iterator.IteratorResourceClosing;
+import org.apache.jena.atlas.web.ContentType;
+import org.apache.jena.atlas.web.TypedInputStream;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.irix.IRIs;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.riot.lang.PipedQuadsStream;
+import org.apache.jena.riot.lang.PipedRDFIterator;
+import org.apache.jena.riot.lang.PipedTriplesStream;
import org.apache.jena.riot.lang.RiotParsers;
-import org.apache.jena.riot.system.*;
-import org.apache.jena.riot.system.stream.StreamManager ;
-import org.apache.jena.riot.writer.NQuadsWriter ;
-import org.apache.jena.riot.writer.NTriplesWriter ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.core.DatasetGraphFactory ;
-import org.apache.jena.sparql.core.Quad ;
-import org.apache.jena.sparql.graph.GraphFactory ;
-import org.apache.jena.sparql.util.Context ;
-import org.apache.jena.sparql.util.Symbol ;
-import org.apache.jena.sys.JenaSystem ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
+import org.apache.jena.riot.system.RiotLib;
+import org.apache.jena.riot.system.StreamRDF;
+import org.apache.jena.riot.system.StreamRDFLib;
+import org.apache.jena.riot.system.stream.StreamManager;
+import org.apache.jena.riot.writer.NQuadsWriter;
+import org.apache.jena.riot.writer.NTriplesWriter;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphFactory;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.graph.GraphFactory;
+import org.apache.jena.sys.JenaSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* <p>
@@ -106,491 +107,411 @@ import org.slf4j.LoggerFactory ;
public class RDFDataMgr
{
- static { JenaSystem.init() ; }
+ static { JenaSystem.init(); }
- static Logger log = LoggerFactory.getLogger(RDFDataMgr.class) ;
+ static Logger log = LoggerFactory.getLogger(RDFDataMgr.class);
- /** @deprecated Use {@link SysRIOT#sysStreamManager} */
- @Deprecated
- public static Symbol streamManagerSymbol = SysRIOT.sysStreamManager;
-
- /** Read triples into a Model from the given location.
- * The syntax is determined from input source URI (content negotiation or extension).
+ /**
+ * Read triples into a Model from the given location. The syntax is determined
+ * from input source URI (content negotiation or file extension).
+ *
* @param model Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @throws RiotNotFoundException if the location is not found - the model is unchanged.
- * @see #read(Model,String,Lang,Context)
+ * @param uri URI to read from (includes file: and a plain file name).
+ * @throws RiotNotFoundException if the location is not found - the model is
+ * unchanged.
*/
- public static void read(Model model, String uri) { read(model.getGraph(), uri) ; }
+ public static void read(Model model, String uri) {
+ Objects.requireNonNull(model, "Model is null");
+ read(model.getGraph(), uri, defaultLang(uri));
+ }
- /** Read triples into a Model from the given location.
- * The syntax is determined from input source URI (content negotiation or extension).
+ /**
+ * Read triples into a Model from the given location. The syntax is determined
+ * from input source URI (content negotiation or file extension).
+ *
* @param graph Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @throws RiotNotFoundException if the location is not found - the graph is unchanged.
- * @see #read(Graph,String,Lang,Context)
- */
- public static void read(Graph graph, String uri) { read(graph, uri, defaultBase(uri), defaultLang(uri), (Context)null) ; }
-
- /** Read triples into a Model from the given location, with a hint of the language (MIME type)
- * @param model Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @param hintLang Hint for the syntax.
- * @throws RiotNotFoundException if the location is not found - the model is unchanged.
- * @see #read(Model,String,String,Lang,Context)
- */
- public static void read(Model model, String uri, Lang hintLang) { read(model.getGraph(), uri, hintLang) ; }
-
- /** Read triples into a Model from the given location, with a hint of the language (MIME type or short name)
- * @param graph Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @param hintLang Hint for the syntax.
- * @throws RiotNotFoundException if the location is not found - the graph is unchanged.
- * @see #read(Graph,String,Lang,Context)
- */
- public static void read(Graph graph, String uri, Lang hintLang) { read(graph, uri, hintLang, (Context)null) ; }
-
- /** Read triples into a Model from the given location, with hint of language and with some parameters for the reader
- * @see #read(Model,String,String,Lang,Context)
- * Throws parse errors depending on the language and reader; the model may be partially updated.
- * @param model Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
- * @throws RiotNotFoundException if the location is not found - the model is unchanged.
- */
- public static void read(Model model, String uri, String base, Lang hintLang) { read(model.getGraph(), uri, base, hintLang) ; }
-
- /** Read triples into a Model from the given location, with hint of language and the with some parameters for the reader
- * @see #read(Graph,String,String,Lang,Context)
- * Throws parse errors depending on the language and reader; the model may be partially updated.
- * @param graph Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
+ * @param uri URI to read from (includes file: and a plain file name).
* @throws RiotNotFoundException if the location is not found - the graph is unchanged.
*/
- public static void read(Graph graph, String uri, String base, Lang hintLang) { read(graph, uri, base, hintLang, (Context)null) ; }
+ public static void read(Graph graph, String uri) {
+ read(graph, uri, defaultBase(uri), defaultLang(uri));
+ }
- /** Read triples into a Model from the given location, with some parameters for the reader
- * @see #read(Model,String,String,Lang,Context)
- * @param model Destination for the RDF read
- * @param uri URI to read from (includes file: and a plain file name).
- * @param context Content object to control reading process.
+ /**
+ * Read triples into a Model from the given location, with a hint of the language
+ * (MIME type)
+ *
+ * @param model Destination for the RDF read.
+ * @param uri URI to read from (includes file: and a plain file name).
+ * @param hintLang Hint for the syntax.
* @throws RiotNotFoundException if the location is not found - the model is unchanged.
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
*/
- @Deprecated
- public static void read(Model model, String uri, Context context) { read(model.getGraph(), uri, context) ; }
+ public static void read(Model model, String uri, Lang hintLang) {
+ read(model.getGraph(), uri, hintLang);
+ }
- /** Read triples into a Model from the given location, with some parameters for the reader
- * @see #read(Graph,String,String,Lang,Context)
- * @param graph Destination for the RDF read
- * @param uri URI to read from (includes file: and a plain file name).
- * @param context Content object to control reading process.
+ /**
+ * Read triples into a Model from the given location, with a hint of the language
+ * (MIME type or short name)
+ *
+ * @param graph Destination for the RDF read.
+ * @param uri URI to read from (includes file: and a plain file name).
+ * @param hintLang Hint for the syntax.
* @throws RiotNotFoundException if the location is not found - the graph is unchanged.
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
*/
- @Deprecated
- public static void read(Graph graph, String uri, Context context) { read(graph, uri, defaultLang(uri), context) ; }
+ public static void read(Graph graph, String uri, Lang hintLang) {
+ read(graph, uri, defaultBase(uri), hintLang);
+ }
- /** Read triples into a Model from the given location, with hint of language and the with some parameters for the reader
- * @see #read(Model,String,String,Lang,Context)
- * @param model Destination for the RDF read
- * @param uri URI to read from (includes file: and a plain file name).
- * @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
+ /**
+ * Read triples into a Model from the given location, with a hint of language.
+ * Throws parse errors depending on the
+ * language and reader; the model may be partially updated.
+ *
+ * @param model Destination for the RDF read.
+ * @param uri URI to read from (includes file: and a plain file name).
+ * @param base Base URI (defaults to uri).
+ * @param hintLang Hint for the syntax
* @throws RiotNotFoundException if the location is not found - the model is unchanged.
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
*/
- @Deprecated
- public static void read(Model model, String uri, Lang hintLang, Context context)
- { read(model, uri, defaultBase(uri), hintLang, context) ; }
-
- /** Read triples into a Model from the given location, with hint of language and with some parameters for the reader
- * @see #read(Graph,String,String,Lang,Context)
- * @param graph Destination for the RDF read
- * @param uri URI to read from (includes file: and a plain file name).
- * @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
- * @throws RiotNotFoundException if the location is not found - the graph is unchanged.
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
- */
- @Deprecated
- public static void read(Graph graph, String uri, Lang hintLang, Context context)
- { read(graph, uri, defaultBase(uri), hintLang, context) ; }
+ public static void read(Model model, String uri, String base, Lang hintLang) {
+ read(model.getGraph(), uri, base, hintLang);
+ }
- /** Read triples into a Model from the given location, with hint of language
- * and with some parameters for the reader.
+ /**
+ * Read triples into a Model from the given location, with a hint of language.
* Throws parse errors depending on the language and reader; the model may be partially updated.
- * @param model Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
- * @throws RiotNotFoundException if the location is not found - the model is unchanged.
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
- */
- @Deprecated
- public static void read(Model model, String uri, String base, Lang hintLang, Context context)
- { read(model.getGraph(), uri, base, hintLang, context) ; }
-
- /** Read triples into a Model from the given location, with hint of language and the with some parameters for the reader
- * Throws parse errors depending on the language and reader; the graph may be partially updated.
- * @param graph Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
- * @throws RiotNotFoundException if the location is not found - the model is unchanged.
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
+ *
+ * @param graph Destination for the RDF read.
+ * @param uri URI to read from (includes file: and a plain file name).
+ * @param base Base URI (defaults to uri).
+ * @param hintLang Hint for the syntax
+ * @throws RiotNotFoundException if the location is not found - the graph is
+ * unchanged.
*/
- @Deprecated
- public static void read(Graph graph, String uri, String base, Lang hintLang, Context context)
- {
- StreamRDF dest = StreamRDFLib.graph(graph) ;
- parseFromURI(dest, uri, base, hintLang, context) ;
+ public static void read(Graph graph, String uri, String base, Lang hintLang) {
+ Objects.requireNonNull(graph, "Graph is null");
+ StreamRDF dest = StreamRDFLib.graph(graph);
+ parseFromURI(dest, uri, base, hintLang);
}
- /** Read triples into a Model with bytes from an InputStream.
- * A base URI and a syntax can be provided.
- * The base URI defaults to "no base" in which case the data should have no relative URIs.
- * The lang gives the syntax of the stream.
+ /**
+ * Read triples into a Model with bytes from an InputStream.
+ * A base URI and a syntax can be provided.
+ * The base URI defaults to "no base" in which case the data should have no relative URIs.
+ * The lang gives the syntax of the stream.
* @param model Destination for the RDF read.
* @param in InputStream
* @param lang Language syntax
*/
- public static void read(Model model, InputStream in, Lang lang) { read(model.getGraph(), in, lang) ; }
+ public static void read(Model model, InputStream in, Lang lang) {
+ read(model.getGraph(), in, lang);
+ }
- /** Read triples into a Model with bytes from an InputStream.
- * A base URI and a syntax can be provided.
- * The base URI defaults to "no base" in which case the data should have no relative URIs.
- * The lang gives the syntax of the stream.
+ /**
+ * Read triples into a Model with bytes from an InputStream.
+ * A base URI and a syntax can be provided.
+ * The base URI defaults to "no base" in which case the data should have no relative URIs.
+ * The lang gives the syntax of the stream.
+ *
* @param graph Destination for the RDF read.
* @param in InputStream
* @param lang Language syntax
*/
- public static void read(Graph graph, InputStream in, Lang lang) { read(graph, in, defaultBase(), lang) ; }
+ public static void read(Graph graph, InputStream in, Lang lang) {
+ read(graph, in, defaultBase(), lang);
+ }
- /** Read triples into a Model with bytes from an InputStream.
- * A base URI and a syntax can be provided.
- * The base URI defaults to "no base" in which case the data should have no relative URIs.
- * The lang gives the syntax of the stream.
+ /**
+ * Read triples into a Model with bytes from an InputStream.
+ * A base URI and a syntax can be provided.
+ * The base URI defaults to "no base" in which case the data should have no relative URIs.
+ * The lang gives the syntax of the stream.
+ *
* @param model Destination for the RDF read.
* @param in InputStream
* @param base Base URI
* @param lang Language syntax
*/
- public static void read(Model model, InputStream in, String base, Lang lang)
- { read(model.getGraph(), in, base, lang) ; }
+ public static void read(Model model, InputStream in, String base, Lang lang) {
+ read(model.getGraph(), in, base, lang);
+ }
- /** Read triples into a Model with bytes from an InputStream.
- * A base URI and a syntax can be provided.
- * The base URI defaults to "no base" in which case the data should have no relative URIs.
- * The lang gives the syntax of the stream.
+ /**
+ * Read triples into a Model with bytes from an InputStream.
+ * A base URI and a syntax can be provided.
+ * The base URI defaults to "no base" in which case the data should have no relative URIs.
+ * The lang gives the syntax of the stream.
+ *
* @param graph Destination for the RDF read.
* @param in InputStream
* @param base Base URI
* @param lang Language syntax
*/
public static void read(Graph graph, InputStream in, String base, Lang lang) {
- Objects.requireNonNull(in, "InputStream is null") ;
- StreamRDF dest = StreamRDFLib.graph(graph) ;
- parseFromInputStream(dest, in, base, lang, null) ;
+ Objects.requireNonNull(graph, "Graph is null");
+ Objects.requireNonNull(in, "InputStream is null");
+ StreamRDF dest = StreamRDFLib.graph(graph);
+ parseFromInputStream(dest, in, base, lang);
}
- /** Read triples into a model with chars from an Reader.
+ /**
+ * Read triples into a model with chars from an Reader.
* Use of java.io.Readers is not encouraged - use with a StringReader is the primary use case.
- * For files, open a {@link java.io.FileInputStream} to ensure correct character set handling.
- * @deprecated Use an InputStream or StringReader.
+ * For files, open a {@link java.io.FileInputStream}, not a {@link java.io.Reader}
+ * to ensure correct character set handling.
+ *
* @param model Destination for the RDF read.
* @param in Reader
* @param base Base URI
* @param lang Language syntax
+ * @deprecated Use an InputStream or StringReader.
*/
@Deprecated
public static void read(Model model, Reader in, String base, Lang lang) {
- Objects.requireNonNull(in, "Reader is null") ;
- read(model.getGraph(), in, base, lang) ;
+ Objects.requireNonNull(in, "Reader is null");
+ read(model.getGraph(), in, base, lang);
}
/** Read triples into a model with chars from an Reader.
* Use of java.io.Readers is not encouraged - use with a StringReader is the primary use case.
- * For files, open a {@link java.io.FileInputStream} to ensure correct character set handling.
- * @deprecated Use an InputStream or StringReader.
+ * For files, open a {@link java.io.FileInputStream}, not a {@link java.io.Reader}
+ * to ensure correct character set handling.
* @param graph Destination for the RDF read.
* @param in Reader
* @param base Base URI
* @param lang Language syntax
+ * @deprecated Use an InputStream or StringReader.
*/
@Deprecated
public static void read(Graph graph, Reader in, String base, Lang lang) {
- StreamRDF dest = StreamRDFLib.graph(graph) ;
- parseFromReader(dest, in, base, lang, null) ;
+ StreamRDF dest = StreamRDFLib.graph(graph);
+ parseFromReader(dest, in, base, lang);
}
- /** Read triples into a model with chars from a StringReader.
+ /**
+ * Read triples into a model with chars from a StringReader.
+ *
* @param model Destination for the RDF read.
* @param in InputStream
* @param base Base URI
* @param lang Language syntax
*/
public static void read(Model model, StringReader in, String base, Lang lang) {
- Graph g = model.getGraph() ;
- StreamRDF dest = StreamRDFLib.graph(g) ;
- parseFromReader(dest, in, base, lang, (Context)null) ;
+ Graph g = model.getGraph();
+ StreamRDF dest = StreamRDFLib.graph(g);
+ parseFromReader(dest, in, base, lang);
}
- /** Read triples into a model with chars from a StringReader.
+ /**
+ * Read triples into a model with chars from a StringReader.
+ *
* @param graph Destination for the RDF read.
* @param in InputStream
* @param base Base URI
* @param lang Language syntax
*/
public static void read(Graph graph, StringReader in, String base, Lang lang) {
- StreamRDF dest = StreamRDFLib.graph(graph) ;
- parseFromReader(dest, in, base, lang, (Context)null) ;
+ Objects.requireNonNull(graph, "Graph is null");
+ Objects.requireNonNull(in, "StringReader is null");
+ StreamRDF dest = StreamRDFLib.graph(graph);
+ parseFromReader(dest, in, base, lang);
}
- private static Model createModel() { return ModelFactory.createDefaultModel() ; }
- private static Graph createGraph() { return GraphFactory.createDefaultGraph() ; }
- private static Dataset createDataset() { return DatasetFactory.createTxnMem() ; }
- private static DatasetGraph createDatasetGraph() { return DatasetGraphFactory.createTxnMem() ; }
+ private static Model createModel() { return ModelFactory.createDefaultModel(); }
+ private static Graph createGraph() { return GraphFactory.createDefaultGraph(); }
+ private static Dataset createDataset() { return DatasetFactory.createTxnMem(); }
+ private static DatasetGraph createDatasetGraph() { return DatasetGraphFactory.createTxnMem(); }
- // Load:
- /** Create a memory Model and read in some data
+ /**
+ * Create a memory Model and read in some data
+ *
* @see #read(Model,String)
*/
public static Model loadModel(String uri) {
- Model m = createModel() ;
- read(m, uri) ;
- return m ;
+ Model m = createModel();
+ read(m, uri);
+ return m;
}
- /** Create a memory Model and read in some data
+ /**
+ * Create a memory Model and read in some data
+ *
* @see #read(Model,String,Lang)
*/
public static Model loadModel(String uri, Lang lang) {
- Model m = createModel() ;
- read(m, uri,lang) ;
- return m ;
+ Model m = createModel();
+ read(m, uri,lang);
+ return m;
}
- /** Create a memory Graph and read in some data
+ /**
+ * Create a memory Graph and read in some data
* @see #read(Graph,String)
*/
public static Graph loadGraph(String uri) {
- Graph g = createGraph() ;
- read(g, uri) ;
- return g ;
+ Graph g = createGraph();
+ read(g, uri);
+ return g;
}
- /** Create a memory Graph and read in some data
+ /**
+ * Create a memory Graph and read in some data
* @see #read(Graph,String,Lang)
*/
public static Graph loadGraph(String uri, Lang lang) {
- Graph g = createGraph() ;
- read(g, uri, lang) ;
- return g ;
+ Graph g = createGraph();
+ read(g, uri, lang);
+ return g;
}
-// public static Graph loadGraph(String uri, String base) { return null ; }
-// public static Graph loadGraph(String uri, String base, Lang lang) { return null ; }
-
- /** Create a memory Dataset and read in some data
- * @see #read(Dataset,String)
+ /**
+ * Create a memory Dataset and read in some data
+ * @see #read(Dataset,String,Lang)
*/
public static Dataset loadDataset(String uri) {
- Dataset ds = createDataset() ;
- read(ds, uri) ;
- return ds ;
+ Dataset ds = createDataset();
+ read(ds, uri);
+ return ds;
}
- /** Create a memory Dataset and read in some data
+ /**
+ * Create a memory Dataset and read in some data
* @see #read(Dataset,String,Lang)
*/
public static Dataset loadDataset(String uri, Lang lang) {
- Dataset ds = createDataset() ;
- read(ds, uri, lang) ;
- return ds ;
+ Dataset ds = createDataset();
+ read(ds, uri, lang);
+ return ds;
}
- /** Create a memory DatasetGraph and read in some data
+ /**
+ * Create a memory DatasetGraph and read in some data
* @see #read(DatasetGraph,String)
*/
public static DatasetGraph loadDatasetGraph(String uri) {
- DatasetGraph ds = createDatasetGraph() ;
- read(ds, uri) ;
- return ds ;
+ DatasetGraph ds = createDatasetGraph();
+ read(ds, uri);
+ return ds;
}
- /** Create a memory DatasetGraph and read in some data
+
+ /**
+ * Create a memory DatasetGraph and read in some data
* @see #read(DatasetGraph,String,Lang)
*/
public static DatasetGraph loadDatasetGraph(String uri, Lang lang) {
- DatasetGraph ds = createDatasetGraph() ;
- read(ds, uri, lang) ;
- return ds ;
+ DatasetGraph ds = createDatasetGraph();
+ read(ds, uri, lang);
+ return ds;
}
- /** Read quads or triples into a Dataset from the given location, with hint of language.
- * @see #read(Dataset, String, String, Lang, Context)
+ /**
+ * Read quads or triples into a Dataset from the given location, with a hint of the language.
* @param dataset Destination
* @param uri URI to read from (includes file: and a plain file name).
*/
public static void read(Dataset dataset, String uri) {
- read(dataset.asDatasetGraph(), uri) ;
+ read(dataset.asDatasetGraph(), uri);
}
- /** Read quads or triples into a Dataset from the given location, with hint of language.
- * @see #read(DatasetGraph, String, String, Lang, Context)
+ /**
+ * Read quads or triples into a Dataset from the given location, with a hint of the language.
* @param dataset Destination
* @param uri URI to read from (includes file: and a plain file name).
*/
public static void read(DatasetGraph dataset, String uri) {
- read(dataset, uri, defaultLang(uri)) ;
+ read(dataset, uri, defaultLang(uri));
}
- /** Read quads or triples into a Dataset from the given location, with hint of language.
- * @see #read(Dataset, String, String, Lang, Context)
+ /**
+ * Read quads or triples into a Dataset from the given location, with a hint of the language.
* @param dataset Destination
* @param uri URI to read from (includes file: and a plain file name).
* @param hintLang Language syntax
*/
public static void read(Dataset dataset, String uri, Lang hintLang) {
- read(dataset.asDatasetGraph(), uri, hintLang) ;
+ read(dataset.asDatasetGraph(), uri, hintLang);
}
- /** Read quads or triples into a Dataset from the given location, with hint of language.
- * @see #read(DatasetGraph, String, String, Lang, Context)
+ /**
+ * Read quads or triples into a Dataset from the given location, with a hint of the language.
* @param dataset Destination
* @param uri URI to read from (includes file: and a plain file name).
* @param hintLang Language syntax
*/
public static void read(DatasetGraph dataset, String uri, Lang hintLang) {
- read(dataset, uri, hintLang, (Context)null) ;
+ read(dataset, uri, defaultBase(uri), hintLang);
}
- /** Read quads or triples into a Dataset from the given location, with hint of language.
- * @see #read(Dataset, String, String, Lang, Context)
+ /**
+ * Read quads or triples into a Dataset from the given location, with a hint of the language.
* @param dataset Destination
* @param uri URI to read from (includes file: and a plain file name).
* @param base Base URI (defaults to uri).
* @param hintLang Language syntax
*/
public static void read(Dataset dataset, String uri, String base, Lang hintLang) {
- read(dataset.asDatasetGraph(), uri, base, hintLang) ;
+ read(dataset.asDatasetGraph(), uri, base, hintLang);
}
- /** Read quads or triples into a Dataset from the given location, with hint of language.
- * @see #read(DatasetGraph, String, String, Lang, Context)
+ /**
+ * Read quads or triples into a Dataset from the given location, with a hint of the language.
* @param dataset Destination
* @param uri URI to read from (includes file: and a plain file name).
* @param base Base URI (defaults to uri).
* @param hintLang Language syntax
*/
public static void read(DatasetGraph dataset, String uri, String base, Lang hintLang) {
- read(dataset, uri, base, hintLang, (Context)null) ;
- }
-
-
- /** Read quads or triples into a Dataset from the given location.
- * @see #read(Dataset, String, String, Lang, Context)
- * @param dataset Destination
- * @param uri URI to read from (includes file: and a plain file name).
- * @param hintLang Language syntax
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
- */
- @Deprecated
- public static void read(Dataset dataset, String uri, Lang hintLang, Context context) {
- read(dataset.asDatasetGraph(), uri, hintLang, context) ;
- }
-
- /** Read quads or triples into a Dataset from the given location.
- * @see #read(DatasetGraph, String, String, Lang, Context)
- * @param dataset Destination
- * @param uri URI to read from (includes file: and a plain file name).
- * @param hintLang Language syntax
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
- */
- @Deprecated
- public static void read(DatasetGraph dataset, String uri, Lang hintLang, Context context) {
- read(dataset, uri, defaultBase(uri), hintLang, context) ;
- }
-
- /** Read quads or triples into a Dataset from the given location.
- * @see #read(Dataset, String, String, Lang, Context)
- * @param dataset Destination
- * @param uri URI to read from (includes file: and a plain file name).
- * @param base Base URI (defaults to uri).
- * @param hintLang Language syntax
- * @param context Context for the reader
- * @throws RiotNotFoundException if the location is not found - the dataset is unchanged.
- * Throws parse errors depending on the language and reader; the dataset may be partially updated.
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
- */
- @Deprecated
- public static void read(Dataset dataset, String uri, String base, Lang hintLang, Context context) {
- read(dataset.asDatasetGraph(), uri, defaultBase(uri), hintLang, context) ;
- }
-
- /** Read quads or triples into a Dataset from the given location.
- * @see #read(Dataset, String, String, Lang, Context)
- * @param dataset Destination
- * @param uri URI to read from (includes file: and a plain file name).
- * @param base Base URI (defaults to uri).
- * @param hintLang Language syntax
- * @param context Context for the reader
- * @throws RiotNotFoundException if the location is not found - the dataset is unchanged.
- * Throws parse errors depending on the language and reader; the dataset may be partially updated.
- * @deprecated To be removed. Use {@code RDFParser.create().context(context)...}
- */
- @Deprecated
- public static void read(DatasetGraph dataset, String uri, String base, Lang hintLang, Context context) {
- StreamRDF sink = StreamRDFLib.dataset(dataset) ;
- parseFromURI(sink, uri, base, hintLang, context) ;
+ StreamRDF sink = StreamRDFLib.dataset(dataset);
+ parseFromURI(sink, uri, base, hintLang);
}
- /** Read quads or triples into a dataset with bytes from an input stream.
+ /**
+ * Read quads or triples into a dataset with bytes from an input stream.
* @param dataset Destination
* @param in InputStream
* @param lang Language syntax
*/
public static void read(Dataset dataset, InputStream in, Lang lang) {
- read(dataset.asDatasetGraph(), in, lang) ;
+ read(dataset.asDatasetGraph(), in, lang);
}
- /** Read quads or triples into a dataset with bytes from an input stream.
+ /**
+ * Read quads or triples into a dataset with bytes from an input stream.
* @param dataset Destination
* @param in InputStream
* @param lang Language syntax
*/
public static void read(DatasetGraph dataset, InputStream in, Lang lang) {
- read(dataset, in, defaultBase(), lang) ;
+ read(dataset, in, defaultBase(), lang);
}
- /** Read quads or triples into a dataset with bytes from an input stream.
+ /**
+ * Read quads or triples into a dataset with bytes from an input stream.
* @param dataset Destination
* @param in InputStream
* @param base Base URI
* @param lang Language syntax
*/
public static void read(Dataset dataset, InputStream in, String base, Lang lang) {
- read(dataset.asDatasetGraph(), in, base, lang) ;
+ read(dataset.asDatasetGraph(), in, base, lang);
}
- /** Read quads or triples into a dataset with bytes from an input stream.
+ /**
+ * Read quads or triples into a dataset with bytes from an input stream.
* @param dataset Destination
* @param in InputStream
* @param base Base URI
* @param lang Language syntax
*/
public static void read(DatasetGraph dataset, InputStream in, String base, Lang lang) {
- Objects.requireNonNull(in, "InputStream is null") ;
- StreamRDF dest = StreamRDFLib.dataset(dataset) ;
- parseFromInputStream(dest, in, base, lang, (Context)null) ;
+ Objects.requireNonNull(in, "InputStream is null");
+ StreamRDF dest = StreamRDFLib.dataset(dataset);
+ parseFromInputStream(dest, in, base, lang);
}
- /** Read quads into a dataset with chars from an Reader.
+ /**
+ * Read quads into a dataset with chars from an Reader.
* Use java.io.Readers is not encouraged - use with a StringReader is the primary use case.
* For files, open a {@link java.io.FileInputStream} to ensure correct character set handling.
* @param dataset Destination
@@ -601,11 +522,12 @@ public class RDFDataMgr
*/
@Deprecated
public static void read(Dataset dataset, Reader in, String base, Lang lang) {
- Objects.requireNonNull(in, "Java Reader is null") ;
- read(dataset.asDatasetGraph(), in, base, lang) ;
+ Objects.requireNonNull(in, "Java Reader is null");
+ read(dataset.asDatasetGraph(), in, base, lang);
}
- /** Read quads into a dataset with chars from an Reader.
+ /**
+ * Read quads into a dataset with chars from an Reader.
* Use java.io.Readers is not encouraged - use with a StringReader is the primary use case.
* For files, open a {@link java.io.FileInputStream} to ensure correct character set handling.
* @param dataset Destination
@@ -616,11 +538,12 @@ public class RDFDataMgr
*/
@Deprecated
public static void read(DatasetGraph dataset, Reader in, String base, Lang lang) {
- StreamRDF dest = StreamRDFLib.dataset(dataset) ;
- parseFromReader(dest, in, base, lang, (Context)null) ;
+ StreamRDF dest = StreamRDFLib.dataset(dataset);
+ parseFromReader(dest, in, base, lang);
}
- /** Read quads into a dataset with chars from a StringReader.
+ /**
+ * Read quads into a dataset with chars from a StringReader.
* Use java.io.Readers is not encouraged - use with a StringReader is the primary use case.
* For files, open a {@link java.io.FileInputStream} to ensure correct character set handling.
* @param dataset Destination
@@ -629,10 +552,11 @@ public class RDFDataMgr
* @param lang Language syntax
*/
public static void read(Dataset dataset, StringReader in, String base, Lang lang) {
- read(dataset.asDatasetGraph(), in, base, lang) ;
+ read(dataset.asDatasetGraph(), in, base, lang);
}
- /** Read quads into a dataset with chars from a StringReader.
+ /**
+ * Read quads into a dataset with chars from a StringReader.
* Use java.io.Readers is not encouraged - use with a StringReader is the primary use case.
* For files, open a {@link java.io.FileInputStream} to ensure correct character set handling.
* @param dataset Destination
@@ -641,288 +565,183 @@ public class RDFDataMgr
* @param lang Language syntax
*/
public static void read(DatasetGraph dataset, StringReader in, String base, Lang lang) {
- StreamRDF dest = StreamRDFLib.dataset(dataset) ;
- parseFromReader(dest, in, base, lang, (Context)null) ;
+ StreamRDF dest = StreamRDFLib.dataset(dataset);
+ parseFromReader(dest, in, base, lang);
}
- /** Read RDF data.
- * Use {@code RDFParser.source(uri).parse(sink)}
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param uri URI to read from (includes file: and a plain file name).
+ * @deprecated Use {@code RDFParser.source(uri).parse(sink)}
*/
- //@deprecated Use {@code RDFParser.source(uri).parse(sink)}
- //@Deprecated
+ @Deprecated
public static void parse(StreamRDF sink, String uri) {
- parse(sink, uri, defaultLang(uri)) ;
+ parse(sink, uri, defaultLang(uri));
}
- /** Read RDF data.
- * Use {@code RDFParser.source(uri).lang(hintLang).parse(sink)}
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param uri URI to read from (includes file: and a plain file name).
* @param lang Hint for the syntax
- */
- //* @deprecated Use {@code RDFParser.source(uri).lang(hintLang).parse(sink)}
- //@Deprecated
- public static void parse(StreamRDF sink, String uri, Lang lang) {
- parse(sink, uri, lang, (Context)null) ;
- }
-
- /** Read RDF data.
- * @param sink Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
- * @deprecated To be removed. Use {@code RDFParser.source(uri).lang(hintLang).context(context).parse(sink)}
+ * @deprecated Use {@code RDFParser.source(uri).lang(hintLang).parse(sink)}
*/
@Deprecated
- public static void parse(StreamRDF sink, String uri, Lang hintLang, Context context) {
- parse(sink, uri, defaultBase(uri), hintLang, context) ;
- }
-
- /** Read RDF data.
- * @param sink Destination for the RDF read.
- * @param uri URI to read from (includes file: and a plain file name).
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
- * @deprecated To be removed. Use {@code RDFParser.source(uri).base(base)...}
- */
- @Deprecated
- public static void parse(StreamRDF sink, String uri, String base, Lang hintLang) {
- parse(sink, uri, base, hintLang, (Context)null) ;
+ public static void parse(StreamRDF sink, String uri, Lang lang) {
+ parse(sink, uri, defaultBase(uri), lang);
}
- /** Read RDF data.
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param uri URI to read from (includes file: and a plain file name).
* @param base Base URI (defaults to uri).
* @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
- * @deprecated To be removed. Use {@code RDFParser.source(uri).lang(hintLang).base(base).context(context).parse(sink)}
+ * @deprecated Use {@code RDFParser.source(uri).base(base).lang(hintLang).parse(sink)}
*/
@Deprecated
- public static void parse(StreamRDF sink, String uri, String base, Lang hintLang, Context context) {
+ public static void parse(StreamRDF sink, String uri, String base, Lang hintLang) {
if ( uri == null )
- throw new IllegalArgumentException("URI to read from is null") ;
+ throw new IllegalArgumentException("URI to read from is null");
if ( base == null )
- base = SysRIOT.chooseBaseIRI(uri) ;
+ base = IRIs.toBase(uri);
if ( hintLang == null )
- hintLang = RDFLanguages.pathnameToLang(uri) ;
- parseFromURI(sink, uri, base, hintLang, context);
+ hintLang = RDFLanguages.pathnameToLang(uri);
+ parseFromURI(sink, uri, base, hintLang);
}
- // TODO Deprecate this?
- /** Read RDF data.
- * Use {@code RDFParser.source(in).lang(lang).parse(sink)}
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param in Bytes to read.
* @param lang Syntax for the stream.
+ * @deprecated To be removed. Use {@code RDFParser.source(in).lang(lang).parse(sink)}
*/
- //@deprecated To be removed. Use {@code RDFParser.source(in).lang(lang).parse(sink)}
- //@Deprecated
+ @Deprecated
public static void parse(StreamRDF sink, InputStream in, Lang lang) {
- parseFromInputStream(sink, in, defaultBase(), lang, (Context)null) ;
- }
-
- // TODO Deprecate this?
- /** Read RDF data.
- * Use {@code RDFParser.source(in).lang(lang).base(base).parse(sink)}
- * @param sink Destination for the RDF read.
- * @param in Bytes to read.
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
- */
- //@deprecated To be removed. Use {@code RDFParser.source(in).lang(lang).base(base).parse(sink)}
- //@Deprecated
- public static void parse(StreamRDF sink, InputStream in, String base, Lang hintLang) {
- parseFromInputStream(sink, in, base, hintLang, null) ;
+ parseFromInputStream(sink, in, defaultBase(), lang);
}
- /** Read RDF data.
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param in Bytes to read.
* @param base Base URI (defaults to uri).
* @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
- * @deprecated To be removed. Use {@code RDFParser.source(in).base(base).lang(hintLang).context(context).parse(sink)}
+ * @deprecated To be removed. Use {@code RDFParser.source(in).lang(lang).base(base).parse(sink)}
*/
@Deprecated
- public static void parse(StreamRDF sink, InputStream in, String base, Lang hintLang, Context context) {
- parseFromInputStream(sink, in, base, hintLang, context) ;
+ public static void parse(StreamRDF sink, InputStream in, String base, Lang hintLang) {
+ parseFromInputStream(sink, in, base, hintLang);
}
- /** Read RDF data.
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param in StringReader
* @param lang Syntax for the stream.
* @deprecated To be removed. Use {@code RDFParser.create().source(in).lang(hintLang)...}
*/
+ @Deprecated
public static void parse(StreamRDF sink, StringReader in, Lang lang) {
- parse(sink, in, defaultBase(), lang, (Context)null) ;
+ parse(sink, in, defaultBase(), lang);
}
- /** Read RDF data.
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param in Reader
* @param base Base URI (defaults to uri).
* @param hintLang Hint for the syntax
* @deprecated To be removed. Use {@code RDFParser.create().source(in).base(base).lang(hintLang).parse(sink)}
*/
- public static void parse(StreamRDF sink, StringReader in, String base, Lang hintLang) {
- parse(sink, in, base, hintLang, (Context)null) ;
- }
-
- /** Read RDF data.
- * @param sink Destination for the RDF read.
- * @param in StringReader
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
- * @deprecated To be removed. Use {@code RDFParser.create().source(in).base(base).lang(hintLang).context(context).pase(sink)}
- */
- @Deprecated
- public static void parse(StreamRDF sink, StringReader in, String base, Lang hintLang, Context context) {
- parseFromReader(sink, in, base, hintLang, context) ;
- }
-
- /** Read RDF data.
- * @param sink Destination for the RDF read.
- * @param in Reader
- * @param lang Syntax for the stream.
- * @deprecated To be removed. An {@code InputStream} or {@code StringReader} is preferable. Use {@code RDFParser.create().source(in).lang(hintLang).parse()}
- */
- @Deprecated
- public static void parse(StreamRDF sink, Reader in, Lang lang) {
- parse(sink, in, defaultBase(), lang, (Context)null) ;
- }
-
- /** Read RDF data.
- * @param sink Destination for the RDF read.
- * @param in Reader
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
- * @deprecated To be removed. An {@code InputStream} or {@code StringReader} is preferable. Use {@code RDFParser.create().source(in).lang(hintLang).context(context).parse(sink)}
- */
@Deprecated
- public static void parse(StreamRDF sink, Reader in, String base, Lang hintLang) {
- parse(sink, in, base, hintLang, (Context)null) ;
- }
-
- /** Read RDF data.
- * @param sink Destination for the RDF read.
- * @param in Reader
- * @param base Base URI (defaults to uri).
- * @param hintLang Hint for the syntax
- * @param context Content object to control reading process.
- * @deprecated To be removed. An {@code InputStream} or {@code StringReader} is preferable. Use {@code RDFParser.create().source(in).lang(hintLang).base(base).context(context).parse(sink)}
- */
- @Deprecated
- public static void parse(StreamRDF sink, Reader in, String base, Lang hintLang, Context context) {
- parseFromReader(sink, in, base, hintLang, context) ;
+ public static void parse(StreamRDF sink, StringReader in, String base, Lang hintLang) {
+ parseFromReader(sink, in, base, hintLang);
}
- /** Read RDF data.
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param in Bytes to read. This must include the content type.
* @deprecated To be removed. Use an {@code InputStream} and {@code RDFParser.source(in).lang(hintLang).parse(sink)}
*/
@Deprecated
public static void parse(StreamRDF sink, TypedInputStream in) {
- parse(sink, in, defaultBase()) ;
+ parse(sink, in, defaultBase());
}
-
- /** Read RDF data.
+ /**
+ * Read RDF data.
* @param sink Destination for the RDF read.
* @param in Bytes to read.
* @param base Base URI
- * @deprecated To be removed. Use an {@code InputStream} and {@code RDFParser.source(in).base(base).lang(lang).parse(sink)}
+ * @deprecated To be removed. Use an {@code InputStream} and {@code RDFParser.source(in).base(base).lang(lang).parse(sink)}
*/
@Deprecated
public static void parse(StreamRDF sink, TypedInputStream in, String base) {
- parse(sink, in, base, (Context)null);
+ Objects.requireNonNull(in, "TypedInputStream is null");
+ Lang hintLang = RDFLanguages.contentTypeToLang(in.getMediaType());
+ processFromTypedInputStream(sink, in, base, hintLang);
}
- /** Read RDF data.
- * @param sink Destination for the RDF read.
- * @param in Bytes to read.
- * @param base Base URI
- * @param context Content object to control reading process.
- * @deprecated To be removed. Use {@code RDFParser.source(in).lang(lang).base(base).context(context).parse(sink)}
- */
- @Deprecated
- public static void parse(StreamRDF sink, TypedInputStream in, String base, Context context) {
- Objects.requireNonNull(in, "TypedInputStream is null") ;
- Lang hintLang = RDFLanguages.contentTypeToLang(in.getMediaType()) ;
- processFromTypedInputStream(sink, in, base, hintLang, context) ;
- }
-
- /** Open a stream to the destination (URI or filename)
+ /**
+ * Open a stream to the destination (URI or filename)
* Performs content negotiation, including looking at file extension.
* @param filenameOrURI
* @return TypedInputStream
*/
public static TypedInputStream open(String filenameOrURI)
- { return open(filenameOrURI, (Context)null) ; }
-
- /** Open a stream to the destination (URI or filename)
- * Performs content negotiation, including looking at file extension.
- * @param filenameOrURI
- * @param context
- * @return TypedInputStream
- */
- public static TypedInputStream open(String filenameOrURI, Context context) {
- StreamManager sMgr = StreamManager.get(context) ;
- return open(filenameOrURI, sMgr) ;
- }
+ { return open(filenameOrURI, StreamManager.get()); }
- /** Open a stream to the destination (URI or filename)
+ /**
+ * Open a stream to the destination (URI or filename)
* Performs content negotiation, including looking at file extension.
* @param filenameOrURI
* @param streamManager
* @return TypedInputStream
*/
public static TypedInputStream open(String filenameOrURI, StreamManager streamManager) {
- TypedInputStream in = streamManager.open(filenameOrURI) ;
+ TypedInputStream in = streamManager.open(filenameOrURI);
if ( in == null )
- throw new RiotNotFoundException("Not found: "+filenameOrURI) ;
- return in ;
+ throw new RiotNotFoundException("Not found: "+filenameOrURI);
+ return in;
}
// ----
- // The ways to parse from 3 kinds of source: URI, InputStream and Reader.
+ // The ways to parse from 4 kinds of source: URI, InputStream, Reader and TypedInputStream
- private static void parseFromInputStream(StreamRDF destination, InputStream in, String baseUri, Lang lang, Context context) {
+ private static void parseFromInputStream(StreamRDF destination, InputStream in, String baseUri, Lang lang) {
RDFParser.create()
.source(in)
.base(baseUri)
.lang(lang)
- .context(context)
+ //.context(context)
.parse(destination);
}
@SuppressWarnings("deprecation")
- private static void parseFromReader(StreamRDF destination, Reader in, String baseUri, Lang lang, Context context) {
+ private static void parseFromReader(StreamRDF destination, Reader in, String baseUri, Lang lang) {
RDFParser.create()
.source(in)
.base(baseUri)
.lang(lang)
- .context(context)
+ //.context(context)
.parse(destination);
}
- private static void parseFromURI(StreamRDF destination, String uri, String baseUri, Lang lang, Context context) {
+ private static void parseFromURI(StreamRDF destination, String uri, String baseUri, Lang lang) {
RDFParser.create()
.source(uri)
.base(baseUri)
.lang(lang)
- .context(context)
+ //.context(context)
.parse(destination);
}
// ---- Support for RDFDataMgr.parse from a TypedInputStream only.
- @Deprecated
- private static void processFromTypedInputStream(StreamRDF sink, TypedInputStream in, String baseUri, Lang hintLang, Context context) {
+ private static void processFromTypedInputStream(StreamRDF sink, TypedInputStream in, String baseUri, Lang hintLang) {
// If the input stream comes with a content type, use that in preference to the hint (compatibility).
// Except for text/plain.
// Do here, which duplicates RDFParser, because "TypedInputStream" gets lost at RDFParser
@@ -930,7 +749,7 @@ public class RDFDataMgr
// Special case of text/plain.
ContentType ct = WebContent.determineCT(in.getContentType(), hintLang, null);
Lang lang2 = RDFLanguages.contentTypeToLang(ct);
- hintLang = lang2 ;
+ hintLang = lang2;
}
RDFParser.create()
.source(in)
@@ -938,7 +757,7 @@ public class RDFDataMgr
.lang(hintLang)
// We made the decision above.
.forceLang(hintLang)
- .context(context)
+ //.context(context)
.parse(sink);
}
@@ -946,12 +765,12 @@ public class RDFDataMgr
/** Default base - no known URI. e.g. input streams */
private static String defaultBase() {
- return null ;
+ return null;
}
/** Default base - URI present */
private static String defaultBase(String uri) {
- return uri ;
+ return uri;
}
/** Default lang - usually left as unknown so that extended content negotiation happens */
@@ -963,19 +782,19 @@ public class RDFDataMgr
private static RDFFormat langToFormatOrException(Lang lang) {
RDFFormat serialization = RDFWriterRegistry.defaultSerialization(lang);
if ( serialization == null )
- throw new RiotException("No output format for "+lang) ;
- return serialization ;
+ throw new RiotException("No output format for "+lang);
+ return serialization;
}
/** Determine the Lang, given the URI target, any content type header string and a hint */
public static Lang determineLang(String target, String ctStr, Lang hintLang) {
- ContentType ct = WebContent.determineCT(ctStr, hintLang, target) ;
+ ContentType ct = WebContent.determineCT(ctStr, hintLang, target);
if ( ct == null )
- return hintLang ;
- Lang lang = RDFLanguages.contentTypeToLang(ct) ;
+ return hintLang;
+ Lang lang = RDFLanguages.contentTypeToLang(ct);
if (lang == null )
- return hintLang ;
- return lang ;
+ return hintLang;
+ return lang;
}
// -------- WRITERS
@@ -1011,7 +830,7 @@ public class RDFDataMgr
* @param out Writer
* @param model Model to write
* @param lang Serialization format
- * @deprecated Use of writers is deprecated - use an OutputStream
+ * @deprecated Use of writers is deprecated - use an {@link java.io.OutputStream}
*/
@Deprecated
public static void write(Writer out, Model model, Lang lang) {
@@ -1031,7 +850,7 @@ public class RDFDataMgr
* @param out OutputStream
* @param model Model to write
* @param serialization Serialization format
- * @deprecated Use of writers is deprecated - use an OutputStream
+ * @deprecated Use of writers is deprecated - use an {@link java.io.OutputStream}
*/
@Deprecated
public static void write(Writer out, Model model, RDFFormat serialization) {
@@ -1071,7 +890,7 @@ public class RDFDataMgr
* @param out Writer
* @param graph Graph to write
* @param lang Serialization format
- * @deprecated Use of writers is deprecated - use an OutputStream
+ * @deprecated Use of writers is deprecated - use an {@link java.io.OutputStream}
*/
@Deprecated
public static void write(Writer out, Graph graph, Lang lang) {
@@ -1092,7 +911,7 @@ public class RDFDataMgr
* @param out OutputStream
* @param graph Graph to write
* @param serialization Serialization format
- * @deprecated Use of writers is deprecated - use an OutputStream
+ * @deprecated Use of writers is deprecated - use an {@link java.io.OutputStream}
*/
@Deprecated
public static void write(Writer out, Graph graph, RDFFormat serialization) {
@@ -1140,7 +959,7 @@ public class RDFDataMgr
* @param out Writer
* @param dataset Dataset to write
* @param serialization Serialization format
- * @deprecated Use of writers is deprecated - use an OutputStream
+ * @deprecated Use of writers is deprecated - use an {@link java.io.OutputStream}
*/
@Deprecated
public static void write(Writer out, Dataset dataset, RDFFormat serialization) {
@@ -1189,7 +1008,7 @@ public class RDFDataMgr
* @param out Writer
* @param dataset DatasetGraph to write
* @param serialization Serialization format
- * @deprecated Use of writers is deprecated - use an OutputStream
+ * @deprecated Use of writers is deprecated - use an {@link java.io.OutputStream}
*/
@Deprecated
public static void write(Writer out, DatasetGraph dataset, RDFFormat serialization) {
@@ -1212,55 +1031,6 @@ public class RDFDataMgr
NQuadsWriter.write(out, iterator);
}
- /** Create a writer for an RDF language
- * @param lang Language for the serialization.
- * @return WriterGraphRIOT
- * @deprecated Use {@code RDFWriter.create().lang(Lang).source(graph).build()}
- */
- @Deprecated
- public static WriterGraphRIOT createGraphWriter(Lang lang) {
- RDFFormat serialization = langToFormatOrException(lang);
- return createGraphWriter$(serialization);
- }
-
- /** Create a writer for an RDF language
- * @param serialization Serialization format
- * @return WriterGraphRIOT
- * @deprecated Use {@code RDFWriter.create().format(serialization).source(graph).build()}
- */
- @Deprecated
- public static WriterGraphRIOT createGraphWriter(RDFFormat serialization) {
- return createGraphWriter$(serialization);
- }
-
- /** Create a writer for an RDF language
- * @param lang Language for the serialization.
- * @return WriterGraphRIOT
- * @deprecated Use {@code RDFWriter.create().lang(lang).source(datasetGraph).build()}
- */
- @Deprecated
- public static WriterDatasetRIOT createDatasetWriter(Lang lang) {
- RDFFormat serialization = langToFormatOrException(lang);
- return createDatasetWriter$(serialization);
- }
-
- /** Create a writer for an RDF language
- * @param serialization Serialization format
- * @return WriterGraphRIOT
- * @deprecated Use {@code RDFWriter.create().format(serialization).source(datasetGraph).build()}
- */
- @Deprecated
- public static WriterDatasetRIOT createDatasetWriter(RDFFormat serialization) {
- return createDatasetWriter$(serialization);
- }
-
- private static WriterGraphRIOT createGraphWriter$(RDFFormat serialization) {
- WriterGraphRIOTFactory wf = RDFWriterRegistry.getWriterGraphFactory(serialization);
- if ( wf == null )
- throw new RiotException("No graph writer for " + serialization);
- return wf.create(serialization);
- }
-
private static WriterDatasetRIOT createDatasetWriter$(RDFFormat serialization) {
WriterDatasetRIOTFactory wf = RDFWriterRegistry.getWriterDatasetFactory(serialization);
if ( wf == null )
@@ -1269,21 +1039,21 @@ public class RDFDataMgr
}
private static void write$(OutputStream out, Graph graph, RDFFormat serialization) {
- RDFWriter.create().format(serialization).source(graph).output(out);
+ RDFWriter.create(graph).format(serialization).output(out);
}
@SuppressWarnings("deprecation")
private static void write$(Writer out, Graph graph, RDFFormat serialization) {
- RDFWriter.create().format(serialization).source(graph).build().output(out);
+ RDFWriter.create(graph).format(serialization).build().output(out);
}
private static void write$(OutputStream out, DatasetGraph dataset, RDFFormat serialization) {
- RDFWriter.create().format(serialization).source(dataset).output(out);
+ RDFWriter.create(dataset).format(serialization).output(out);
}
@SuppressWarnings("deprecation")
private static void write$(Writer out, DatasetGraph dataset, RDFFormat serialization) {
- RDFWriter.create().format(serialization).source(dataset).build().output(out);
+ RDFWriter.create(dataset).format(serialization).build().output(out);
}
/**
@@ -1300,7 +1070,7 @@ public class RDFDataMgr
// Otherwise, we have to spin up a thread to deal with it
PipedRDFIterator<Triple> it = new PipedRDFIterator<>();
PipedTriplesStream out = new PipedTriplesStream(it);
- Thread t = new Thread(()->parseFromInputStream(out, input, baseIRI, lang, null)) ;
+ Thread t = new Thread(()->parseFromInputStream(out, input, baseIRI, lang));
t.start();
return it;
}
@@ -1323,7 +1093,7 @@ public class RDFDataMgr
final PipedRDFIterator<Quad> it = new PipedRDFIterator<>();
final PipedQuadsStream out = new PipedQuadsStream(it);
- Thread t = new Thread(()->parseFromInputStream(out, input, baseIRI, lang, null)) ;
+ Thread t = new Thread(()->parseFromInputStream(out, input, baseIRI, lang));
t.start();
return it;
}
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/RDFParser.java b/jena-arq/src/main/java/org/apache/jena/riot/RDFParser.java
index 4d7e87b..cdb984f 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/RDFParser.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/RDFParser.java
@@ -122,7 +122,7 @@ public class RDFParser {
* This is a shortcut for {@code RDFParser.create().source(path)}.
*
* @param path
- * @return this
+ * @return RDFParserBuilder
*/
public static RDFParserBuilder source(Path path) {
return RDFParserBuilder.create().source(path);
@@ -135,7 +135,7 @@ public class RDFParser {
* This is a shortcut for {@code RDFParser.create().source(uriOrFile)}.
*
* @param uriOrFile
- * @return this
+ * @return RDFParserBuilder
*/
public static RDFParserBuilder source(String uriOrFile) {
@@ -148,7 +148,7 @@ public class RDFParser {
* <p>
* Shortcut for {@code RDFParser.create.fromString(string)}.
* @param string
- * @return this
+ * @return RDFParserBuilder
*/
public static RDFParserBuilder fromString(String string) {
return RDFParserBuilder.create().fromString(string);
@@ -162,7 +162,7 @@ public class RDFParser {
* <p>
* This is a shortcut for {@code RDFParser.create().source(input)}.
* @param input
- * @return this
+ * @return RDFParserBuilder
*/
public static RDFParserBuilder source(InputStream input) {
return RDFParserBuilder.create().source(input);
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/RDFWriter.java b/jena-arq/src/main/java/org/apache/jena/riot/RDFWriter.java
index 3a1ed89..f2d81cf 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/RDFWriter.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/RDFWriter.java
@@ -27,6 +27,8 @@ import java.util.Objects;
import org.apache.jena.atlas.io.IO;
import org.apache.jena.atlas.web.ContentType;
import org.apache.jena.graph.Graph;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
import org.apache.jena.riot.system.PrefixMap;
import org.apache.jena.riot.system.PrefixMapFactory;
import org.apache.jena.sparql.core.DatasetGraph;
@@ -72,6 +74,38 @@ public class RDFWriter {
*/
public static RDFWriterBuilder create() { return new RDFWriterBuilder(); }
+ /** Create an {@link RDFWriterBuilder} and set the source of writing to the graph argument.
+ * @param graph A {@link Graph}.
+ * @return RDFWriterBuilder
+ */
+ public static RDFWriterBuilder create(Graph graph) {
+ return create().source(graph);
+ }
+
+ /** Create an {@link RDFWriterBuilder} and set the source of writing to the graph argument.
+ * @param model A {@link Model}.
+ * @return RDFWriterBuilder
+ */
+ public static RDFWriterBuilder create(Model model) {
+ return create().source(model);
+ }
+
+ /** Create an {@link RDFWriterBuilder} and set the source of writing to the graph argument.
+ * @param dataset A {@link DatasetGraph}.
+ * @return RDFWriterBuilder
+ */
+ public static RDFWriterBuilder create(DatasetGraph dataset) {
+ return create().source(dataset);
+ }
+
+ /** Create an {@link RDFWriterBuilder} and set the source of writing to the graph argument.
+ * @param dataset A {@link Dataset}.
+ * @return RDFWriterBuilder
+ */
+ public static RDFWriterBuilder create(Dataset dataset) {
+ return create().source(dataset);
+ }
+
/*package*/ RDFWriter(DatasetGraph dataset, Graph graph, RDFFormat format, Lang lang, String baseURI, Context context) {
this.dataset = dataset;
this.graph = graph;
@@ -117,7 +151,7 @@ public class RDFWriter {
* <p>
* The {@code Lang} or {@code RDFFormat} must have been set.
* @param javaWriter
- * @deprecated Using Java Writers risk corrupting the character set. Only UTF-8 is safe.
+ * @deprecated Using Java Writers risks corruption because of mismatch of character set. Only UTF-8 is safe.
*/
@Deprecated
public void output(Writer javaWriter) {
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/RDFWriterBuilder.java b/jena-arq/src/main/java/org/apache/jena/riot/RDFWriterBuilder.java
index 2ad2c2a..6bf8ba2 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/RDFWriterBuilder.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/RDFWriterBuilder.java
@@ -34,10 +34,10 @@ public class RDFWriterBuilder {
private Lang lang = null;
private RDFFormat format = null;
private String baseURI = null;
-
+
/** A new {@code RDFWriterBuilder}.
* <p>
- * See also {@link RDFWriter#create()}
+ * See also {@link RDFWriter#create()}
*/
RDFWriterBuilder () {}
@@ -58,7 +58,7 @@ public class RDFWriterBuilder {
* Any previous source setting is cleared.
* <p>
* Equivalent to {@code source(model.getGraph()(s)}
- *
+ *
* @param model A {@link Model}.
* @return this
*/
@@ -83,17 +83,17 @@ public class RDFWriterBuilder {
* Any previous source setting is cleared.
* <p>
* Equivalent to {@code source(dataset.asDatasetGraph())}
- *
+ *
* @param dataset A {@link DatasetGraph}.
* @return this
*/
public RDFWriterBuilder source(Dataset dataset) {
return source(dataset.asDatasetGraph());
}
-
+
// // Not implemented
// public RDFWriterBuilder labels(NodeToLabel nodeToLabel) { return this; }
-//
+//
// // Not implemented
// public RDFWriterBuilder formatter(NodeFormatter nodeFormatter) { return this; }
@@ -101,14 +101,14 @@ public class RDFWriterBuilder {
if ( context == null )
context = new Context();
}
-
+
/**
* Set the context for the writer when built.
- *
+ *
* If a context is already partly set
- * for this builder, merge the new settings
+ * for this builder, merge the new settings
* into the outstanding context.
- *
+ *
* @param context
* @return this
* @see Context
@@ -118,10 +118,10 @@ public class RDFWriterBuilder {
return this;
ensureContext();
this.context.putAll(context);
- return this;
+ return this;
}
-
- /**
+
+ /**
* Added a setting to the context for the writer when built.
* A value of "null" removes a previous setting.
* @param symbol
@@ -134,16 +134,16 @@ public class RDFWriterBuilder {
context.put(symbol, value);
return this;
}
-
+
/**
- * Set the output language to a {@link Lang}; this will set the format.
+ * Set the output language to a {@link Lang}; this will set the format.
* <p>
* If {@code Lang} and {@code RDFFormat} are not set, an attempt is made to guess it from file name or URI on output.
* <p>
* If output is to an {@code OutputStream}, {@code Lang} or {@code RDFFormat} must be set.
* <p>
* Any previous setting of {@code Lang} or {@code RDFFormat} is cleared.
- *
+ *
* @param lang
* @return this
*/
@@ -154,7 +154,7 @@ public class RDFWriterBuilder {
}
/**
- * Set the output format to a {@link RDFFormat}.
+ * Set the output format to a {@link RDFFormat}.
* <p>
* If {@code Lang} and {@code RDFFormat} are not set, an attempt is made to guess it from file name or URI on output.
* <p>
@@ -169,12 +169,12 @@ public class RDFWriterBuilder {
this.format = format;
return this;
}
-
+
public RDFWriterBuilder base(String baseURI) {
this.baseURI = baseURI;
return this;
}
-
+
@Override
public RDFWriterBuilder clone() {
RDFWriterBuilder clone = new RDFWriterBuilder();
@@ -186,32 +186,32 @@ public class RDFWriterBuilder {
clone.baseURI = this.baseURI;
return clone;
}
-
- public RDFWriter build() {
+
+ public RDFWriter build() {
if ( context == null )
context = RIOT.getContext().copy();
if ( dataset == null && graph == null )
throw new RiotException("No source to be written");
return new RDFWriter(dataset, graph, format, lang, baseURI, context);
}
-
-
+
+
/** Short form for {@code build().output(outputStream)}.
- *
+ *
* @param outputStream
*/
public void output(OutputStream outputStream) {
build().output(outputStream);
}
-
+
/** Short form for {@code build().output(filename)}.
- *
+ *
* @param filename
*/
public void output(String filename) {
build().output(filename);
}
-
+
/** Short form for {@code build().asString()}.
*/
public String asString() {
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java b/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
index 5c2dd01..bc93888 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/SysRIOT.java
@@ -106,7 +106,7 @@ public class SysRIOT
/**
* Return a URI suitable for a baseURI, based on some input (which may be null).
*
- * @deprecated Use {@code IRIs.getBaseStr();}
+ * @deprecated Use {@link IRIs#toBase(String)}
*/
@Deprecated
public static String chooseBaseIRI(String baseURI) {
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/TestRDFWriter.java b/jena-arq/src/test/java/org/apache/jena/riot/TestRDFWriter.java
index 0e6726b..6189ce5 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/TestRDFWriter.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/TestRDFWriter.java
@@ -33,7 +33,7 @@ public class TestRDFWriter {
private static Graph graph = SSE.parseGraph("(graph (:s :p :o))");
@Test public void rdfwriter_1() {
- RDFWriter.create().source(graph).build();
+ RDFWriter.create(graph).build();
}
@Test(expected=RiotException.class)
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java b/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
index e8d84a3..83ef11f 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/stream/TestStreamManager.java
@@ -42,43 +42,43 @@ public class TestStreamManager
{
private static final String directory = "testing/RIOT/StreamManager" ;
private static final String absDirectory = new File(directory).getAbsolutePath() ;
-
+
private static StreamManager streamMgrDir ;
private static StreamManager streamMgrHere ;
private static StreamManager streamMgrNull ;
private static StreamManager streamMgrStd ;
-
+
@BeforeClass static public void beforeClass()
- {
+ {
streamMgrStd = StreamManager.get() ;
streamMgrDir = new StreamManager() ;
// Not current directory.
streamMgrDir.addLocator(new LocatorFile(directory)) ;
streamMgrDir.addLocator(new LocatorHTTP()) ;
-
+
streamMgrHere = new StreamManager() ;
// Not current directory.
streamMgrHere.addLocator(new LocatorFile()) ;
streamMgrHere.addLocator(new LocatorHTTP()) ;
-
+
streamMgrNull = new StreamManager() ;
}
-
+
@AfterClass static public void afterClass()
- {
+ {
StreamManager.setGlobal(streamMgrStd) ;
}
-
+
private static Context context(StreamManager streamMgr)
{
Context context = new Context() ;
context.put(SysRIOT.sysStreamManager, streamMgr) ;
return context ;
}
-
+
@Test public void fm_open_01() { open(streamMgrNull, directory+"/D.ttl", context(streamMgrHere)) ; }
@Test public void fm_open_02() { open(streamMgrHere, directory+"/D.ttl", null) ; }
-
+
@Test public void fm_open_03() { open(streamMgrNull, "D.ttl", context(streamMgrDir)) ; }
@Test public void fm_open_04() { open(streamMgrDir, "D.ttl", null) ; }
@@ -87,17 +87,17 @@ public class TestStreamManager
@Test public void fm_open_07() { open(streamMgrHere, "file:D.ttl", context(streamMgrDir)) ; }
@Test public void fm_open_08() { open(streamMgrDir, "file:D.ttl", null) ; }
-
+
@Test public void fm_open_09() { open(streamMgrHere, absDirectory+"/D.ttl", null) ; }
@Test public void fm_open_10() { open(streamMgrDir, absDirectory+"/D.ttl", null) ; }
@Test public void fm_open_11() { open(streamMgrDir, "file://"+absDirectory+"/D.ttl", null) ; }
@Test public void fm_open_12() { open(streamMgrHere, "file://"+absDirectory+"/D.ttl", null) ; }
-
+
@Test (expected=RiotNotFoundException.class)
public void fm_open_20() { open(null, "nosuchfile", context(streamMgrDir)) ; }
@Test (expected=RiotNotFoundException.class)
public void fm_open_21() { open(streamMgrHere, "nosuchfile", null) ; }
-
+
@Test public void fm_read_01() { read("D.nt") ; }
@Test public void fm_read_02() { read("D.ttl") ; }
@Test public void fm_read_03() { read("D.rdf") ; }
@@ -109,24 +109,22 @@ public class TestStreamManager
@Test public void fm_read_13() { read("file:D.rdf") ; }
@Test public void fm_read_14() { read("file:D.rj") ; }
@Test public void fm_read_15() { read("file:D.jsonld") ; }
-
+
// TriG
// NQuads
-
+
private static void open(StreamManager streamMgr, String dataName, Context context)
{
StreamManager.setGlobal(streamMgr) ;
try {
- TypedInputStream in = ( context != null )
- ? RDFDataMgr.open(dataName, context)
- : RDFDataMgr.open(dataName) ;
+ TypedInputStream in = RDFDataMgr.open(dataName, StreamManager.get(context));
assertNotNull(in) ;
IO.close(in) ;
} finally {
StreamManager.setGlobal(streamMgrStd) ;
}
}
-
+
private static void read(String dataName)
{
try {
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java b/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java
index 35b3854..74e73d4 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java
@@ -525,7 +525,7 @@ public class TestJsonLDWriter {
private String toString(Model m, RDFFormat f, Context jenaContext) {
try(ByteArrayOutputStream out = new ByteArrayOutputStream()) {
- RDFWriter.create().source(m).format(f).context(jenaContext).output(out);
+ RDFWriter.create(m).format(f).context(jenaContext).output(out);
out.flush();
return out.toString("UTF-8");
} catch (IOException e) { throw new RuntimeException(e); }
diff --git a/jena-cmds/src/main/java/riotcmd/infer.java b/jena-cmds/src/main/java/riotcmd/infer.java
index 0bf6d65..e16dc6e 100644
--- a/jena-cmds/src/main/java/riotcmd/infer.java
+++ b/jena-cmds/src/main/java/riotcmd/infer.java
@@ -28,6 +28,7 @@ import org.apache.jena.rdf.model.Model ;
import org.apache.jena.riot.Lang ;
import org.apache.jena.riot.RDFDataMgr ;
import org.apache.jena.riot.RDFLanguages ;
+import org.apache.jena.riot.RDFParser;
import org.apache.jena.riot.process.inf.InfFactory ;
import org.apache.jena.riot.system.StreamRDF ;
import org.apache.jena.riot.system.StreamRDFLib ;
@@ -58,7 +59,7 @@ import org.apache.jena.riot.system.StreamRDFLib ;
* equivalentClass
* equivalentProperty
* sameAs
- * differentFrom (and allDifferent)
+ * differentFrom (and allDifferent)
# Property Characteristics:
@@ -69,7 +70,7 @@ import org.apache.jena.riot.system.StreamRDFLib ;
* InverseFunctionalProperty
* ObjectProperty
* DatatypeProperty
- * disjointWith
+ * disjointWith
AllegroGraph RDFS++
* rdf:type
@@ -84,11 +85,11 @@ public class infer extends CmdGeneral
{
static final ArgDecl argRDFS = new ArgDecl(ArgDecl.HasValue, "rdfs") ;
private Model vocab ;
-
+
public static void main(String... argv)
{
new infer(argv).mainRun() ;
- }
+ }
protected infer(String[] argv)
{
@@ -101,7 +102,7 @@ public class infer extends CmdGeneral
// Sink<Triple> sink = new SinkTripleOutput(System.out) ;
// sink = new InferenceExpanderRDFS(sink, vocab) ;
// RiotReader.parseTriples(filename, sink) ;
-// IO.flush(System.out);
+// IO.flush(System.out);
// }
@Override
@@ -124,14 +125,14 @@ public class infer extends CmdGeneral
{
StreamRDF sink = StreamRDFLib.writer(System.out) ;
sink = InfFactory.inf(sink, vocab) ;
-
+
List<String> files = getPositionalOrStdin() ;
if ( files.isEmpty() )
files.add("-") ;
-
+
for ( String fn : files )
processFile(fn, sink) ;
- IO.flush(System.out);
+ IO.flush(System.out);
}
private void processFile(String filename, StreamRDF sink)
@@ -139,9 +140,9 @@ public class infer extends CmdGeneral
Lang lang = filename.equals("-") ? RDFLanguages.NQUADS : RDFLanguages.filenameToLang(filename, RDFLanguages.NQUADS) ;
if ( filename.equals("-") )
- RDFDataMgr.parse(sink, System.in, null, RDFLanguages.NQUADS) ;
+ RDFParser.source(System.in).lang(RDFLanguages.NQUADS).parse(sink);
else
- RDFDataMgr.parse(sink, filename) ;
+ RDFParser.source(filename).parse(sink);
}
@Override
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/base/LoaderOps.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/base/LoaderOps.java
index 4401950..f9b7c72 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/base/LoaderOps.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/loader/base/LoaderOps.java
@@ -32,7 +32,7 @@ import org.apache.jena.dboe.trans.bplustree.BPlusTree;
import org.apache.jena.dboe.trans.data.TransBinaryDataFile;
import org.apache.jena.graph.Node;
import org.apache.jena.graph.Triple;
-import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.RDFParser;
import org.apache.jena.riot.system.StreamRDF;
import org.apache.jena.riot.system.StreamRDFWrapper;
import org.apache.jena.sparql.core.Quad;
@@ -102,15 +102,10 @@ public class LoaderOps {
public static void inputFile(StreamRDF sink, String source, ProgressMonitor monitor) {
if ( monitor != null ) {
sink = new ProgressStreamRDF(sink, monitor);
- //monitor.start();
}
sink.start();
- RDFDataMgr.parse(sink, source);
+ RDFParser.source(source).parse(sink);
sink.finish();
- if ( monitor != null ) {
- //monitor.finish();
- //monitor.finishMessage("Data");
- }
}
/** Copy a stream to several indexes (sequential version) */
diff --git a/jena-db/jena-tdb2/src/test/java/org/apache/jena/tdb2/loader/AbstractTestLoader.java b/jena-db/jena-tdb2/src/test/java/org/apache/jena/tdb2/loader/AbstractTestLoader.java
index 3b8f544..63a9467 100644
--- a/jena-db/jena-tdb2/src/test/java/org/apache/jena/tdb2/loader/AbstractTestLoader.java
+++ b/jena-db/jena-tdb2/src/test/java/org/apache/jena/tdb2/loader/AbstractTestLoader.java
@@ -32,6 +32,7 @@ import org.apache.jena.graph.NodeFactory;
import org.apache.jena.graph.Triple;
import org.apache.jena.query.ARQ;
import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.RDFParser;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.sparql.core.Quad;
import org.apache.jena.sparql.util.IsoMatcher;
@@ -126,7 +127,7 @@ public abstract class AbstractTestLoader {
DatasetGraph dsg = fresh();
DataLoader loader = maker.apply(dsg, null);
loader.startBulk();
- RDFDataMgr.parse(loader.stream(), DIR + "data-1.nq");
+ RDFParser.source(DIR + "data-1.nq").parse(loader.stream());
loader.finishBulk();
Txn.executeRead(dsg, ()->{
assertTrue(dsg.getDefaultGraph().isEmpty());
diff --git a/jena-shacl/src/test/java/org/apache/jena/shacl/compact/TestReadShaclCompact.java b/jena-shacl/src/test/java/org/apache/jena/shacl/compact/TestReadShaclCompact.java
index 9616921..ca518c5 100644
--- a/jena-shacl/src/test/java/org/apache/jena/shacl/compact/TestReadShaclCompact.java
+++ b/jena-shacl/src/test/java/org/apache/jena/shacl/compact/TestReadShaclCompact.java
@@ -44,8 +44,8 @@ public class TestReadShaclCompact extends AbstractTestShaclCompact {
System.err.println("graph(jena) = "+graphGot.size());
System.err.println("graph(ref) = "+graphOther.size());
if ( false ) {
- RDFWriter.create().source(graphGot).format(RDFFormat.TURTLE_PRETTY).output(System.err);
- RDFWriter.create().source(graphOther).format(RDFFormat.TURTLE_PRETTY).output(System.err);
+ RDFWriter.create(graphGot).format(RDFFormat.TURTLE_PRETTY).output(System.err);
+ RDFWriter.create(graphOther).format(RDFFormat.TURTLE_PRETTY).output(System.err);
}
}
assertTrue("test: "+fileBaseName, isomorphic);
diff --git a/jena-shacl/src/test/java/org/apache/jena/shacl/compact/TestWriteShaclCompact.java b/jena-shacl/src/test/java/org/apache/jena/shacl/compact/TestWriteShaclCompact.java
index 48658e7..79ab12a 100644
--- a/jena-shacl/src/test/java/org/apache/jena/shacl/compact/TestWriteShaclCompact.java
+++ b/jena-shacl/src/test/java/org/apache/jena/shacl/compact/TestWriteShaclCompact.java
@@ -87,8 +87,8 @@ public class TestWriteShaclCompact extends AbstractTestShaclCompact {
System.err.println("graph(jena) = "+graphGot.size());
System.err.println("graph(ref) = "+graphOther.size());
if ( true ) {
- RDFWriter.create().source(graphGot).format(RDFFormat.TURTLE_PRETTY).context(cxt).output(System.err);
- RDFWriter.create().source(graphOther).format(RDFFormat.TURTLE_PRETTY).context(cxt).output(System.err);
+ RDFWriter.create(graphGot).format(RDFFormat.TURTLE_PRETTY).context(cxt).output(System.err);
+ RDFWriter.create(graphOther).format(RDFFormat.TURTLE_PRETTY).context(cxt).output(System.err);
}
}
assertTrue("test: "+fileBaseName, isomorphic);
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader/BulkLoader.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader/BulkLoader.java
index e5f64fa..5e0caf2 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader/BulkLoader.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader/BulkLoader.java
@@ -26,8 +26,8 @@ import org.apache.jena.atlas.lib.DateTimeUtils ;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.Triple ;
import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFDataMgr ;
import org.apache.jena.riot.RDFLanguages ;
+import org.apache.jena.riot.RDFParser;
import org.apache.jena.riot.system.PrefixMap;
import org.apache.jena.sparql.core.Quad ;
import org.apache.jena.tdb.TDB ;
@@ -121,7 +121,7 @@ public class BulkLoader {
for ( String url : urls ) {
loadLogger.info("Load: " + url + " -- " + DateTimeUtils.nowAsString()) ;
Lang lang = RDFLanguages.filenameToLang(url, Lang.NTRIPLES) ;
- RDFDataMgr.parse(dest, url, lang) ;
+ RDFParser.source(url).lang(lang).parse(dest);
}
dest.finishBulk() ;
}
@@ -130,7 +130,7 @@ public class BulkLoader {
private static void loadTriples$(BulkStreamRDF dest, InputStream input) {
loadLogger.info("Load: from input stream -- " + DateTimeUtils.nowAsString()) ;
dest.startBulk() ;
- RDFDataMgr.parse(dest, input, Lang.NTRIPLES) ;
+ RDFParser.source(input).lang(Lang.NTRIPLES).parse(dest);
dest.finishBulk() ;
}
@@ -140,7 +140,7 @@ public class BulkLoader {
for ( String url : urls ) {
loadLogger.info("Load: " + url + " -- " + DateTimeUtils.nowAsString()) ;
Lang lang = RDFLanguages.filenameToLang(url, Lang.NQUADS) ;
- RDFDataMgr.parse(dest, url, lang) ;
+ RDFParser.source(url).lang(lang).parse(dest);
}
dest.finishBulk() ;
}
@@ -151,7 +151,7 @@ public class BulkLoader {
lang = Lang.NQUADS;
loadLogger.info("Load: from input stream -- " + DateTimeUtils.nowAsString()) ;
dest.startBulk() ;
- RDFDataMgr.parse(dest, input, lang) ;
+ RDFParser.source(input).lang(lang).parse(dest);
dest.finishBulk() ;
}
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java
index 1228bf8..eaac6e3 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/bulkloader2/ProcNodeTableBuilder.java
@@ -29,7 +29,7 @@ import org.apache.jena.atlas.lib.DateTimeUtils ;
import org.apache.jena.atlas.lib.ProgressMonitor ;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.Triple ;
-import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.riot.RDFParser;
import org.apache.jena.sparql.core.Quad ;
import org.apache.jena.tdb.TDB ;
import org.apache.jena.tdb.base.file.Location ;
@@ -75,7 +75,7 @@ public class ProcNodeTableBuilder {
for( String filename : datafiles) {
if ( datafiles.size() > 0 )
cmdLog.info("Load: "+filename+" -- "+DateTimeUtils.nowAsString()) ;
- RDFDataMgr.parse(sink, filename) ;
+ RDFParser.source(filename).parse(sink);
}
sink.finishBulk() ;
IO.close(outputTriples) ;