commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [7/8] incubator-commonsrdf git commit: cleaner .stream() calls
Date Mon, 04 Jul 2016 11:24:04 GMT
cleaner .stream() calls


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

Branch: refs/heads/jena
Commit: c4311b36e4dd7e7b6d04bb1cf27848e1341e979c
Parents: 53c4dea
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Mon Jul 4 12:21:09 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Mon Jul 4 12:21:09 2016 +0100

----------------------------------------------------------------------
 .../apache/commons/rdf/jena/JenaCommonsRDF.java  | 16 ++++++++++++----
 .../apache/commons/rdf/jena/impl/JCR_Graph.java  | 19 ++++++++++---------
 2 files changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c4311b36/jena/src/main/java/org/apache/commons/rdf/jena/JenaCommonsRDF.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaCommonsRDF.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaCommonsRDF.java
index 04caeb7..1423a78 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaCommonsRDF.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/JenaCommonsRDF.java
@@ -21,14 +21,22 @@ package org.apache.commons.rdf.jena;
 import java.util.Optional;
 import java.util.function.Consumer;
 
-import org.apache.commons.rdf.api.* ;
-import org.apache.commons.rdf.jena.impl.*;
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Literal;
+import org.apache.commons.rdf.api.Quad;
+import org.apache.commons.rdf.api.RDFSyntax;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.RDFTermFactory;
+import org.apache.commons.rdf.api.Triple;
+import org.apache.commons.rdf.jena.impl.JCR_Factory;
 import org.apache.jena.datatypes.RDFDatatype ;
 import org.apache.jena.datatypes.xsd.XSDDatatype ;
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.NodeFactory ;
 import org.apache.jena.riot.Lang;
-import org.apache.jena.riot.RDFDataMgr;
 import org.apache.jena.riot.RDFLanguages;
 import org.apache.jena.riot.system.StreamRDF ;
 import org.apache.jena.riot.system.StreamRDFBase;
@@ -89,7 +97,7 @@ public class JenaCommonsRDF {
         if ( graph instanceof JenaGraph )
             return ((JenaGraph)graph).getGraph() ;
         org.apache.jena.graph.Graph g = GraphFactory.createGraphMem() ;
-        graph.getTriples().forEach(t->g.add(toJena(t))) ; 
+        graph.stream().forEach(t->g.add(toJena(t))) ; 
         return g ;   
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c4311b36/jena/src/main/java/org/apache/commons/rdf/jena/impl/JCR_Graph.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JCR_Graph.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JCR_Graph.java
index c8bbdca..e8d241e 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JCR_Graph.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JCR_Graph.java
@@ -19,10 +19,13 @@
 package org.apache.commons.rdf.jena.impl;
 
 import java.io.StringWriter ;
-import java.util.Iterator ;
 import java.util.stream.Stream ;
 
-import org.apache.commons.rdf.api.* ;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.Triple;
 import org.apache.commons.rdf.jena.JenaCommonsRDF;
 import org.apache.commons.rdf.jena.JenaGraph;
 import org.apache.jena.atlas.iterator.Iter ;
@@ -84,16 +87,14 @@ public class JCR_Graph implements Graph, JenaGraph {
     }
 
     @Override
-    public Stream<? extends Triple> getTriples() {
-        return getTriples(null, null, null) ;
+    public Stream<? extends Triple> stream() {
+    	return Iter.asStream(graph.find(null, null, null), true).map(JenaCommonsRDF::fromJena);
     }
 
     @Override
-    public Stream<? extends Triple> getTriples(BlankNodeOrIRI subject, IRI predicate,
RDFTerm object) {
-        Iterator<org.apache.jena.graph.Triple> iter = graph.find(toJenaAny(subject),toJenaAny(predicate),toJenaAny(object))
;
-        Iterator<Triple> iter2 = Iter.map(iter, t-> JenaCommonsRDF.fromJena(t))
;
-        return Iter.asStream(iter2) ;
-                        
+    public Stream<? extends Triple> stream(BlankNodeOrIRI s, IRI p, RDFTerm o) {
+        return Iter.asStream(graph.find(toJenaAny(s),toJenaAny(p),toJenaAny(o)), true).
+        		map(JenaCommonsRDF::fromJena);
     }
 
     private Node toJenaAny(RDFTerm term) {


Mime
View raw message