commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [27/33] incubator-commonsrdf git commit: Avoid re-wrapping for RDFTermFactoryJena
Date Mon, 28 Mar 2016 04:55:23 GMT
Avoid re-wrapping for RDFTermFactoryJena


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

Branch: refs/heads/jena
Commit: aa5f797744cc4dd7fe0e0daf674f4265f7ff3ad8
Parents: 8fcf85c
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Mon Mar 28 05:20:39 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Mon Mar 28 05:20:39 2016 +0100

----------------------------------------------------------------------
 .../org/apache/commons/rdf/jena/JenaCommonsRDF.java  | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/aa5f7977/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 a0fb178..8bf8b6d 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
@@ -106,6 +106,10 @@ public class JenaCommonsRDF {
 
     /** Convert from Jena {@link Node} to any RDFCommons implementation */
     public static RDFTerm fromJena(RDFTermFactory factory, Node node) {
+    	if (factory instanceof RDFTermFactoryJena) {
+    		// No need to convert, just wrap
+    		return fromJena(node);
+    	}
         if ( node.isURI() )
             return factory.createIRI(node.getURI()) ;
         if ( node.isLiteral() ) {
@@ -124,6 +128,10 @@ public class JenaCommonsRDF {
 
     /** Convert from Jena {@link org.apache.jena.graph.Triple} to any RDFCommons implementation
*/
    public static Triple fromJena(RDFTermFactory factory, org.apache.jena.graph.Triple triple)
{
+	   	if (factory instanceof RDFTermFactoryJena) {
+			// No need to convert, just wrap
+			return fromJena(triple);
+		}
         BlankNodeOrIRI subject = (BlankNodeOrIRI)(fromJena(factory, triple.getSubject()))
;
         IRI predicate = (IRI)(fromJena(factory, triple.getPredicate())) ;
         RDFTerm object = fromJena(factory, triple.getObject()) ;
@@ -135,7 +143,12 @@ public class JenaCommonsRDF {
     *  Use {@link #fromJena(org.apache.jena.graph.Graph)} for a wrapper.
     */
    public static Graph fromJena(RDFTermFactory factory, org.apache.jena.graph.Graph graph)
{
-       Graph g = factory.createGraph() ;
+	   	if (factory instanceof RDFTermFactoryJena) {
+			// No need to convert, just wrap
+			return fromJena(graph);
+		}
+
+	   Graph g = factory.createGraph() ;
        graph.find(Node.ANY, Node.ANY, Node.ANY).forEachRemaining( t-> {
            g.add(fromJena(factory, t) );
        }) ;


Mime
View raw message