jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1412681 - in /jena/trunk/jena-arq/src: main/java/org/apache/jena/riot/ main/java/org/openjena/riot/ test/java/org/apache/jena/riot/ test/java/org/openjena/riot/
Date Thu, 22 Nov 2012 21:53:00 GMT
Author: andy
Date: Thu Nov 22 21:52:58 2012
New Revision: 1412681

URL: http://svn.apache.org/viewvc?rev=1412681&view=rev
Log: (empty)

Added:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/ParserRegistry.java
      - copied, changed from r1412666, jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFParserRegistry.java
Removed:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFParserRegistry.java
Modified:
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Dataset.java
    jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Model.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/WebReader2.java
    jena/trunk/jena-arq/src/main/java/org/openjena/riot/RIOT.java
    jena/trunk/jena-arq/src/main/java/org/openjena/riot/SysRIOT.java
    jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java
    jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Dataset.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Dataset.java?rev=1412681&r1=1412680&r2=1412681&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Dataset.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Dataset.java Thu Nov 22 21:52:58
2012
@@ -198,7 +198,7 @@ public class IO_Dataset
     private static ReaderRIOT<Quad> getReaderQuads(ContentType ct)
     {
         Lang2 lang = RDFLanguages.contentTypeToLang(ct) ;
-        ReaderRIOTFactory<Quad> r = RDFParserRegistry.getFactoryQuads(lang) ;
+        ReaderRIOTFactory<Quad> r = ParserRegistry.getFactoryQuads(lang) ;
         if ( r == null )
             return null ;
         return r.create(lang) ;

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Model.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Model.java?rev=1412681&r1=1412680&r2=1412681&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Model.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/IO_Model.java Thu Nov 22 21:52:58
2012
@@ -237,7 +237,7 @@ public class IO_Model
     private static ReaderRIOT<Triple> getReaderTriples(ContentType ct)
     {
         Lang2 lang = RDFLanguages.contentTypeToLang(ct) ;
-        ReaderRIOTFactory<Triple> r = RDFParserRegistry.getFactoryTriples(lang) ;
+        ReaderRIOTFactory<Triple> r = ParserRegistry.getFactoryTriples(lang) ;
         if ( r == null )
             return null ;
         return r.create(lang) ;

Copied: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/ParserRegistry.java (from r1412666,
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/ParserRegistry.java?p2=jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/ParserRegistry.java&p1=jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/RDFParserRegistry.java&r1=1412666&r2=1412681&rev=1412681&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/ParserRegistry.java Thu Nov 22
21:52:58 2012
@@ -43,7 +43,7 @@ import static org.apache.jena.riot.RDFLa
  * 
  */
 
-public class RDFParserRegistry
+public class ParserRegistry
 {
     /** Map Jena I/O names to language */
     private static Map<String, Lang2> mapJenaNameToLang                 = DS.map()
;
@@ -53,15 +53,22 @@ public class RDFParserRegistry
     /** map language to a quads parser */ 
     private static Map<Lang2, ReaderRIOTFactory<Quad>> langToQuads      = DS.map()
;
 
-    static { init() ; }
-    
     /** Register a Jena IO name */
     private static void registerShortNameForLang(String name, Lang2 lang)
     {
         mapJenaNameToLang.put(RDFLanguages.canonicalKey(name), lang) ;
     }
 
-    public static void init()
+    private static boolean initialized = false ;
+    public static synchronized void init ()
+    {
+        if ( initialized ) return ;
+        initialized = true ;
+        initStandard() ;
+        
+    }
+    
+    private static void initStandard()
     {
         // Make sure the constants are initialized.
         RDFLanguages.init() ;
@@ -91,13 +98,13 @@ public class RDFParserRegistry
             
         registerShortNameForLang("TRIG",            langTriG) ;
         
-        registerLangTriples(langRDFXML, pfTriples) ;
-        registerLangTriples(langNTriples, pfTriples) ;
-        registerLangTriples(langTurtle, pfTriples) ;
-        registerLangTriples(langRDFJSON, pfTriples) ;
+        registerLangTriples(langRDFXML,     pfTriples) ;
+        registerLangTriples(langNTriples,   pfTriples) ;
+        registerLangTriples(langTurtle,     pfTriples) ;
+        registerLangTriples(langRDFJSON,    pfTriples) ;
         
-        registerLangQuads(langNQuads, pfQuads) ;
-        registerLangQuads(langTriG,   pfQuads) ;
+        registerLangQuads(langNQuads,       pfQuads) ;
+        registerLangQuads(langTriG,         pfQuads) ;
     }
 
     // ****

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=1412681&r1=1412680&r2=1412681&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 Thu Nov 22 21:52:58
2012
@@ -43,12 +43,10 @@ import org.openjena.riot.RiotException ;
 import com.hp.hpl.jena.util.FileUtils ;
 
 /** Central registry of RDF langauges and syntaxes.
- * @see RDFParserRegistry
+ * @see ParserRegistry
  */
 public class RDFLanguages
 {
-    public static  void init () { initStandard() ; }
-    
     public static final String strLangRDFXML     = "RDF/XML" ;
     public static final String strLangTurtle     = "Turtle" ;
     public static final String strLangNTriples   = "N-Triples" ;
@@ -109,6 +107,14 @@ public class RDFLanguages
     private static Map<String, Lang2> mapLabelToLang                    = DS.map()
;
     
     // ----------------------
+    private static boolean initialized = false ;
+    public static synchronized void init ()
+    {
+        if ( initialized ) return ;
+        initialized = true ;
+        initStandard() ;
+    }
+    // ----------------------
     
     /** Standard built-in languages */  
     public static void initStandard()
@@ -124,11 +130,11 @@ public class RDFLanguages
     /** Register a language.
      * To create a {@link Lang2} object use {@link LangBuilder}.
      * See also 
-     * {@link RDFParserRegistry#registerLangTriples} and 
-     * {@link RDFParserRegistry#registerLangQuads}
+     * {@link ParserRegistry#registerLangTriples} and 
+     * {@link ParserRegistry#registerLangQuads}
      * for registering a language and it's RDF parser fatory.
      * 
-     * @see RDFParserRegistry
+     * @see ParserRegistry
      */
     public static void register(Lang2 lang)
     {
@@ -181,10 +187,10 @@ public class RDFLanguages
     }
     
     /** return true if the language is registered with the triples parser factories */
-    public static boolean isTriples(Lang2 lang) { return RDFParserRegistry.isTriples(lang)
; }
+    public static boolean isTriples(Lang2 lang) { return ParserRegistry.isTriples(lang) ;
}
     
     /** return true if the language is registered with the quads parser factories */
-    public static boolean isQuads(Lang2 lang)   { return RDFParserRegistry.isQuads(lang)
; }
+    public static boolean isQuads(Lang2 lang)   { return ParserRegistry.isQuads(lang) ; }
     
     /** Map a content type (without charset) to a {@link Lang2} */
     public static Lang2 contentTypeToLang(String contentType)

Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/WebReader2.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/WebReader2.java?rev=1412681&r1=1412680&r2=1412681&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/WebReader2.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/WebReader2.java Thu Nov 22 21:52:58
2012
@@ -455,7 +455,10 @@ public class WebReader2
 
         ReaderRIOT<Triple> reader = getReaderTriples(ct) ;
         if ( reader == null )
+        {
+            getReaderTriples(ct) ;
             throw new RiotException("No triples reader for content type: "+ct.getContentType())
;
+        }
         
         reader.read(in.getInput(), baseUri, ct, sink, context) ;
     }
@@ -463,7 +466,7 @@ public class WebReader2
     private static ReaderRIOT<Triple> getReaderTriples(ContentType ct)
     {
         Lang2 lang = RDFLanguages.contentTypeToLang(ct) ;
-        ReaderRIOTFactory<Triple> r = RDFParserRegistry.getFactoryTriples(lang) ;
+        ReaderRIOTFactory<Triple> r = ParserRegistry.getFactoryTriples(lang) ;
         if ( r == null )
             return null ;
         return r.create(lang) ;
@@ -505,7 +508,7 @@ public class WebReader2
     private static ReaderRIOT<Quad> getReaderQuads(ContentType ct)
     {
         Lang2 lang = RDFLanguages.contentTypeToLang(ct) ;
-        ReaderRIOTFactory<Quad> r = RDFParserRegistry.getFactoryQuads(lang) ;
+        ReaderRIOTFactory<Quad> r = ParserRegistry.getFactoryQuads(lang) ;
         if ( r == null )
             return null ;
         return r.create(lang) ;

Modified: jena/trunk/jena-arq/src/main/java/org/openjena/riot/RIOT.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/openjena/riot/RIOT.java?rev=1412681&r1=1412680&r2=1412681&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/openjena/riot/RIOT.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/openjena/riot/RIOT.java Thu Nov 22 21:52:58 2012
@@ -18,6 +18,8 @@
 
 package org.openjena.riot;
 
+import org.apache.jena.riot.ParserRegistry ;
+import org.apache.jena.riot.RDFLanguages ;
 import org.apache.jena.riot.WebReader2 ;
 
 import com.hp.hpl.jena.query.ARQ ;
@@ -66,6 +68,9 @@ public class RIOT
         ARQMgt.register(NS+".system:type=SystemInfo", sysInfo2) ;
         SystemARQ.registerSubSystem(sysInfo2) ;
         
+        RDFLanguages.init() ;
+        ParserRegistry.init() ;
+        
         SysRIOT.wireIntoJena() ;
         WebReader2.wireIntoJena() ;
     }

Modified: jena/trunk/jena-arq/src/main/java/org/openjena/riot/SysRIOT.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/openjena/riot/SysRIOT.java?rev=1412681&r1=1412680&r2=1412681&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/openjena/riot/SysRIOT.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/openjena/riot/SysRIOT.java Thu Nov 22 21:52:58 2012
@@ -18,13 +18,11 @@
 
 package org.openjena.riot;
 
-import org.apache.jena.riot.RDFLanguages ;
-import org.apache.jena.riot.RDFParserRegistry ;
 import org.openjena.atlas.event.EventType ;
 import org.openjena.riot.system.JenaReaderNTriples2 ;
 import org.openjena.riot.system.JenaReaderRdfJson ;
 import org.openjena.riot.system.JenaReaderTurtle2 ;
-import org.openjena.riot.system.JenaWriterRdfJson;
+import org.openjena.riot.system.JenaWriterRdfJson ;
 import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
 
@@ -42,7 +40,6 @@ public class SysRIOT
     public static boolean strictMode             = false ;
     
     public static final String BNodeGenIdPrefix = "genid" ;
-
     
     static public String fmtMessage(String message, long line, long col)
     {
@@ -67,10 +64,7 @@ public class SysRIOT
     
     public static void wireIntoJena()
     {
-        RDFLanguages.init() ;
-        RDFParserRegistry.init() ;
-
-        
+        RIOT.init() ;
         /* No getter (!!)
          * Standard:
             com.hp.hpl.jena.rdf.model.impl.NTripleReader

Modified: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java?rev=1412681&r1=1412680&r2=1412681&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/TC_Riot.java Thu Nov 22 21:52:58
2012
@@ -20,8 +20,10 @@ package org.apache.jena.riot;
 
 import org.apache.jena.riot.adapters.TS_RIOTAdapters ;
 import org.apache.jena.riot.stream.TS_IO2 ;
+import org.junit.BeforeClass ;
 import org.junit.runner.RunWith ;
 import org.junit.runners.Suite ;
+import org.openjena.riot.RIOT ;
 import org.openjena.riot.TS_Riot ;
 
 @RunWith(Suite.class)
@@ -33,5 +35,11 @@ import org.openjena.riot.TS_Riot ;
       , TS_RIOTAdapters.class
 })
 
+
 public class TC_Riot
-{}
+{
+    @BeforeClass public static void beforeClass()
+    { 
+        RIOT.init() ;
+    }
+}

Modified: jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java?rev=1412681&r1=1412680&r2=1412681&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java Thu Nov 22 21:52:58 2012
@@ -63,7 +63,6 @@ public class TS_Riot
     @BeforeClass public static void beforeClass()
     { 
         BaseTest.setTestLogging() ;
-        SysRIOT.wireIntoJena() ;
     }
 
     @AfterClass public static void afterClass()



Mime
View raw message