jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1374272 - in /jena/Experimental/riot-reader: ./ src/main/java/riot_reader/WebReader2.java src/test/java/riot_reader/TestJenaReaderRIOT.java
Date Fri, 17 Aug 2012 14:08:08 GMT
Author: andy
Date: Fri Aug 17 14:08:07 2012
New Revision: 1374272

URL: http://svn.apache.org/viewvc?rev=1374272&view=rev
Log:
Bodge to make more of unmodified standard Jena work.

Modified:
    jena/Experimental/riot-reader/   (props changed)
    jena/Experimental/riot-reader/src/main/java/riot_reader/WebReader2.java
    jena/Experimental/riot-reader/src/test/java/riot_reader/TestJenaReaderRIOT.java

Propchange: jena/Experimental/riot-reader/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Aug 17 14:08:07 2012
@@ -0,0 +1 @@
+target

Modified: jena/Experimental/riot-reader/src/main/java/riot_reader/WebReader2.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-reader/src/main/java/riot_reader/WebReader2.java?rev=1374272&r1=1374271&r2=1374272&view=diff
==============================================================================
--- jena/Experimental/riot-reader/src/main/java/riot_reader/WebReader2.java (original)
+++ jena/Experimental/riot-reader/src/main/java/riot_reader/WebReader2.java Fri Aug 17 14:08:07
2012
@@ -74,19 +74,39 @@ public class WebReader2
 
     public static void wireIntoJena()
     {
-        // Wire in generic 
-        String readerRDF = RDFReaderRIOT.class.getName() ;
-        RDFReaderFImpl.setBaseReaderClassName("RDF/XML",    readerRDF) ;           // And
default
-        RDFReaderFImpl.setBaseReaderClassName("RDF/XML-ABBREV", readerRDF) ;
-
-        RDFReaderFImpl.setBaseReaderClassName("N-TRIPLES",  readerRDF) ;
-        RDFReaderFImpl.setBaseReaderClassName("N-TRIPLE",   readerRDF) ;
-        RDFReaderFImpl.setBaseReaderClassName("N3",         readerRDF) ;
-        RDFReaderFImpl.setBaseReaderClassName("TURTLE",     readerRDF) ;
-        RDFReaderFImpl.setBaseReaderClassName("Turtle",     readerRDF) ;
-        RDFReaderFImpl.setBaseReaderClassName("TTL",        readerRDF) ;
-        RDFReaderFImpl.setBaseReaderClassName("RDF/JSON",   readerRDF) ;
-    }
+//        // Wire in generic 
+//        String readerRDF = RDFReaderRIOT.class.getName() ;
+//        RDFReaderFImpl.setBaseReaderClassName("RDF/XML",    readerRDF) ;           // And
default
+//        RDFReaderFImpl.setBaseReaderClassName("RDF/XML-ABBREV", readerRDF) ;
+//
+//        RDFReaderFImpl.setBaseReaderClassName("N-TRIPLES",  readerRDF) ;
+//        RDFReaderFImpl.setBaseReaderClassName("N-TRIPLE",   readerRDF) ;
+//        RDFReaderFImpl.setBaseReaderClassName("N3",         readerRDF) ;
+//        RDFReaderFImpl.setBaseReaderClassName("TURTLE",     readerRDF) ;
+//        RDFReaderFImpl.setBaseReaderClassName("Turtle",     readerRDF) ;
+//        RDFReaderFImpl.setBaseReaderClassName("TTL",        readerRDF) ;
+//        RDFReaderFImpl.setBaseReaderClassName("RDF/JSON",   readerRDF) ;
+        
+      RDFReaderFImpl.setBaseReaderClassName("RDF/XML",    RDFReaderRIOT_RDFXML.class.getName())
;           // And default
+      RDFReaderFImpl.setBaseReaderClassName("RDF/XML-ABBREV", RDFReaderRIOT_RDFXML.class.getName())
;
+
+      RDFReaderFImpl.setBaseReaderClassName("N-TRIPLES",  RDFReaderRIOT_NT.class.getName())
;
+      RDFReaderFImpl.setBaseReaderClassName("N-TRIPLE",   RDFReaderRIOT_NT.class.getName())
;
+      RDFReaderFImpl.setBaseReaderClassName("N3",         RDFReaderRIOT_TTL.class.getName())
;
+      RDFReaderFImpl.setBaseReaderClassName("TURTLE",     RDFReaderRIOT_TTL.class.getName())
;
+      RDFReaderFImpl.setBaseReaderClassName("Turtle",     RDFReaderRIOT_TTL.class.getName())
;
+      RDFReaderFImpl.setBaseReaderClassName("TTL",        RDFReaderRIOT_TTL.class.getName())
;
+      RDFReaderFImpl.setBaseReaderClassName("RDF/JSON",   RDFReaderRIOT_RDFJSON.class.getName())
;
+    }
+    
+    // Yukky hack to integrate into current jena-core where the structure of model.read assumes
+    // the language is determined before the reading process starts.
+    
+    public static class RDFReaderRIOT_RDFXML extends RDFReaderRIOT   { public RDFReaderRIOT_RDFXML()
{ super("RDF/XML") ; } }
+    public static class RDFReaderRIOT_TTL extends RDFReaderRIOT      { public RDFReaderRIOT_TTL()
{ super("TTL") ; } }
+    public static class RDFReaderRIOT_NT extends RDFReaderRIOT       { public RDFReaderRIOT_NT()
{ super("N-TRIPLE") ; } }
+    public static class RDFReaderRIOT_RDFJSON extends RDFReaderRIOT  { public RDFReaderRIOT_RDFJSON()
{ super("RDF/JSON") ; } }
+
     
     public static void resetJenaReaders()
     {

Modified: jena/Experimental/riot-reader/src/test/java/riot_reader/TestJenaReaderRIOT.java
URL: http://svn.apache.org/viewvc/jena/Experimental/riot-reader/src/test/java/riot_reader/TestJenaReaderRIOT.java?rev=1374272&r1=1374271&r2=1374272&view=diff
==============================================================================
--- jena/Experimental/riot-reader/src/test/java/riot_reader/TestJenaReaderRIOT.java (original)
+++ jena/Experimental/riot-reader/src/test/java/riot_reader/TestJenaReaderRIOT.java Fri Aug
17 14:08:07 2012
@@ -75,21 +75,32 @@ public class TestJenaReaderRIOT extends 
     
     @Test public void read_30()
     {
-        TypedInputStream2 in = WebReader2.open(filename("D-not-TTL.ttl") );
-        Model m0 = ModelFactory.createDefaultModel() ;
-        WebReader2.read(m0, in.getInput(), Langs.langRDFXML) ;
+        {
+            TypedInputStream2 in = WebReader2.open(filename("D-not-TTL.ttl") );
+            Model m0 = ModelFactory.createDefaultModel() ;
+            WebReader2.read(m0, in.getInput(), Langs.langRDFXML) ;
+        }
+
+        TypedInputStream2 in1 = WebReader2.open(filename("D-not-TTL.ttl") );
         Model m1 = ModelFactory.createDefaultModel() ;
         // Fails until integration with jena-core as hintlang gets lost.
-        m1.read(in.getInput(), null, "RDF/XML") ;
+        m1.read(in1.getInput(), null, "RDF/XML") ;
     }
     
     // test read from StringReader..
     @Test public void read_31()
     {
-        StringReader s = new StringReader("<s> <p> <p> .") ;
-        Model m = ModelFactory.createDefaultModel() ;
-        WebReader2.read(m, s, null, Langs.langNTriples) ;
-        m.read(s, null, "N-TRIPLES") ;
+        String x = "<s> <p> <p> ." ;
+        
+        {
+            StringReader s = new StringReader(x) ;
+            Model m = ModelFactory.createDefaultModel() ;
+            WebReader2.read(m, s, null, Langs.langNTriples) ;
+        }
+        
+        StringReader s1 = new StringReader("<s> <p> <p> .") ;
+        Model m1 = ModelFactory.createDefaultModel() ;
+        m1.read(s1, null, "N-TRIPLES") ;
     }
     
     @Test public void read_32()
@@ -102,10 +113,14 @@ public class TestJenaReaderRIOT extends 
             "     <j.0:p rdf:resource=\"http://example/o\"/>" ,
             "   </rdf:Description>" ,
             "</rdf:RDF>") ;
-        StringReader s = new StringReader(x) ;
+        {
+            StringReader s = new StringReader(x) ;
+            Model m = ModelFactory.createDefaultModel() ;
+            WebReader2.read(m, s, null, Langs.langRDFXML) ;
+        }
+        StringReader s1 = new StringReader(x) ;
         Model m = ModelFactory.createDefaultModel() ;
-        WebReader2.read(m, s, null, Langs.langRDFXML) ;
-        m.read(s, null, "RDF/XML") ;
+        m.read(s1, null, "RDF/XML") ;
     }
 
     // Stream opening is hardwired into jena!



Mime
View raw message