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: Mod ModSymbol to better name ModContext
Date Tue, 22 Dec 2015 12:41:28 GMT
Mod ModSymbol to better name ModContext

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

Branch: refs/heads/master
Commit: 212d588e1f14c6dd53b71db46b9ae1ed5d1c68ba
Parents: 802acb5
Author: Andy Seaborne <andy@apache.org>
Authored: Tue Dec 22 12:41:04 2015 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Tue Dec 22 12:41:04 2015 +0000

----------------------------------------------------------------------
 jena-arq/src/main/java/arq/cmdline/CmdARQ.java  |  4 +-
 .../src/main/java/arq/cmdline/ModContext.java   | 92 ++++++++++++++++++++
 .../src/main/java/arq/cmdline/ModSymbol.java    | 80 ++---------------
 .../src/main/java/riotcmd/CmdLangParse.java     |  6 +-
 jena-arq/src/test/java/riotcmd/rdflangtest.java |  6 +-
 5 files changed, 105 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/212d588e/jena-arq/src/main/java/arq/cmdline/CmdARQ.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/arq/cmdline/CmdARQ.java b/jena-arq/src/main/java/arq/cmdline/CmdARQ.java
index 2d82d98..d6fb553 100644
--- a/jena-arq/src/main/java/arq/cmdline/CmdARQ.java
+++ b/jena-arq/src/main/java/arq/cmdline/CmdARQ.java
@@ -31,7 +31,7 @@ public abstract class CmdARQ extends CmdGeneral
 {
 	static { JenaSystem.init() ; }
 
-    protected ModSymbol modSymbol = new ModSymbol() ;
+    protected ModContext modContext = new ModContext() ;
     ArgDecl  strictDecl = new ArgDecl(ArgDecl.NoValue, "strict") ;
     
     protected boolean cmdStrictMode = false ; 
@@ -39,11 +39,11 @@ public abstract class CmdARQ extends CmdGeneral
     protected CmdARQ(String[] argv)
     {
         super(argv) ;
-        addModule(modSymbol) ;
         modVersion.addClass(Jena.class) ;
         modVersion.addClass(ARQ.class) ;
         modVersion.addClass(RIOT.class) ;
         super.add(strictDecl, "--strict", "Operate in strict SPARQL mode (no extensions of
any kind)") ; 
+        addModule(modContext) ;
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/jena/blob/212d588e/jena-arq/src/main/java/arq/cmdline/ModContext.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/arq/cmdline/ModContext.java b/jena-arq/src/main/java/arq/cmdline/ModContext.java
new file mode 100644
index 0000000..28c999a
--- /dev/null
+++ b/jena-arq/src/main/java/arq/cmdline/ModContext.java
@@ -0,0 +1,92 @@
+/*
+ * 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 java.io.PrintStream ;
+
+import jena.cmd.ArgDecl;
+import jena.cmd.CmdArgModule;
+import jena.cmd.CmdGeneral;
+import jena.cmd.ModBase;
+
+import org.apache.jena.atlas.io.IndentedWriter ;
+import org.apache.jena.query.ARQ ;
+import org.apache.jena.sparql.util.Context ;
+import org.apache.jena.sparql.util.MappingRegistry ;
+import org.apache.jena.sparql.util.Symbol ;
+import org.apache.jena.system.JenaSystem ;
+
+/** Set Context items */
+public class ModContext extends ModBase
+{
+    static { JenaSystem.init(); }
+
+    protected final ArgDecl setDecl = new ArgDecl(ArgDecl.HasValue, "set", "define", "defn",
"def") ;
+
+    private Context context = new Context() ;
+
+    @Override
+    public void registerWith(CmdGeneral cmdLine) {
+        cmdLine.getUsage().startCategory("Symbol definition");
+        cmdLine.add(setDecl, "--set", "Set a configuration symbol to a value");
+    }
+
+    public void checkCommandLine(CmdArgModule cmdLine) {}
+
+    @Override
+    public void processArgs(CmdArgModule cmdLine) {
+        if ( cmdLine.getValues(setDecl) == null || cmdLine.getValues(setDecl).size() == 0
)
+            return;
+
+        for ( String arg : cmdLine.getValues(setDecl) ) {
+            String[] frags = arg.split("=", 2);
+            if ( frags.length != 2 ) {
+                throw new RuntimeException("Can't split '" + arg + "' -- looking for '='
to separate name and value");
+            }
+
+            String symbolName = frags[0];
+            String value = frags[1];
+
+            // Make it a long name.
+            symbolName = MappingRegistry.mapPrefixName(symbolName);
+            Symbol symbol = Symbol.create(symbolName);
+            context.set(symbol, value);
+            System.err.println(symbol+"="+value);
+        }
+
+        ARQ.getContext().putAll(context);
+    }
+
+    public void verbose() {
+        verbose(System.out);
+    }
+
+    public void verbose(PrintStream stream) {
+        IndentedWriter out = new IndentedWriter(stream);
+        verbose(out);
+        out.flush();
+    }
+
+    public void verbose(IndentedWriter out) {
+        for ( Symbol symbol : context.keys() ) {
+            String value = context.getAsString(symbol);
+            out.println(symbol + " -> " + value);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/212d588e/jena-arq/src/main/java/arq/cmdline/ModSymbol.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/arq/cmdline/ModSymbol.java b/jena-arq/src/main/java/arq/cmdline/ModSymbol.java
index 689dafe..b465644 100644
--- a/jena-arq/src/main/java/arq/cmdline/ModSymbol.java
+++ b/jena-arq/src/main/java/arq/cmdline/ModSymbol.java
@@ -18,79 +18,9 @@
 
 package arq.cmdline;
 
-import java.io.PrintStream ;
-
-import jena.cmd.ArgDecl;
-import jena.cmd.CmdArgModule;
-import jena.cmd.CmdGeneral;
-import jena.cmd.ModBase;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-import org.apache.jena.query.ARQ ;
-import org.apache.jena.sparql.util.Context ;
-import org.apache.jena.sparql.util.MappingRegistry ;
-import org.apache.jena.sparql.util.Symbol ;
-import org.apache.jena.system.JenaSystem ;
-
-public class ModSymbol extends ModBase
-{
-    static { JenaSystem.init(); }
-
-    protected final ArgDecl setDecl = new ArgDecl(ArgDecl.HasValue, "set", "define", "defn",
"def") ;
-private Context context = new Context() ;
-
-    @Override
-    public void registerWith(CmdGeneral cmdLine)
-    {
-        cmdLine.getUsage().startCategory("Symbol definition") ;
-        cmdLine.add(setDecl, "--set", "Set a configuration symbol to a value") ;
-    }
-    
-    public void checkCommandLine(CmdArgModule cmdLine)
-    {}
-
-    @Override
-    public void processArgs(CmdArgModule cmdLine)
-    {
-        
-        if ( cmdLine.getValues(setDecl) == null || cmdLine.getValues(setDecl).size() == 0
)
-            return ;
-
-        for ( String arg : cmdLine.getValues( setDecl ) )
-        {
-            String[] frags = arg.split( "=", 2 );
-            if ( frags.length != 2 )
-            {
-                throw new RuntimeException( "Can't split '" + arg + "' -- looking for '='
to separate name and value" );
-            }
-
-            String symbolName = frags[0];
-            String value = frags[1];
-
-            // Make it a long name.
-            symbolName = MappingRegistry.mapPrefixName( symbolName );
-            Symbol symbol = Symbol.create( symbolName );
-            context.set( symbol, value );
-        }
-        
-        ARQ.getContext().putAll(context) ;
-    }
-    
-    public void verbose() { verbose(System.out) ; }
-    
-    public void verbose(PrintStream stream)
-    {
-        IndentedWriter out = new IndentedWriter(stream) ;
-        verbose(out) ;
-        out.flush();
-    }
-    
-    public void verbose(IndentedWriter out)
-    {
-        for ( Symbol symbol : context.keys() )
-        {
-            String value = context.getAsString( symbol );
-            out.println( symbol + " -> " + value );
-        }
-    }
+/** Set Context items
+ *  @deprecated Use ModContext.
+ */
+@Deprecated
+public class ModSymbol extends ModContext {
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/212d588e/jena-arq/src/main/java/riotcmd/CmdLangParse.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/riotcmd/CmdLangParse.java b/jena-arq/src/main/java/riotcmd/CmdLangParse.java
index 86756e7..61f3b96 100644
--- a/jena-arq/src/main/java/riotcmd/CmdLangParse.java
+++ b/jena-arq/src/main/java/riotcmd/CmdLangParse.java
@@ -25,7 +25,7 @@ import java.util.zip.GZIPOutputStream ;
 
 import arq.cmdline.ModLangOutput ;
 import arq.cmdline.ModLangParse ;
-import arq.cmdline.ModSymbol ;
+import arq.cmdline.ModContext ;
 import arq.cmdline.ModTime ;
 import jena.cmd.ArgDecl ;
 import jena.cmd.CmdException;
@@ -58,7 +58,7 @@ public abstract class CmdLangParse extends CmdGeneral
     protected ModLangParse modLangParse         = new ModLangParse() ;
     protected ModLangOutput modLangOutput       = new ModLangOutput() ;
     protected InferenceSetupRDFS setup          = null ; 
-    protected ModSymbol modSymbol               = new ModSymbol() ;
+    protected ModContext modContext             = new ModContext() ;
     protected ArgDecl strictDecl                = new ArgDecl(ArgDecl.NoValue, "strict")
;
 
     protected boolean cmdStrictMode = false ; 
@@ -92,7 +92,7 @@ public abstract class CmdLangParse extends CmdGeneral
     protected CmdLangParse(String[] argv)
     {
         super(argv) ;
-        addModule(modSymbol) ;
+        addModule(modContext) ;
         addModule(modTime) ;
         addModule(modLangOutput) ;
         addModule(modLangParse) ;

http://git-wip-us.apache.org/repos/asf/jena/blob/212d588e/jena-arq/src/test/java/riotcmd/rdflangtest.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/riotcmd/rdflangtest.java b/jena-arq/src/test/java/riotcmd/rdflangtest.java
index 5fafa91..1f5af3b 100644
--- a/jena-arq/src/test/java/riotcmd/rdflangtest.java
+++ b/jena-arq/src/test/java/riotcmd/rdflangtest.java
@@ -19,7 +19,7 @@
 package riotcmd;
 
 import arq.cmdline.ModEngine ;
-import arq.cmdline.ModSymbol ;
+import arq.cmdline.ModContext ;
 import jena.cmd.ArgDecl ;
 import jena.cmd.CmdException ;
 import jena.cmd.CmdGeneral ;
@@ -61,7 +61,7 @@ import org.apache.jena.vocabulary.RDF ;
 public class rdflangtest extends CmdGeneral
 {
     static { JenaSystem.init() ; }
-    protected ModSymbol modSymbol       = new ModSymbol() ;
+    protected ModContext modContext     = new ModContext() ;
     protected ArgDecl  strictDecl       = new ArgDecl(ArgDecl.NoValue, "strict") ;
     protected boolean  cmdStrictMode    = false ; 
 
@@ -79,13 +79,13 @@ public class rdflangtest extends CmdGeneral
     public rdflangtest(String[] argv)
     {
         super(argv) ;
-        addModule(modSymbol) ;
         super.add(strictDecl, "--strict", "Operate in strict mode (no extensions of any kind)")
;
         super.modVersion.addClass(ARQ.class) ;
         //add(allDecl, "--all", "run all tests") ;
         getUsage().startCategory("Tests (execute test manifest)") ;
         getUsage().addUsage("<manifest>", "run the tests specified in the given manifest")
;
         add(earlDecl, "--earl", "create EARL report") ;
+        addModule(modContext) ;
     }
     
     protected ModEngine setModEngine()


Mime
View raw message