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 2018/04/29 15:10:01 UTC

[2/5] jena git commit: JENA-1535: Parse a specified language if given --syntax.

JENA-1535: Parse a specified language if given --syntax.


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

Branch: refs/heads/master
Commit: 36320298fdb38a9db6674ba8604f679009326b13
Parents: ad5b445
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 27 23:27:38 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 27 23:49:56 2018 +0100

----------------------------------------------------------------------
 jena-cmds/src/main/java/riotcmd/CmdLangParse.java | 12 +++++++++---
 jena-cmds/src/main/java/riotcmd/riot.java         |  3 ---
 2 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/36320298/jena-cmds/src/main/java/riotcmd/CmdLangParse.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/riotcmd/CmdLangParse.java b/jena-cmds/src/main/java/riotcmd/CmdLangParse.java
index 10d1d57..c14f220 100644
--- a/jena-cmds/src/main/java/riotcmd/CmdLangParse.java
+++ b/jena-cmds/src/main/java/riotcmd/CmdLangParse.java
@@ -218,8 +218,14 @@ public abstract class CmdLangParse extends CmdGeneral
         RDFParserBuilder builder = RDFParser.create();
         if ( baseURI != null )
             builder.base(baseURI);
-        Lang lang = selectLang(null, null, RDFLanguages.NQUADS) ;
-        builder.lang(lang);
+        if ( modLangParse.getLang() != null )
+            // Always use the command line specified syntax.
+            builder.forceLang(modLangParse.getLang());
+        else {
+            // Otherwise, use the command selected langauge, with N-Quads as the ultimate fallback.  
+            Lang lang = selectLang(null, null, RDFLanguages.NQUADS) ;
+            builder.lang(RDFLanguages.NQUADS);
+        }
 
         // Set the source.
         if ( filename.equals("-") ) {
@@ -234,7 +240,7 @@ public abstract class CmdLangParse extends CmdGeneral
         return parseRIOT(builder, filename);
     }
 
-    protected abstract Lang selectLang(String filename, ContentType contentType, Lang dftLang  ) ;
+    protected abstract Lang selectLang(String filename, ContentType contentType, Lang dftLang) ;
 
     protected ParseRecord parseRIOT(RDFParserBuilder builder, /*Info for the ProcessOutcome*/ String filename) {
         boolean checking = true ;

http://git-wip-us.apache.org/repos/asf/jena/blob/36320298/jena-cmds/src/main/java/riotcmd/riot.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/riotcmd/riot.java b/jena-cmds/src/main/java/riotcmd/riot.java
index 4ef6df8..d332d17 100644
--- a/jena-cmds/src/main/java/riotcmd/riot.java
+++ b/jena-cmds/src/main/java/riotcmd/riot.java
@@ -42,9 +42,6 @@ public class riot extends CmdLangParse
     @Override
     protected Lang selectLang(String filename, ContentType contentType, Lang dftLang)
     {
-        if ( modLangParse.getLang() != null )
-            return modLangParse.getLang() ;
-        
         if ( contentType != null && ! WebContent.matchContentType(WebContent.ctTextPlain, contentType) )
             return RDFLanguages.contentTypeToLang(contentType) ;