commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [1/3] incubator-commonsrdf git commit: JenaFactory -> InternalJenaFactory
Date Fri, 07 Oct 2016 14:19:44 GMT
Repository: incubator-commonsrdf
Updated Branches:
  refs/heads/jena 51d7b4117 -> 7dd08a24f


JenaFactory -> InternalJenaFactory


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

Branch: refs/heads/jena
Commit: c718800490b3cc9176239f8dab215cbebd5c3c5b
Parents: 51d7b41
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Oct 7 15:13:39 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Oct 7 15:14:00 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/jena/JenaRDFTermFactory.java    |  46 +++---
 .../commons/rdf/jena/impl/AbstractQuadLike.java |  20 +--
 .../rdf/jena/impl/InternalJenaFactory.java      | 162 ++++++++++++++++++
 .../commons/rdf/jena/impl/JenaDatasetImpl.java  |   2 +-
 .../commons/rdf/jena/impl/JenaFactory.java      | 164 -------------------
 .../commons/rdf/jena/impl/JenaLiteralImpl.java  |   4 +-
 .../commons/rdf/jena/TestBlankNodeJena.java     |   8 +-
 7 files changed, 202 insertions(+), 204 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c7188004/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 4d5c592..0cc84c0 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
@@ -34,7 +34,7 @@ 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.api.TripleLike;
-import org.apache.commons.rdf.jena.impl.JenaFactory;
+import org.apache.commons.rdf.jena.impl.InternalJenaFactory;
 import org.apache.jena.datatypes.RDFDatatype;
 import org.apache.jena.datatypes.xsd.XSDDatatype;
 import org.apache.jena.graph.Node;
@@ -60,7 +60,7 @@ import org.apache.jena.sparql.graph.GraphFactory;
  */
 public final class JenaRDFTermFactory implements RDFTermFactory {
 
-	private static JenaFactory jenaFactory = new JenaFactory(){};
+	private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
 	
 	private final UUID salt;
 
@@ -91,55 +91,55 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 
 	@Override
 	public JenaBlankNode createBlankNode() {
-		return jenaFactory.createBlankNode(getSalt());
+		return internalJenaFactory.createBlankNode(getSalt());
 	}
 
 	@Override
 	public JenaBlankNode createBlankNode(String name) {
-		return jenaFactory.createBlankNode(name, getSalt());
+		return internalJenaFactory.createBlankNode(name, getSalt());
 	}
 	
 	@Override
 	public JenaDataset createDataset() {
-		return jenaFactory.createDataset(getSalt());
+		return internalJenaFactory.createDataset(getSalt());
 	}
 
 	@Override
 	public JenaGraph createGraph() {
-		return jenaFactory.createGraph(getSalt());
+		return internalJenaFactory.createGraph(getSalt());
 	}
 
 	@Override
 	public JenaIRI createIRI(String iri) {
 		validateIRI(iri);
-		return jenaFactory.createIRI(iri);
+		return internalJenaFactory.createIRI(iri);
 	}
 
 	@Override
 	public JenaLiteral createLiteral(String lexicalForm) {
-		return jenaFactory.createLiteral(lexicalForm);
+		return internalJenaFactory.createLiteral(lexicalForm);
 	}
 
 	@Override
 	public JenaLiteral createLiteral(String lexicalForm, IRI dataType) {
-		return jenaFactory.createLiteralDT(lexicalForm, dataType.getIRIString());
+		return internalJenaFactory.createLiteralDT(lexicalForm, dataType.getIRIString());
 	}
 
 	@Override
 	public JenaLiteral createLiteral(String lexicalForm, String languageTag) {
 		validateLang(languageTag);
-		return jenaFactory.createLiteralLang(lexicalForm, languageTag);
+		return internalJenaFactory.createLiteralLang(lexicalForm, languageTag);
 	}
 
 	@Override
 	public JenaTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return jenaFactory.createTriple(subject, predicate, object);
+		return internalJenaFactory.createTriple(subject, predicate, object);
 	}
 	
 	@Override
 	public JenaQuad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate,
RDFTerm object)
 			throws IllegalArgumentException, UnsupportedOperationException {
-		return jenaFactory.createQuad(subject, predicate, object, graphName);
+		return internalJenaFactory.createQuad(subject, predicate, object, graphName);
 	}
 
 	/**
@@ -164,7 +164,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 */
 	public JenaGeneralizedTripleLike createGeneralizedTriple(
 			RDFTerm subject, RDFTerm predicate, RDFTerm object) {
-		return jenaFactory.createGeneralizedTriple(subject, predicate, object);
+		return internalJenaFactory.createGeneralizedTriple(subject, predicate, object);
 	}
 
 	/**
@@ -191,7 +191,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 */
 	public JenaGeneralizedQuadLike createGeneralizedQuad(
 			RDFTerm subject, RDFTerm predicate, RDFTerm object, RDFTerm graphName) {
-		return jenaFactory.createGeneralizedQuad(subject, predicate, object, graphName);
+		return internalJenaFactory.createGeneralizedQuad(subject, predicate, object, graphName);
 	}	
 	/**
 	 * Adapt an existing Jena Node to CommonsRDF {@link RDFTerm}.
@@ -213,7 +213,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 *             if the node is not concrete or represents a variable in Jena.
 	 */
 	public JenaRDFTerm fromJena(Node node) throws ConversionException {
-		return jenaFactory.fromJena(node, getSalt());
+		return internalJenaFactory.fromJena(node, getSalt());
 	}
 
 	/**
@@ -278,7 +278,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 *             is a generalized triple
 	 */
 	public JenaTriple fromJena(org.apache.jena.graph.Triple triple) throws ConversionException
{
-		return jenaFactory.fromJena(triple, getSalt());
+		return internalJenaFactory.fromJena(triple, getSalt());
 	}
 
 	/**
@@ -304,7 +304,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 *             if any of the triple's nodes are not concrete
 	 */
 	public JenaTripleLike<RDFTerm, RDFTerm, RDFTerm> fromJenaGeneralized(org.apache.jena.graph.Triple
triple) throws ConversionException {
-		return jenaFactory.fromJenaGeneralized(triple, getSalt());
+		return internalJenaFactory.fromJenaGeneralized(triple, getSalt());
 	}
 
 	/**
@@ -334,7 +334,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 *             if any of the quad nodes are not concrete
 	 */
 	public JenaQuadLike<RDFTerm, RDFTerm, RDFTerm, RDFTerm> fromJenaGeneralized(org.apache.jena.sparql.core.Quad
quad) throws ConversionException {
-		return jenaFactory.fromJenaGeneralized(quad, getSalt());
+		return internalJenaFactory.fromJenaGeneralized(quad, getSalt());
 	}
 	
 	/**
@@ -389,7 +389,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * @return Adapted quad
 	 */	
 	public JenaQuad fromJena(org.apache.jena.sparql.core.Quad quad) {
-		return jenaFactory.fromJena(quad, getSalt());
+		return internalJenaFactory.fromJena(quad, getSalt());
 	}
 
 	/**
@@ -411,7 +411,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * @return Adapted {@link JenaGraph}
 	 */
 	public JenaGraph fromJena(org.apache.jena.graph.Graph graph) {
-		return jenaFactory.fromJena(graph, getSalt());
+		return internalJenaFactory.fromJena(graph, getSalt());
 	}
 
 	/**
@@ -430,7 +430,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * @return Adapted {@link JenaGraph}
 	 */
 	public JenaGraph fromJena(org.apache.jena.rdf.model.Model model) {
-		return jenaFactory.fromJena(model, getSalt());
+		return internalJenaFactory.fromJena(model, getSalt());
 	}	
 
 	/**
@@ -450,7 +450,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * @return Adapted {@link JenaDataset} 
 	 */
 	public JenaDataset fromJena(DatasetGraph datasetGraph) {
-		return jenaFactory.fromJena(datasetGraph, getSalt());
+		return internalJenaFactory.fromJena(datasetGraph, getSalt());
 	}	
 	
 	/**
@@ -470,7 +470,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * @return Adapted {@link JenaDataset} 
 	 */
 	public JenaDataset fromJena(org.apache.jena.query.Dataset datasetGraph) {
-		return jenaFactory.fromJena(datasetGraph.asDatasetGraph(), getSalt());
+		return internalJenaFactory.fromJena(datasetGraph.asDatasetGraph(), getSalt());
 	}		
 
 	/**

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c7188004/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractQuadLike.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractQuadLike.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractQuadLike.java
index f8451ea..dd0d384 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractQuadLike.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractQuadLike.java
@@ -40,13 +40,13 @@ import org.apache.jena.sparql.core.Quad;
  * 
  * @see JenaTripleImpl
  * @see JenaQuadImpl
- * @see jenaFactory#createGeneralizedTriple(RDFTerm, RDFTerm, RDFTerm)
- * @see jenaFactory#createGeneralizedQuad(RDFTerm, RDFTerm, RDFTerm, RDFTerm)
+ * @see internalJenaFactory#createGeneralizedTriple(RDFTerm, RDFTerm, RDFTerm)
+ * @see internalJenaFactory#createGeneralizedQuad(RDFTerm, RDFTerm, RDFTerm, RDFTerm)
  *
  */
 abstract class AbstractQuadLike<S extends RDFTerm, P extends RDFTerm, O extends RDFTerm,
G extends RDFTerm> implements JenaQuadLike<S,P,O,G> {
 
-	private static JenaFactory jenaFactory = new JenaFactory(){};
+	private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
 	
 	final Optional<G> graphName;
 	final S subject;
@@ -69,18 +69,18 @@ abstract class AbstractQuadLike<S extends RDFTerm, P extends RDFTerm,
O extends
 	@SuppressWarnings("unchecked")
 	AbstractQuadLike(org.apache.jena.sparql.core.Quad quad, UUID salt) {
 		this.quad = Objects.requireNonNull(quad);
-		this.subject = (S) jenaFactory.fromJena(quad.getSubject(), salt);
-		this.predicate = (P) jenaFactory.fromJena(quad.getPredicate(), salt);
-		this.object = (O)jenaFactory.fromJena(quad.getObject(), salt);
-		this.graphName = Optional.of((G) jenaFactory.fromJena(quad.getGraph(), salt));		
+		this.subject = (S) internalJenaFactory.fromJena(quad.getSubject(), salt);
+		this.predicate = (P) internalJenaFactory.fromJena(quad.getPredicate(), salt);
+		this.object = (O)internalJenaFactory.fromJena(quad.getObject(), salt);
+		this.graphName = Optional.of((G) internalJenaFactory.fromJena(quad.getGraph(), salt));
	
 	}
 
 	@SuppressWarnings("unchecked")
 	AbstractQuadLike(org.apache.jena.graph.Triple triple, UUID salt) {
 		this.triple = Objects.requireNonNull(triple);		
-		this.subject = (S) jenaFactory.fromJena(triple.getSubject(), salt);
-		this.predicate = (P) jenaFactory.fromJena(triple.getPredicate(), salt);
-		this.object = (O)jenaFactory.fromJena(triple.getObject(), salt);
+		this.subject = (S) internalJenaFactory.fromJena(triple.getSubject(), salt);
+		this.predicate = (P) internalJenaFactory.fromJena(triple.getPredicate(), salt);
+		this.object = (O)internalJenaFactory.fromJena(triple.getObject(), salt);
 		this.graphName = Optional.empty();
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c7188004/jena/src/main/java/org/apache/commons/rdf/jena/impl/InternalJenaFactory.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/InternalJenaFactory.java
b/jena/src/main/java/org/apache/commons/rdf/jena/impl/InternalJenaFactory.java
new file mode 100644
index 0000000..eb09d67
--- /dev/null
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/InternalJenaFactory.java
@@ -0,0 +1,162 @@
+/**
+ * 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.commons.rdf.jena.impl;
+
+import java.util.Optional;
+import java.util.UUID;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.jena.ConversionException;
+import org.apache.commons.rdf.jena.JenaBlankNode;
+import org.apache.commons.rdf.jena.JenaDataset;
+import org.apache.commons.rdf.jena.JenaGeneralizedQuadLike;
+import org.apache.commons.rdf.jena.JenaGeneralizedTripleLike;
+import org.apache.commons.rdf.jena.JenaGraph;
+import org.apache.commons.rdf.jena.JenaIRI;
+import org.apache.commons.rdf.jena.JenaLiteral;
+import org.apache.commons.rdf.jena.JenaQuad;
+import org.apache.commons.rdf.jena.JenaRDFTerm;
+import org.apache.commons.rdf.jena.JenaRDFTermFactory;
+import org.apache.commons.rdf.jena.JenaTriple;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphFactory;
+import org.apache.jena.sparql.graph.GraphFactory;
+
+/**
+ * Construct Jena implementations of Commons RDF.
+ * <p>
+ * This class is deliberately an abstract class, as it is an internal helper
+ * which <strong>may change</strong> in any minor version update; users should
+ * instead use {@link JenaRDFTermFactory}.
+ * <p>
+ * For the purpose of blank node identity, some of these methods require a
+ * {@link UUID} to use as a salt. See {@link BlankNode#uniqueReference()} for
+ * details.
+ * 
+ */
+public abstract class InternalJenaFactory {
+
+	public JenaBlankNode createBlankNode(String id, UUID salt) {
+		return new JenaBlankNodeImpl(NodeFactory.createBlankNode(id), salt);
+	}
+
+	public JenaBlankNode createBlankNode(UUID salt) {
+		return new JenaBlankNodeImpl(NodeFactory.createBlankNode(), salt);
+	}
+	public JenaDataset createDataset(UUID salt) {
+		DatasetGraph dg = DatasetGraphFactory.createGeneral();
+		// Or which createMethod() -- a bit confusing with lots of choice..
+		return new JenaDatasetImpl(dg, salt);
+	}
+
+	public JenaGraph createGraph(UUID salt) {
+		return new JenaGraphImpl(GraphFactory.createDefaultGraph(), salt);
+	}
+
+	public JenaIRI createIRI(String iriStr) {
+		return new JenaIRIImpl(iriStr);
+	}
+
+	public JenaLiteral createLiteral(String lexStr) {
+		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr));
+	}
+
+	public JenaLiteral createLiteralDT(String lexStr, String datatypeIRI) {
+		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, NodeFactory.getType(datatypeIRI)));
+	}
+
+	public JenaLiteral createLiteralLang(String lexStr, String langTag) {
+		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, langTag));
+	}
+
+	public JenaTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+		return new JenaTripleImpl(subject, predicate, object);
+	}
+
+	public JenaQuad createQuad(BlankNodeOrIRI subject, IRI predicate, RDFTerm object, BlankNodeOrIRI
graphName) {
+		return new JenaQuadImpl(subject, predicate, object, Optional.ofNullable(graphName));
+	}
+
+	public JenaGeneralizedTripleLike createGeneralizedTriple(RDFTerm subject, RDFTerm predicate,
RDFTerm object) {
+		return new JenaGeneralizedTripleLikeImpl(subject, predicate, object);
+	}
+
+	public JenaGeneralizedQuadLike createGeneralizedQuad(RDFTerm subject, RDFTerm predicate,
RDFTerm object, RDFTerm graphName) {
+		return new JenaGeneralizedQuadLikeImpl(subject, predicate, object, Optional.ofNullable(graphName));
+	}
+	
+	public JenaRDFTerm fromJena(Node node, UUID salt) throws ConversionException {
+		if (! node.isConcrete()) {
+			throw new ConversionException("Node is not a concrete RDF Term: " + node); 
+		}
+		if (node.isURI()) {
+			return new JenaIRIImpl(node);
+		}
+		if (node.isLiteral()) {
+			return new JenaLiteralImpl(node);
+		}
+		if (node.isBlank()) {
+			return new JenaBlankNodeImpl(node, salt);
+		}
+		if (node.equals(Node.ANY)) {
+			// NOTE: JenaAny no longer supported by Commons RDF
+			//return JenaAnyImpl.Singleton.instance;
+		}
+		if (node.isVariable()) {
+			// NOTE: JenaVariable no longer supported by Commons RDF
+			//return new JenaVariableImpl(node);
+		}
+		throw new ConversionException("Unrecognized node type: " + node);
+	}
+
+	public JenaGraph fromJena(org.apache.jena.graph.Graph graph, UUID salt) {
+		return new JenaGraphImpl(graph, salt);
+	}
+
+	public JenaGraph fromJena(Model model, UUID salt) {
+		return new JenaGraphImpl(model, salt);
+	}
+
+	public JenaDataset fromJena(DatasetGraph datasetGraph, UUID salt) {
+		return new JenaDatasetImpl(datasetGraph, salt);
+	}
+	
+	public JenaTriple fromJena(org.apache.jena.graph.Triple triple, UUID salt) {
+		return new JenaTripleImpl(triple, salt);
+	}
+
+	public JenaGeneralizedTripleLike fromJenaGeneralized(org.apache.jena.graph.Triple triple,
UUID salt) {
+		return new JenaGeneralizedTripleLikeImpl(triple, salt);
+	}
+
+	public JenaGeneralizedQuadLike fromJenaGeneralized(org.apache.jena.sparql.core.Quad quad,
UUID salt) {
+		return new JenaGeneralizedQuadLikeImpl(quad, salt);
+	}
+	
+	public JenaQuad fromJena(org.apache.jena.sparql.core.Quad quad, UUID salt) {
+		return new JenaQuadImpl(quad, salt);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c7188004/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 fec063f..5c410ee 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
@@ -94,7 +94,7 @@ class JenaDatasetImpl implements JenaDataset {
 
 	private Node toJenaPattern(Optional<? extends RDFTerm> graphName) {
 		// In theory we could have done:
-		//   factory.toJena(graphName.orElse(jenaFactory::createAnyVariable))
+		//   factory.toJena(graphName.orElse(internalJenaFactory::createAnyVariable))
 		// but because of generics casting rules that doesn't work :(						
 
 		if (graphName == null) {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c7188004/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java
deleted file mode 100644
index ec15d35..0000000
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java
+++ /dev/null
@@ -1,164 +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.commons.rdf.jena.impl;
-
-import java.util.Optional;
-import java.util.UUID;
-
-import org.apache.commons.rdf.api.BlankNode;
-import org.apache.commons.rdf.api.BlankNodeOrIRI;
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.api.RDFTerm;
-import org.apache.commons.rdf.jena.ConversionException;
-import org.apache.commons.rdf.jena.JenaBlankNode;
-import org.apache.commons.rdf.jena.JenaDataset;
-import org.apache.commons.rdf.jena.JenaGeneralizedQuadLike;
-import org.apache.commons.rdf.jena.JenaGeneralizedTripleLike;
-import org.apache.commons.rdf.jena.JenaGraph;
-import org.apache.commons.rdf.jena.JenaIRI;
-import org.apache.commons.rdf.jena.JenaLiteral;
-import org.apache.commons.rdf.jena.JenaQuad;
-import org.apache.commons.rdf.jena.JenaQuadLike;
-import org.apache.commons.rdf.jena.JenaRDFTerm;
-import org.apache.commons.rdf.jena.JenaRDFTermFactory;
-import org.apache.commons.rdf.jena.JenaTriple;
-import org.apache.commons.rdf.jena.JenaTripleLike;
-import org.apache.jena.graph.Node;
-import org.apache.jena.graph.NodeFactory;
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.sparql.core.DatasetGraph;
-import org.apache.jena.sparql.core.DatasetGraphFactory;
-import org.apache.jena.sparql.graph.GraphFactory;
-
-/**
- * Construct Jena implementations of Commons RDF.
- * <p>
- * This class is deliberately an abstract class, as it is an internal helper
- * which <strong>may change</strong> in any minor version update; users should
- * instead use {@link JenaRDFTermFactory}.
- * <p>
- * For the purpose of blank node identity, some of these methods require a
- * {@link UUID} to use as a salt. See {@link BlankNode#uniqueReference()} for
- * details.
- * 
- */
-public abstract class JenaFactory {
-
-	public JenaBlankNode createBlankNode(String id, UUID salt) {
-		return new JenaBlankNodeImpl(NodeFactory.createBlankNode(id), salt);
-	}
-
-	public JenaBlankNode createBlankNode(UUID salt) {
-		return new JenaBlankNodeImpl(NodeFactory.createBlankNode(), salt);
-	}
-	public JenaDataset createDataset(UUID salt) {
-		DatasetGraph dg = DatasetGraphFactory.createGeneral();
-		// Or which createMethod() -- a bit confusing with lots of choice..
-		return new JenaDatasetImpl(dg, salt);
-	}
-
-	public JenaGraph createGraph(UUID salt) {
-		return new JenaGraphImpl(GraphFactory.createDefaultGraph(), salt);
-	}
-
-	public JenaIRI createIRI(String iriStr) {
-		return new JenaIRIImpl(iriStr);
-	}
-
-	public JenaLiteral createLiteral(String lexStr) {
-		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr));
-	}
-
-	public JenaLiteral createLiteralDT(String lexStr, String datatypeIRI) {
-		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, NodeFactory.getType(datatypeIRI)));
-	}
-
-	public JenaLiteral createLiteralLang(String lexStr, String langTag) {
-		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, langTag));
-	}
-
-	public JenaTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return new JenaTripleImpl(subject, predicate, object);
-	}
-
-	public JenaQuad createQuad(BlankNodeOrIRI subject, IRI predicate, RDFTerm object, BlankNodeOrIRI
graphName) {
-		return new JenaQuadImpl(subject, predicate, object, Optional.ofNullable(graphName));
-	}
-
-	public JenaGeneralizedTripleLike createGeneralizedTriple(RDFTerm subject, RDFTerm predicate,
RDFTerm object) {
-		return new JenaGeneralizedTripleLikeImpl(subject, predicate, object);
-	}
-
-	public JenaGeneralizedQuadLike createGeneralizedQuad(RDFTerm subject, RDFTerm predicate,
RDFTerm object, RDFTerm graphName) {
-		return new JenaGeneralizedQuadLikeImpl(subject, predicate, object, Optional.ofNullable(graphName));
-	}
-	
-	public JenaRDFTerm fromJena(Node node, UUID salt) throws ConversionException {
-		if (! node.isConcrete()) {
-			throw new ConversionException("Node is not a concrete RDF Term: " + node); 
-		}
-		if (node.isURI()) {
-			return new JenaIRIImpl(node);
-		}
-		if (node.isLiteral()) {
-			return new JenaLiteralImpl(node);
-		}
-		if (node.isBlank()) {
-			return new JenaBlankNodeImpl(node, salt);
-		}
-		if (node.equals(Node.ANY)) {
-			// NOTE: JenaAny no longer supported by Commons RDF
-			//return JenaAnyImpl.Singleton.instance;
-		}
-		if (node.isVariable()) {
-			// NOTE: JenaVariable no longer supported by Commons RDF
-			//return new JenaVariableImpl(node);
-		}
-		throw new ConversionException("Unrecognized node type: " + node);
-	}
-
-	public JenaGraph fromJena(org.apache.jena.graph.Graph graph, UUID salt) {
-		return new JenaGraphImpl(graph, salt);
-	}
-
-	public JenaGraph fromJena(Model model, UUID salt) {
-		return new JenaGraphImpl(model, salt);
-	}
-
-	public JenaDataset fromJena(DatasetGraph datasetGraph, UUID salt) {
-		return new JenaDatasetImpl(datasetGraph, salt);
-	}
-	
-	public JenaTriple fromJena(org.apache.jena.graph.Triple triple, UUID salt) {
-		return new JenaTripleImpl(triple, salt);
-	}
-
-	public JenaGeneralizedTripleLike fromJenaGeneralized(org.apache.jena.graph.Triple triple,
UUID salt) {
-		return new JenaGeneralizedTripleLikeImpl(triple, salt);
-	}
-
-	public JenaGeneralizedQuadLike fromJenaGeneralized(org.apache.jena.sparql.core.Quad quad,
UUID salt) {
-		return new JenaGeneralizedQuadLikeImpl(quad, salt);
-	}
-	
-	public JenaQuad fromJena(org.apache.jena.sparql.core.Quad quad, UUID salt) {
-		return new JenaQuadImpl(quad, salt);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c7188004/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java
index 173af4c..74c6d9c 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaLiteralImpl.java
@@ -28,7 +28,7 @@ import org.apache.jena.graph.Node;
 
 class JenaLiteralImpl extends AbstractJenaRDFTerm implements JenaLiteral {
 
-	private static JenaFactory jenaFactory = new JenaFactory(){};
+	private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
 	
 	JenaLiteralImpl(Node node) {
 		super(node);
@@ -52,7 +52,7 @@ class JenaLiteralImpl extends AbstractJenaRDFTerm implements JenaLiteral
{
 
 	@Override
 	public IRI getDatatype() {
-		return jenaFactory.createIRI(asJenaNode().getLiteralDatatype().getURI());
+		return internalJenaFactory.createIRI(asJenaNode().getLiteralDatatype().getURI());
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/c7188004/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java
index 0ac6326..a3db975 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestBlankNodeJena.java
@@ -22,11 +22,11 @@ import java.util.UUID;
 
 import org.apache.commons.rdf.api.AbstractBlankNodeTest ;
 import org.apache.commons.rdf.api.BlankNode ;
-import org.apache.commons.rdf.jena.impl.JenaFactory;
+import org.apache.commons.rdf.jena.impl.InternalJenaFactory;
 
 public class TestBlankNodeJena extends AbstractBlankNodeTest {
 
-	JenaFactory jenaFactory = new JenaFactory(){};
+	InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
 	
 	/** 
 	 * Fixed salt for the purpose of this test.
@@ -35,12 +35,12 @@ public class TestBlankNodeJena extends AbstractBlankNodeTest {
 
 	@Override
     protected BlankNode getBlankNode() {
-        return jenaFactory.createBlankNode(SALT) ;
+        return internalJenaFactory.createBlankNode(SALT) ;
     }
     
     @Override
     protected BlankNode getBlankNode(String identifier) {
-        return jenaFactory.createBlankNode(identifier, SALT) ;
+        return internalJenaFactory.createBlankNode(identifier, SALT) ;
     }
 }
 


Mime
View raw message