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 2015/10/21 18:46:22 UTC
[03/10] jena git commit: JENA-1051: Use functions and casts to reduce
use of bare nulls.
JENA-1051: Use functions and casts to reduce use of bare nulls.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/a0e5f231
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/a0e5f231
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/a0e5f231
Branch: refs/heads/master
Commit: a0e5f2319a4998ddba82aa089319becbaaa11a18
Parents: ebc14ed
Author: Andy Seaborne <an...@apache.org>
Authored: Wed Oct 21 13:07:44 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Wed Oct 21 17:44:11 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/jena/riot/RDFDataMgr.java | 87 ++++++++++++--------
1 file changed, 52 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/a0e5f231/jena-arq/src/main/java/org/apache/jena/riot/RDFDataMgr.java
----------------------------------------------------------------------
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 844169d..38444a7 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
@@ -102,7 +102,7 @@ public class RDFDataMgr
* @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, null, null, null) ; }
+ 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.
@@ -120,7 +120,7 @@ public class RDFDataMgr
* @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, null) ; }
+ 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)
@@ -142,7 +142,7 @@ public class RDFDataMgr
* @param hintLang Hint for the syntax
* @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, null) ; }
+ public static void read(Graph graph, String uri, String base, Lang hintLang) { read(graph, uri, base, hintLang, (Context)null) ; }
/** Read triples into a Model from the given location, with some parameters for the reader
* @see #read(Model,String,String,Lang,Context)
@@ -160,7 +160,7 @@ public class RDFDataMgr
* @param context Content object to control reading process.
* @throws RiotNotFoundException if the location is not found - the graph is unchanged.
*/
- public static void read(Graph graph, String uri, Context context) { read(graph, uri, null, context) ; }
+ public static void read(Graph graph, String uri, Context context) { read(graph, uri, defaultLang(uri), context) ; }
/** 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)
@@ -171,7 +171,7 @@ public class RDFDataMgr
* @throws RiotNotFoundException if the location is not found - the model is unchanged.
*/
public static void read(Model model, String uri, Lang hintLang, Context context)
- { read(model, uri, uri, hintLang, 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)
@@ -182,7 +182,7 @@ public class RDFDataMgr
* @throws RiotNotFoundException if the location is not found - the graph is unchanged.
*/
public static void read(Graph graph, String uri, Lang hintLang, Context context)
- { read(graph, uri, uri, hintLang, context) ; }
+ { read(graph, 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.
@@ -230,7 +230,7 @@ public class RDFDataMgr
* @param in InputStream
* @param lang Language syntax
*/
- public static void read(Graph graph, InputStream in, Lang lang) { read(graph, in, null, 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.
@@ -256,7 +256,7 @@ public class RDFDataMgr
public static void read(Graph graph, InputStream in, String base, Lang lang) {
Objects.requireNonNull(in, "InputStream is null") ;
StreamRDF dest = StreamRDFLib.graph(graph) ;
- process(dest, new TypedInputStream(in), base, lang, null) ;
+ process(dest, new TypedInputStream(in), base, lang, (Context)null) ;
}
/** Read triples into a model with chars from an Reader.
@@ -285,7 +285,7 @@ public class RDFDataMgr
@Deprecated
public static void read(Graph graph, Reader in, String base, Lang lang) {
StreamRDF dest = StreamRDFLib.graph(graph) ;
- process(dest, in, base, lang, null) ;
+ process(dest, in, base, lang, (Context)null) ;
}
/** Read triples into a model with chars from a StringReader.
@@ -297,7 +297,7 @@ public class RDFDataMgr
public static void read(Model model, StringReader in, String base, Lang lang) {
Graph g = model.getGraph() ;
StreamRDF dest = StreamRDFLib.graph(g) ;
- process(dest, in, base, lang, null) ;
+ process(dest, in, base, lang, (Context)null) ;
}
/** Read triples into a model with chars from a StringReader.
@@ -308,7 +308,7 @@ public class RDFDataMgr
*/
public static void read(Graph graph, StringReader in, String base, Lang lang) {
StreamRDF dest = StreamRDFLib.graph(graph) ;
- process(dest, in, base, lang, null) ;
+ process(dest, in, base, lang, (Context)null) ;
}
private static Model createModel() { return ModelFactory.createDefaultModel() ; }
@@ -417,7 +417,7 @@ public class RDFDataMgr
* @param uri URI to read from (includes file: and a plain file name).
*/
public static void read(DatasetGraph dataset, String uri) {
- read(dataset, uri, null) ;
+ read(dataset, uri, defaultLang(uri)) ;
}
/** Read quads or triples into a Dataset from the given location, with hint of language.
@@ -437,7 +437,7 @@ public class RDFDataMgr
* @param hintLang Language syntax
*/
public static void read(DatasetGraph dataset, String uri, Lang hintLang) {
- read(dataset, uri, hintLang, null) ;
+ read(dataset, uri, hintLang, (Context)null) ;
}
/** Read quads or triples into a Dataset from the given location, with hint of language.
@@ -459,7 +459,7 @@ public class RDFDataMgr
* @param hintLang Language syntax
*/
public static void read(DatasetGraph dataset, String uri, String base, Lang hintLang) {
- read(dataset, uri, base, hintLang, null) ;
+ read(dataset, uri, base, hintLang, (Context)null) ;
}
@@ -480,7 +480,7 @@ public class RDFDataMgr
* @param hintLang Language syntax
*/
public static void read(DatasetGraph dataset, String uri, Lang hintLang, Context context) {
- read(dataset, uri, uri, hintLang, context) ;
+ read(dataset, uri, defaultBase(uri), hintLang, context) ;
}
/** Read quads or triples into a Dataset from the given location.
@@ -495,7 +495,7 @@ public class RDFDataMgr
*/
public static void read(Dataset dataset, String uri, String base, Lang hintLang, Context context) {
- read(dataset.asDatasetGraph(), uri, uri, hintLang, context) ;
+ read(dataset.asDatasetGraph(), uri, defaultBase(uri), hintLang, context) ;
}
/** Read quads or triples into a Dataset from the given location.
@@ -529,7 +529,7 @@ public class RDFDataMgr
* @param lang Language syntax
*/
public static void read(DatasetGraph dataset, InputStream in, Lang lang) {
- read(dataset, in, null, lang) ;
+ read(dataset, in, defaultBase(), lang) ;
}
/** Read quads or triples into a dataset with bytes from an input stream.
@@ -551,7 +551,7 @@ public class RDFDataMgr
public static void read(DatasetGraph dataset, InputStream in, String base, Lang lang) {
Objects.requireNonNull(in, "InputStream is null") ;
StreamRDF dest = StreamRDFLib.dataset(dataset) ;
- process(dest, new TypedInputStream(in), base, lang, null) ;
+ process(dest, new TypedInputStream(in), base, lang, (Context)null) ;
}
/** Read quads into a dataset with chars from an Reader.
@@ -580,7 +580,7 @@ public class RDFDataMgr
@Deprecated
public static void read(DatasetGraph dataset, Reader in, String base, Lang lang) {
StreamRDF dest = StreamRDFLib.dataset(dataset) ;
- process(dest, in, base, lang, null) ;
+ process(dest, in, base, lang, (Context)null) ;
}
/** Read quads into a dataset with chars from a StringReader.
@@ -606,7 +606,7 @@ public class RDFDataMgr
*/
public static void read(DatasetGraph dataset, StringReader in, String base, Lang lang) {
StreamRDF dest = StreamRDFLib.dataset(dataset) ;
- process(dest, in, base, lang, null) ;
+ process(dest, in, base, lang, (Context)null) ;
}
/** Read RDF data.
@@ -614,7 +614,7 @@ public class RDFDataMgr
* @param uri URI to read from (includes file: and a plain file name).
*/
public static void parse(StreamRDF sink, String uri) {
- parse(sink, uri, null) ;
+ parse(sink, uri, defaultLang(uri)) ;
}
/** Read RDF data.
@@ -623,7 +623,7 @@ public class RDFDataMgr
* @param lang Hint for the syntax
*/
public static void parse(StreamRDF sink, String uri, Lang lang) {
- parse(sink, uri, lang, null) ;
+ parse(sink, uri, lang, (Context)null) ;
}
@@ -634,7 +634,7 @@ public class RDFDataMgr
* @param context Content object to control reading process.
*/
public static void parse(StreamRDF sink, String uri, Lang hintLang, Context context) {
- parse(sink, uri, uri, hintLang, context) ;
+ parse(sink, uri, defaultBase(uri), hintLang, context) ;
}
/** Read RDF data.
@@ -644,7 +644,7 @@ public class RDFDataMgr
* @param hintLang Hint for the syntax
*/
public static void parse(StreamRDF sink, String uri, String base, Lang hintLang) {
- parse(sink, uri, base, hintLang, null) ;
+ parse(sink, uri, base, hintLang, (Context)null) ;
}
/** Read RDF data.
@@ -674,7 +674,7 @@ public class RDFDataMgr
* @param lang Syntax for the stream.
*/
public static void parse(StreamRDF sink, InputStream in, Lang lang) {
- parse(sink, in, null, lang, null) ;
+ parse(sink, in, defaultBase(), lang, (Context)null) ;
}
/** Read RDF data.
@@ -684,7 +684,7 @@ public class RDFDataMgr
* @param hintLang Hint for the syntax
*/
public static void parse(StreamRDF sink, InputStream in, String base, Lang hintLang) {
- parse(sink, in, base, hintLang, null) ;
+ parse(sink, in, base, hintLang, (Context)null) ;
}
/** Read RDF data.
@@ -704,7 +704,7 @@ public class RDFDataMgr
* @param lang Syntax for the stream.
*/
public static void parse(StreamRDF sink, StringReader in, Lang lang) {
- parse(sink, in, null, lang, null) ;
+ parse(sink, in, defaultBase(), lang, (Context)null) ;
}
/** Read RDF data.
@@ -714,7 +714,7 @@ public class RDFDataMgr
* @param hintLang Hint for the syntax
*/
public static void parse(StreamRDF sink, StringReader in, String base, Lang hintLang) {
- parse(sink, in, base, hintLang, null) ;
+ parse(sink, in, base, hintLang, (Context)null) ;
}
/** Read RDF data.
@@ -736,7 +736,7 @@ public class RDFDataMgr
*/
@Deprecated
public static void parse(StreamRDF sink, Reader in, Lang lang) {
- parse(sink, in, null, lang, null) ;
+ parse(sink, in, defaultBase(), lang, (Context)null) ;
}
/** Read RDF data.
@@ -748,7 +748,7 @@ public class RDFDataMgr
*/
@Deprecated
public static void parse(StreamRDF sink, Reader in, String base, Lang hintLang) {
- parse(sink, in, base, hintLang, null) ;
+ parse(sink, in, base, hintLang, (Context)null) ;
}
/** Read RDF data.
@@ -769,7 +769,7 @@ public class RDFDataMgr
* @param in Bytes to read. This must include the content type.
*/
public static void parse(StreamRDF sink, TypedInputStream in) {
- parse(sink, in, (String)null) ;
+ parse(sink, in, defaultBase()) ;
}
@@ -897,6 +897,23 @@ public class RDFDataMgr
return r.create(lang) ;
}
+ // Operations to remove "null"s in the code.
+
+ /** Default base - no known URI. e.g. input streams */
+ private static String defaultBase() {
+ return null ;
+ }
+
+ /** Default base - URI present */
+ private static String defaultBase(String uri) {
+ return uri ;
+ }
+
+ /** Default lang - usually left as unknow so that extended content negotation happens */
+ private static Lang defaultLang(String uri) {
+ return null;
+ }
+
/** 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) ;
@@ -1192,22 +1209,22 @@ public class RDFDataMgr
private static void write$(OutputStream out, Graph graph, RDFFormat serialization) {
WriterGraphRIOT w = createGraphWriter$(serialization);
- w.write(out, graph, RiotLib.prefixMap(graph), null, null);
+ w.write(out, graph, RiotLib.prefixMap(graph), null, (Context)null);
}
private static void write$(Writer out, Graph graph, RDFFormat serialization) {
WriterGraphRIOT w = createGraphWriter$(serialization);
- w.write(out, graph, RiotLib.prefixMap(graph), null, null);
+ w.write(out, graph, RiotLib.prefixMap(graph), null, (Context)null);
}
private static void write$(OutputStream out, DatasetGraph dataset, RDFFormat serialization) {
WriterDatasetRIOT w = createDatasetWriter$(serialization);
- w.write(out, dataset, RiotLib.prefixMap(dataset), null, null);
+ w.write(out, dataset, RiotLib.prefixMap(dataset), null, (Context)null);
}
private static void write$(Writer out, DatasetGraph dataset, RDFFormat serialization) {
WriterDatasetRIOT w = createDatasetWriter$(serialization);
- w.write(out, dataset, RiotLib.prefixMap(dataset), null, null);
+ w.write(out, dataset, RiotLib.prefixMap(dataset), null, (Context)null);
}
/**