jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1444848 - in /jena/trunk/jena-arq/src: main/java/org/apache/jena/riot/ main/java/org/apache/jena/riot/lang/ test/java/org/apache/jena/riot/lang/
Date Mon, 11 Feb 2013 16:25:18 GMT
Author: andy
Date: Mon Feb 11 16:25:18 2013
New Revision: 1444848

URL: http://svn.apache.org/r1444848
Log:
Add a "null" language which produces no triples or quads.

Added:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNull.java
Modified:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/Lang.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/LangBuilder.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFLanguages.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFParserRegistry.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RiotReader.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLang.java

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/Lang.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/Lang.java?rev=1444848&r1=1444847&r2=1444848&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/Lang.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/Lang.java Mon Feb 11 16:25:18 2013
@@ -50,7 +50,8 @@ public class Lang 
     public static Lang TURTLE ; 
     public static Lang RDFJSON ; 
     public static Lang NQUADS ; 
-    public static Lang TRIG ; 
+    public static Lang TRIG ;
+    public static Lang RDFNULL ;
 
     private final String label ;                    // Primary name
     private final ContentType contentType ;         // Primary content type.

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/LangBuilder.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/LangBuilder.java?rev=1444848&r1=1444847&r2=1444848&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/LangBuilder.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/LangBuilder.java Mon Feb 11 16:25:18
2013
@@ -53,6 +53,8 @@ public class LangBuilder {
     /** Create a builder - convenience operation to 
      * take the language name and content type
      * which should be set if at all possible.
+     * @param langname
+     * @param officialContentType
      */
     public static LangBuilder create(String langname, String officialContentType)
     {

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFLanguages.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFLanguages.java?rev=1444848&r1=1444847&r2=1444848&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFLanguages.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFLanguages.java Mon Feb 11 16:25:18
2013
@@ -104,6 +104,11 @@ public class RDFLanguages
                                                 .addFileExtensions("nq")
                                                 .build() ;
 
+    /** The "null" language */
+    public static final Lang RDFNULL  = LangBuilder.create("rdf/null", "null/rdf")
+                                                .addAltNames("NULL", "null")  
+                                                .build() ;
+    
     // ---- Central registry
     
     /** Mapping of colloquial name to language */
@@ -125,13 +130,14 @@ public class RDFLanguages
     {
         initStandard() ;
         // Needed to avoid a class initialization loop. 
-        Lang.RDFXML = RDFLanguages.RDFXML ; 
-        Lang.NTRIPLES = RDFLanguages.NTRIPLES ; 
-        Lang.N3 = RDFLanguages.N3 ; 
-        Lang.TURTLE = RDFLanguages.TURTLE ; 
-        Lang.RDFJSON = RDFLanguages.RDFJSON ; 
-        Lang.NQUADS = RDFLanguages.NQUADS ; 
-        Lang.TRIG = RDFLanguages.TRIG ; 
+        Lang.RDFXML     = RDFLanguages.RDFXML ; 
+        Lang.NTRIPLES   = RDFLanguages.NTRIPLES ; 
+        Lang.N3         = RDFLanguages.N3 ; 
+        Lang.TURTLE     = RDFLanguages.TURTLE ; 
+        Lang.RDFJSON    = RDFLanguages.RDFJSON ; 
+        Lang.NQUADS     = RDFLanguages.NQUADS ; 
+        Lang.TRIG       = RDFLanguages.TRIG ; 
+        Lang.RDFNULL    = RDFLanguages.RDFNULL ;
     }
     // ----------------------
     
@@ -145,6 +151,7 @@ public class RDFLanguages
         register(RDFJSON) ;
         register(TRIG) ;
         register(NQUADS) ;
+        register(RDFNULL) ;
     }
 
     /** Register a language.

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFParserRegistry.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFParserRegistry.java?rev=1444848&r1=1444847&r2=1444848&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFParserRegistry.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFParserRegistry.java Mon Feb
11 16:25:18 2013
@@ -77,31 +77,6 @@ public class RDFParserRegistry
         // Make sure the constants are initialized.
         RDFLanguages.init() ;
         
-        // Reader name and variations to lang - must include Jena old-name.
-        registerShortNameForLang("RDF/XML",         RDFXML) ;
-        registerShortNameForLang("RDFXML",          RDFXML) ;
-        registerShortNameForLang("RDF/XML-ABBREV",  RDFXML) ;
-        
-        registerShortNameForLang("N-TRIPLE",        NTRIPLES) ;
-        registerShortNameForLang("N-TRIPLES",       NTRIPLES) ;
-        registerShortNameForLang("NTRIPLE",         NTRIPLES) ;
-        registerShortNameForLang("NTRIPLES",        NTRIPLES) ;
-        registerShortNameForLang("NT",              NTRIPLES) ;
-            
-        registerShortNameForLang("TURTLE",          TURTLE) ;
-        registerShortNameForLang("TTL",             TURTLE) ;
-
-        registerShortNameForLang("RDF/JSON",        RDFJSON) ;
-        registerShortNameForLang("RDFJSON",         RDFJSON) ;
-        
-        registerShortNameForLang("N-QUADS",         NQUADS) ;
-        registerShortNameForLang("NQUADS",          NQUADS) ;
-        registerShortNameForLang("N-QUAD",          NQUADS) ;
-        registerShortNameForLang("NQUAD",           NQUADS) ;
-        registerShortNameForLang("NQ",              NQUADS) ;
-            
-        registerShortNameForLang("TRIG",            TRIG) ;
-        
         registerLangTriples(RDFXML,     parserFactory) ;
         registerLangTriples(NTRIPLES,   parserFactory) ;
         registerLangTriples(N3,         parserFactory) ;
@@ -112,12 +87,6 @@ public class RDFParserRegistry
         registerLangQuads(TRIG,         parserFactory) ;
     }
 
-    /** Register a Jena IO name */
-    private static void registerShortNameForLang(String name, Lang lang)
-    {
-        mapJenaNameToLang.put(RDFLanguages.canonicalKey(name), lang) ;
-    }
-
     /** Register a language and it's parser factory.
      * To create a {@link Lang} object use {@link LangBuilder}.
      */

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RiotReader.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RiotReader.java?rev=1444848&r1=1444847&r2=1444848&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RiotReader.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RiotReader.java Mon Feb 11 16:25:18
2013
@@ -25,6 +25,7 @@ import static org.apache.jena.riot.RDFLa
 import static org.apache.jena.riot.RDFLanguages.RDFXML ;
 import static org.apache.jena.riot.RDFLanguages.TRIG ;
 import static org.apache.jena.riot.RDFLanguages.TURTLE ;
+import static org.apache.jena.riot.RDFLanguages.RDFNULL ;
 import static org.apache.jena.riot.RDFLanguages.filenameToLang ;
 
 import java.io.InputStream ;
@@ -35,16 +36,7 @@ import org.apache.jena.atlas.io.PeekRead
 import org.apache.jena.atlas.iterator.IteratorResourceClosing ;
 import org.apache.jena.atlas.json.io.parser.TokenizerJSON ;
 import org.apache.jena.atlas.lib.Sink ;
-import org.apache.jena.riot.lang.LangNQuads ;
-import org.apache.jena.riot.lang.LangNTriples ;
-import org.apache.jena.riot.lang.LangRDFJSON ;
-import org.apache.jena.riot.lang.LangRDFXML ;
-import org.apache.jena.riot.lang.LangRIOT ;
-import org.apache.jena.riot.lang.LangTriG ;
-import org.apache.jena.riot.lang.LangTurtle ;
-import org.apache.jena.riot.lang.PipedQuadsStream ;
-import org.apache.jena.riot.lang.PipedRDFIterator ;
-import org.apache.jena.riot.lang.PipedTriplesStream ;
+import org.apache.jena.riot.lang.* ;
 import org.apache.jena.riot.system.ErrorHandlerFactory ;
 import org.apache.jena.riot.system.IRIResolver ;
 import org.apache.jena.riot.system.RiotLib ;
@@ -159,6 +151,9 @@ public class RiotReader
         if ( RDFLanguages.sameLang(TRIG, lang) )
             return createParserTriG(tokenizer, baseIRI, dest) ;
         
+        if ( RDFLanguages.sameLang(RDFNULL, lang) )
+            return new LangNull() ;
+        
         return null ;
     }
 

Added: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNull.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNull.java?rev=1444848&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNull.java (added)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/lang/LangNull.java Mon Feb 11 16:25:18
2013
@@ -0,0 +1,49 @@
+/**
+ * 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 org.apache.jena.riot.lang;
+
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.system.ParserProfile ;
+
+/** Dummy language */
+public class LangNull implements LangRIOT
+{
+
+    @Override
+    public ParserProfile getProfile()
+    {
+        return null ;
+    }
+
+    @Override
+    public void setProfile(ParserProfile profile)
+    {}
+
+    @Override
+    public void parse()
+    {}
+
+    @Override
+    public Lang getLang()
+    {
+        return Lang.RDFNULL ;
+    }
+
+}
+

Modified: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLang.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLang.java?rev=1444848&r1=1444847&r2=1444848&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLang.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/lang/TestLang.java Mon Feb 11 16:25:18
2013
@@ -73,6 +73,8 @@ public class TestLang extends BaseTest
     {
         for (Lang l : RDFLanguages.getRegisteredLanguages() )
         {
+            if ( RDFLanguages.RDFNULL.equals(l) )
+                continue ;
             Assert.assertNotNull( l+" does not have file extensions defined", l.getFileExtensions());
             Assert.assertTrue( l+" does not have file extensions defined", l.getFileExtensions().size()
> 0);
         }
@@ -99,7 +101,11 @@ public class TestLang extends BaseTest
     public void testDefaultInExtensions()
     {
         for (Lang l : RDFLanguages.getRegisteredLanguages() )
+        {
+            if ( RDFLanguages.RDFNULL.equals(l) )
+                continue ;
             Assert.assertTrue( l+" default extension not in file extensions list", l.getFileExtensions().contains(
l.getFileExtensions().get(0))  );
+        }
     }
     
     @Test



Mime
View raw message