commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [5/8] incubator-commonsrdf git commit: avoid 'static' in JenaRDFTermFactory
Date Fri, 07 Oct 2016 13:48:23 GMT
avoid 'static' in JenaRDFTermFactory


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

Branch: refs/heads/jena
Commit: edc303640de509e838628249b27b344f22fa61ae
Parents: 35e1366
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Oct 7 14:08:19 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Oct 7 14:09:40 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/jena/JenaRDFTermFactory.java    | 12 ++-----
 .../commons/rdf/jena/impl/JenaDatasetImpl.java  | 26 ++++++++-------
 .../rdf/jena/impl/JenaGeneralizedQuad.java      | 17 +++++-----
 .../commons/rdf/jena/impl/JenaGraphImpl.java    | 33 +++++++++++---------
 4 files changed, 45 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/edc30364/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
index 10d8fa1..aa4bacf 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
@@ -205,7 +205,6 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * {@link Node#getBlankNodeId()} for the purpose of its
 	 * {@link BlankNode#uniqueReference()}.
 	 * 
-	 * @see #fromJena(Node, UUID)
 	 * @see #fromJena(RDFTermFactory, Node)
 	 * 
 	 * @param node
@@ -229,7 +228,6 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * for multiple conversion sessions.
 	 * 
 	 * @see #fromJena(Node)
-	 * @see #fromJena(Node, UUID)
 	 * 
 	 * @param factory {@link RDFTermFactory} to use for creating {@link RDFTerm}.
 	 * @param node
@@ -273,7 +271,6 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * {@link Node#getBlankNodeId()} for the purpose of its
 	 * {@link BlankNode#uniqueReference()}.
 	 *
-	 * @see #fromJena(org.apache.jena.graph.Triple, UUID)
 	 * @see #fromJena(RDFTermFactory, org.apache.jena.graph.Triple)
 	 * 
 	 * @param triple
@@ -300,7 +297,6 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * {@link Node#getBlankNodeId()} for the purpose of its
 	 * {@link BlankNode#uniqueReference()}.
 	 *
-	 * @see #fromJena(org.apache.jena.graph.Triple, UUID)
 	 * @see #fromJena(RDFTermFactory, org.apache.jena.graph.Triple)
 	 * 
 	 * @param triple
@@ -357,7 +353,6 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * for multiple conversion sessions.
 	 * 
 	 * @see #fromJena(org.apache.jena.graph.Triple)
-	 * @see #fromJena(org.apache.jena.graph.Triple, UUID)
 	 *
 	 * @param factory {@link RDFTermFactory} to use for creating the {@link Triple} and its
 	 * {@link RDFTerm}s.
@@ -494,7 +489,6 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * instance for multiple conversion sessions.
 	 * 
 	 * @see #fromJena(org.apache.jena.sparql.core.Quad)
-	 * @see #fromJena(org.apache.jena.sparql.core.Quad, UUID)
 	 * @see #fromJenaGeneralized(org.apache.jena.sparql.core.Quad)
 	 *
 	 * @param factory
@@ -637,7 +631,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * @param term Commons RDF {@link RDFTerm} to convert
 	 * @return Converted Jena {@link Node}
 	 */
-	public static Node toJena(RDFTerm term) {
+	public Node toJena(RDFTerm term) {
 		if (term == null) {
 			return null;
 		}
@@ -674,7 +668,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * @param triple Commons RDF {@link Triple} to convert
 	 * @return Converted Jena {@link org.apache.jena.graph.Triple}
 	 */
-	public static org.apache.jena.graph.Triple toJena(Triple triple) {
+	public org.apache.jena.graph.Triple toJena(Triple triple) {
 		if (triple instanceof JenaTriple)
 			return ((JenaTriple) triple).asJenaTriple();
 		return org.apache.jena.graph.Triple.create(
@@ -694,7 +688,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * @param quad Commons RDF {@link Quad} to convert
 	 * @return Converted Jena {@link org.apache.jena.sparql.core.Quad}
 	 */
-	public static org.apache.jena.sparql.core.Quad toJena(Quad quad) {
+	public org.apache.jena.sparql.core.Quad toJena(Quad quad) {
 		if (quad instanceof JenaQuad) {
 			return ((JenaQuad) quad).asJenaQuad();
 		}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/edc30364/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
index 4cd6bd1..76b018c 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
@@ -44,25 +44,27 @@ public class JenaDatasetImpl implements JenaDataset {
 
 	private DatasetGraph graph;
 	private UUID salt;
+	private JenaRDFTermFactory factory;
 
-	/* package */ JenaDatasetImpl(DatasetGraph graph, UUID salt) {
+	JenaDatasetImpl(DatasetGraph graph, UUID salt) {
 		this.graph = graph;
 		this.salt = salt;
+		this.factory = new JenaRDFTermFactory(salt);
 	}
 
 	@Override
 	public void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm
object) {
 		graph.add(				
 				org.apache.jena.sparql.core.Quad.create(
-				JenaRDFTermFactory.toJena(graphName),
-				JenaRDFTermFactory.toJena(subject),				
-				JenaRDFTermFactory.toJena(predicate), 
-				JenaRDFTermFactory.toJena(object)));
+				factory.toJena(graphName),
+				factory.toJena(subject),				
+				factory.toJena(predicate), 
+				factory.toJena(object)));
 	}
 
 	@Override
 	public void add(Quad quad) {
-		graph.add(JenaRDFTermFactory.toJena(quad));
+		graph.add(factory.toJena(quad));
 	}
 	
 	@Override
@@ -92,25 +94,25 @@ public class JenaDatasetImpl implements JenaDataset {
 
 	private Node toJenaPattern(Optional<? extends RDFTerm> graphName) {
 		// In theory we could have done:
-		//   JenaRDFTermFactory.toJena(graphName.orElse(JenaFactory::createAnyVariable))
+		//   factory.toJena(graphName.orElse(JenaFactory::createAnyVariable))
 		// but because of generics casting rules that doesn't work :(						
 
 		if (graphName == null) {
 			return ANY;
 		}
 		// null: default graph
-		return JenaRDFTermFactory.toJena(graphName.orElse(null));
+		return factory.toJena(graphName.orElse(null));
 	}
 
 	private Node toJenaPattern(RDFTerm term) {
 		if (term == null)
 			return ANY;
-		return JenaRDFTermFactory.toJena(term);
+		return factory.toJena(term);
 	}
 
 	@Override
 	public boolean contains(Quad quad) {
-		return graph.contains(JenaRDFTermFactory.toJena(quad));
+		return graph.contains(factory.toJena(quad));
 	}
 
 	@Override
@@ -124,7 +126,7 @@ public class JenaDatasetImpl implements JenaDataset {
 
 	@Override
 	public void remove(Quad quad) {
-		graph.delete(JenaRDFTermFactory.toJena(quad));
+		graph.delete(factory.toJena(quad));
 	}
 
 	@Override
@@ -167,7 +169,7 @@ public class JenaDatasetImpl implements JenaDataset {
 	
 	@Override
 	public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
-		GraphView gv = GraphView.createNamedGraph(graph, JenaRDFTermFactory.toJena(graphName));
+		GraphView gv = GraphView.createNamedGraph(graph, factory.toJena(graphName));
 		return Optional.of(new JenaGraphImpl(gv, salt));
 	}	
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/edc30364/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuad.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuad.java
b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuad.java
index 5456ec9..cad2355 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuad.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGeneralizedQuad.java
@@ -84,22 +84,25 @@ public class JenaGeneralizedQuad<S extends RDFTerm, P extends RDFTerm,
O extends
 
 	@Override
 	public org.apache.jena.sparql.core.Quad asJenaQuad() {
+		JenaRDFTermFactory factory = new JenaRDFTermFactory();
 		if (quad == null) {
 			quad = org.apache.jena.sparql.core.Quad.create(
-					JenaRDFTermFactory.toJena(graphName.orElse(null)),
-					JenaRDFTermFactory.toJena(subject), 
-					JenaRDFTermFactory.toJena(predicate),
-					JenaRDFTermFactory.toJena(object));
+					factory.toJena(graphName.orElse(null)),
+					factory.toJena(subject), 
+					factory.toJena(predicate),
+					factory.toJena(object));
 		}
 		return quad;
 	}
 
 	@Override
 	public org.apache.jena.graph.Triple asJenaTriple() {
+		JenaRDFTermFactory factory = new JenaRDFTermFactory();
 		if (triple == null) {
-			triple = org.apache.jena.graph.Triple.create(JenaRDFTermFactory.toJena(subject), 
-				JenaRDFTermFactory.toJena(predicate),
-				JenaRDFTermFactory.toJena(object));
+			triple = org.apache.jena.graph.Triple.create(
+				factory.toJena(subject), 
+				factory.toJena(predicate),
+				factory.toJena(object));
 		}
 		return triple;
 	}	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/edc30364/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
index 49a09ae..89162e0 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
@@ -37,32 +37,35 @@ import org.apache.jena.riot.RDFDataMgr;
 
 public class JenaGraphImpl implements JenaGraph {
 
-	private org.apache.jena.graph.Graph graph;
-	private UUID salt;
+	private final org.apache.jena.graph.Graph graph;
+	private final UUID salt;
+	private final transient JenaRDFTermFactory factory;
 	private Model model;
 
 	JenaGraphImpl(org.apache.jena.graph.Graph graph, UUID salt) {
 		this.graph = graph;
 		this.salt = salt;
+		this.factory = new JenaRDFTermFactory(salt);
 	}
 
 	JenaGraphImpl(Model model, UUID salt) {
 		this.model = model;
 		this.graph = model.getGraph();
 		this.salt = salt;
+		this.factory = new JenaRDFTermFactory(salt);
 	}
 
 	@Override
 	public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
 		graph.add(org.apache.jena.graph.Triple.create(
-				JenaRDFTermFactory.toJena(subject),
-				JenaRDFTermFactory.toJena(predicate), 
-				JenaRDFTermFactory.toJena(object)));
+				factory.toJena(subject),
+				factory.toJena(predicate), 
+				factory.toJena(object)));
 	}
 
 	@Override
 	public void add(Triple triple) {
-		graph.add(JenaRDFTermFactory.toJena(triple));
+		graph.add(factory.toJena(triple));
 	}
 
 	@Override
@@ -83,27 +86,27 @@ public class JenaGraphImpl implements JenaGraph {
 	@Override
 	public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
 		return graph.contains(
-				JenaRDFTermFactory.toJena(subject), 
-				JenaRDFTermFactory.toJena(predicate),
-				JenaRDFTermFactory.toJena(object));
+				factory.toJena(subject), 
+				factory.toJena(predicate),
+				factory.toJena(object));
 	}
 
 	@Override
 	public boolean contains(Triple triple) {
-		return graph.contains(JenaRDFTermFactory.toJena(triple));
+		return graph.contains(factory.toJena(triple));
 	}
 
 	@Override
 	public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
 		graph.delete(org.apache.jena.graph.Triple.create(
-				JenaRDFTermFactory.toJena(subject),
-				JenaRDFTermFactory.toJena(predicate), 
-				JenaRDFTermFactory.toJena(object)));
+				factory.toJena(subject),
+				factory.toJena(predicate), 
+				factory.toJena(object)));
 	}
 
 	@Override
 	public void remove(Triple triple) {
-		graph.delete(JenaRDFTermFactory.toJena(triple));
+		graph.delete(factory.toJena(triple));
 	}
 
 	@Override
@@ -127,7 +130,7 @@ public class JenaGraphImpl implements JenaGraph {
 	private Node toJenaAny(RDFTerm term) {
 		if (term == null)
 			return Node.ANY;
-		return JenaRDFTermFactory.toJena(term);
+		return factory.toJena(term);
 	}
 
 	@Override


Mime
View raw message