commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [08/33] incubator-commonsrdf git commit: Sort out examples
Date Mon, 28 Mar 2016 04:55:04 GMT
Sort out examples


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/ce34d558
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/ce34d558
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/ce34d558

Branch: refs/heads/jena
Commit: ce34d5585a278de387772d24a0597dcfcb3c5b6f
Parents: 4e8e597
Author: Andy Seaborne <andy@seaborne.org>
Authored: Thu Aug 27 15:56:15 2015 +0100
Committer: Andy Seaborne <andy@seaborne.org>
Committed: Thu Aug 27 15:56:15 2015 +0100

----------------------------------------------------------------------
 .../examples/Ex_JenaGraphToCommonsRDFGraph.java | 55 +++++++++++++++++
 .../examples/Ex_ParseIntoCommonsRDFGraph.java   | 42 +++++++++++++
 .../jena/commonsrdf/examples/Example1.java      | 63 --------------------
 3 files changed, 97 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ce34d558/src/main/java/org/apache/jena/commonsrdf/examples/Ex_JenaGraphToCommonsRDFGraph.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/jena/commonsrdf/examples/Ex_JenaGraphToCommonsRDFGraph.java
b/src/main/java/org/apache/jena/commonsrdf/examples/Ex_JenaGraphToCommonsRDFGraph.java
new file mode 100644
index 0000000..346d2ca
--- /dev/null
+++ b/src/main/java/org/apache/jena/commonsrdf/examples/Ex_JenaGraphToCommonsRDFGraph.java
@@ -0,0 +1,55 @@
+/**
+ * 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.commonsrdf.examples;
+
+import org.apache.commons.rdf.api.Graph ;
+import org.apache.commons.rdf.api.RDFTermFactory ;
+import org.apache.jena.atlas.logging.LogCtl ;
+import org.apache.jena.commonsrdf.JenaCommonsRDF ;
+import org.apache.jena.commonsrdf.RDFTermFactoryJena ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.sparql.graph.GraphFactory ;
+
+/** Adapt a Jena Graph after parsing data into it */
+public class Ex_JenaGraphToCommonsRDFGraph {
+    static { LogCtl.setCmdLogging(); }
+    
+    public static void main(String ...a) {
+        org.apache.jena.graph.Graph jGraph = GraphFactory.createGraphMem() ;
+        RDFDataMgr.read(jGraph, "D.ttl") ;
+        
+        // "graph" is a 
+        Graph graph = JenaCommonsRDF.fromJena(jGraph) ;
+        
+        
+        // Add to CommonsRDF Graph
+        RDFTermFactory rft = new RDFTermFactoryJena() ;
+        graph.add(rft.createIRI("http://example/s2"),
+                  rft.createIRI("http://example/p2"),
+                  rft.createLiteral("foo")) ;
+        System.out.println("==== Write CommonsRDF graph\n") ;
+        graph.getTriples().forEach(System.out::println) ;
+        
+        System.out.println("\n==== Write Jena graph directly\n") ;
+        // And its in the Jena graph
+        RDFDataMgr.write(System.out, jGraph, Lang.TTL) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ce34d558/src/main/java/org/apache/jena/commonsrdf/examples/Ex_ParseIntoCommonsRDFGraph.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/jena/commonsrdf/examples/Ex_ParseIntoCommonsRDFGraph.java
b/src/main/java/org/apache/jena/commonsrdf/examples/Ex_ParseIntoCommonsRDFGraph.java
new file mode 100644
index 0000000..b3dd218
--- /dev/null
+++ b/src/main/java/org/apache/jena/commonsrdf/examples/Ex_ParseIntoCommonsRDFGraph.java
@@ -0,0 +1,42 @@
+/**
+ * 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.commonsrdf.examples;
+
+import org.apache.commons.rdf.api.Graph ;
+import org.apache.commons.rdf.api.RDFTermFactory ;
+import org.apache.jena.atlas.logging.LogCtl ;
+import org.apache.jena.commonsrdf.JenaCommonsRDF ;
+import org.apache.jena.commonsrdf.RDFTermFactoryJena ;
+import org.apache.jena.riot.RDFDataMgr ;
+import org.apache.jena.riot.system.StreamRDF ;
+
+/** Use jena to parse data into an CommonsRDF graph */
+public class Ex_ParseIntoCommonsRDFGraph {
+    static { LogCtl.setCmdLogging(); }
+    
+    public static void main(String ...a) {
+        RDFTermFactory rft = new RDFTermFactoryJena() ; // This can be a non-Jena backed
factory 
+        Graph graph = rft.createGraph() ;
+        StreamRDF dest = JenaCommonsRDF.streamJenaToCommonsRDF(rft, graph) ;
+        RDFDataMgr.parse(dest, "D.ttl") ;
+        System.out.println("==== Write CommonsRDF graph\n") ;
+        graph.getTriples().forEach(System.out::println) ;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ce34d558/src/main/java/org/apache/jena/commonsrdf/examples/Example1.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/jena/commonsrdf/examples/Example1.java b/src/main/java/org/apache/jena/commonsrdf/examples/Example1.java
deleted file mode 100644
index 9c9d5f2..0000000
--- a/src/main/java/org/apache/jena/commonsrdf/examples/Example1.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * 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.commonsrdf.examples;
-
-import org.apache.commons.rdf.api.Graph ;
-import org.apache.commons.rdf.api.RDFTermFactory ;
-import org.apache.jena.atlas.logging.LogCtl ;
-import org.apache.jena.commonsrdf.JenaCommonsRDF ;
-import org.apache.jena.commonsrdf.RDFTermFactoryJena ;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.riot.system.StreamRDF ;
-import org.apache.jena.sparql.graph.GraphFactory ;
-
-/** Short examples */
-public class Example1 {
-    static { LogCtl.setCmdLogging(); }
-    
-    public static void main(String ...a) {
-        jenaGraphToCommonsRDFGraph() ;
-    }
-    
-    public static void jenaGraphToCommonsRDFGraph() {
-        org.apache.jena.graph.Graph jGraph = GraphFactory.createGraphMem() ;
-        RDFDataMgr.read(jGraph, "D.ttl") ;
-        
-        Graph graph = JenaCommonsRDF.fromJena(jGraph) ;
-        
-        
-        // Add to CommonsRDF Graph
-        RDFTermFactory rft = new RDFTermFactoryJena() ;
-        graph.add(rft.createIRI("http://example/s2"),
-                  rft.createIRI("http://example/p2"),
-                  rft.createLiteral("foo")) ;
-        graph.getTriples().forEach(System.out::println) ;
-    }
-
-    public static void parseIntoCommonsRDFGraph() {
-        RDFTermFactory rft = new RDFTermFactoryJena() ;
-        Graph graph = rft.createGraph() ;
-        StreamRDF dest = JenaCommonsRDF.streamJenaToCommonsRDF(rft, graph) ;
-        RDFDataMgr.parse(dest, "D.ttl") ;
-        graph.getTriples().forEach(System.out::println) ;
-    }
-
-    
-}
-


Mime
View raw message