jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1620652 - in /jena/trunk/jena-arq/src/main/java: arq/cmdline/ModLangOutput.java riotcmd/CmdLangParse.java
Date Tue, 26 Aug 2014 16:29:04 GMT
Author: andy
Date: Tue Aug 26 16:29:04 2014
New Revision: 1620652

URL: http://svn.apache.org/r1620652
Log:
JENA-768 : Preparation for stream output formats in riotcmd.riot.

Added:
    jena/trunk/jena-arq/src/main/java/arq/cmdline/ModLangOutput.java   (with props)
Modified:
    jena/trunk/jena-arq/src/main/java/riotcmd/CmdLangParse.java

Added: jena/trunk/jena-arq/src/main/java/arq/cmdline/ModLangOutput.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/arq/cmdline/ModLangOutput.java?rev=1620652&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/main/java/arq/cmdline/ModLangOutput.java (added)
+++ jena/trunk/jena-arq/src/main/java/arq/cmdline/ModLangOutput.java Tue Aug 26 16:29:04 2014
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package arq.cmdline;
+
+import org.apache.jena.riot.RDFFormat ;
+
+public class ModLangOutput implements ArgModuleGeneral
+{
+    protected ArgDecl argOutput     = new ArgDecl(ArgDecl.HasValue, "out", "output") ;
+    private RDFFormat format        = RDFFormat.NQUADS ;
+    
+    @Override
+    public void registerWith(CmdGeneral cmdLine) {
+        cmdLine.getUsage().startCategory("Output control") ;
+        cmdLine.add(argOutput,    "--out=FMT",  "Output in the given format") ;
+    }
+
+    @Override
+    public void processArgs(CmdArgModule cmdLine) {
+        if ( cmdLine.contains(argOutput) ) {
+            String langName = cmdLine.getValue(argOutput) ;
+//            Lang output = RDFLanguages.nameToLang(langName) ;
+//            if ( output == null )
+//                throw new CmdException("Not recognized as an RDF language : '"+langName+"'")
;
+//            if ( ! StreamRDFWriter.registered(output) ) {
+//                // ** Java8
+////                StreamRDFWriter.registered().stream()
+////                    .map(fmt -> fmt.getLang()) 
+////                    .distinct()
+////                    .forEach(x -> System.err.println("   "+x.getLabel())) ;
+//                
+//                Set<Lang> seen = new HashSet<>() ;
+//                for ( RDFFormat fmt : StreamRDFWriter.registered()) {
+//                    if ( seen.contains(fmt.getLang()) )
+//                        continue ;
+//                    seen.add(fmt.getLang()) ;
+//                    System.err.println("   "+fmt.getLang().getLabel()) ;
+//                }
+//                
+//                throw new CmdException("Not recognized as an streaming RDF language : '"+langName+"'")
;
+//            }
+        }
+    }
+
+    public RDFFormat getOutputFormat() {
+        return format ;
+    }
+}

Propchange: jena/trunk/jena-arq/src/main/java/arq/cmdline/ModLangOutput.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jena/trunk/jena-arq/src/main/java/riotcmd/CmdLangParse.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/riotcmd/CmdLangParse.java?rev=1620652&r1=1620651&r2=1620652&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/riotcmd/CmdLangParse.java (original)
+++ jena/trunk/jena-arq/src/main/java/riotcmd/CmdLangParse.java Tue Aug 26 16:29:04 2014
@@ -42,13 +42,10 @@ import com.hp.hpl.jena.query.ARQ ;
 /** Common framework for running RIOT parsers */
 public abstract class CmdLangParse extends CmdGeneral
 {
-    // We are not a TDB command but still set the logging.
-    //static { CmdTDB.setLogging() ; }
-    // Module.
     protected ModTime modTime                   = new ModTime() ;
     protected ModLangParse modLangParse         = new ModLangParse() ;
+    protected ModLangOutput modLangOutput       = new ModLangOutput() ;
     protected ModSymbol modSymbol               = new ModSymbol() ;
-    protected ArgDecl argStrict                 = new ArgDecl(ArgDecl.NoValue, "strict")
;    
     protected InferenceSetupRDFS setup          = null ; 
     
     interface LangHandler {
@@ -86,11 +83,14 @@ public abstract class CmdLangParse exten
         
         super.addModule(modTime) ;
         super.addModule(modLangParse) ;
+        super.addModule(modLangOutput) ;
         super.addModule(modSymbol) ;
         
         super.modVersion.addClass(Jena.class) ;
         super.modVersion.addClass(ARQ.class) ;
         super.modVersion.addClass(RIOT.class) ;
+        
+        
     }
 
     @Override
@@ -100,17 +100,15 @@ public abstract class CmdLangParse exten
         return getCommandName()+" [--time] [--check|--noCheck] [--sink] [--base=IRI] file
..." ;
     }
 
-    @Override
-    protected void processModulesAndArgs()
-    { 
-        if ( this.contains(argStrict) )
-            RIOT.setStrictMode(true) ;
-    }
-
     protected long totalMillis = 0 ; 
     protected long totalTuples = 0 ; 
     
     OutputStream output = System.out ;
+    StreamRDF outputStream = null ;
+    
+
+    @Override
+    protected void processModulesAndArgs() {}
     
     @Override
     protected void exec()
@@ -121,6 +119,8 @@ public abstract class CmdLangParse exten
         if ( modLangParse.getRDFSVocab() != null )
             setup = new InferenceSetupRDFS(modLangParse.getRDFSVocab()) ;
      
+        outputStream = createSink() ;
+        
         try {
             if ( super.getPositional().isEmpty() )
                 parseFile("-") ;
@@ -172,10 +172,6 @@ public abstract class CmdLangParse exten
 
     protected void parseRIOT(String baseURI, String filename, TypedInputStream in)
     {
-        // I ti s shame we effectively duplicate deciding thelnaguage but we want to control
the
-        // pasrer at a deep level (in validation, we want line numbers get into error message)
-        // This code predates RDFDataMgr.
-        
         ContentType ct = in.getMediaType() ;
         
         baseURI = SysRIOT.chooseBaseIRI(baseURI, filename) ;
@@ -231,7 +227,7 @@ public abstract class CmdLangParse exten
         if ( labelsAsGiven )
             labels = NodeToLabel.createBNodeByLabelEncoded() ;
         
-        StreamRDF s = createSink() ;
+        StreamRDF s = outputStream ; 
         if ( setup != null )
             s = InfFactory.inf(s, setup) ;
         StreamRDFCounting sink = StreamRDFLib.count(s) ;
@@ -275,6 +271,11 @@ public abstract class CmdLangParse exten
         StreamRDF s = StreamRDFLib.sinkNull() ;
         if ( ! modLangParse.toBitBucket() )
             s = StreamRDFLib.writer(output) ;
+        else {
+            RDFFormat fmt = modLangOutput.getOutputFormat() ;
+            // Framework : Ignore for now.
+        }
+        
         return s ;
     }
     



Mime
View raw message