jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [3/3] jena git commit: Always process base URI for RDF/XML.
Date Thu, 22 Oct 2015 14:34:44 GMT
Always process base URI for RDF/XML.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/57028e83
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/57028e83
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/57028e83

Branch: refs/heads/master
Commit: 57028e83ad820d47af8422eabcd44293b0913f6e
Parents: 5cfe4b7
Author: Andy Seaborne <andy@apache.org>
Authored: Thu Oct 22 15:34:13 2015 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Thu Oct 22 15:34:13 2015 +0100

----------------------------------------------------------------------
 .../org/apache/jena/riot/lang/RiotParsers.java  | 125 +++++++++++--------
 1 file changed, 72 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/57028e83/jena-arq/src/main/java/org/apache/jena/riot/lang/RiotParsers.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/RiotParsers.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/RiotParsers.java
index 3a315fc..8a6fb3e 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/RiotParsers.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/RiotParsers.java
@@ -34,16 +34,50 @@ import org.apache.jena.atlas.io.PeekReader ;
 import org.apache.jena.atlas.json.io.parser.TokenizerJSON ;
 import org.apache.jena.riot.* ;
 import org.apache.jena.riot.out.CharSpace ;
-import org.apache.jena.riot.system.ErrorHandlerFactory ;
-import org.apache.jena.riot.system.IRIResolver ;
-import org.apache.jena.riot.system.RiotLib ;
-import org.apache.jena.riot.system.StreamRDF ;
+import org.apache.jena.riot.system.* ;
 import org.apache.jena.riot.tokens.Tokenizer ;
 import org.apache.jena.riot.tokens.TokenizerFactory ;
 
-/** @deprecated Use RDFDataMgr operations */
+/** @deprecated Use RDFDataMgr operations.
+ * This class will become internal to RIOT.
+ */
 @Deprecated
 public class RiotParsers {
+    private RiotParsers() {}
+    
+    /** Create a parser 
+     * @deprecated Use {@link RDFDataMgr#createReader(Lang)}
+     */
+    @Deprecated
+    public static LangRIOT createParser(InputStream input, Lang lang, String baseIRI, StreamRDF
dest)
+    {
+        if ( lang == RDFXML )
+            return createParserRDFXML(input, baseIRI, dest) ;
+        if ( lang == CSV )
+            return new LangCSV (input, baseIRI, baseIRI, ErrorHandlerFactory.getDefaultErrorHandler(),
 dest);
+            
+        Tokenizer tokenizer = ( lang == RDFJSON ) ?
+            new TokenizerJSON(PeekReader.makeUTF8(input)) :
+                TokenizerFactory.makeTokenizerUTF8(input) ;
+        return createParser(tokenizer, lang, baseIRI, dest) ;
+    }
+
+    /** Create a parser 
+     * @deprecated Use {@link RDFDataMgr#createReader(Lang)}
+     */
+    @Deprecated
+    public static LangRIOT createParser(Reader input, Lang lang, String baseIRI, StreamRDF
dest)
+    {
+        if ( lang == RDFXML )
+            return createParserRDFXML(input, baseIRI, dest) ;
+        if ( lang == CSV)
+            return new LangCSV (input, baseIRI, baseIRI, ErrorHandlerFactory.getDefaultErrorHandler(),
 dest);
+        
+        Tokenizer tokenizer = ( lang == RDFJSON ) ?
+            new TokenizerJSON(PeekReader.make(input)) :
+                TokenizerFactory.makeTokenizer(input) ;
+        return createParser(tokenizer, lang, baseIRI, dest) ;
+    }
 
     /** Create a parser for Turtle
      * @deprecated use an RDFDataMgr operation with argument Lang.Turtle
@@ -61,8 +95,8 @@ public class RiotParsers {
     @Deprecated
     public static LangTurtle createParserTurtle(Tokenizer tokenizer, String baseIRI, StreamRDF
dest)
     {
-        RiotLib.profile(RDFLanguages.TURTLE, baseIRI) ;
-        LangTurtle parser = new LangTurtle(tokenizer, RiotLib.profile(RDFLanguages.TURTLE,
baseIRI), dest) ;
+        ParserProfile profile = RiotLib.profile(RDFLanguages.TURTLE, baseIRI) ;
+        LangTurtle parser = new LangTurtle(tokenizer, profile, dest) ;
         return parser ;
     }
 
@@ -72,11 +106,32 @@ public class RiotParsers {
     @Deprecated
     public static LangRDFXML createParserRDFXML(InputStream input, String baseIRI, StreamRDF
dest)
     {
-        if ( baseIRI == null )
-            baseIRI = SysRIOT.chooseBaseIRI() ;
+        baseIRI = baseURI_RDFXML(baseIRI) ;
+        LangRDFXML parser = LangRDFXML.create(input, baseIRI, baseIRI, ErrorHandlerFactory.getDefaultErrorHandler(),
dest) ;
+        return parser ;
+    }
+
+    /** Create a parser for RDF/XML
+     * @deprecated use an RDFDataMgr operation with argument Lang.RDFXML
+     */
+    @Deprecated
+    public static LangRDFXML createParserRDFXML(Reader input, String baseIRI, StreamRDF dest)
+    {
+        baseIRI = baseURI_RDFXML(baseIRI) ;
         LangRDFXML parser = LangRDFXML.create(input, baseIRI, baseIRI, ErrorHandlerFactory.getDefaultErrorHandler(),
dest) ;
         return parser ;
     }
+    
+    /** Sort out the base URi fo RDF/XML parsing. */
+    private static String baseURI_RDFXML(String baseIRI) {
+        // LangRIOT derived from LangEngine do this in ParserProfile 
+        if ( baseIRI == null )
+            return SysRIOT.chooseBaseIRI() ;
+        else {
+            return IRIResolver.resolveStringSilent(baseIRI) ;
+            //return SysRIOT.chooseBaseIRI(baseIRI) ;
+        }
+    }
 
     /** Create parsers for RDF/JSON
      * @deprecated use an RDFDataMgr operation with argument Lang.RDFJSON
@@ -84,7 +139,8 @@ public class RiotParsers {
     @Deprecated
     public static LangRDFJSON createParserRdfJson(Tokenizer tokenizer, StreamRDF dest)
     {
-    	LangRDFJSON parser = new LangRDFJSON(tokenizer, RiotLib.profile(RDFLanguages.RDFJSON,
null), dest) ;
+        ParserProfile profile =  RiotLib.profile(RDFLanguages.RDFJSON, null) ;
+    	LangRDFJSON parser = new LangRDFJSON(tokenizer, profile, dest) ;
     	return parser;
     }
 
@@ -114,7 +170,8 @@ public class RiotParsers {
     @Deprecated
     public static LangTriG createParserTriG(Tokenizer tokenizer, String baseIRI, StreamRDF
dest)
     {
-        LangTriG parser = new LangTriG(tokenizer, RiotLib.profile(RDFLanguages.TRIG, baseIRI),
dest) ;
+        ParserProfile profile = RiotLib.profile(RDFLanguages.TRIG, baseIRI) ;
+        LangTriG parser = new LangTriG(tokenizer, profile, dest) ;
         return parser ;
     }
 
@@ -143,7 +200,8 @@ public class RiotParsers {
     @Deprecated
     public static LangNTriples createParserNTriples(Tokenizer tokenizer, StreamRDF dest)
     {
-        LangNTriples parser = new LangNTriples(tokenizer, RiotLib.profile(RDFLanguages.NTRIPLES,
null), dest) ;
+        ParserProfile profile = RiotLib.profile(RDFLanguages.NTRIPLES, null) ;
+        LangNTriples parser = new LangNTriples(tokenizer, profile, dest) ;
         return parser ;
     }
 
@@ -172,53 +230,14 @@ public class RiotParsers {
     @Deprecated
     public static LangNQuads createParserNQuads(Tokenizer tokenizer, StreamRDF dest)
     {
-        LangNQuads parser = new LangNQuads(tokenizer, RiotLib.profile(RDFLanguages.NQUADS,
null), dest) ;
+        ParserProfile profile = RiotLib.profile(RDFLanguages.NQUADS, null) ;
+        LangNQuads parser = new LangNQuads(tokenizer, profile, dest) ;
         return parser ;
     }
 
     /** Create a parser 
      * @deprecated Use {@link RDFDataMgr#createReader(Lang)}
      */
-    @Deprecated
-    public static LangRIOT createParser(InputStream input, Lang lang, String baseIRI, StreamRDF
dest)
-    {
-        if ( lang == RDFXML )
-        {
-            if ( baseIRI != null )
-                baseIRI = SysRIOT.chooseBaseIRI(baseIRI) ;
-            return LangRDFXML.create(input, baseIRI, baseIRI, ErrorHandlerFactory.getDefaultErrorHandler(),
dest) ;
-        } else if ( lang == CSV){
-        	return new LangCSV (input, baseIRI, baseIRI, ErrorHandlerFactory.getDefaultErrorHandler(),
 dest);
-        }
-        Tokenizer tokenizer = ( lang == RDFJSON ) ?
-            new TokenizerJSON(PeekReader.makeUTF8(input)) :
-                TokenizerFactory.makeTokenizerUTF8(input) ;
-        return createParser(tokenizer, lang, baseIRI, dest) ;
-    }
-
-    /** Create a parser 
-     * @deprecated Use {@link RDFDataMgr#createReader(Lang)}
-     */
-    @Deprecated
-    public static LangRIOT createParser(Reader input, Lang lang, String baseIRI, StreamRDF
dest)
-    {
-        if ( lang == RDFXML )
-        {
-            if ( baseIRI != null )
-                baseIRI = IRIResolver.resolveStringSilent(baseIRI) ;
-            return LangRDFXML.create(input, baseIRI, baseIRI, ErrorHandlerFactory.getDefaultErrorHandler(),
dest) ;
-        } else if ( lang == CSV){
-        	return new LangCSV (input, baseIRI, baseIRI, ErrorHandlerFactory.getDefaultErrorHandler(),
 dest);
-        }
-        Tokenizer tokenizer = ( lang == RDFJSON ) ?
-            new TokenizerJSON(PeekReader.make(input)) :
-                TokenizerFactory.makeTokenizer(input) ;
-        return createParser(tokenizer, lang, baseIRI, dest) ;
-    }
-
-    /** Create a parser 
-     * @deprecated Use {@link RDFDataMgr#createReader(Lang)}
-     */
     @Deprecated  
     public static LangRIOT createParser(Tokenizer tokenizer, Lang lang, String baseIRI, StreamRDF
dest)
     {


Mime
View raw message