You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commonsrdf.apache.org by st...@apache.org on 2016/10/19 08:54:28 UTC

[1/3] incubator-commonsrdf git commit: RDF4JTermFactory -> RDF4JFactory

Repository: incubator-commonsrdf
Updated Branches:
  refs/heads/master 5aa8d6cb7 -> 0bb936968


RDF4JTermFactory -> RDF4JFactory


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

Branch: refs/heads/master
Commit: d043b0759e8bd6d261db3fa03cdd0248b46cf47e
Parents: 5aa8d6c
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Oct 19 09:47:54 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Oct 19 09:47:54 2016 +0100

----------------------------------------------------------------------
 rdf4j/pom.xml                                   |   2 +-
 .../commons/rdf/rdf4j/RDF4JBlankNode.java       |   2 +-
 .../apache/commons/rdf/rdf4j/RDF4JDataset.java  |   4 +-
 .../apache/commons/rdf/rdf4j/RDF4JFactory.java  | 601 +++++++++++++++++++
 .../apache/commons/rdf/rdf4j/RDF4JGraph.java    |  10 +-
 .../org/apache/commons/rdf/rdf4j/RDF4JIRI.java  |   2 +-
 .../apache/commons/rdf/rdf4j/RDF4JLiteral.java  |   2 +-
 .../org/apache/commons/rdf/rdf4j/RDF4JQuad.java |   2 +-
 .../commons/rdf/rdf4j/RDF4JTermFactory.java     | 601 -------------------
 .../apache/commons/rdf/rdf4j/RDF4JTriple.java   |   2 +-
 .../rdf/rdf4j/experimental/RDF4JParser.java     |  12 +-
 .../rdf4j/impl/AbstractRepositoryGraphLike.java |   6 +-
 .../rdf/rdf4j/impl/InternalRDF4JFactory.java    |  14 +-
 .../commons/rdf/rdf4j/impl/ModelGraphImpl.java  |   6 +-
 .../apache/commons/rdf/rdf4j/impl/QuadImpl.java |  10 +-
 .../commons/rdf/rdf4j/impl/TripleImpl.java      |   8 +-
 .../apache/commons/rdf/rdf4j/package-info.java  |   8 +-
 .../apache/commons/rdf/rdf4j/BlankNodeTest.java |   2 +-
 .../org/apache/commons/rdf/rdf4j/GraphTest.java |   2 +-
 .../commons/rdf/rdf4j/MemoryGraphTest.java      |   2 +-
 .../commons/rdf/rdf4j/NativeStoreGraphTest.java |   2 +-
 .../rdf/rdf4j/Rdf4JRDFTermFactoryTest.java      |   2 +-
 src/site/markdown/implementations.md            |  12 +-
 23 files changed, 657 insertions(+), 657 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/pom.xml
----------------------------------------------------------------------
diff --git a/rdf4j/pom.xml b/rdf4j/pom.xml
index ce21b98..0c6cb28 100644
--- a/rdf4j/pom.xml
+++ b/rdf4j/pom.xml
@@ -121,7 +121,7 @@
 
 
 		<!-- There are multiple RDF4J sail/repository implementations, we use the 
-			below from RDF4JTermFactory. -->
+			below from RDF4JFactory. -->
 		<dependency>
 			<groupId>org.eclipse.rdf4j</groupId>
 			<artifactId>rdf4j-sail-memory</artifactId>

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java
index 3e5a055..2ed616f 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java
@@ -27,7 +27,7 @@ import org.eclipse.rdf4j.model.BNode;
  * The underlying RDF4J {@link BNode} instance can 
  * be retrieved with {@link #asValue()}.
  * 
- * @see RDF4JTermFactory#createBlankNode() 
+ * @see RDF4JFactory#createBlankNode() 
  */
 public interface RDF4JBlankNode extends RDF4JBlankNodeOrIRI, BlankNode {
 	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java
index b00ab39..2066c34 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java
@@ -30,8 +30,8 @@ import org.apache.commons.rdf.api.RDFTerm;
 /**
  * Marker interface for RDF4J implementations of Dataset.
  * 
- * @see RDF4JTermFactory#createDataset()
- * @see RDF4JTermFactory#asRDFTermDataset(org.eclipse.rdf4j.repository.Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
+ * @see RDF4JFactory#createDataset()
+ * @see RDF4JFactory#asRDFTermDataset(org.eclipse.rdf4j.repository.Repository, org.apache.commons.rdf.rdf4j.RDF4JFactory.Option...)
  */
 public interface RDF4JDataset extends Dataset, RDF4JGraphLike<Quad> {
 	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JFactory.java
new file mode 100644
index 0000000..7d4eabe
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JFactory.java
@@ -0,0 +1,601 @@
+/**
+ * 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.rdf4j;
+
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+
+// To avoid confusion, avoid importing
+// classes that are in both
+// commons.rdf and openrdf.model (e.g. IRI, Literal)
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Dataset;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.Quad;
+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.rdf4j.impl.InternalRDF4JFactory;
+import org.eclipse.rdf4j.model.BNode;
+import org.eclipse.rdf4j.model.Model;
+import org.eclipse.rdf4j.model.Resource;
+import org.eclipse.rdf4j.model.Statement;
+import org.eclipse.rdf4j.model.Value;
+import org.eclipse.rdf4j.model.ValueFactory;
+import org.eclipse.rdf4j.model.impl.LinkedHashModel;
+import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
+import org.eclipse.rdf4j.repository.Repository;
+import org.eclipse.rdf4j.repository.RepositoryConnection;
+import org.eclipse.rdf4j.repository.sail.SailRepository;
+import org.eclipse.rdf4j.sail.Sail;
+import org.eclipse.rdf4j.sail.memory.MemoryStore;
+
+/**
+ * RDF4J implementation of RDFTermFactory.
+ * <p>
+ * The {@link #RDF4JFactory()} constructor uses a {@link SimpleValueFactory}
+ * to create corresponding RDF4J {@link Value} instances. Alternatively, this
+ * factory can be constructed with a different {@link ValueFactory} using
+ * {@link #RDF4JFactory(ValueFactory)}.
+ * <p>
+ * {@link #asRDFTerm(Value)} can be used to convert any RDF4J {@link Value} to
+ * an RDFTerm. Note that adapted {@link BNode}s are considered equal if they are
+ * converted with the same {@link RDF4JFactory} instance and have the same
+ * {@link BNode#getID()}.
+ * <p>
+ * {@link #createGraph()} creates a new Graph backed by {@link LinkedHashModel}.
+ * To use other models, see {@link #asRDFTermGraph(Model)}.
+ * <p>
+ * To adapt a RDF4J {@link Repository} as a {@link Dataset} or {@link Graph},
+ * use {@link #asRDFTermDataset(Repository, Option...)} 
+ * or 
+ * {@link #asRDFTermGraph(Repository, Option...)}.
+ * <p>
+ * {@link #asTriple(Statement)} can be used to convert a RDF4J {@link Statement}
+ * to a Commons RDF {@link Triple}, and equivalent {@link #asQuad(Statement)} to
+ * convert a {@link Quad}.
+ * <p>
+ * To convert any {@link Triple} or {@link Quad} to to RDF4J {@link Statement},
+ * use {@link #asStatement(TripleLike)}. This recognises previously converted
+ * {@link RDF4JTriple}s and {@link RDF4JQuad}s without re-converting their
+ * {@link RDF4JTripleLike#asStatement()}.
+ * <p>
+ * Likewise, {@link #asValue(RDFTerm)} can be used to convert any Commons RDF
+ * {@link RDFTerm} to a corresponding RDF4J {@link Value}. This recognises
+ * previously converted {@link RDF4JTerm}s without re-converting their
+ * {@link RDF4JTerm#asValue()}.
+ * <p>
+ * For the purpose of {@link BlankNode} equivalence, this factory contains an
+ * internal {@link UUID} salt that is used by adapter methods like
+ * {@link #asQuad(Statement)}, {@link #asTriple(Statement)},
+ * {@link #asRDFTerm(Value)} as well as {@link #createBlankNode(String)}. As
+ * RDF4J {@link BNode} instances from multiple repositories or models may have
+ * the same {@link BNode#getID()}, converting them with the above methods might
+ * cause accidental {@link BlankNode} equivalence. Note that the {@link Graph}
+ * and {@link Dataset} adapter methods like
+ * {@link #asRDFTermDataset(Repository, Option...)}
+ * and 
+ * {@link #asRDFTermGraph(Repository, Option...)}
+ * therefore uses a unique {@link RDF4JFactory} internally.
+ *
+ */
+public final class RDF4JFactory implements RDFTermFactory {
+
+	/**
+	 * InternalRDF4JFactory is deliberately abstract
+	 */
+	private static InternalRDF4JFactory rdf4j = new InternalRDF4JFactory() {
+	};
+
+	public enum Option { 
+		/** 
+		 * The Graph/Dataset should include any inferred statements 
+		 */
+		includeInferred,
+		/**
+		 * The graph/dataset should handle {@link Repository#initialize()} (if
+		 * needed) and {@link Repository#shutDown()} on {@link Graph#close()} /
+		 * {@link Dataset#close()}.
+		 */
+		handleInitAndShutdown
+	}
+
+	private final UUID salt;
+
+	private final ValueFactory valueFactory;
+
+	/**
+	 * Construct an {@link RDF4JFactory}.
+	 * 
+	 */
+	public RDF4JFactory() {
+		this(SimpleValueFactory.getInstance(), UUID.randomUUID());
+	}
+
+	/**
+	 * Construct an {@link RDF4JFactory}.
+	 * <p>
+	 * This constructor is intended for use with the value factory from
+	 * {@link Repository#getValueFactory()} when using 
+	 * Repository-based graphs and datasets.
+	 * 
+	 * @param valueFactory
+	 *            The RDF4J {@link ValueFactory} to use
+	 */
+	public RDF4JFactory(ValueFactory valueFactory) {
+		this(valueFactory, UUID.randomUUID());
+	}
+
+	/**
+	 * Construct an {@link RDF4JFactory}.
+	 * <p>
+	 * This constructor may be used if reproducible
+	 * {@link BlankNode#uniqueReference()} in {@link BlankNode} is desirable.
+	 * 
+	 * @param salt
+	 *            An {@link UUID} salt to be used by any created
+	 *            {@link BlankNode}s for the purpose of
+	 *            {@link BlankNode#uniqueReference()}
+	 */	
+	public RDF4JFactory(UUID salt) {
+		this(SimpleValueFactory.getInstance(), salt);
+	}
+	/**
+	 * Construct an {@link RDF4JFactory}.
+	 * <p>
+	 * This constructor may be used if reproducible
+	 * {@link BlankNode#uniqueReference()} in {@link BlankNode} is desirable.
+	 * 
+	 * @param valueFactory
+	 *            The RDF4J {@link ValueFactory} to use
+	 * @param salt
+	 *            An {@link UUID} salt to be used by any created
+	 *            {@link BlankNode}s for the purpose of
+	 *            {@link BlankNode#uniqueReference()}
+	 */	
+	public RDF4JFactory(ValueFactory valueFactory, UUID salt) {
+		this.valueFactory = valueFactory;
+		this.salt = salt;
+	}
+
+	/**
+	 * Adapt a RDF4J {@link Statement} as a Commons RDF {@link Quad}.
+	 * <p>
+	 * For the purpose of {@link BlankNode} equivalence, this method will use an
+	 * internal salt UUID that is unique per instance of
+	 * {@link RDF4JFactory}.
+	 * <p>
+	 * <strong>NOTE:</strong> If combining RDF4J {@link Statement}s multiple
+	 * repositories or models, then their {@link BNode}s may have the same
+	 * {@link BNode#getID()}, which with this method would become equivalent
+	 * according to {@link BlankNode#equals(Object)} and
+	 * {@link BlankNode#uniqueReference()}, unless a separate
+	 * {@link RDF4JFactory} instance is used per RDF4J repository/model.
+	 *
+	 * @param statement
+	 *            The statement to convert
+	 * @return A {@link RDF4JQuad} that is equivalent to the statement
+	 */
+	public RDF4JQuad asQuad(final Statement statement) {
+		return rdf4j.createQuadImpl(statement, salt);
+	}
+
+	/**
+	 *
+	 * Adapt a RDF4J {@link Value} as a Commons RDF {@link RDFTerm}.
+	 * <p>
+	 * The value will be of the same kind as the term, e.g. a
+	 * {@link org.eclipse.rdf4j.model.BNode} is converted to a
+	 * {@link org.apache.commons.rdf.api.BlankNode}, a
+	 * {@link org.eclipse.rdf4j.model.IRI} is converted to a
+	 * {@link org.apache.commons.rdf.api.IRI} and a
+	 * {@link org.eclipse.rdf4j.model.Literal}. is converted to a
+	 * {@link org.apache.commons.rdf.api.Literal}
+	 * <p>
+	 * For the purpose of {@link BlankNode} equivalence, this method will use an
+	 * internal salt UUID that is unique per instance of
+	 * {@link RDF4JFactory}.
+	 * <p>
+	 * <strong>NOTE:</strong> If combining RDF4J values from multiple
+	 * repositories or models, then their {@link BNode}s may have the same
+	 * {@link BNode#getID()}, which with this method would become equivalent
+	 * according to {@link BlankNode#equals(Object)} and
+	 * {@link BlankNode#uniqueReference()}, unless a separate
+	 * {@link RDF4JFactory} instance is used per RDF4J repository/model.
+	 *
+	 * @param value
+	 *            The RDF4J {@link Value} to convert.
+	 * @return A {@link RDFTerm} that corresponds to the RDF4J value
+	 * @throws IllegalArgumentException
+	 *             if the value is not a BNode, Literal or IRI
+	 */
+	public RDF4JTerm asRDFTerm(Value value) {
+		return asRDFTerm(value, salt);
+	}
+	
+	/**
+	 * Adapt a RDF4J {@link Value} as a Commons RDF {@link RDFTerm}.
+	 * <p>
+	 * The value will be of the same kind as the term, e.g. a
+	 * {@link org.eclipse.rdf4j.model.BNode} is converted to a
+	 * {@link org.apache.commons.rdf.api.BlankNode}, a
+	 * {@link org.eclipse.rdf4j.model.IRI} is converted to a
+	 * {@link org.apache.commons.rdf.api.IRI} and a
+	 * {@link org.eclipse.rdf4j.model.Literal}. is converted to a
+	 * {@link org.apache.commons.rdf.api.Literal}
+	 *
+	 * @param value
+	 *            The RDF4J {@link Value} to convert.
+	 * @param salt
+	 *            A {@link UUID} salt to use for uniquely mapping any
+	 *            {@link BNode}s. The salt should typically be the same for
+	 *            multiple statements in the same {@link Repository} or
+	 *            {@link Model} to ensure {@link BlankNode#equals(Object)} and
+	 *            {@link BlankNode#uniqueReference()} works as intended.
+	 * @return A {@link RDFTerm} that corresponds to the RDF4J value
+	 * @throws IllegalArgumentException
+	 *             if the value is not a BNode, Literal or IRI
+	 */
+	public static RDF4JTerm asRDFTerm(final Value value, UUID salt) {
+		if (value instanceof BNode) {
+			return rdf4j.createBlankNodeImpl((BNode) value, salt);
+		}
+		if (value instanceof org.eclipse.rdf4j.model.Literal) {
+			return rdf4j.createLiteralImpl((org.eclipse.rdf4j.model.Literal) value);
+		}
+		if (value instanceof org.eclipse.rdf4j.model.IRI) {
+			return rdf4j.createIRIImpl((org.eclipse.rdf4j.model.IRI) value);
+		}
+		throw new IllegalArgumentException("Value is not a BNode, Literal or IRI: " + value.getClass());
+	}	
+
+	/**
+	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Dataset}.
+	 * <p>
+	 * Changes to the dataset are reflected in the repository, and vice versa.
+	 * <p>
+	 * <strong>Note:</strong> Some operations on the {@link RDF4JDataset}
+	 * requires the use of try-with-resources to close underlying
+	 * {@link RepositoryConnection}s, including
+	 * {@link RDF4JDataset#iterate()}, 
+	 * {@link RDF4JDataset#stream()} and {@link RDF4JDataset#getGraphNames()}.
+	 *
+	 * @param repository
+	 *            RDF4J {@link Repository} to connect to.
+	 * @param options
+	 *            Zero or more {@link Option}
+	 * @return A {@link Dataset} backed by the RDF4J repository.
+	 */
+	public RDF4JDataset asRDFTermDataset(Repository repository, Option... options) {
+		EnumSet<Option> opts = optionSet(options);
+		return rdf4j.createRepositoryDatasetImpl(repository, 
+				opts.contains(Option.handleInitAndShutdown), 
+				opts.contains(Option.includeInferred));
+	}
+
+	/**
+	 * Adapt an RDF4J {@link Model} as a Commons RDF {@link Graph}.
+	 * <p>
+	 * Changes to the graph are reflected in the model, and vice versa.
+	 *
+	 * @param model
+	 *            RDF4J {@link Model} to adapt.
+	 * @return Adapted {@link Graph}.
+	 */
+	public RDF4JGraph asRDFTermGraph(Model model) {
+		return rdf4j.createModelGraphImpl(model, this);
+	}
+
+	/**
+	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Graph}.
+	 * <p>
+	 * The graph will only include triples in the default graph (equivalent to
+	 * context <code>new Resource[0]{null})</code> in RDF4J).
+	 * <p>
+	 * Changes to the graph are reflected in the repository, and vice versa.
+	 * <p>
+	 * <strong>Note:</strong> Some operations on the {@link RDF4JGraph}
+	 * requires the use of try-with-resources to close underlying
+	 * {@link RepositoryConnection}s, including
+	 * {@link RDF4JGraph#iterate()} and 
+	 * {@link RDF4JGraph#stream()}.
+	 *
+	 * @param repository
+	 *            RDF4J {@link Repository} to connect to.
+	 * @param options
+	 *            Zero or more {@link Option}
+	 * @return A {@link Graph} backed by the RDF4J repository.
+	 */
+	public RDF4JGraph asRDFTermGraph(Repository repository, Option... options) {
+		EnumSet<Option> opts = optionSet(options);
+		return rdf4j.createRepositoryGraphImpl(repository, 
+				opts.contains(Option.handleInitAndShutdown), 
+				opts.contains(Option.includeInferred), 
+				new Resource[]{null}); // default graph
+	}
+
+	/**
+	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Graph}.
+	 * <p>
+	 * The graph will include triples in any contexts (e.g. the union graph).
+	 * <p>
+	 * Changes to the graph are reflected in the repository, and vice versa.
+	 *
+	 * @param repository
+	 *            RDF4J {@link Repository} to connect to.
+	 * @param options
+	 *            Zero or more {@link Option}
+	 * @return A union {@link Graph} backed by the RDF4J repository.
+	 */
+	public RDF4JGraph asRDFTermGraphUnion(Repository repository, Option... options) {
+		EnumSet<Option> opts = optionSet(options);
+		return rdf4j.createRepositoryGraphImpl(repository, 
+				opts.contains(Option.handleInitAndShutdown), 
+				opts.contains(Option.includeInferred),
+				new Resource[]{}); // union graph 
+		
+	}
+
+	/**
+	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Graph}.
+	 * <p>
+	 * The graph will include triples in the specified contexts.
+	 * <p>
+	 * Changes to the graph are reflected in the repository, and vice versa.
+	 * Triples added/removed to the graph are reflected in all the specified
+	 * contexts.
+	 * <p>
+	 * <strong>Note:</strong> Some operations on the {@link RDF4JGraph}
+	 * requires the use of try-with-resources to close underlying
+	 * {@link RepositoryConnection}s, including
+	 * {@link RDF4JGraph#iterate()} and 
+	 * {@link RDF4JGraph#stream()}.
+	 *
+	 * @param repository
+	 *            RDF4J {@link Repository} to connect to.
+	 * @param contexts
+	 *            A {@link Set} of {@link BlankNodeOrIRI} specifying the graph
+	 *            names to use as a context. The set may include the value
+	 *            <code>null</code> to indicate the default graph. The empty set
+	 *            indicates any context, e.g. the <em>union graph</em>.
+	 * @param option
+	 *            Zero or more {@link Option}s
+	 * @return A {@link Graph} backed by the RDF4J repository.
+	 */
+	public RDF4JGraph asRDFTermGraph(Repository repository, Set<? extends BlankNodeOrIRI> contexts,
+			Option... option) {
+		EnumSet<Option> opts = optionSet(option);
+		/** NOTE: asValue() deliberately CAN handle <code>null</code> */
+		Resource[] resources = contexts.stream().map(g -> (Resource) asValue(g)).toArray(Resource[]::new);
+		return rdf4j.createRepositoryGraphImpl(Objects.requireNonNull(repository), 
+				opts.contains(Option.handleInitAndShutdown),
+				opts.contains(Option.includeInferred),
+				resources);
+	}
+
+	/**
+	 * Adapt a Commons RDF {@link Triple} or {@link Quad} as a RDF4J
+	 * {@link Statement}.
+	 * <p>
+	 * If the <code>tripleLike</code> argument is an {@link RDF4JTriple} or a
+	 * {@link RDF4JQuad}, then its {@link RDF4JTripleLike#asStatement()} is
+	 * returned as-is. Note that this means that a {@link RDF4JTriple} would
+	 * preserve its {@link Statement#getContext()}, and that any
+	 * {@link BlankNode}s would be deemed equivalent in RDF4J if they have the
+	 * same {@link BNode#getID()}.
+	 *
+	 * @param tripleLike
+	 *            A {@link Triple} or {@link Quad} to adapt
+	 * @return A corresponding {@link Statement}
+	 */
+	public Statement asStatement(TripleLike tripleLike) {
+		if (tripleLike instanceof RDF4JTripleLike) {
+			// Return original statement - this covers both RDF4JQuad and
+			// RDF4JTriple
+			return ((RDF4JTripleLike) tripleLike).asStatement();
+		}
+
+		org.eclipse.rdf4j.model.Resource subject = (org.eclipse.rdf4j.model.Resource) asValue(tripleLike.getSubject());
+		org.eclipse.rdf4j.model.IRI predicate = (org.eclipse.rdf4j.model.IRI) asValue(tripleLike.getPredicate());
+		Value object = asValue(tripleLike.getObject());
+
+		org.eclipse.rdf4j.model.Resource context = null;
+		if (tripleLike instanceof Quad) {
+			Quad quad = (Quad) tripleLike;
+			context = (org.eclipse.rdf4j.model.Resource) asValue(quad.getGraphName().orElse(null));
+		}
+
+		return getValueFactory().createStatement(subject, predicate, object, context);
+	}
+
+	/**
+	 * Adapt a RDF4J {@link Statement} as a Commons RDF {@link Triple}.
+	 * <p>
+	 * For the purpose of {@link BlankNode} equivalence, this method will use an
+	 * internal salt UUID that is unique per instance of
+	 * {@link RDF4JFactory}.
+	 * <p>
+	 * <strong>NOTE:</strong> If combining RDF4J statements from multiple
+	 * repositories or models, then their {@link BNode}s may have the same
+	 * {@link BNode#getID()}, which with this method would become equivalent
+	 * according to {@link BlankNode#equals(Object)} and
+	 * {@link BlankNode#uniqueReference()}, unless a separate
+	 * {@link RDF4JFactory} instance is used per RDF4J repository/model.
+	 *
+	 * @param statement
+	 *            The RDF4J {@link Statement} to adapt.
+	 * @return A {@link RDF4JTriple} that is equivalent to the statement
+	 */
+	public RDF4JTriple asTriple(final Statement statement) {
+		return rdf4j.createTripleImpl(statement, salt);
+	}
+
+	/**
+	 * Adapt a Commons RDF {@link RDFTerm} as a RDF4J {@link Value}.
+	 * <p>
+	 * The value will be of the same kind as the term, e.g. a
+	 * {@link org.apache.commons.rdf.api.BlankNode} is converted to a
+	 * {@link org.eclipse.rdf4j.model.BNode}, a
+	 * {@link org.apache.commons.rdf.api.IRI} is converted to a
+	 * {@link org.eclipse.rdf4j.model.IRI} and a
+	 * {@link org.apache.commons.rdf.api.Literal} is converted to a
+	 * {@link org.eclipse.rdf4j.model.Literal}.
+	 * <p>
+	 * If the provided {@link RDFTerm} is <code>null</code>, then the returned
+	 * value is <code>null</code>.
+	 * <p>
+	 * If the provided term is an instance of {@link RDF4JTerm}, then the
+	 * {@link RDF4JTerm#asValue()} is returned without any conversion. Note that
+	 * this could mean that a {@link Value} from a different kind of
+	 * {@link ValueFactory} could be returned.
+	 *
+	 * @param term
+	 *            RDFTerm to adapt to RDF4J Value
+	 * @return Adapted RDF4J {@link Value}
+	 */
+	public Value asValue(RDFTerm term) {
+		if (term == null) {
+			return null;
+		}
+		if (term instanceof RDF4JTerm) {
+			// One of our own - avoid converting again.
+			// (This is crucial to avoid double-escaping in BlankNode)
+			return ((RDF4JTerm) term).asValue();
+		}
+		if (term instanceof org.apache.commons.rdf.api.IRI) {
+			org.apache.commons.rdf.api.IRI iri = (org.apache.commons.rdf.api.IRI) term;
+			return getValueFactory().createIRI(iri.getIRIString());
+		}
+		if (term instanceof org.apache.commons.rdf.api.Literal) {
+			org.apache.commons.rdf.api.Literal literal = (org.apache.commons.rdf.api.Literal) term;
+			String label = literal.getLexicalForm();
+			if (literal.getLanguageTag().isPresent()) {
+				String lang = literal.getLanguageTag().get();
+				return getValueFactory().createLiteral(label, lang);
+			}
+			org.eclipse.rdf4j.model.IRI dataType = (org.eclipse.rdf4j.model.IRI) asValue(literal.getDatatype());
+			return getValueFactory().createLiteral(label, dataType);
+		}
+		if (term instanceof BlankNode) {
+			// This is where it gets tricky to support round trips!
+			BlankNode blankNode = (BlankNode) term;
+			// FIXME: The uniqueReference might not be a valid BlankNode
+			// identifier..
+			// does it have to be in RDF4J?
+			return getValueFactory().createBNode(blankNode.uniqueReference());
+		}
+		throw new IllegalArgumentException("RDFTerm was not an IRI, Literal or BlankNode: " + term.getClass());
+	}
+
+	@Override
+	public RDF4JBlankNode createBlankNode() {
+		BNode bnode = getValueFactory().createBNode();
+		return (RDF4JBlankNode) asRDFTerm(bnode);
+	}
+
+	@Override
+	public RDF4JBlankNode createBlankNode(String name) {
+		BNode bnode = getValueFactory().createBNode(name);
+		return (RDF4JBlankNode) asRDFTerm(bnode);
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 * <p>
+	 * <strong>Note:</strong> Some operations on the {@link RDF4JDataset}
+	 * requires the use of try-with-resources to close underlying
+	 * {@link RepositoryConnection}s, including
+	 * {@link RDF4JDataset#iterate()}, 
+	 * {@link RDF4JDataset#stream()} and {@link RDF4JDataset#getGraphNames()}.
+	 * 
+	 */
+	@Override
+	public RDF4JDataset createDataset() {
+		Sail sail = new MemoryStore();
+		Repository repository = new SailRepository(sail);
+		return rdf4j.createRepositoryDatasetImpl(repository, true, false);
+	}
+
+	@Override
+	public RDF4JGraph createGraph() {
+		return asRDFTermGraph(new LinkedHashModel());
+	}
+
+	@Override
+	public RDF4JIRI createIRI(String iri) throws IllegalArgumentException {
+		return (RDF4JIRI) asRDFTerm(getValueFactory().createIRI(iri));
+	}
+
+	@Override
+	public RDF4JLiteral createLiteral(String lexicalForm)
+			throws IllegalArgumentException {
+		org.eclipse.rdf4j.model.Literal lit = getValueFactory().createLiteral(lexicalForm);
+		return (RDF4JLiteral) asRDFTerm(lit);
+	}
+
+	@Override
+	public org.apache.commons.rdf.api.Literal createLiteral(String lexicalForm, org.apache.commons.rdf.api.IRI dataType)
+			throws IllegalArgumentException {
+		org.eclipse.rdf4j.model.IRI iri = getValueFactory().createIRI(dataType.getIRIString());
+		org.eclipse.rdf4j.model.Literal lit = getValueFactory().createLiteral(lexicalForm, iri);
+		return (org.apache.commons.rdf.api.Literal) asRDFTerm(lit);
+	}
+
+	@Override
+	public org.apache.commons.rdf.api.Literal createLiteral(String lexicalForm, String languageTag)
+			throws IllegalArgumentException {
+		org.eclipse.rdf4j.model.Literal lit = getValueFactory().createLiteral(lexicalForm, languageTag);
+		return (org.apache.commons.rdf.api.Literal) asRDFTerm(lit);
+	}
+
+	@Override
+	public RDF4JTriple createTriple(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object)
+			throws IllegalArgumentException {
+		final Statement statement = getValueFactory().createStatement(
+				(org.eclipse.rdf4j.model.Resource) asValue(subject), (org.eclipse.rdf4j.model.IRI) asValue(predicate),
+				asValue(object));
+		return asTriple(statement);
+	}
+
+	@Override
+	public Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate,
+			RDFTerm object) throws IllegalArgumentException {
+		final Statement statement = getValueFactory().createStatement(
+				(org.eclipse.rdf4j.model.Resource) asValue(subject), (org.eclipse.rdf4j.model.IRI) asValue(predicate),
+				asValue(object), (org.eclipse.rdf4j.model.Resource) asValue(graphName));
+		return asQuad(statement);
+	}
+
+	public ValueFactory getValueFactory() {
+		return valueFactory;
+	}
+
+	private EnumSet<Option> optionSet(Option... options) {
+		EnumSet<Option> opts = EnumSet.noneOf(Option.class);
+		opts.addAll(Arrays.asList(options));
+		return opts;
+	}
+	
+	
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
index a83a9ab..b7ef9a2 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
@@ -33,10 +33,10 @@ import org.eclipse.rdf4j.repository.Repository;
 /**
  * Marker interface for RDF4J implementations of Graph.
  * 
- * @see RDF4JTermFactory#createGraph()
- * @see RDF4JTermFactory#asRDFTermGraph(Model)
- * @see RDF4JTermFactory#asRDFTermGraph(Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
- * @see RDF4JTermFactory#asRDFTermGraphUnion(Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
+ * @see RDF4JFactory#createGraph()
+ * @see RDF4JFactory#asRDFTermGraph(Model)
+ * @see RDF4JFactory#asRDFTermGraph(Repository, org.apache.commons.rdf.rdf4j.RDF4JFactory.Option...)
+ * @see RDF4JFactory#asRDFTermGraphUnion(Repository, org.apache.commons.rdf.rdf4j.RDF4JFactory.Option...)
  * @see RDF4JDataset#getGraph()
  * @see RDF4JDataset#getGraph(BlankNodeOrIRI)
  */
@@ -64,7 +64,7 @@ public interface RDF4JGraph extends Graph, RDF4JGraphLike<Triple> {
 	 * Note that the context mask itself cannot be <code>null</code>.
 	 * <p>
 	 * The returned set is an immutable copy; to specify a different mask, use
-	 * {@link RDF4JTermFactory#asRDFTermGraph(Repository, Set, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)}
+	 * {@link RDF4JFactory#asRDFTermGraph(Repository, Set, org.apache.commons.rdf.rdf4j.RDF4JFactory.Option...)}
 	 *
 	 * @return The context mask as a set of {@link BlankNodeOrIRI} graph names, which
 	 *         may contain the value <code>null</code>.

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java
index 37efa0a..270567b 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java
@@ -24,7 +24,7 @@ package org.apache.commons.rdf.rdf4j;
  * The underlying RDF4J {@link org.eclipse.rdf4j.model.IRI} 
  * instance can be retrieved with {@link #asValue()}.
  * 
- * @see RDF4JTermFactory#createIRI(String)
+ * @see RDF4JFactory#createIRI(String)
  */
 public interface RDF4JIRI 
 	extends RDF4JBlankNodeOrIRI, org.apache.commons.rdf.api.IRI {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java
index 114d3f9..f6b0349 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java
@@ -24,7 +24,7 @@ package org.apache.commons.rdf.rdf4j;
  * The underlying RDF4J {@link org.eclipse.rdf4j.model.Literal} instance can be
  * retrieved with {@link #asValue()}.
  * 
- * @see RDF4JTermFactory#createLiteral(String)
+ * @see RDF4JFactory#createLiteral(String)
  */
 public interface RDF4JLiteral extends RDF4JTerm, org.apache.commons.rdf.api.Literal {
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JQuad.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JQuad.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JQuad.java
index 2d5b68f..d3fbcf0 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JQuad.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JQuad.java
@@ -22,7 +22,7 @@ import org.apache.commons.rdf.api.Quad;
 /**
  * Marker interface for RDF4J implementations of Quad.
  * 
- * @see RDF4JTermFactory#createQuad(org.apache.commons.rdf.api.BlankNodeOrIRI, org.apache.commons.rdf.api.BlankNodeOrIRI, org.apache.commons.rdf.api.IRI, org.apache.commons.rdf.api.RDFTerm)
+ * @see RDF4JFactory#createQuad(org.apache.commons.rdf.api.BlankNodeOrIRI, org.apache.commons.rdf.api.BlankNodeOrIRI, org.apache.commons.rdf.api.IRI, org.apache.commons.rdf.api.RDFTerm)
  */
 public interface RDF4JQuad extends Quad, RDF4JTripleLike {
 	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
deleted file mode 100644
index c503077..0000000
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
+++ /dev/null
@@ -1,601 +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.rdf4j;
-
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.Objects;
-import java.util.Set;
-import java.util.UUID;
-
-// To avoid confusion, avoid importing
-// classes that are in both
-// commons.rdf and openrdf.model (e.g. IRI, Literal)
-import org.apache.commons.rdf.api.BlankNode;
-import org.apache.commons.rdf.api.BlankNodeOrIRI;
-import org.apache.commons.rdf.api.Dataset;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.Quad;
-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.rdf4j.impl.InternalRDF4JFactory;
-import org.eclipse.rdf4j.model.BNode;
-import org.eclipse.rdf4j.model.Model;
-import org.eclipse.rdf4j.model.Resource;
-import org.eclipse.rdf4j.model.Statement;
-import org.eclipse.rdf4j.model.Value;
-import org.eclipse.rdf4j.model.ValueFactory;
-import org.eclipse.rdf4j.model.impl.LinkedHashModel;
-import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
-import org.eclipse.rdf4j.repository.Repository;
-import org.eclipse.rdf4j.repository.RepositoryConnection;
-import org.eclipse.rdf4j.repository.sail.SailRepository;
-import org.eclipse.rdf4j.sail.Sail;
-import org.eclipse.rdf4j.sail.memory.MemoryStore;
-
-/**
- * RDF4J implementation of RDFTermFactory.
- * <p>
- * The {@link #RDF4JTermFactory()} constructor uses a {@link SimpleValueFactory}
- * to create corresponding RDF4J {@link Value} instances. Alternatively, this
- * factory can be constructed with a different {@link ValueFactory} using
- * {@link #RDF4JTermFactory(ValueFactory)}.
- * <p>
- * {@link #asRDFTerm(Value)} can be used to convert any RDF4J {@link Value} to
- * an RDFTerm. Note that adapted {@link BNode}s are considered equal if they are
- * converted with the same {@link RDF4JTermFactory} instance and have the same
- * {@link BNode#getID()}.
- * <p>
- * {@link #createGraph()} creates a new Graph backed by {@link LinkedHashModel}.
- * To use other models, see {@link #asRDFTermGraph(Model)}.
- * <p>
- * To adapt a RDF4J {@link Repository} as a {@link Dataset} or {@link Graph},
- * use {@link #asRDFTermDataset(Repository, Option...)} 
- * or 
- * {@link #asRDFTermGraph(Repository, Option...)}.
- * <p>
- * {@link #asTriple(Statement)} can be used to convert a RDF4J {@link Statement}
- * to a Commons RDF {@link Triple}, and equivalent {@link #asQuad(Statement)} to
- * convert a {@link Quad}.
- * <p>
- * To convert any {@link Triple} or {@link Quad} to to RDF4J {@link Statement},
- * use {@link #asStatement(TripleLike)}. This recognises previously converted
- * {@link RDF4JTriple}s and {@link RDF4JQuad}s without re-converting their
- * {@link RDF4JTripleLike#asStatement()}.
- * <p>
- * Likewise, {@link #asValue(RDFTerm)} can be used to convert any Commons RDF
- * {@link RDFTerm} to a corresponding RDF4J {@link Value}. This recognises
- * previously converted {@link RDF4JTerm}s without re-converting their
- * {@link RDF4JTerm#asValue()}.
- * <p>
- * For the purpose of {@link BlankNode} equivalence, this factory contains an
- * internal {@link UUID} salt that is used by adapter methods like
- * {@link #asQuad(Statement)}, {@link #asTriple(Statement)},
- * {@link #asRDFTerm(Value)} as well as {@link #createBlankNode(String)}. As
- * RDF4J {@link BNode} instances from multiple repositories or models may have
- * the same {@link BNode#getID()}, converting them with the above methods might
- * cause accidental {@link BlankNode} equivalence. Note that the {@link Graph}
- * and {@link Dataset} adapter methods like
- * {@link #asRDFTermDataset(Repository, Option...)}
- * and 
- * {@link #asRDFTermGraph(Repository, Option...)}
- * therefore uses a unique {@link RDF4JTermFactory} internally.
- *
- */
-public final class RDF4JTermFactory implements RDFTermFactory {
-
-	/**
-	 * InternalRDF4JFactory is deliberately abstract
-	 */
-	private static InternalRDF4JFactory rdf4j = new InternalRDF4JFactory() {
-	};
-
-	public enum Option { 
-		/** 
-		 * The Graph/Dataset should include any inferred statements 
-		 */
-		includeInferred,
-		/**
-		 * The graph/dataset should handle {@link Repository#initialize()} (if
-		 * needed) and {@link Repository#shutDown()} on {@link Graph#close()} /
-		 * {@link Dataset#close()}.
-		 */
-		handleInitAndShutdown
-	}
-
-	private final UUID salt;
-
-	private final ValueFactory valueFactory;
-
-	/**
-	 * Construct an {@link RDF4JTermFactory}.
-	 * 
-	 */
-	public RDF4JTermFactory() {
-		this(SimpleValueFactory.getInstance(), UUID.randomUUID());
-	}
-
-	/**
-	 * Construct an {@link RDF4JTermFactory}.
-	 * <p>
-	 * This constructor is intended for use with the value factory from
-	 * {@link Repository#getValueFactory()} when using 
-	 * Repository-based graphs and datasets.
-	 * 
-	 * @param valueFactory
-	 *            The RDF4J {@link ValueFactory} to use
-	 */
-	public RDF4JTermFactory(ValueFactory valueFactory) {
-		this(valueFactory, UUID.randomUUID());
-	}
-
-	/**
-	 * Construct an {@link RDF4JTermFactory}.
-	 * <p>
-	 * This constructor may be used if reproducible
-	 * {@link BlankNode#uniqueReference()} in {@link BlankNode} is desirable.
-	 * 
-	 * @param salt
-	 *            An {@link UUID} salt to be used by any created
-	 *            {@link BlankNode}s for the purpose of
-	 *            {@link BlankNode#uniqueReference()}
-	 */	
-	public RDF4JTermFactory(UUID salt) {
-		this(SimpleValueFactory.getInstance(), salt);
-	}
-	/**
-	 * Construct an {@link RDF4JTermFactory}.
-	 * <p>
-	 * This constructor may be used if reproducible
-	 * {@link BlankNode#uniqueReference()} in {@link BlankNode} is desirable.
-	 * 
-	 * @param valueFactory
-	 *            The RDF4J {@link ValueFactory} to use
-	 * @param salt
-	 *            An {@link UUID} salt to be used by any created
-	 *            {@link BlankNode}s for the purpose of
-	 *            {@link BlankNode#uniqueReference()}
-	 */	
-	public RDF4JTermFactory(ValueFactory valueFactory, UUID salt) {
-		this.valueFactory = valueFactory;
-		this.salt = salt;
-	}
-
-	/**
-	 * Adapt a RDF4J {@link Statement} as a Commons RDF {@link Quad}.
-	 * <p>
-	 * For the purpose of {@link BlankNode} equivalence, this method will use an
-	 * internal salt UUID that is unique per instance of
-	 * {@link RDF4JTermFactory}.
-	 * <p>
-	 * <strong>NOTE:</strong> If combining RDF4J {@link Statement}s multiple
-	 * repositories or models, then their {@link BNode}s may have the same
-	 * {@link BNode#getID()}, which with this method would become equivalent
-	 * according to {@link BlankNode#equals(Object)} and
-	 * {@link BlankNode#uniqueReference()}, unless a separate
-	 * {@link RDF4JTermFactory} instance is used per RDF4J repository/model.
-	 *
-	 * @param statement
-	 *            The statement to convert
-	 * @return A {@link RDF4JQuad} that is equivalent to the statement
-	 */
-	public RDF4JQuad asQuad(final Statement statement) {
-		return rdf4j.createQuadImpl(statement, salt);
-	}
-
-	/**
-	 *
-	 * Adapt a RDF4J {@link Value} as a Commons RDF {@link RDFTerm}.
-	 * <p>
-	 * The value will be of the same kind as the term, e.g. a
-	 * {@link org.eclipse.rdf4j.model.BNode} is converted to a
-	 * {@link org.apache.commons.rdf.api.BlankNode}, a
-	 * {@link org.eclipse.rdf4j.model.IRI} is converted to a
-	 * {@link org.apache.commons.rdf.api.IRI} and a
-	 * {@link org.eclipse.rdf4j.model.Literal}. is converted to a
-	 * {@link org.apache.commons.rdf.api.Literal}
-	 * <p>
-	 * For the purpose of {@link BlankNode} equivalence, this method will use an
-	 * internal salt UUID that is unique per instance of
-	 * {@link RDF4JTermFactory}.
-	 * <p>
-	 * <strong>NOTE:</strong> If combining RDF4J values from multiple
-	 * repositories or models, then their {@link BNode}s may have the same
-	 * {@link BNode#getID()}, which with this method would become equivalent
-	 * according to {@link BlankNode#equals(Object)} and
-	 * {@link BlankNode#uniqueReference()}, unless a separate
-	 * {@link RDF4JTermFactory} instance is used per RDF4J repository/model.
-	 *
-	 * @param value
-	 *            The RDF4J {@link Value} to convert.
-	 * @return A {@link RDFTerm} that corresponds to the RDF4J value
-	 * @throws IllegalArgumentException
-	 *             if the value is not a BNode, Literal or IRI
-	 */
-	public RDF4JTerm asRDFTerm(Value value) {
-		return asRDFTerm(value, salt);
-	}
-	
-	/**
-	 * Adapt a RDF4J {@link Value} as a Commons RDF {@link RDFTerm}.
-	 * <p>
-	 * The value will be of the same kind as the term, e.g. a
-	 * {@link org.eclipse.rdf4j.model.BNode} is converted to a
-	 * {@link org.apache.commons.rdf.api.BlankNode}, a
-	 * {@link org.eclipse.rdf4j.model.IRI} is converted to a
-	 * {@link org.apache.commons.rdf.api.IRI} and a
-	 * {@link org.eclipse.rdf4j.model.Literal}. is converted to a
-	 * {@link org.apache.commons.rdf.api.Literal}
-	 *
-	 * @param value
-	 *            The RDF4J {@link Value} to convert.
-	 * @param salt
-	 *            A {@link UUID} salt to use for uniquely mapping any
-	 *            {@link BNode}s. The salt should typically be the same for
-	 *            multiple statements in the same {@link Repository} or
-	 *            {@link Model} to ensure {@link BlankNode#equals(Object)} and
-	 *            {@link BlankNode#uniqueReference()} works as intended.
-	 * @return A {@link RDFTerm} that corresponds to the RDF4J value
-	 * @throws IllegalArgumentException
-	 *             if the value is not a BNode, Literal or IRI
-	 */
-	public static RDF4JTerm asRDFTerm(final Value value, UUID salt) {
-		if (value instanceof BNode) {
-			return rdf4j.createBlankNodeImpl((BNode) value, salt);
-		}
-		if (value instanceof org.eclipse.rdf4j.model.Literal) {
-			return rdf4j.createLiteralImpl((org.eclipse.rdf4j.model.Literal) value);
-		}
-		if (value instanceof org.eclipse.rdf4j.model.IRI) {
-			return rdf4j.createIRIImpl((org.eclipse.rdf4j.model.IRI) value);
-		}
-		throw new IllegalArgumentException("Value is not a BNode, Literal or IRI: " + value.getClass());
-	}	
-
-	/**
-	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Dataset}.
-	 * <p>
-	 * Changes to the dataset are reflected in the repository, and vice versa.
-	 * <p>
-	 * <strong>Note:</strong> Some operations on the {@link RDF4JDataset}
-	 * requires the use of try-with-resources to close underlying
-	 * {@link RepositoryConnection}s, including
-	 * {@link RDF4JDataset#iterate()}, 
-	 * {@link RDF4JDataset#stream()} and {@link RDF4JDataset#getGraphNames()}.
-	 *
-	 * @param repository
-	 *            RDF4J {@link Repository} to connect to.
-	 * @param options
-	 *            Zero or more {@link Option}
-	 * @return A {@link Dataset} backed by the RDF4J repository.
-	 */
-	public RDF4JDataset asRDFTermDataset(Repository repository, Option... options) {
-		EnumSet<Option> opts = optionSet(options);
-		return rdf4j.createRepositoryDatasetImpl(repository, 
-				opts.contains(Option.handleInitAndShutdown), 
-				opts.contains(Option.includeInferred));
-	}
-
-	/**
-	 * Adapt an RDF4J {@link Model} as a Commons RDF {@link Graph}.
-	 * <p>
-	 * Changes to the graph are reflected in the model, and vice versa.
-	 *
-	 * @param model
-	 *            RDF4J {@link Model} to adapt.
-	 * @return Adapted {@link Graph}.
-	 */
-	public RDF4JGraph asRDFTermGraph(Model model) {
-		return rdf4j.createModelGraphImpl(model, this);
-	}
-
-	/**
-	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Graph}.
-	 * <p>
-	 * The graph will only include triples in the default graph (equivalent to
-	 * context <code>new Resource[0]{null})</code> in RDF4J).
-	 * <p>
-	 * Changes to the graph are reflected in the repository, and vice versa.
-	 * <p>
-	 * <strong>Note:</strong> Some operations on the {@link RDF4JGraph}
-	 * requires the use of try-with-resources to close underlying
-	 * {@link RepositoryConnection}s, including
-	 * {@link RDF4JGraph#iterate()} and 
-	 * {@link RDF4JGraph#stream()}.
-	 *
-	 * @param repository
-	 *            RDF4J {@link Repository} to connect to.
-	 * @param options
-	 *            Zero or more {@link Option}
-	 * @return A {@link Graph} backed by the RDF4J repository.
-	 */
-	public RDF4JGraph asRDFTermGraph(Repository repository, Option... options) {
-		EnumSet<Option> opts = optionSet(options);
-		return rdf4j.createRepositoryGraphImpl(repository, 
-				opts.contains(Option.handleInitAndShutdown), 
-				opts.contains(Option.includeInferred), 
-				new Resource[]{null}); // default graph
-	}
-
-	/**
-	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Graph}.
-	 * <p>
-	 * The graph will include triples in any contexts (e.g. the union graph).
-	 * <p>
-	 * Changes to the graph are reflected in the repository, and vice versa.
-	 *
-	 * @param repository
-	 *            RDF4J {@link Repository} to connect to.
-	 * @param options
-	 *            Zero or more {@link Option}
-	 * @return A union {@link Graph} backed by the RDF4J repository.
-	 */
-	public RDF4JGraph asRDFTermGraphUnion(Repository repository, Option... options) {
-		EnumSet<Option> opts = optionSet(options);
-		return rdf4j.createRepositoryGraphImpl(repository, 
-				opts.contains(Option.handleInitAndShutdown), 
-				opts.contains(Option.includeInferred),
-				new Resource[]{}); // union graph 
-		
-	}
-
-	/**
-	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Graph}.
-	 * <p>
-	 * The graph will include triples in the specified contexts.
-	 * <p>
-	 * Changes to the graph are reflected in the repository, and vice versa.
-	 * Triples added/removed to the graph are reflected in all the specified
-	 * contexts.
-	 * <p>
-	 * <strong>Note:</strong> Some operations on the {@link RDF4JGraph}
-	 * requires the use of try-with-resources to close underlying
-	 * {@link RepositoryConnection}s, including
-	 * {@link RDF4JGraph#iterate()} and 
-	 * {@link RDF4JGraph#stream()}.
-	 *
-	 * @param repository
-	 *            RDF4J {@link Repository} to connect to.
-	 * @param contexts
-	 *            A {@link Set} of {@link BlankNodeOrIRI} specifying the graph
-	 *            names to use as a context. The set may include the value
-	 *            <code>null</code> to indicate the default graph. The empty set
-	 *            indicates any context, e.g. the <em>union graph</em>.
-	 * @param option
-	 *            Zero or more {@link Option}s
-	 * @return A {@link Graph} backed by the RDF4J repository.
-	 */
-	public RDF4JGraph asRDFTermGraph(Repository repository, Set<? extends BlankNodeOrIRI> contexts,
-			Option... option) {
-		EnumSet<Option> opts = optionSet(option);
-		/** NOTE: asValue() deliberately CAN handle <code>null</code> */
-		Resource[] resources = contexts.stream().map(g -> (Resource) asValue(g)).toArray(Resource[]::new);
-		return rdf4j.createRepositoryGraphImpl(Objects.requireNonNull(repository), 
-				opts.contains(Option.handleInitAndShutdown),
-				opts.contains(Option.includeInferred),
-				resources);
-	}
-
-	/**
-	 * Adapt a Commons RDF {@link Triple} or {@link Quad} as a RDF4J
-	 * {@link Statement}.
-	 * <p>
-	 * If the <code>tripleLike</code> argument is an {@link RDF4JTriple} or a
-	 * {@link RDF4JQuad}, then its {@link RDF4JTripleLike#asStatement()} is
-	 * returned as-is. Note that this means that a {@link RDF4JTriple} would
-	 * preserve its {@link Statement#getContext()}, and that any
-	 * {@link BlankNode}s would be deemed equivalent in RDF4J if they have the
-	 * same {@link BNode#getID()}.
-	 *
-	 * @param tripleLike
-	 *            A {@link Triple} or {@link Quad} to adapt
-	 * @return A corresponding {@link Statement}
-	 */
-	public Statement asStatement(TripleLike tripleLike) {
-		if (tripleLike instanceof RDF4JTripleLike) {
-			// Return original statement - this covers both RDF4JQuad and
-			// RDF4JTriple
-			return ((RDF4JTripleLike) tripleLike).asStatement();
-		}
-
-		org.eclipse.rdf4j.model.Resource subject = (org.eclipse.rdf4j.model.Resource) asValue(tripleLike.getSubject());
-		org.eclipse.rdf4j.model.IRI predicate = (org.eclipse.rdf4j.model.IRI) asValue(tripleLike.getPredicate());
-		Value object = asValue(tripleLike.getObject());
-
-		org.eclipse.rdf4j.model.Resource context = null;
-		if (tripleLike instanceof Quad) {
-			Quad quad = (Quad) tripleLike;
-			context = (org.eclipse.rdf4j.model.Resource) asValue(quad.getGraphName().orElse(null));
-		}
-
-		return getValueFactory().createStatement(subject, predicate, object, context);
-	}
-
-	/**
-	 * Adapt a RDF4J {@link Statement} as a Commons RDF {@link Triple}.
-	 * <p>
-	 * For the purpose of {@link BlankNode} equivalence, this method will use an
-	 * internal salt UUID that is unique per instance of
-	 * {@link RDF4JTermFactory}.
-	 * <p>
-	 * <strong>NOTE:</strong> If combining RDF4J statements from multiple
-	 * repositories or models, then their {@link BNode}s may have the same
-	 * {@link BNode#getID()}, which with this method would become equivalent
-	 * according to {@link BlankNode#equals(Object)} and
-	 * {@link BlankNode#uniqueReference()}, unless a separate
-	 * {@link RDF4JTermFactory} instance is used per RDF4J repository/model.
-	 *
-	 * @param statement
-	 *            The RDF4J {@link Statement} to adapt.
-	 * @return A {@link RDF4JTriple} that is equivalent to the statement
-	 */
-	public RDF4JTriple asTriple(final Statement statement) {
-		return rdf4j.createTripleImpl(statement, salt);
-	}
-
-	/**
-	 * Adapt a Commons RDF {@link RDFTerm} as a RDF4J {@link Value}.
-	 * <p>
-	 * The value will be of the same kind as the term, e.g. a
-	 * {@link org.apache.commons.rdf.api.BlankNode} is converted to a
-	 * {@link org.eclipse.rdf4j.model.BNode}, a
-	 * {@link org.apache.commons.rdf.api.IRI} is converted to a
-	 * {@link org.eclipse.rdf4j.model.IRI} and a
-	 * {@link org.apache.commons.rdf.api.Literal} is converted to a
-	 * {@link org.eclipse.rdf4j.model.Literal}.
-	 * <p>
-	 * If the provided {@link RDFTerm} is <code>null</code>, then the returned
-	 * value is <code>null</code>.
-	 * <p>
-	 * If the provided term is an instance of {@link RDF4JTerm}, then the
-	 * {@link RDF4JTerm#asValue()} is returned without any conversion. Note that
-	 * this could mean that a {@link Value} from a different kind of
-	 * {@link ValueFactory} could be returned.
-	 *
-	 * @param term
-	 *            RDFTerm to adapt to RDF4J Value
-	 * @return Adapted RDF4J {@link Value}
-	 */
-	public Value asValue(RDFTerm term) {
-		if (term == null) {
-			return null;
-		}
-		if (term instanceof RDF4JTerm) {
-			// One of our own - avoid converting again.
-			// (This is crucial to avoid double-escaping in BlankNode)
-			return ((RDF4JTerm) term).asValue();
-		}
-		if (term instanceof org.apache.commons.rdf.api.IRI) {
-			org.apache.commons.rdf.api.IRI iri = (org.apache.commons.rdf.api.IRI) term;
-			return getValueFactory().createIRI(iri.getIRIString());
-		}
-		if (term instanceof org.apache.commons.rdf.api.Literal) {
-			org.apache.commons.rdf.api.Literal literal = (org.apache.commons.rdf.api.Literal) term;
-			String label = literal.getLexicalForm();
-			if (literal.getLanguageTag().isPresent()) {
-				String lang = literal.getLanguageTag().get();
-				return getValueFactory().createLiteral(label, lang);
-			}
-			org.eclipse.rdf4j.model.IRI dataType = (org.eclipse.rdf4j.model.IRI) asValue(literal.getDatatype());
-			return getValueFactory().createLiteral(label, dataType);
-		}
-		if (term instanceof BlankNode) {
-			// This is where it gets tricky to support round trips!
-			BlankNode blankNode = (BlankNode) term;
-			// FIXME: The uniqueReference might not be a valid BlankNode
-			// identifier..
-			// does it have to be in RDF4J?
-			return getValueFactory().createBNode(blankNode.uniqueReference());
-		}
-		throw new IllegalArgumentException("RDFTerm was not an IRI, Literal or BlankNode: " + term.getClass());
-	}
-
-	@Override
-	public RDF4JBlankNode createBlankNode() {
-		BNode bnode = getValueFactory().createBNode();
-		return (RDF4JBlankNode) asRDFTerm(bnode);
-	}
-
-	@Override
-	public RDF4JBlankNode createBlankNode(String name) {
-		BNode bnode = getValueFactory().createBNode(name);
-		return (RDF4JBlankNode) asRDFTerm(bnode);
-	}
-	
-	/**
-	 * {@inheritDoc}
-	 * <p>
-	 * <strong>Note:</strong> Some operations on the {@link RDF4JDataset}
-	 * requires the use of try-with-resources to close underlying
-	 * {@link RepositoryConnection}s, including
-	 * {@link RDF4JDataset#iterate()}, 
-	 * {@link RDF4JDataset#stream()} and {@link RDF4JDataset#getGraphNames()}.
-	 * 
-	 */
-	@Override
-	public RDF4JDataset createDataset() {
-		Sail sail = new MemoryStore();
-		Repository repository = new SailRepository(sail);
-		return rdf4j.createRepositoryDatasetImpl(repository, true, false);
-	}
-
-	@Override
-	public RDF4JGraph createGraph() {
-		return asRDFTermGraph(new LinkedHashModel());
-	}
-
-	@Override
-	public RDF4JIRI createIRI(String iri) throws IllegalArgumentException {
-		return (RDF4JIRI) asRDFTerm(getValueFactory().createIRI(iri));
-	}
-
-	@Override
-	public RDF4JLiteral createLiteral(String lexicalForm)
-			throws IllegalArgumentException {
-		org.eclipse.rdf4j.model.Literal lit = getValueFactory().createLiteral(lexicalForm);
-		return (RDF4JLiteral) asRDFTerm(lit);
-	}
-
-	@Override
-	public org.apache.commons.rdf.api.Literal createLiteral(String lexicalForm, org.apache.commons.rdf.api.IRI dataType)
-			throws IllegalArgumentException {
-		org.eclipse.rdf4j.model.IRI iri = getValueFactory().createIRI(dataType.getIRIString());
-		org.eclipse.rdf4j.model.Literal lit = getValueFactory().createLiteral(lexicalForm, iri);
-		return (org.apache.commons.rdf.api.Literal) asRDFTerm(lit);
-	}
-
-	@Override
-	public org.apache.commons.rdf.api.Literal createLiteral(String lexicalForm, String languageTag)
-			throws IllegalArgumentException {
-		org.eclipse.rdf4j.model.Literal lit = getValueFactory().createLiteral(lexicalForm, languageTag);
-		return (org.apache.commons.rdf.api.Literal) asRDFTerm(lit);
-	}
-
-	@Override
-	public RDF4JTriple createTriple(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object)
-			throws IllegalArgumentException {
-		final Statement statement = getValueFactory().createStatement(
-				(org.eclipse.rdf4j.model.Resource) asValue(subject), (org.eclipse.rdf4j.model.IRI) asValue(predicate),
-				asValue(object));
-		return asTriple(statement);
-	}
-
-	@Override
-	public Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate,
-			RDFTerm object) throws IllegalArgumentException {
-		final Statement statement = getValueFactory().createStatement(
-				(org.eclipse.rdf4j.model.Resource) asValue(subject), (org.eclipse.rdf4j.model.IRI) asValue(predicate),
-				asValue(object), (org.eclipse.rdf4j.model.Resource) asValue(graphName));
-		return asQuad(statement);
-	}
-
-	public ValueFactory getValueFactory() {
-		return valueFactory;
-	}
-
-	private EnumSet<Option> optionSet(Option... options) {
-		EnumSet<Option> opts = EnumSet.noneOf(Option.class);
-		opts.addAll(Arrays.asList(options));
-		return opts;
-	}
-	
-	
-	
-}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java
index 7308f8f..e475a08 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java
@@ -22,7 +22,7 @@ import org.apache.commons.rdf.api.Triple;
 /**
  * Marker interface for RDF4J implementations of Triple.
  * 
- * @see RDF4JTermFactory#createTriple(org.apache.commons.rdf.api.BlankNodeOrIRI, org.apache.commons.rdf.api.IRI, org.apache.commons.rdf.api.RDFTerm)
+ * @see RDF4JFactory#createTriple(org.apache.commons.rdf.api.BlankNodeOrIRI, org.apache.commons.rdf.api.IRI, org.apache.commons.rdf.api.RDFTerm)
  */
 public interface RDF4JTriple extends Triple, RDF4JTripleLike {
 	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
index 17aecf9..f9a1e74 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
@@ -34,7 +34,7 @@ import org.apache.commons.rdf.experimental.RDFParser;
 import org.apache.commons.rdf.rdf4j.RDF4JBlankNodeOrIRI;
 import org.apache.commons.rdf.rdf4j.RDF4JDataset;
 import org.apache.commons.rdf.rdf4j.RDF4JGraph;
-import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.rdf4j.RDF4JFactory;
 import org.apache.commons.rdf.simple.experimental.AbstractRDFParser;
 import org.eclipse.rdf4j.model.Model;
 import org.eclipse.rdf4j.model.Resource;
@@ -101,20 +101,20 @@ public class RDF4JParser extends AbstractRDFParser<RDF4JParser> implements RDFPa
 		}
 	}
 
-	private RDF4JTermFactory rdf4jTermFactory;
+	private RDF4JFactory rdf4jTermFactory;
 	private ParserConfig parserConfig = new ParserConfig();
 
 	@Override
-	protected RDF4JTermFactory createRDFTermFactory() {
-		return new RDF4JTermFactory();
+	protected RDF4JFactory createRDFTermFactory() {
+		return new RDF4JFactory();
 	}
 
 	@Override
 	protected RDF4JParser prepareForParsing() throws IOException, IllegalStateException {
 		RDF4JParser c = prepareForParsing();
-		// Ensure we have an RDF4JTermFactory for conversion.
+		// Ensure we have an RDF4JFactory for conversion.
 		// We'll make a new one if user has provided a non-RDF4J factory
-		c.rdf4jTermFactory = (RDF4JTermFactory) getRdfTermFactory().filter(RDF4JTermFactory.class::isInstance)
+		c.rdf4jTermFactory = (RDF4JFactory) getRdfTermFactory().filter(RDF4JFactory.class::isInstance)
 				.orElseGet(c::createRDFTermFactory);
 		return c;
 	}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
index 00388b9..1948a32 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
@@ -22,7 +22,7 @@ import java.util.UUID;
 
 import org.apache.commons.rdf.api.TripleLike;
 import org.apache.commons.rdf.rdf4j.RDF4JGraphLike;
-import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.rdf4j.RDF4JFactory;
 import org.eclipse.rdf4j.model.Model;
 import org.eclipse.rdf4j.model.Statement;
 import org.eclipse.rdf4j.repository.Repository;
@@ -34,7 +34,7 @@ abstract class AbstractRepositoryGraphLike<T extends TripleLike>
 	protected final Repository repository;
 	protected final boolean includeInferred;
 	protected final boolean handleInitAndShutdown;
-	protected final RDF4JTermFactory rdf4jTermFactory;
+	protected final RDF4JFactory rdf4jTermFactory;
 	protected final UUID salt;
 
 	AbstractRepositoryGraphLike(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred) {
@@ -45,7 +45,7 @@ abstract class AbstractRepositoryGraphLike<T extends TripleLike>
 		if (handleInitAndShutdown && !repository.isInitialized()) {
 			repository.initialize();
 		}
-		rdf4jTermFactory = new RDF4JTermFactory(repository.getValueFactory(), salt);
+		rdf4jTermFactory = new RDF4JFactory(repository.getValueFactory(), salt);
 	}	
 	
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
index fa4344f..7744e01 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
@@ -27,7 +27,7 @@ import org.apache.commons.rdf.rdf4j.RDF4JIRI;
 import org.apache.commons.rdf.rdf4j.RDF4JLiteral;
 import org.apache.commons.rdf.rdf4j.RDF4JQuad;
 import org.apache.commons.rdf.rdf4j.RDF4JTerm;
-import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.rdf4j.RDF4JFactory;
 import org.apache.commons.rdf.rdf4j.RDF4JTriple;
 import org.eclipse.rdf4j.model.BNode;
 import org.eclipse.rdf4j.model.IRI;
@@ -42,17 +42,17 @@ import org.eclipse.rdf4j.repository.Repository;
  * <p>
  * <strong>Internal class:</strong> This "abstract" class is intended for
  * internal use by Commons RDF and may change in any minor update. Use instead
- * {@link RDF4JTermFactory} methods like
- * {@link RDF4JTermFactory#createBlankNode()},
- * {@link RDF4JTermFactory#asRDFTerm(org.eclipse.rdf4j.model.Value)} and
- * {@link RDF4JTermFactory#asRDFTermGraph(Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)}
+ * {@link RDF4JFactory} methods like
+ * {@link RDF4JFactory#createBlankNode()},
+ * {@link RDF4JFactory#asRDFTerm(org.eclipse.rdf4j.model.Value)} and
+ * {@link RDF4JFactory#asRDFTermGraph(Repository, org.apache.commons.rdf.rdf4j.RDF4JFactory.Option...)}
  * <p>
  * This class exists as a <code>public</code> bridge between the packages
  * {@link org.apache.commons.rdf.rdf4j} and
  * {@link org.apache.commons.rdf.rdf4j.impl} by exposing the package-public
  * constructors.
  * 
- * @see RDF4JTermFactory
+ * @see RDF4JFactory
  */
 public abstract class InternalRDF4JFactory {
 
@@ -103,7 +103,7 @@ public abstract class InternalRDF4JFactory {
 	 *            factory to use for adapting graph triples
 	 * @return Adapted {@link RDF4JGraph}
 	 */
-	public RDF4JGraph createModelGraphImpl(Model model, RDF4JTermFactory rdf4jTermFactory) {
+	public RDF4JGraph createModelGraphImpl(Model model, RDF4JFactory rdf4jTermFactory) {
 		return new ModelGraphImpl(model, rdf4jTermFactory);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
index a2aaf4b..0d2695e 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
@@ -31,7 +31,7 @@ import org.apache.commons.rdf.api.Triple;
 import org.apache.commons.rdf.rdf4j.ClosableIterable;
 import org.apache.commons.rdf.rdf4j.RDF4JBlankNodeOrIRI;
 import org.apache.commons.rdf.rdf4j.RDF4JGraph;
-import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.rdf4j.RDF4JFactory;
 import org.apache.commons.rdf.rdf4j.RDF4JTriple;
 import org.eclipse.rdf4j.model.Model;
 import org.eclipse.rdf4j.model.Resource;
@@ -40,9 +40,9 @@ import org.eclipse.rdf4j.repository.Repository;
 final class ModelGraphImpl implements RDF4JGraph {
 	
 	private Model model;
-	private RDF4JTermFactory rdf4jTermFactory;
+	private RDF4JFactory rdf4jTermFactory;
 
-	ModelGraphImpl(Model model, RDF4JTermFactory rdf4jTermFactory) {
+	ModelGraphImpl(Model model, RDF4JFactory rdf4jTermFactory) {
 		this.model = model;	
 		this.rdf4jTermFactory = rdf4jTermFactory;
 	}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java
index 18a0c84..cf60883 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java
@@ -26,7 +26,7 @@ import org.apache.commons.rdf.api.Quad;
 import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.api.Triple;
 import org.apache.commons.rdf.rdf4j.RDF4JQuad;
-import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.rdf4j.RDF4JFactory;
 import org.eclipse.rdf4j.model.Statement;
 
 final class QuadImpl implements Quad, RDF4JQuad {
@@ -65,23 +65,23 @@ final class QuadImpl implements Quad, RDF4JQuad {
 			if (statement.getContext() == null) { 
 				return Optional.empty();
 			}			
-			BlankNodeOrIRI g = (BlankNodeOrIRI) RDF4JTermFactory.asRDFTerm(statement.getContext(), salt);
+			BlankNodeOrIRI g = (BlankNodeOrIRI) RDF4JFactory.asRDFTerm(statement.getContext(), salt);
 			return Optional.of(g);
 		}
 		
 		@Override
 		public RDFTerm getObject() {
-			return RDF4JTermFactory.asRDFTerm(statement.getObject(), salt);
+			return RDF4JFactory.asRDFTerm(statement.getObject(), salt);
 		}
 	
 		@Override
 		public org.apache.commons.rdf.api.IRI getPredicate() {
-			return (org.apache.commons.rdf.api.IRI) RDF4JTermFactory.asRDFTerm(statement.getPredicate(), null);
+			return (org.apache.commons.rdf.api.IRI) RDF4JFactory.asRDFTerm(statement.getPredicate(), null);
 		}
 		
 		@Override
 		public BlankNodeOrIRI getSubject() {
-			return (BlankNodeOrIRI) RDF4JTermFactory.asRDFTerm(statement.getSubject(), salt);
+			return (BlankNodeOrIRI) RDF4JFactory.asRDFTerm(statement.getSubject(), salt);
 		}
 
 		@Override

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java
index e1dcb60..23041c4 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java
@@ -23,7 +23,7 @@ import java.util.UUID;
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
 import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.api.Triple;
-import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.rdf4j.RDF4JFactory;
 import org.apache.commons.rdf.rdf4j.RDF4JTriple;
 import org.eclipse.rdf4j.model.Statement;
 
@@ -54,17 +54,17 @@ final class TripleImpl implements Triple, RDF4JTriple {
 	
 		@Override
 		public RDFTerm getObject() {
-			return RDF4JTermFactory.asRDFTerm(statement.getObject(), salt);
+			return RDF4JFactory.asRDFTerm(statement.getObject(), salt);
 		}
 	
 		@Override
 		public org.apache.commons.rdf.api.IRI getPredicate() {
-			return (org.apache.commons.rdf.api.IRI) RDF4JTermFactory.asRDFTerm(statement.getPredicate(), null);
+			return (org.apache.commons.rdf.api.IRI) RDF4JFactory.asRDFTerm(statement.getPredicate(), null);
 		}
 		
 		@Override
 		public BlankNodeOrIRI getSubject() {
-			return (BlankNodeOrIRI) RDF4JTermFactory.asRDFTerm(statement.getSubject(), salt);
+			return (BlankNodeOrIRI) RDF4JFactory.asRDFTerm(statement.getSubject(), salt);
 		}
 	
 		@Override

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
index a3928f3..f17a499 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
@@ -18,9 +18,9 @@
 /**
  * Commons RDF integration with <a href="http://rdf4j.org/">RDF4J</a>.
  * <p>
- * Use the {@link org.apache.commons.rdf.rdf4j.RDF4JTermFactory} to convert
+ * Use the {@link org.apache.commons.rdf.rdf4j.RDF4JFactory} to convert
  * between Commons RDF and RDF4J types, for instance
- * {@link org.apache.commons.rdf.rdf4j.RDF4JTermFactory#asQuad(org.eclipse.rdf4j.model.Statement)}
+ * {@link org.apache.commons.rdf.rdf4j.RDF4JFactory#asQuad(org.eclipse.rdf4j.model.Statement)}
  * converts a RDF4J {@link org.eclipse.rdf4j.model.Statement} to a
  * {@link org.apache.commons.rdf.api.Quad}. Converted RDF terms implement the
  * {@link org.apache.commons.rdf.rdf4j.RDF4JTerm} interface, and converted
@@ -32,9 +32,9 @@
  * {@link org.eclipse.rdf4j.repository.Repository} instances can be adapted to
  * Commons RDF {@link org.apache.commons.rdf.api.Graph} and
  * {@link org.apache.commons.rdf.api.Dataset}, e.g. using
- * {@link org.apache.commons.rdf.rdf4j.RDF4JTermFactory#asRDFTermGraph(org.eclipse.rdf4j.model.Model)}
+ * {@link org.apache.commons.rdf.rdf4j.RDF4JFactory#asRDFTermGraph(org.eclipse.rdf4j.model.Model)}
  * or
- * {@link org.apache.commons.rdf.rdf4j.RDF4JTermFactory#asRDFTermDataset(org.eclipse.rdf4j.repository.Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)}
+ * {@link org.apache.commons.rdf.rdf4j.RDF4JFactory#asRDFTermDataset(org.eclipse.rdf4j.repository.Repository, org.apache.commons.rdf.rdf4j.RDF4JFactory.Option...)}
  * The returned adapted graph/dataset is directly mapped, so changes are
  * propagated both ways. For convenience, the marker interface
  * {@link org.apache.commons.rdf.rdf4j.RDF4JGraph} and

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java
index 09ae666..1da3c11 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java
@@ -22,7 +22,7 @@ import org.apache.commons.rdf.api.BlankNode;
 
 public class BlankNodeTest extends AbstractBlankNodeTest {
 
-	RDF4JTermFactory factory = new RDF4JTermFactory();
+	RDF4JFactory factory = new RDF4JFactory();
 	
 	@Override
 	protected BlankNode getBlankNode() {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java
index 09ad421..07b60c2 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java
@@ -24,7 +24,7 @@ public class GraphTest extends AbstractGraphTest{
 
 	@Override
 	public RDFTermFactory createFactory() {
-		return new RDF4JTermFactory();
+		return new RDF4JFactory();
 	}
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java
index 3d99968..c275e67 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java
@@ -35,7 +35,7 @@ public class MemoryGraphTest extends AbstractGraphTest {
 
 	public static final class MemoryStoreFactory implements RDFTermFactory {
 
-		RDF4JTermFactory rdf4jFactory = new RDF4JTermFactory(new MemValueFactory());
+		RDF4JFactory rdf4jFactory = new RDF4JFactory(new MemValueFactory());
 
 		public RDF4JBlankNode createBlankNode() {
 			return rdf4jFactory.createBlankNode();

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
index 4d47e0c..77ee128 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
@@ -51,7 +51,7 @@ public class NativeStoreGraphTest extends AbstractGraphTest {
 
 	public final class NativeStoreFactory implements RDFTermFactory {
 
-		RDF4JTermFactory rdf4jFactory = new RDF4JTermFactory(getRepository().getValueFactory());
+		RDF4JFactory rdf4jFactory = new RDF4JFactory(getRepository().getValueFactory());
 
 		@Override
 		public RDF4JGraph createGraph() {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactoryTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactoryTest.java
index bc06c62..9dbbf4b 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactoryTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactoryTest.java
@@ -25,7 +25,7 @@ public class Rdf4JRDFTermFactoryTest extends AbstractRDFTermFactoryTest {
 
 	@Override
 	public RDFTermFactory createFactory() {
-		return new RDF4JTermFactory();
+		return new RDF4JFactory();
 	}
 	
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d043b075/src/site/markdown/implementations.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/implementations.md b/src/site/markdown/implementations.md
index 30235e1..0e4ab9b 100644
--- a/src/site/markdown/implementations.md
+++ b/src/site/markdown/implementations.md
@@ -131,20 +131,20 @@ The generalized triples/quads can be accessed as [org.apache.jena.graph.Triple](
 ```java
 import org.apache.commons.rdf.api.Graph;
 import org.apache.commons.rdf.api.RDFTermFactory;
-import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.rdf4j.RDF4JFactory;
 
-RDFTermFactory rdfTermFactory = new RDF4JTermFactory();
+RDFTermFactory rdfTermFactory = new RDF4JFactory();
 Graph graph = rdfTermFactory.createGraph();
 ```
 
-Objects created with  [RDF4JTermFactory](apidocs/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.html) implement interfaces like [RDF4JTerm](apidocs/org/apache/commons/rdf/rdf4j/RDF4JTerm.html) and [RDF4JGraph](apidocs/org/apache/commons/rdf/rdf4j/RDF4JGraph.html) which give access to the underlying Jena objects through methods like [asValue()](apidocs/org/apache/commons/rdf/rdf4j/RDF4JTerm.html#asValue--) and [asRepository()](apidocs/org/apache/commons/rdf/rdf4j/RDF4JGraphLike.html#asRepository--).
+Objects created with  [RDF4JFactory](apidocs/org/apache/commons/rdf/rdf4j/RDF4JFactory.html) implement interfaces like [RDF4JTerm](apidocs/org/apache/commons/rdf/rdf4j/RDF4JTerm.html) and [RDF4JGraph](apidocs/org/apache/commons/rdf/rdf4j/RDF4JGraph.html) which give access to the underlying Jena objects through methods like [asValue()](apidocs/org/apache/commons/rdf/rdf4j/RDF4JTerm.html#asValue--) and [asRepository()](apidocs/org/apache/commons/rdf/rdf4j/RDF4JGraphLike.html#asRepository--).
 
-`RDF4JTermFactory` includes additional methods for converting from/to RDF4J and Commons RDF, like [asTriple(Statement)](apidocs/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.html#asTriple-org.eclipse.rdf4j.model.Statement-) and
-[asRDFTerm(Value)](apidocs/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.html#asRDFTerm-org.eclipse.rdf4j.model.Value-).
+`RDF4JFactory` includes additional methods for converting from/to RDF4J and Commons RDF, like [asTriple(Statement)](apidocs/org/apache/commons/rdf/rdf4j/RDF4JFactory.html#asTriple-org.eclipse.rdf4j.model.Statement-) and
+[asRDFTerm(Value)](apidocs/org/apache/commons/rdf/rdf4j/RDF4JFactory.html#asRDFTerm-org.eclipse.rdf4j.model.Value-).
 
 #### Closing RDF4J resources
 
-When using `RDF4JTermFactory` with an RDF4J `Repository`, e.g. from [asRDFTermGraph(Repository)](apidocs/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.html#asRDFTermGraph-org.eclipse.rdf4j.repository.Repository-org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...-), care must be taken to close underlying resources when using the methods [stream()](apidocs/org/apache/commons/rdf/rdf4j/RDF4JGraph.html#stream--) and [iterate()](apidocs/org/apache/commons/rdf/rdf4j/RDF4JGraph.html#iterate--) for both `Graph`s and `Dataset`s.
+When using `RDF4JFactory` with an RDF4J `Repository`, e.g. from [asRDFTermGraph(Repository)](apidocs/org/apache/commons/rdf/rdf4j/RDF4JFactory.html#asRDFTermGraph-org.eclipse.rdf4j.repository.Repository-org.apache.commons.rdf.rdf4j.RDF4JFactory.Option...-), care must be taken to close underlying resources when using the methods [stream()](apidocs/org/apache/commons/rdf/rdf4j/RDF4JGraph.html#stream--) and [iterate()](apidocs/org/apache/commons/rdf/rdf4j/RDF4JGraph.html#iterate--) for both `Graph`s and `Dataset`s.
 
 This can generally achieved using a [try-with-resources](https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html) block, e.g.:
 


[3/3] incubator-commonsrdf git commit: JenaJLdRDFTermFactory -> JsonLdFactory

Posted by st...@apache.org.
JenaJLdRDFTermFactory -> JsonLdFactory


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

Branch: refs/heads/master
Commit: 0bb936968b865c1499d8af1cf3ae4ef46ab9b5bc
Parents: ec8a4ac
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Oct 19 09:51:30 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Oct 19 09:51:30 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/jsonldjava/JsonLdFactory.java   | 306 +++++++++++++++++++
 .../commons/rdf/jsonldjava/JsonLdGraphLike.java |   8 +-
 .../commons/rdf/jsonldjava/JsonLdQuadLike.java  |   2 +-
 .../rdf/jsonldjava/JsonLdRDFTermFactory.java    | 306 -------------------
 .../jsonldjava/experimental/JsonLdParser.java   |  18 +-
 .../commons/rdf/jsonldjava/package-info.java    |   2 +-
 .../org.apache.commons.rdf.api.RDFTermFactory   |   2 +-
 .../rdf/jsonldjava/JsonLdFactoryTest.java       |  54 ++++
 .../commons/rdf/jsonldjava/JsonLdGraphTest.java |   2 +-
 .../rdf/jsonldjava/JsonLdParserBuilderTest.java |   2 +-
 .../jsonldjava/JsonLdRDFTermFactoryTest.java    |  54 ----
 src/site/markdown/implementations.md            |   4 +-
 12 files changed, 380 insertions(+), 380 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdFactory.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdFactory.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdFactory.java
new file mode 100644
index 0000000..a66fd3d
--- /dev/null
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdFactory.java
@@ -0,0 +1,306 @@
+/**
+ * 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.jsonldjava;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+import java.util.UUID;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Dataset;
+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.RDFTerm;
+import org.apache.commons.rdf.api.RDFTermFactory;
+import org.apache.commons.rdf.api.Triple;
+import org.apache.commons.rdf.simple.Types;
+
+import com.github.jsonldjava.core.RDFDataset;
+import com.github.jsonldjava.core.RDFDataset.Node;
+
+public final class JsonLdFactory implements RDFTermFactory {
+
+	final String bnodePrefix;
+
+	public JsonLdFactory() {
+		// An "outside Graph" bnodePrefix
+		this("urn:uuid:" + UUID.randomUUID() + "#b");
+	}
+
+	JsonLdFactory(String bnodePrefix) {
+		this.bnodePrefix = Objects.requireNonNull(bnodePrefix);
+	}
+
+	/**
+	 * Adapt a JsonLd {@link RDFDataset} as a Commons RDF {@link Dataset}.
+	 * <p>
+	 * Changes to the Commons RDF {@link Dataset} are reflected in the JsonLd
+	 * {@link RDFDataset} and vice versa.
+	 * 
+	 * @see #asGraph(RDFDataset)
+	 * @param rdfDataSet JsonLd {@link RDFDataset} to adapt
+	 * @return Adapted {@link Dataset}
+	 */
+	public JsonLdDataset asDataset(RDFDataset rdfDataSet) {
+		return new JsonLdDatasetImpl(rdfDataSet);
+	}
+
+	/**
+	 * Adapt a JsonLd {@link RDFDataset} as a Commons RDF {@link Graph}.
+	 * <p>
+	 * Only triples in the <em>default graph</em> are included. To retrieve
+	 * any other graph, {@link #asDataset(RDFDataset)} together with 
+	 * {@link Dataset#getGraph(BlankNodeOrIRI)}.  
+	 * <p>
+	 * Changes to the Commons RDF {@link Graph} are reflected in the JsonLd
+	 * {@link RDFDataset} and vice versa.
+	 * 
+	 * @see #asDataset(RDFDataset)
+	 * @see #asUnionGraph(RDFDataset) 
+	 * @param rdfDataSet JsonLd {@link RDFDataset} to adapt
+	 * @return Adapted {@link Graph} covering the <em>default graph</em>
+	 */	
+	public JsonLdGraph asGraph(RDFDataset rdfDataSet) {
+		return new JsonLdGraphImpl(rdfDataSet);
+	}
+
+	public Node asJsonLdNode(RDFTerm term) {
+		if (term instanceof JsonLdBlankNode) {
+			JsonLdBlankNode jsonLdBlankNode = (JsonLdBlankNode) term;
+			if (jsonLdBlankNode.uniqueReference().startsWith(bnodePrefix)) {
+				// Only return blank nodes 'as is' if they have the same prefix
+				return jsonLdBlankNode.asJsonLdNode();
+			}
+		} else if (term instanceof JsonLdTerm) {
+			// non-Bnodes can always be return as-is
+			return ((JsonLdTerm) term).asJsonLdNode();
+		}
+		if (term instanceof IRI) {
+			return new RDFDataset.IRI(((IRI) term).getIRIString());
+		}
+		if (term instanceof BlankNode) {
+			String ref = ((BlankNode) term).uniqueReference();
+			if (ref.startsWith(bnodePrefix)) {
+				// one of our own (but no longer a JsonLdBlankNode),
+				// we can recover the label after our unique prefix
+				return new RDFDataset.BlankNode(ref.replace(bnodePrefix, ""));
+			}
+			// The "foreign" unique reference might not be a valid bnode string,
+			// we'll convert to a UUID
+			UUID uuid = UUID.nameUUIDFromBytes(ref.getBytes(StandardCharsets.UTF_8));
+			return new RDFDataset.BlankNode("_:" + uuid);
+		}
+		if (term instanceof Literal) {
+			Literal literal = (Literal) term;
+			return new RDFDataset.Literal(literal.getLexicalForm(), literal.getDatatype().getIRIString(),
+					literal.getLanguageTag().orElse(null));
+		}
+		throw new IllegalArgumentException("RDFTerm not instanceof IRI, BlankNode or Literal: " + term);
+	}	
+
+	/**
+	 * Adapt a Commons RDF {@link org.apache.commons.rdf.api.Quad} as a JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}.
+	 * 
+	 * @param quad Commons RDF {@link org.apache.commons.rdf.api.Quad}  to adapt
+	 * @return Adapted JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}
+	 */
+	public RDFDataset.Quad asJsonLdQuad(org.apache.commons.rdf.api.Quad quad) {
+		BlankNodeOrIRI g = quad.getGraphName().orElse(null);		
+		return createJsonLdQuad(g, quad.getSubject(), quad.getPredicate(), quad.getObject());
+	}
+	
+	/**
+	 * Adapt a Commons RDF {@link Triple} as a JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}.
+	 * 
+	 * @param triple Commons RDF {@link Triple} to adapt
+	 * @return Adapted JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}
+	 */
+	public RDFDataset.Quad asJsonLdQuad(Triple triple) {
+		return createJsonLdQuad(null, triple.getSubject(), triple.getPredicate(), triple.getObject());
+	}
+
+	/**
+	 * Adapt a JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad} as a Commons RDF
+	 * {@link org.apache.commons.rdf.api.Quad}.
+	 * <p>
+	 * The underlying JsonLd quad can be retrieved with
+	 * {@link JsonLdQuad#asJsonLdQuad()}.
+	 * 
+	 * @param quad
+	 *            A JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad} to adapt
+	 * @return Adapted {@link JsonLdQuad}
+	 */
+	public JsonLdQuad asQuad(final RDFDataset.Quad quad) {
+		return new JsonLdQuadImpl(quad, bnodePrefix);
+	}
+
+	/**
+	 * Adapt a JsonLd {@link Node} as a Commons RDF {@link RDFTerm}.
+	 * <p>
+	 * The underlying node can be retrieved with
+	 * {@link JsonLdTerm#asJsonLdNode()}.
+	 * 
+	 * @param node
+	 *            A JsonLd {@link Node} to adapt
+	 * @return Adapted {@link JsonLdTerm}
+	 */
+	public JsonLdTerm asRDFTerm(final Node node) {
+		return asRDFTerm(node, bnodePrefix);
+	}
+
+	/**
+	 * Adapt a JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad} as a Commons RDF
+	 * {@link org.apache.commons.rdf.api.Triple}.
+	 * <p>
+	 * The underlying JsonLd quad can be retrieved with
+	 * {@link JsonLdTriple#asJsonLdQuad()}.
+	 * 
+	 * @param quad
+	 *            A JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad} to adapt
+	 * @return Adapted {@link JsonLdTriple}
+	 */
+	public JsonLdTriple asTriple(final RDFDataset.Quad quad) {
+		return new JsonLdTripleImpl(quad, bnodePrefix);
+	}
+
+	/**
+	 * Adapt a JsonLd {@link RDFDataset} as a Commons RDF {@link Graph}.
+	 * <p>
+	 * The graph can be seen as a <em>union graph</em> as it will contains all the
+	 * triples across all the graphs of the underlying {@link RDFDataset}.
+	 * <p>
+	 * Note that some triple operations on a union graph 
+	 * can be inefficient as they need to remove any duplicate
+	 * triples across the graphs.   
+	 * <p>
+	 * Changes to the Commons RDF {@link Graph} are reflected in the JsonLd
+	 * {@link RDFDataset} and vice versa. Triples removed from the graph are
+	 * removed from <strong>all</strong> graphs, while triples added
+	 * are added to the <em>default graph</em>.
+	 * 
+	 * @param rdfDataSet JsonLd {@link RDFDataset} to adapt
+	 * @return Adapted {@link Dataset}
+	 */	
+	public JsonLdUnionGraph asUnionGraph(RDFDataset rdfDataSet) {
+		return new JsonLdUnionGraphImpl(rdfDataSet);
+	}
+
+	@Override
+	public JsonLdBlankNode createBlankNode() {
+		String id = "_:" + UUID.randomUUID().toString();
+		return new JsonLdBlankNodeImpl(new RDFDataset.BlankNode(id), bnodePrefix);
+	}
+
+	@Override
+	public JsonLdBlankNode createBlankNode(String name) {
+		String id = "_:" + name;
+		// TODO: Check if name is valid JSON-LD BlankNode identifier
+		return new JsonLdBlankNodeImpl(new RDFDataset.BlankNode(id), bnodePrefix);
+	}
+
+	@Override
+	public JsonLdDataset createDataset() {
+		return new JsonLdDatasetImpl(bnodePrefix);
+	}
+
+	@Override
+	public JsonLdGraph createGraph() {
+		return new JsonLdGraphImpl(bnodePrefix);
+	}
+
+	@Override
+	public JsonLdIRI createIRI(String iri) {
+		return new JsonLdIRIImpl(iri);
+	}
+
+	@Override
+	public JsonLdLiteral createLiteral(String literal) {
+		return new JsonLdLiteralImpl(new RDFDataset.Literal(literal, null, null));
+	}
+
+	@Override
+	public JsonLdLiteral createLiteral(String literal, IRI dataType) {
+		return new JsonLdLiteralImpl(new RDFDataset.Literal(literal, dataType.getIRIString(), null));
+	}
+
+	@Override
+	public JsonLdLiteral createLiteral(String literal, String language) {
+		return new JsonLdLiteralImpl(new RDFDataset.Literal(literal, Types.RDF_LANGSTRING.getIRIString(), language));
+	}
+
+	@Override
+	public JsonLdQuad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
+			throws IllegalArgumentException, UnsupportedOperationException {
+		return new JsonLdQuadImpl(createJsonLdQuad(graphName, subject, predicate, object), bnodePrefix);
+	}
+
+	@Override
+	public JsonLdTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+		return new JsonLdTripleImpl(createJsonLdQuad(null, subject, predicate, object), bnodePrefix);
+	}
+
+	String asJsonLdString(BlankNodeOrIRI blankNodeOrIRI) {
+		if (blankNodeOrIRI == null) {
+			return null;
+		}
+		if (blankNodeOrIRI instanceof IRI) {
+			return ((IRI)blankNodeOrIRI).getIRIString();
+		} else if (blankNodeOrIRI instanceof BlankNode) {
+			BlankNode blankNode = (BlankNode) blankNodeOrIRI;
+			String ref = blankNode.uniqueReference();
+			if (ref.startsWith(bnodePrefix)) { 
+				// One of ours (but possibly not a JsonLdBlankNode) -  
+				// we can use the suffix directly
+				return ref.replace(bnodePrefix, "_:");
+			} else {
+				// Map to unique bnode identifier, e.g. _:0dbd92ee-ab1a-45e7-bba2-7ade54f87ec5
+				UUID uuid = UUID.nameUUIDFromBytes(ref.getBytes(StandardCharsets.UTF_8));
+				return "_:"+ uuid;
+			}
+		} else {
+			throw new IllegalArgumentException("Expected a BlankNode or IRI, not: " + blankNodeOrIRI);
+		}
+	}
+
+	JsonLdTerm asRDFTerm(final Node node, String blankNodePrefix) {
+		if (node == null) {
+			return null; // e.g. default graph
+		}
+		if (node.isIRI()) {
+			return new JsonLdIRIImpl(node);
+		} else if (node.isBlankNode()) {
+			return new JsonLdBlankNodeImpl(node, blankNodePrefix);
+		} else if (node.isLiteral()) {
+			// TODO: Our own JsonLdLiteral
+			if (node.getLanguage() != null) {
+				return createLiteral(node.getValue(), node.getLanguage());
+			} else {
+				return createLiteral(node.getValue(), createIRI(node.getDatatype()));
+			}
+		} else {
+			throw new IllegalArgumentException("Node is neither IRI, BlankNode nor Literal: " + node);
+		}
+	}
+
+	RDFDataset.Quad createJsonLdQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+		return new RDFDataset.Quad(asJsonLdNode(subject), asJsonLdNode(predicate), asJsonLdNode(object), asJsonLdString(graphName));
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
index 579a03a..401de1f 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphLike.java
@@ -72,7 +72,7 @@ abstract class AbstractJsonLdGraphLike<T extends TripleLike>
 	 */
 	final String bnodePrefix;
 
-	final JsonLdRDFTermFactory factory;
+	final JsonLdFactory factory;
 
 	/**
 	 * The underlying JSON-LD {@link RDFDataset}.
@@ -89,7 +89,7 @@ abstract class AbstractJsonLdGraphLike<T extends TripleLike>
 	AbstractJsonLdGraphLike(RDFDataset rdfDataSet, String bnodePrefix) {
 		this.rdfDataSet = Objects.requireNonNull(rdfDataSet);
 		this.bnodePrefix = Objects.requireNonNull(bnodePrefix);
-		this.factory = new JsonLdRDFTermFactory(bnodePrefix);
+		this.factory = new JsonLdFactory(bnodePrefix);
 	}
 	
 	AbstractJsonLdGraphLike(String bnodePrefix) {
@@ -161,8 +161,8 @@ abstract class AbstractJsonLdGraphLike<T extends TripleLike>
 	 * Convert JsonLd Quad to a Commons RDF {@link Triple} or {@link org.apache.commons.rdf.api.Quad}
 	 * 
 	 * 
-	 * @see JsonLdRDFTermFactory#asTriple(Quad)
-	 * @see JsonLdRDFTermFactory#asQuad(Quad)
+	 * @see JsonLdFactory#asTriple(Quad)
+	 * @see JsonLdFactory#asQuad(Quad)
 	 * @param jsonldQuad jsonld quad to convert
 	 * @return converted {@link TripleLike}
 	 */

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java
index bd9d472..acb429a 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdQuadLike.java
@@ -32,7 +32,7 @@ public interface JsonLdQuadLike<G extends RDFTerm> extends QuadLike<G>, JsonLdTr
 		
 		// Note: We always pass the blankNodePrefix and don't rely on the internal
 		// blankNodePrefix in this static factory
-		private static JsonLdRDFTermFactory rdfTermFactory = new JsonLdRDFTermFactory();
+		private static JsonLdFactory rdfTermFactory = new JsonLdFactory();
 		
 		private final Quad quad;
 		private String blankNodePrefix;

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
deleted file mode 100644
index 2e586f9..0000000
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactory.java
+++ /dev/null
@@ -1,306 +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.jsonldjava;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Objects;
-import java.util.UUID;
-
-import org.apache.commons.rdf.api.BlankNode;
-import org.apache.commons.rdf.api.BlankNodeOrIRI;
-import org.apache.commons.rdf.api.Dataset;
-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.RDFTerm;
-import org.apache.commons.rdf.api.RDFTermFactory;
-import org.apache.commons.rdf.api.Triple;
-import org.apache.commons.rdf.simple.Types;
-
-import com.github.jsonldjava.core.RDFDataset;
-import com.github.jsonldjava.core.RDFDataset.Node;
-
-public final class JsonLdRDFTermFactory implements RDFTermFactory {
-
-	final String bnodePrefix;
-
-	public JsonLdRDFTermFactory() {
-		// An "outside Graph" bnodePrefix
-		this("urn:uuid:" + UUID.randomUUID() + "#b");
-	}
-
-	JsonLdRDFTermFactory(String bnodePrefix) {
-		this.bnodePrefix = Objects.requireNonNull(bnodePrefix);
-	}
-
-	/**
-	 * Adapt a JsonLd {@link RDFDataset} as a Commons RDF {@link Dataset}.
-	 * <p>
-	 * Changes to the Commons RDF {@link Dataset} are reflected in the JsonLd
-	 * {@link RDFDataset} and vice versa.
-	 * 
-	 * @see #asGraph(RDFDataset)
-	 * @param rdfDataSet JsonLd {@link RDFDataset} to adapt
-	 * @return Adapted {@link Dataset}
-	 */
-	public JsonLdDataset asDataset(RDFDataset rdfDataSet) {
-		return new JsonLdDatasetImpl(rdfDataSet);
-	}
-
-	/**
-	 * Adapt a JsonLd {@link RDFDataset} as a Commons RDF {@link Graph}.
-	 * <p>
-	 * Only triples in the <em>default graph</em> are included. To retrieve
-	 * any other graph, {@link #asDataset(RDFDataset)} together with 
-	 * {@link Dataset#getGraph(BlankNodeOrIRI)}.  
-	 * <p>
-	 * Changes to the Commons RDF {@link Graph} are reflected in the JsonLd
-	 * {@link RDFDataset} and vice versa.
-	 * 
-	 * @see #asDataset(RDFDataset)
-	 * @see #asUnionGraph(RDFDataset) 
-	 * @param rdfDataSet JsonLd {@link RDFDataset} to adapt
-	 * @return Adapted {@link Graph} covering the <em>default graph</em>
-	 */	
-	public JsonLdGraph asGraph(RDFDataset rdfDataSet) {
-		return new JsonLdGraphImpl(rdfDataSet);
-	}
-
-	public Node asJsonLdNode(RDFTerm term) {
-		if (term instanceof JsonLdBlankNode) {
-			JsonLdBlankNode jsonLdBlankNode = (JsonLdBlankNode) term;
-			if (jsonLdBlankNode.uniqueReference().startsWith(bnodePrefix)) {
-				// Only return blank nodes 'as is' if they have the same prefix
-				return jsonLdBlankNode.asJsonLdNode();
-			}
-		} else if (term instanceof JsonLdTerm) {
-			// non-Bnodes can always be return as-is
-			return ((JsonLdTerm) term).asJsonLdNode();
-		}
-		if (term instanceof IRI) {
-			return new RDFDataset.IRI(((IRI) term).getIRIString());
-		}
-		if (term instanceof BlankNode) {
-			String ref = ((BlankNode) term).uniqueReference();
-			if (ref.startsWith(bnodePrefix)) {
-				// one of our own (but no longer a JsonLdBlankNode),
-				// we can recover the label after our unique prefix
-				return new RDFDataset.BlankNode(ref.replace(bnodePrefix, ""));
-			}
-			// The "foreign" unique reference might not be a valid bnode string,
-			// we'll convert to a UUID
-			UUID uuid = UUID.nameUUIDFromBytes(ref.getBytes(StandardCharsets.UTF_8));
-			return new RDFDataset.BlankNode("_:" + uuid);
-		}
-		if (term instanceof Literal) {
-			Literal literal = (Literal) term;
-			return new RDFDataset.Literal(literal.getLexicalForm(), literal.getDatatype().getIRIString(),
-					literal.getLanguageTag().orElse(null));
-		}
-		throw new IllegalArgumentException("RDFTerm not instanceof IRI, BlankNode or Literal: " + term);
-	}	
-
-	/**
-	 * Adapt a Commons RDF {@link org.apache.commons.rdf.api.Quad} as a JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}.
-	 * 
-	 * @param quad Commons RDF {@link org.apache.commons.rdf.api.Quad}  to adapt
-	 * @return Adapted JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}
-	 */
-	public RDFDataset.Quad asJsonLdQuad(org.apache.commons.rdf.api.Quad quad) {
-		BlankNodeOrIRI g = quad.getGraphName().orElse(null);		
-		return createJsonLdQuad(g, quad.getSubject(), quad.getPredicate(), quad.getObject());
-	}
-	
-	/**
-	 * Adapt a Commons RDF {@link Triple} as a JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}.
-	 * 
-	 * @param triple Commons RDF {@link Triple} to adapt
-	 * @return Adapted JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad}
-	 */
-	public RDFDataset.Quad asJsonLdQuad(Triple triple) {
-		return createJsonLdQuad(null, triple.getSubject(), triple.getPredicate(), triple.getObject());
-	}
-
-	/**
-	 * Adapt a JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad} as a Commons RDF
-	 * {@link org.apache.commons.rdf.api.Quad}.
-	 * <p>
-	 * The underlying JsonLd quad can be retrieved with
-	 * {@link JsonLdQuad#asJsonLdQuad()}.
-	 * 
-	 * @param quad
-	 *            A JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad} to adapt
-	 * @return Adapted {@link JsonLdQuad}
-	 */
-	public JsonLdQuad asQuad(final RDFDataset.Quad quad) {
-		return new JsonLdQuadImpl(quad, bnodePrefix);
-	}
-
-	/**
-	 * Adapt a JsonLd {@link Node} as a Commons RDF {@link RDFTerm}.
-	 * <p>
-	 * The underlying node can be retrieved with
-	 * {@link JsonLdTerm#asJsonLdNode()}.
-	 * 
-	 * @param node
-	 *            A JsonLd {@link Node} to adapt
-	 * @return Adapted {@link JsonLdTerm}
-	 */
-	public JsonLdTerm asRDFTerm(final Node node) {
-		return asRDFTerm(node, bnodePrefix);
-	}
-
-	/**
-	 * Adapt a JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad} as a Commons RDF
-	 * {@link org.apache.commons.rdf.api.Triple}.
-	 * <p>
-	 * The underlying JsonLd quad can be retrieved with
-	 * {@link JsonLdTriple#asJsonLdQuad()}.
-	 * 
-	 * @param quad
-	 *            A JsonLd {@link com.github.jsonldjava.core.RDFDataset.Quad} to adapt
-	 * @return Adapted {@link JsonLdTriple}
-	 */
-	public JsonLdTriple asTriple(final RDFDataset.Quad quad) {
-		return new JsonLdTripleImpl(quad, bnodePrefix);
-	}
-
-	/**
-	 * Adapt a JsonLd {@link RDFDataset} as a Commons RDF {@link Graph}.
-	 * <p>
-	 * The graph can be seen as a <em>union graph</em> as it will contains all the
-	 * triples across all the graphs of the underlying {@link RDFDataset}.
-	 * <p>
-	 * Note that some triple operations on a union graph 
-	 * can be inefficient as they need to remove any duplicate
-	 * triples across the graphs.   
-	 * <p>
-	 * Changes to the Commons RDF {@link Graph} are reflected in the JsonLd
-	 * {@link RDFDataset} and vice versa. Triples removed from the graph are
-	 * removed from <strong>all</strong> graphs, while triples added
-	 * are added to the <em>default graph</em>.
-	 * 
-	 * @param rdfDataSet JsonLd {@link RDFDataset} to adapt
-	 * @return Adapted {@link Dataset}
-	 */	
-	public JsonLdUnionGraph asUnionGraph(RDFDataset rdfDataSet) {
-		return new JsonLdUnionGraphImpl(rdfDataSet);
-	}
-
-	@Override
-	public JsonLdBlankNode createBlankNode() {
-		String id = "_:" + UUID.randomUUID().toString();
-		return new JsonLdBlankNodeImpl(new RDFDataset.BlankNode(id), bnodePrefix);
-	}
-
-	@Override
-	public JsonLdBlankNode createBlankNode(String name) {
-		String id = "_:" + name;
-		// TODO: Check if name is valid JSON-LD BlankNode identifier
-		return new JsonLdBlankNodeImpl(new RDFDataset.BlankNode(id), bnodePrefix);
-	}
-
-	@Override
-	public JsonLdDataset createDataset() {
-		return new JsonLdDatasetImpl(bnodePrefix);
-	}
-
-	@Override
-	public JsonLdGraph createGraph() {
-		return new JsonLdGraphImpl(bnodePrefix);
-	}
-
-	@Override
-	public JsonLdIRI createIRI(String iri) {
-		return new JsonLdIRIImpl(iri);
-	}
-
-	@Override
-	public JsonLdLiteral createLiteral(String literal) {
-		return new JsonLdLiteralImpl(new RDFDataset.Literal(literal, null, null));
-	}
-
-	@Override
-	public JsonLdLiteral createLiteral(String literal, IRI dataType) {
-		return new JsonLdLiteralImpl(new RDFDataset.Literal(literal, dataType.getIRIString(), null));
-	}
-
-	@Override
-	public JsonLdLiteral createLiteral(String literal, String language) {
-		return new JsonLdLiteralImpl(new RDFDataset.Literal(literal, Types.RDF_LANGSTRING.getIRIString(), language));
-	}
-
-	@Override
-	public JsonLdQuad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
-			throws IllegalArgumentException, UnsupportedOperationException {
-		return new JsonLdQuadImpl(createJsonLdQuad(graphName, subject, predicate, object), bnodePrefix);
-	}
-
-	@Override
-	public JsonLdTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return new JsonLdTripleImpl(createJsonLdQuad(null, subject, predicate, object), bnodePrefix);
-	}
-
-	String asJsonLdString(BlankNodeOrIRI blankNodeOrIRI) {
-		if (blankNodeOrIRI == null) {
-			return null;
-		}
-		if (blankNodeOrIRI instanceof IRI) {
-			return ((IRI)blankNodeOrIRI).getIRIString();
-		} else if (blankNodeOrIRI instanceof BlankNode) {
-			BlankNode blankNode = (BlankNode) blankNodeOrIRI;
-			String ref = blankNode.uniqueReference();
-			if (ref.startsWith(bnodePrefix)) { 
-				// One of ours (but possibly not a JsonLdBlankNode) -  
-				// we can use the suffix directly
-				return ref.replace(bnodePrefix, "_:");
-			} else {
-				// Map to unique bnode identifier, e.g. _:0dbd92ee-ab1a-45e7-bba2-7ade54f87ec5
-				UUID uuid = UUID.nameUUIDFromBytes(ref.getBytes(StandardCharsets.UTF_8));
-				return "_:"+ uuid;
-			}
-		} else {
-			throw new IllegalArgumentException("Expected a BlankNode or IRI, not: " + blankNodeOrIRI);
-		}
-	}
-
-	JsonLdTerm asRDFTerm(final Node node, String blankNodePrefix) {
-		if (node == null) {
-			return null; // e.g. default graph
-		}
-		if (node.isIRI()) {
-			return new JsonLdIRIImpl(node);
-		} else if (node.isBlankNode()) {
-			return new JsonLdBlankNodeImpl(node, blankNodePrefix);
-		} else if (node.isLiteral()) {
-			// TODO: Our own JsonLdLiteral
-			if (node.getLanguage() != null) {
-				return createLiteral(node.getValue(), node.getLanguage());
-			} else {
-				return createLiteral(node.getValue(), createIRI(node.getDatatype()));
-			}
-		} else {
-			throw new IllegalArgumentException("Node is neither IRI, BlankNode nor Literal: " + node);
-		}
-	}
-
-	RDFDataset.Quad createJsonLdQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return new RDFDataset.Quad(asJsonLdNode(subject), asJsonLdNode(predicate), asJsonLdNode(object), asJsonLdString(graphName));
-	}
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/experimental/JsonLdParser.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/experimental/JsonLdParser.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/experimental/JsonLdParser.java
index 102b2d4..464015f 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/experimental/JsonLdParser.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/experimental/JsonLdParser.java
@@ -32,7 +32,7 @@ import org.apache.commons.rdf.api.IRI;
 import org.apache.commons.rdf.api.RDFSyntax;
 import org.apache.commons.rdf.jsonldjava.JsonLdDataset;
 import org.apache.commons.rdf.jsonldjava.JsonLdGraph;
-import org.apache.commons.rdf.jsonldjava.JsonLdRDFTermFactory;
+import org.apache.commons.rdf.jsonldjava.JsonLdFactory;
 import org.apache.commons.rdf.simple.experimental.AbstractRDFParser;
 
 import com.github.jsonldjava.core.JsonLdError;
@@ -44,8 +44,8 @@ import com.github.jsonldjava.utils.JsonUtils;
 public class JsonLdParser extends AbstractRDFParser<JsonLdParser> {
 
 	@Override
-	protected JsonLdRDFTermFactory createRDFTermFactory() {
-		return new JsonLdRDFTermFactory();
+	protected JsonLdFactory createRDFTermFactory() {
+		return new JsonLdFactory();
 	}
 
 	@Override
@@ -105,7 +105,7 @@ public class JsonLdParser extends AbstractRDFParser<JsonLdParser> {
 				// otherwise we have to merge as normal
 			} 			
 			// TODO: Modify JsonLdProcessor to have an actual triple callback
-			Graph parsedGraph = getJsonLdRDFTermFactory().asGraph(rdfDataset);			
+			Graph parsedGraph = getJsonLdFactory().asGraph(rdfDataset);			
 			// sequential() as we don't know if destination is thread safe :-/
 			parsedGraph.stream().sequential().forEach(intoGraph::add);
 		} else if (getTargetDataset().isPresent()) {
@@ -119,19 +119,19 @@ public class JsonLdParser extends AbstractRDFParser<JsonLdParser> {
 				// otherwise we have to merge.. but also avoid duplicate triples, 
 				// map blank nodes etc, so we'll fall back to normal Dataset appending.
 			}	
-			Dataset fromDataset = getJsonLdRDFTermFactory().asDataset(rdfDataset);
+			Dataset fromDataset = getJsonLdFactory().asDataset(rdfDataset);
 			// .sequential() as we don't know if destination is thread-safe :-/			
 			fromDataset.stream().sequential().forEach(intoDataset::add);
 		} else {	
-			Dataset fromDataset = getJsonLdRDFTermFactory().asDataset(rdfDataset);
+			Dataset fromDataset = getJsonLdFactory().asDataset(rdfDataset);
 			// No need for .sequential() here
 			fromDataset.stream().forEach(getTarget());
 		}
 	}
 	
-	private JsonLdRDFTermFactory getJsonLdRDFTermFactory() {
-		if (getRdfTermFactory().isPresent() && getRdfTermFactory().get() instanceof JsonLdRDFTermFactory) {
-			return (JsonLdRDFTermFactory) getRdfTermFactory().get();
+	private JsonLdFactory getJsonLdFactory() {
+		if (getRdfTermFactory().isPresent() && getRdfTermFactory().get() instanceof JsonLdFactory) {
+			return (JsonLdFactory) getRdfTermFactory().get();
 		}
 		return createRDFTermFactory();		
 	}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
index b9b4acb..1cb5c77 100644
--- a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
@@ -18,7 +18,7 @@
 /**
  * Integration with jsonld-java
  * 
- * @see org.apache.commons.rdf.jsonldjava.JsonLdRDFTermFactory
+ * @see org.apache.commons.rdf.jsonldjava.JsonLdFactory
  * @see org.apache.commons.rdf.jsonldjava.JsonLdGraph
  * @see org.apache.commons.rdf.jsonldjava.JsonLdUnionGraph
  * @see org.apache.commons.rdf.jsonldjava.JsonLdDataset

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory b/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory
index 690fba4..9bf95f8 100644
--- a/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory
+++ b/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory
@@ -1 +1 @@
-org.apache.commons.rdf.jsonldjava.JsonLdRDFTermFactory
\ No newline at end of file
+org.apache.commons.rdf.jsonldjava.JsonLdFactory
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdFactoryTest.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdFactoryTest.java b/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdFactoryTest.java
new file mode 100644
index 0000000..e7c68ea
--- /dev/null
+++ b/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdFactoryTest.java
@@ -0,0 +1,54 @@
+/**
+ * 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.jsonldjava;
+
+import org.apache.commons.rdf.api.AbstractRDFTermFactoryTest;
+import org.apache.commons.rdf.api.RDFTermFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JsonLdFactoryTest extends AbstractRDFTermFactoryTest {
+
+	@Override
+	public RDFTermFactory createFactory() {
+		return new JsonLdFactory();
+	}
+	
+	// TODO: Add support for checking for invalid lang/iri/blanknode IDs
+	
+	@Ignore
+	@Test
+	@Override
+	public void testInvalidLiteralLang() throws Exception {
+		super.testInvalidLiteralLang();
+	}
+	
+	@Ignore
+	@Test
+	@Override
+	public void testInvalidIRI() throws Exception {
+		super.testInvalidIRI();
+	}
+	
+	@Ignore
+	@Test
+	@Override
+	public void testPossiblyInvalidBlankNode() throws Exception {
+		super.testPossiblyInvalidBlankNode();
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphTest.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphTest.java b/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphTest.java
index 5b8d28c..46bc73e 100644
--- a/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphTest.java
+++ b/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdGraphTest.java
@@ -24,7 +24,7 @@ public class JsonLdGraphTest extends AbstractGraphTest {
 
 	@Override
 	public RDFTermFactory createFactory() {
-		return new JsonLdRDFTermFactory();
+		return new JsonLdFactory();
 	}
 	
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdParserBuilderTest.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdParserBuilderTest.java b/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdParserBuilderTest.java
index 4d846ee..bd3c6bb 100644
--- a/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdParserBuilderTest.java
+++ b/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdParserBuilderTest.java
@@ -39,7 +39,7 @@ import org.junit.Test;
 public class JsonLdParserBuilderTest {	
 	private static final String TEST_JSONLD = "/test.jsonld";
 	
-	static JsonLdRDFTermFactory factory = new JsonLdRDFTermFactory();
+	static JsonLdFactory factory = new JsonLdFactory();
 	IRI test = factory.createIRI("http://example.com/test");
 	IRI Type = factory.createIRI("http://example.com/Type");
 	IRI type = factory.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactoryTest.java b/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactoryTest.java
deleted file mode 100644
index 0e86b33..0000000
--- a/jsonld-java/src/test/java/org/apache/commons/rdf/jsonldjava/JsonLdRDFTermFactoryTest.java
+++ /dev/null
@@ -1,54 +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.jsonldjava;
-
-import org.apache.commons.rdf.api.AbstractRDFTermFactoryTest;
-import org.apache.commons.rdf.api.RDFTermFactory;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class JsonLdRDFTermFactoryTest extends AbstractRDFTermFactoryTest {
-
-	@Override
-	public RDFTermFactory createFactory() {
-		return new JsonLdRDFTermFactory();
-	}
-	
-	// TODO: Add support for checking for invalid lang/iri/blanknode IDs
-	
-	@Ignore
-	@Test
-	@Override
-	public void testInvalidLiteralLang() throws Exception {
-		super.testInvalidLiteralLang();
-	}
-	
-	@Ignore
-	@Test
-	@Override
-	public void testInvalidIRI() throws Exception {
-		super.testInvalidIRI();
-	}
-	
-	@Ignore
-	@Test
-	@Override
-	public void testPossiblyInvalidBlankNode() throws Exception {
-		super.testPossiblyInvalidBlankNode();
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0bb93696/src/site/markdown/implementations.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/implementations.md b/src/site/markdown/implementations.md
index f518861..51679fd 100644
--- a/src/site/markdown/implementations.md
+++ b/src/site/markdown/implementations.md
@@ -194,9 +194,9 @@ This is primarily intended to support [JSON-LD](http://json-ld.org/) parsing and
 ```java
 import org.apache.commons.rdf.api.Graph;
 import org.apache.commons.rdf.api.RDFTermFactory;
-import org.apache.commons.rdf.jsonld.JsonLdRDFTermFactory;
+import org.apache.commons.rdf.jsonld.JsonLdFactory;
 
-RDFTermFactory rdfTermFactory = new JsonLdRDFTermFactory();
+RDFTermFactory rdfTermFactory = new JsonLdFactory();
 Graph graph = rdfTermFactory.createGraph();
 ```
 



[2/3] incubator-commonsrdf git commit: JenaRDFTermFactory -> JenaFactory

Posted by st...@apache.org.
JenaRDFTermFactory -> JenaFactory


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

Branch: refs/heads/master
Commit: ec8a4aca0df57365c9450b356614f1a458d2e778
Parents: d043b07
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed Oct 19 09:49:45 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed Oct 19 09:49:45 2016 +0100

----------------------------------------------------------------------
 .../apache/commons/rdf/jena/JenaFactory.java    | 727 +++++++++++++++++++
 .../commons/rdf/jena/JenaRDFTermFactory.java    | 727 -------------------
 .../rdf/jena/experimental/JenaRDFParser.java    |  14 +-
 .../commons/rdf/jena/impl/AbstractQuadLike.java |   6 +-
 .../rdf/jena/impl/InternalJenaFactory.java      |   4 +-
 .../commons/rdf/jena/impl/JenaDatasetImpl.java  |  14 +-
 .../commons/rdf/jena/impl/JenaGraphImpl.java    |  12 +-
 .../apache/commons/rdf/jena/TestGraphJena.java  |   2 +-
 .../jena/TestJenaGraphToCommonsRDFGraph.java    |   4 +-
 .../commons/rdf/jena/TestRDFParserBuilder.java  |   2 +-
 .../rdf/jena/TestRDFTermFactoryJena.java        |   2 +-
 src/site/markdown/implementations.md            |  10 +-
 12 files changed, 762 insertions(+), 762 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/jena/src/main/java/org/apache/commons/rdf/jena/JenaFactory.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaFactory.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaFactory.java
new file mode 100644
index 0000000..0d735c7
--- /dev/null
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/JenaFactory.java
@@ -0,0 +1,727 @@
+/**
+ * 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;
+
+import java.util.Optional;
+import java.util.UUID;
+import java.util.function.Consumer;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Dataset;
+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.QuadLike;
+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.api.TripleLike;
+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;
+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;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.graph.GraphFactory;
+
+/**
+ * RDFTermFactory with Jena-backed objects.
+ * <p>
+ * This factory can also convert existing objects from/to Jena with methods like
+ * {@link #fromJena(org.apache.jena.graph.Graph)} and {@link #toJena(Graph)}.
+ * <p>
+ * For the purpose of {@link BlankNode} identity, this factory will use an internal
+ * {@link UUID} as a salt. See {@link BlankNode#uniqueReference()} for details.
+ * 
+ * @see RDFTermFactory
+ */
+public final class JenaFactory implements RDFTermFactory {
+
+	private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
+	
+	private final UUID salt;
+
+	/**
+	 * Create a JenaFactory.
+	 * <p>
+	 * This constructor will use a randomly generated {@link UUID} as a salt 
+	 * for the purposes of {@link BlankNode} identity, see {@link #getSalt()}.
+	 */
+	public JenaFactory() {
+		this.salt = UUID.randomUUID();
+	}
+
+	/**
+	 * Create a JenaFactory.
+	 * <p>
+	 * This constructor will use the specified {@link UUID} as a salt for
+	 * the purposes of {@link BlankNode} identity, and should only be used in
+	 * cases where predictable and consistent
+	 * {@link BlankNode#uniqueReference()} are important.
+	 * 
+	 * @param salt
+	 *            {@link UUID} to use as salt for {@link BlankNode} equality
+	 */	
+	public JenaFactory(UUID salt) {
+		this.salt = salt;
+	}
+
+	@Override
+	public JenaBlankNode createBlankNode() {
+		return internalJenaFactory.createBlankNode(getSalt());
+	}
+
+	@Override
+	public JenaBlankNode createBlankNode(String name) {
+		return internalJenaFactory.createBlankNode(name, getSalt());
+	}
+	
+	@Override
+	public JenaDataset createDataset() {
+		return internalJenaFactory.createDataset(getSalt());
+	}
+
+	@Override
+	public JenaGraph createGraph() {
+		return internalJenaFactory.createGraph(getSalt());
+	}
+
+	@Override
+	public JenaIRI createIRI(String iri) {
+		validateIRI(iri);
+		return internalJenaFactory.createIRI(iri);
+	}
+
+	@Override
+	public JenaLiteral createLiteral(String lexicalForm) {
+		return internalJenaFactory.createLiteral(lexicalForm);
+	}
+
+	@Override
+	public JenaLiteral createLiteral(String lexicalForm, IRI dataType) {
+		return internalJenaFactory.createLiteralDT(lexicalForm, dataType.getIRIString());
+	}
+
+	@Override
+	public JenaLiteral createLiteral(String lexicalForm, String languageTag) {
+		validateLang(languageTag);
+		return internalJenaFactory.createLiteralLang(lexicalForm, languageTag);
+	}
+
+	@Override
+	public JenaTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+		return internalJenaFactory.createTriple(subject, predicate, object);
+	}
+	
+	@Override
+	public JenaQuad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
+			throws IllegalArgumentException, UnsupportedOperationException {
+		return internalJenaFactory.createQuad(subject, predicate, object, graphName);
+	}
+
+	/**
+	 * Create a generalized Jena triple.
+	 * <p>
+	 * The <em>generalized triple</em> supports any {@link RDFTerm} as its
+	 * {@link TripleLike#getSubject()} {@link TripleLike#getPredicate()} or
+	 * {@link TripleLike#getObject()}.
+	 *
+	 * @see #createTriple(BlankNodeOrIRI, IRI, RDFTerm)
+	 * @see #createGeneralizedQuad(RDFTerm, RDFTerm, RDFTerm, RDFTerm)
+	 * 
+	 * @param subject
+	 *            The subject of the statement
+	 * @param predicate
+	 *            The predicate of the statement
+	 * @param object
+	 *            The object of the statement
+	 * @return Generalized {@link TripleLike}. Note that the generalized triple
+	 *         does <strong>not</strong> implement {@link Triple#equals(Object)}
+	 *         or {@link Triple#hashCode()}.
+	 */
+	public JenaGeneralizedTripleLike createGeneralizedTriple(
+			RDFTerm subject, RDFTerm predicate, RDFTerm object) {
+		return internalJenaFactory.createGeneralizedTriple(subject, predicate, object);
+	}
+
+	/**
+	 * Create a generalized Jena quad.
+	 * <p>
+	 * The <em>generalized quad</em> supports any {@link RDFTerm} as its
+	 * {@link QuadLike#getSubject()} {@link QuadLike#getPredicate()},
+	 * {@link QuadLike#getObject()} or {@link QuadLike#getObject()}.
+	 * 
+	 * @see #createQuad(BlankNodeOrIRI, BlankNodeOrIRI, IRI, RDFTerm)
+	 * @see #createGeneralizedTriple(RDFTerm, RDFTerm, RDFTerm)
+	 * 
+	 * @param subject
+	 *            The subject of the statement
+	 * @param predicate
+	 *            The predicate of the statement
+	 * @param object
+	 *            The object of the statement
+	 * @param graphName
+	 *            The graph name of the statement
+	 * @return Generalized {@link QuadLike}. Note that the generalized quad does
+	 *         <strong>not</strong> implement {@link Quad#equals(Object)} or
+	 *         {@link Quad#hashCode()}.
+	 */
+	public JenaGeneralizedQuadLike createGeneralizedQuad(
+			RDFTerm subject, RDFTerm predicate, RDFTerm object, RDFTerm graphName) {
+		return internalJenaFactory.createGeneralizedQuad(subject, predicate, object, graphName);
+	}	
+	/**
+	 * Adapt an existing Jena Node to CommonsRDF {@link RDFTerm}.
+	 * <p>
+	 * If {@link Node#isLiteral()}, then the returned value is a {@link Literal}.
+	 * If {@link Node#isURI()}, the returned value is a IRI. If {$@link Node#isBlank()},
+	 * the returned value is a {@link BlankNode}, which will use a {@link UUID}
+	 * salt from this {@link JenaFactory} instance in combination with
+	 * {@link Node#getBlankNodeId()} for the purpose of its
+	 * {@link BlankNode#uniqueReference()}.
+	 * 
+	 * @see #fromJena(RDFTermFactory, Node)
+	 * 
+	 * @param node
+	 *            The Jena Node to adapt. It's {@link Node#isConcrete()} must be
+	 *            <code>true</code>.
+	 * @return Adapted {@link JenaRDFTerm}
+	 * @throws ConversionException If the {@link Node} can't be represented as an {@link RDFTerm}, e.g.
+	 *             if the node is not concrete or represents a variable in Jena.
+	 */
+	public JenaRDFTerm fromJena(Node node) throws ConversionException {
+		return internalJenaFactory.fromJena(node, getSalt());
+	}
+
+	/**
+	 * Convert from Jena {@link Node} to any Commons RDF implementation.
+	 * <p>
+	 * Note that if the {@link Node#isBlank()}, then the factory's 
+	 * {@link RDFTermFactory#createBlankNode(String)} will be used, meaning
+	 * that care should be taken if reusing an {@link RDFTermFactory} instance
+	 * for multiple conversion sessions.
+	 * 
+	 * @see #fromJena(Node)
+	 * 
+	 * @param factory {@link RDFTermFactory} to use for creating {@link RDFTerm}.
+	 * @param node
+	 *            The Jena Node to adapt. It's {@link Node#isConcrete()} must be
+	 *            <code>true</code>.
+	 * @return Adapted {@link RDFTerm}
+	 * @throws ConversionException If the {@link Node} can't be represented as an {@link RDFTerm}, e.g.
+	 *             if the node is not concrete or represents a variable in Jena.
+	 */
+	public static RDFTerm fromJena(RDFTermFactory factory, Node node) {
+		if (node == null) {
+			return null;
+		}
+		if (factory instanceof JenaFactory) {
+			// No need to convert, just wrap
+			return ((JenaFactory) factory).fromJena(node);
+		}
+		if (node.isURI())
+			return factory.createIRI(node.getURI());
+		if (node.isLiteral()) {
+			String lang = node.getLiteralLanguage();
+			if (lang != null && !lang.isEmpty())
+				return factory.createLiteral(node.getLiteralLexicalForm(), lang);
+			if (node.getLiteralDatatype().equals(XSDDatatype.XSDstring))
+				return factory.createLiteral(node.getLiteralLexicalForm());
+			IRI dt = factory.createIRI(node.getLiteralDatatype().getURI());
+			return factory.createLiteral(node.getLiteralLexicalForm(), dt);
+		}
+		if (node.isBlank())
+			// The factory
+			return factory.createBlankNode(node.getBlankNodeLabel());
+		throw new ConversionException("Node is not a concrete RDF Term: " + node);
+	}	
+	
+	/**
+	 * Adapt an existing Jena Triple to CommonsRDF {@link Triple}.
+	 * <p>
+	 * If the triple contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this
+	 * {@link JenaFactory} instance in combination with
+	 * {@link Node#getBlankNodeId()} for the purpose of its
+	 * {@link BlankNode#uniqueReference()}.
+	 *
+	 * @see #fromJena(RDFTermFactory, org.apache.jena.graph.Triple)
+	 * 
+	 * @param triple
+	 *            Jena {@link org.apache.jena.graph.Triple} to adapt
+	 * @return Adapted {@link JenaTriple}
+	 * @throws ConversionException
+	 *             if any of the triple's nodes are not concrete or the triple
+	 *             is a generalized triple
+	 */
+	public JenaTriple fromJena(org.apache.jena.graph.Triple triple) throws ConversionException {
+		return internalJenaFactory.fromJena(triple, getSalt());
+	}
+
+	/**
+	 * Adapt a generalized Jena {@link org.apache.jena.graph.Triple} to a CommonsRDF {@link TripleLike}.
+	 * <p>
+	 * The generalized triple supports any {@link RDFTerm} as its {@link TripleLike#getSubject()}
+	 * {@link TripleLike#getPredicate()} or {@link TripleLike#getObject()}.
+	 * <p>
+	 * If the Jena triple contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this
+	 * {@link JenaFactory} instance in combination with
+	 * {@link Node#getBlankNodeId()} for the purpose of its
+	 * {@link BlankNode#uniqueReference()}.
+	 *
+	 * @see #fromJena(RDFTermFactory, org.apache.jena.graph.Triple)
+	 * 
+	 * @param triple
+	 *            Jena triple
+	 * @return Adapted {@link TripleLike}. Note that the generalized triple does
+	 *         <strong>not</strong> implement {@link Triple#equals(Object)} or
+	 *         {@link Triple#hashCode()}.
+	 * @throws ConversionException
+	 *             if any of the triple's nodes are not concrete
+	 */
+	public JenaTripleLike fromJenaGeneralized(org.apache.jena.graph.Triple triple) throws ConversionException {
+		return internalJenaFactory.fromJenaGeneralized(triple, getSalt());
+	}
+
+	/**
+	 * Adapt a generalized Jena {@link org.apache.jena.sparql.core.Quad} to a CommonsRDF {@link QuadLike}.
+	 * <p>
+	 * The generalized quad supports any {@link RDFTerm} as its 
+	 * {@link QuadLike#getGraphName()}, 
+	 * {@link QuadLike#getSubject()}
+	 * {@link QuadLike#getPredicate()} or 
+	 * {@link QuadLike#getObject()}. 
+	 * <p>
+	 * If the Jena quad contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this
+	 * {@link JenaFactory} instance in combination with
+	 * {@link Node#getBlankNodeId()} for the purpose of its
+	 * {@link BlankNode#uniqueReference()}.
+	 *
+	 * @see #fromJena(org.apache.jena.sparql.core.Quad)
+	 * @see #fromJenaGeneralized(org.apache.jena.graph.Triple)
+	 * 
+	 * @param quad
+	 *            Jena quad
+	 * @return Adapted {@link QuadLike}. Note that the generalized quad does
+	 *         <strong>not</strong> implement {@link Quad#equals(Object)} or
+	 *         {@link Quad#hashCode()}.
+	 * @throws ConversionException
+	 *             if any of the quad nodes are not concrete
+	 */
+	public JenaQuadLike<RDFTerm> fromJenaGeneralized(org.apache.jena.sparql.core.Quad quad) throws ConversionException {
+		return internalJenaFactory.fromJenaGeneralized(quad, getSalt());
+	}
+	
+	/**
+	 * Convert from Jena {@link org.apache.jena.graph.Triple} to a Commons RDF
+	 * {@link Triple}.
+	 * <p>
+	 * Note that if any of the triple's nodes {@link Node#isBlank()}, then the factory's 
+	 * {@link RDFTermFactory#createBlankNode(String)} will be used, meaning
+	 * that care should be taken if reusing an {@link RDFTermFactory} instance
+	 * for multiple conversion sessions.
+	 * 
+	 * @see #fromJena(org.apache.jena.graph.Triple)
+	 *
+	 * @param factory {@link RDFTermFactory} to use for creating the {@link Triple} and its
+	 * {@link RDFTerm}s.
+	 * @param triple
+	 *            Jena triple
+	 * @return Converted triple
+	 * @throws ConversionException
+	 *             if any of the triple's nodes are not concrete or the triple
+	 *             is a generalized triple
+	 */
+	public static Triple fromJena(RDFTermFactory factory, org.apache.jena.graph.Triple triple) 
+			throws ConversionException{
+		if (factory instanceof JenaFactory) {
+			// No need to convert, just wrap
+			return ((JenaFactory) factory).fromJena(triple);
+		}
+		final BlankNodeOrIRI subject;
+		final IRI predicate;
+		try {
+			subject = (BlankNodeOrIRI) fromJena(factory, triple.getSubject());
+			predicate = (IRI) fromJena(factory, triple.getPredicate());
+		} catch (ClassCastException ex) {
+			throw new ConversionException("Can't convert generalized triple: " + triple, ex);
+		}
+		RDFTerm object = fromJena(factory, triple.getObject());
+		return factory.createTriple(subject, predicate, object);
+	}
+
+	/**
+	 * Adapt an existing Jena {@link org.apache.jena.sparql.core.Quad} to CommonsRDF {@link Quad}.
+	 * <p>
+	 * If the quad contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this 
+	 * {@link JenaFactory} instance
+	 * in combination with {@link Node#getBlankNodeId()} 
+	 * for the purpose of its {@link BlankNode#uniqueReference()}.
+	 * 
+	 * @param quad
+	 *            Jena quad
+	 * @return Adapted quad
+	 */	
+	public JenaQuad fromJena(org.apache.jena.sparql.core.Quad quad) {
+		return internalJenaFactory.fromJena(quad, getSalt());
+	}
+
+	/**
+	 * Adapt an existing Jena {@link org.apache.jena.graph.Graph} to CommonsRDF
+	 * {@link Graph}.
+	 * <p>
+	 * This does not take a copy, changes to the CommonsRDF Graph are reflected
+	 * in the jena graph, which is accessible from
+	 * {@link JenaGraph#asJenaGraph()}.
+	 * <p>
+	 * If the graph contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this
+	 * {@link JenaFactory} instance in combination with
+	 * {@link Node#getBlankNodeId()} for the purpose of its
+	 * {@link BlankNode#uniqueReference()}.
+	 * 
+	 * @param graph
+	 *            Jena {@link org.apache.jena.graph.Graph} to adapt
+	 * @return Adapted {@link JenaGraph}
+	 */
+	public JenaGraph fromJena(org.apache.jena.graph.Graph graph) {
+		return internalJenaFactory.fromJena(graph, getSalt());
+	}
+
+	/**
+	 * Adapt an existing Jena {@link org.apache.jena.rdf.model.Model} to CommonsRDF {@link Graph}. 
+	 * <p>
+	 * This does not ake a copy, changes to the CommonsRDF Graph are reflected in the jena
+	 * graph, which is accessible from {@link JenaGraph#asJenaGraph()}.
+	 * <p>
+	 * If the graph contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this 
+	 * {@link JenaFactory} instance
+	 * in combination with {@link Node#getBlankNodeId()} 
+	 * for the purpose of its {@link BlankNode#uniqueReference()}.
+	 * @param model
+	 *            Jena {@link org.apache.jena.rdf.model.Model} to adapt
+	 * @return Adapted {@link JenaGraph}
+	 */
+	public JenaGraph fromJena(org.apache.jena.rdf.model.Model model) {
+		return internalJenaFactory.fromJena(model, getSalt());
+	}	
+
+	/**
+	 * Adapt an existing Jena {@link DatasetGraph} to CommonsRDF {@link Dataset}. 
+	 * <p>
+	 * This does not
+	 * take a copy, changes to the CommonsRDF Dataset are reflected in the jena
+	 * dataset graph, which is accessible from {@link JenaDataset#asJenaDatasetGraph()}.
+	 * <p>
+	 * If the dataset contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this 
+	 * {@link JenaFactory} instance
+	 * in combination with {@link Node#getBlankNodeId()} 
+	 * for the purpose of its {@link BlankNode#uniqueReference()}.
+	 * 
+	 * @param datasetGraph Jena {@link DatasetGraph} to adapt
+	 * @return Adapted {@link JenaDataset} 
+	 */
+	public JenaDataset fromJena(DatasetGraph datasetGraph) {
+		return internalJenaFactory.fromJena(datasetGraph, getSalt());
+	}	
+	
+	/**
+	 * Adapt an existing Jena {@link org.apache.jena.query.Dataset} to CommonsRDF {@link Dataset}. 
+	 * <p>
+	 * This does not
+	 * take a copy, changes to the CommonsRDF Dataset are reflected in the jena
+	 * dataset graph, which is accessible from {@link JenaDataset#asJenaDatasetGraph()}.
+	 * <p>
+	 * If the dataset contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this 
+	 * {@link JenaFactory} instance
+	 * in combination with {@link Node#getBlankNodeId()} 
+	 * for the purpose of its {@link BlankNode#uniqueReference()}.
+	 * 
+	 * @param datasetGraph Jena {@link org.apache.jena.query.Dataset} to adapt
+	 * @return Adapted {@link JenaDataset} 
+	 */
+	public JenaDataset fromJena(org.apache.jena.query.Dataset datasetGraph) {
+		return internalJenaFactory.fromJena(datasetGraph.asDatasetGraph(), getSalt());
+	}		
+
+	/**
+	 * Convert from Jena {@link org.apache.jena.sparql.core.Quad} to a Commons
+	 * RDF {@link Quad}.
+	 * <p>
+	 * Note that if any of the quad's nodes {@link Node#isBlank()}, then the
+	 * factory's {@link RDFTermFactory#createBlankNode(String)} will be used,
+	 * meaning that care should be taken if reusing an {@link RDFTermFactory}
+	 * instance for multiple conversion sessions.
+	 * 
+	 * @see #fromJena(org.apache.jena.sparql.core.Quad)
+	 * @see #fromJenaGeneralized(org.apache.jena.sparql.core.Quad)
+	 *
+	 * @param factory
+	 *            {@link RDFTermFactory} to use for creating the {@link Triple}
+	 *            and its {@link RDFTerm}s.
+	 * @param quad
+	 *            Jena {@link org.apache.jena.sparql.core.Quad} to adapt
+	 * @return Converted {@link Quad}
+	 * @throws ConversionException
+	 *             if any of the quad's nodes are not concrete or the quad
+	 *             is a generalized quad
+	 */
+	public static Quad fromJena(RDFTermFactory factory, org.apache.jena.sparql.core.Quad quad) {
+		if (factory instanceof JenaFactory) {
+			// No need to convert, just wrap
+			return ((JenaFactory) factory).fromJena(quad);
+		}
+		BlankNodeOrIRI graphName = (BlankNodeOrIRI) (fromJena(factory, quad.getGraph()));
+		BlankNodeOrIRI subject = (BlankNodeOrIRI) (fromJena(factory, quad.getSubject()));
+		IRI predicate = (IRI) (fromJena(factory, quad.getPredicate()));
+		RDFTerm object = fromJena(factory, quad.getObject());
+		return factory.createQuad(graphName, subject, predicate, object);
+	}
+
+	/**
+	 * Return {@link RDFSyntax} corresponding to a Jena {@link Lang}.
+	 * 
+	 * @param lang {@link Lang} to convert
+	 * @return Matched {@link RDFSyntax}, otherwise {@link Optional#empty()}
+	 */
+	public Optional<RDFSyntax> langToRdfSyntax(Lang lang) {
+		return RDFSyntax.byMediaType(lang.getContentType().getContentType());
+	}
+
+	/**
+	 * Return Jena {@link Lang} corresponding to a {@link RDFSyntax}.
+	 * 
+	 * @param rdfSyntax {@link RDFSyntax} to convert
+	 * @return Matched {@link Lang}, otherwise {@link Optional#empty()}
+	 */
+	public Optional<Lang> rdfSyntaxToLang(RDFSyntax rdfSyntax) {
+		return Optional.ofNullable(RDFLanguages.contentTypeToLang(rdfSyntax.mediaType));
+	}
+
+	/**
+	 * Create a {@link StreamRDF} instance that inserts the converted
+	 * {@link Quad}s. into a the provided {@link Consumer}.
+	 * <p>
+	 * The returned {@link StreamRDF} can be used for instance with Jena's
+	 * {@link RDFDataMgr#parse(StreamRDF, String)}.
+	 * 
+	 * @param factory
+	 *            {@link RDFTermFactory} to use for creating {@link RDFTerm}s
+	 *            and {@link Quad}s.
+	 * @param consumer
+	 *            A {@link Consumer} of {@link Quad}s
+	 * @return A {@link StreamRDF} that will stream converted quads to the
+	 *         consumer
+	 */
+	public static StreamRDF streamJenaToCommonsRDF(RDFTermFactory factory, Consumer<Quad> consumer) {
+		return new StreamRDFBase() {
+			@Override
+			public void quad(org.apache.jena.sparql.core.Quad quad) {
+				consumer.accept(fromJena(factory, quad));
+			}
+		};
+	}
+	
+	/**
+	 * Create a {@link StreamRDF} instance that inserts generalized
+	 * {@link TripleLike}s. into a the provided {@link Consumer}.
+	 * <p>
+	 * A generalized triple allows any {@link RDFTerm} for
+	 * {@link TripleLike#getSubject()}, {@link TripleLike#getPredicate()} and
+	 * {@link TripleLike#getObject()}.
+	 * <p>
+	 * The returned {@link StreamRDF} can be used for instance with Jena's
+	 * {@link RDFDataMgr#parse(StreamRDF, String)}.
+	 * 
+	 * @param generalizedConsumer
+	 *            A {@link Consumer} of generalized {@link TripleLike}s
+	 * @return A {@link StreamRDF} that will stream generalized triples to the
+	 *         consumer
+	 */
+	public StreamRDF streamJenaToGeneralizedTriple(Consumer<TripleLike> generalizedConsumer) {
+		return new StreamRDFBase() {			
+			@Override
+			public void triple(org.apache.jena.graph.Triple triple) {
+				generalizedConsumer.accept(fromJenaGeneralized(triple));
+			}
+		};
+	}	
+
+	/**
+	 * Create a {@link StreamRDF} instance that inserts generalized
+	 * {@link QuadLike}s. into a the provided {@link Consumer}.
+	 * <p>
+	 * A generalized quad allows any {@link RDFTerm} for
+	 * {@link QuadLike#getSubject()}, {@link TripleLike#getPredicate()},
+	 * {@link QuadLike#getObject()} and {@link QuadLike#getGraphName()} .
+	 * <p>
+	 * The returned {@link StreamRDF} can be used for instance with Jena's
+	 * {@link RDFDataMgr#parse(StreamRDF, String)}.
+	 * 
+	 * @param generalizedConsumer
+	 *            A {@link Consumer} of generalized {@link QuadLike}s
+	 * @return A {@link StreamRDF} that will stream generalized quads to the
+	 *         consumer
+	 */
+	public StreamRDF streamJenaToGeneralizedQuad(Consumer<QuadLike<RDFTerm>> generalizedConsumer) {
+		return new StreamRDFBase() {
+			@Override
+			public void quad(org.apache.jena.sparql.core.Quad quad) {
+				generalizedConsumer.accept(fromJenaGeneralized(quad));
+			}
+		};
+	}	
+	
+	/**
+	 * Convert a CommonsRDF Graph to a Jena Graph. If the Graph was from Jena
+	 * originally, return that original object else create a copy using Jena
+	 * objects.
+	 * 
+	 * @param graph Commons RDF {@link Graph} to convert
+	 * @return Converted Jena {@link org.apache.jena.graph.Graph}
+	 */
+	public org.apache.jena.graph.Graph toJena(Graph graph) {
+		if (graph instanceof JenaGraph)
+			return ((JenaGraph) graph).asJenaGraph();
+		org.apache.jena.graph.Graph g = GraphFactory.createGraphMem();
+		graph.stream().forEach(t -> g.add(toJena(t)));
+		return g;
+	}
+
+	/**
+	 * Convert a CommonsRDF RDFTerm to a Jena Node. If the RDFTerm was from Jena
+	 * originally, return that original object, else create a copy using Jena
+	 * objects.
+	 * 
+	 * @param term Commons RDF {@link RDFTerm} to convert
+	 * @return Converted Jena {@link Node}
+	 */
+	public Node toJena(RDFTerm term) {
+		if (term == null) {
+			return null;
+		}
+		if (term instanceof JenaRDFTerm)
+			// TODO: What if it's a JenaBlankNodeImpl with
+			// a different salt? Do we need to rewrite the
+			// jena blanknode identifier?
+			return ((JenaRDFTerm) term).asJenaNode();
+
+		if (term instanceof IRI)
+			return NodeFactory.createURI(((IRI) term).getIRIString());
+
+		if (term instanceof Literal) {
+			Literal lit = (Literal) term;
+			RDFDatatype dt = NodeFactory.getType(lit.getDatatype().getIRIString());
+			String lang = lit.getLanguageTag().orElse("");
+			return NodeFactory.createLiteral(lit.getLexicalForm(), lang, dt);
+		}
+
+		if (term instanceof BlankNode) {
+			String id = ((BlankNode) term).uniqueReference();
+			return NodeFactory.createBlankNode(id);
+		}
+		throw new ConversionException("Not a concrete RDF Term: " + term);
+	}
+
+	/**
+	 * Convert a CommonsRDF {@link Triple} to a Jena
+	 * {@link org.apache.jena.graph.Triple}.
+	 * <p>
+	 * If the triple was from Jena originally, return that original object, else
+	 * create a copy using Jena objects.
+	 * 
+	 * @param triple Commons RDF {@link Triple} to convert
+	 * @return Converted Jena {@link org.apache.jena.graph.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(
+				toJena(triple.getSubject()), 
+				toJena(triple.getPredicate()),
+				toJena(triple.getObject()));
+	}
+
+
+	/**
+	 * Convert a CommonsRDF {@link Quad} to a Jena
+	 * {@link org.apache.jena.sparql.core.Quad}.
+	 * <p>
+	 * If the quad was from Jena originally, return that original object,
+	 * otherwise create a copy using Jena objects.
+	 *
+	 * @param quad Commons RDF {@link Quad} to convert
+	 * @return Converted Jena {@link org.apache.jena.sparql.core.Quad}
+	 */
+	public org.apache.jena.sparql.core.Quad toJena(Quad quad) {
+		if (quad instanceof JenaQuad) {
+			return ((JenaQuad) quad).asJenaQuad();
+		}
+		return org.apache.jena.sparql.core.Quad.create(
+				toJena(quad.getGraphName().orElse(null)),
+				toJena(quad.getSubject()), 
+				toJena(quad.getPredicate()), 
+				toJena(quad.getObject()));
+	}
+
+	// Some simple validations - full IRI parsing is not cheap.
+	private void validateIRI(String iri) {
+		if (iri.contains(" "))
+			throw new IllegalArgumentException();
+		if (iri.contains("<"))
+			throw new IllegalArgumentException();
+		if (iri.contains(">"))
+			throw new IllegalArgumentException();
+	}
+
+	private static void validateLang(String languageTag) {
+		if (languageTag.contains(" "))
+			throw new IllegalArgumentException("Invalid language tag: " + languageTag);
+	}
+
+	/**
+	 * Return the {@link UUID} salt used by this factory.
+	 * <p>
+	 * The salt is used for the purposes of {@link BlankNode} identity, see
+	 * {@link BlankNode#uniqueReference()} for details.
+	 * <p>
+	 * This salt can be used with the constructor 
+	 * {@link JenaFactory#JenaFactory(UUID)}
+	 * if consistent or reproducible {@link BlankNode}s are desirable. 
+	 * 
+	 * @return The {@link UUID} used as salt
+	 */
+	public UUID getSalt() {
+		return salt;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/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
deleted file mode 100644
index a4db1bf..0000000
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
+++ /dev/null
@@ -1,727 +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;
-
-import java.util.Optional;
-import java.util.UUID;
-import java.util.function.Consumer;
-
-import org.apache.commons.rdf.api.BlankNode;
-import org.apache.commons.rdf.api.BlankNodeOrIRI;
-import org.apache.commons.rdf.api.Dataset;
-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.QuadLike;
-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.api.TripleLike;
-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;
-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;
-import org.apache.jena.sparql.core.DatasetGraph;
-import org.apache.jena.sparql.graph.GraphFactory;
-
-/**
- * RDFTermFactory with Jena-backed objects.
- * <p>
- * This factory can also convert existing objects from/to Jena with methods like
- * {@link #fromJena(org.apache.jena.graph.Graph)} and {@link #toJena(Graph)}.
- * <p>
- * For the purpose of {@link BlankNode} identity, this factory will use an internal
- * {@link UUID} as a salt. See {@link BlankNode#uniqueReference()} for details.
- * 
- * @see RDFTermFactory
- */
-public final class JenaRDFTermFactory implements RDFTermFactory {
-
-	private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
-	
-	private final UUID salt;
-
-	/**
-	 * Create a JenaRDFTermFactory.
-	 * <p>
-	 * This constructor will use a randomly generated {@link UUID} as a salt 
-	 * for the purposes of {@link BlankNode} identity, see {@link #getSalt()}.
-	 */
-	public JenaRDFTermFactory() {
-		this.salt = UUID.randomUUID();
-	}
-
-	/**
-	 * Create a JenaRDFTermFactory.
-	 * <p>
-	 * This constructor will use the specified {@link UUID} as a salt for
-	 * the purposes of {@link BlankNode} identity, and should only be used in
-	 * cases where predictable and consistent
-	 * {@link BlankNode#uniqueReference()} are important.
-	 * 
-	 * @param salt
-	 *            {@link UUID} to use as salt for {@link BlankNode} equality
-	 */	
-	public JenaRDFTermFactory(UUID salt) {
-		this.salt = salt;
-	}
-
-	@Override
-	public JenaBlankNode createBlankNode() {
-		return internalJenaFactory.createBlankNode(getSalt());
-	}
-
-	@Override
-	public JenaBlankNode createBlankNode(String name) {
-		return internalJenaFactory.createBlankNode(name, getSalt());
-	}
-	
-	@Override
-	public JenaDataset createDataset() {
-		return internalJenaFactory.createDataset(getSalt());
-	}
-
-	@Override
-	public JenaGraph createGraph() {
-		return internalJenaFactory.createGraph(getSalt());
-	}
-
-	@Override
-	public JenaIRI createIRI(String iri) {
-		validateIRI(iri);
-		return internalJenaFactory.createIRI(iri);
-	}
-
-	@Override
-	public JenaLiteral createLiteral(String lexicalForm) {
-		return internalJenaFactory.createLiteral(lexicalForm);
-	}
-
-	@Override
-	public JenaLiteral createLiteral(String lexicalForm, IRI dataType) {
-		return internalJenaFactory.createLiteralDT(lexicalForm, dataType.getIRIString());
-	}
-
-	@Override
-	public JenaLiteral createLiteral(String lexicalForm, String languageTag) {
-		validateLang(languageTag);
-		return internalJenaFactory.createLiteralLang(lexicalForm, languageTag);
-	}
-
-	@Override
-	public JenaTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return internalJenaFactory.createTriple(subject, predicate, object);
-	}
-	
-	@Override
-	public JenaQuad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
-			throws IllegalArgumentException, UnsupportedOperationException {
-		return internalJenaFactory.createQuad(subject, predicate, object, graphName);
-	}
-
-	/**
-	 * Create a generalized Jena triple.
-	 * <p>
-	 * The <em>generalized triple</em> supports any {@link RDFTerm} as its
-	 * {@link TripleLike#getSubject()} {@link TripleLike#getPredicate()} or
-	 * {@link TripleLike#getObject()}.
-	 *
-	 * @see #createTriple(BlankNodeOrIRI, IRI, RDFTerm)
-	 * @see #createGeneralizedQuad(RDFTerm, RDFTerm, RDFTerm, RDFTerm)
-	 * 
-	 * @param subject
-	 *            The subject of the statement
-	 * @param predicate
-	 *            The predicate of the statement
-	 * @param object
-	 *            The object of the statement
-	 * @return Generalized {@link TripleLike}. Note that the generalized triple
-	 *         does <strong>not</strong> implement {@link Triple#equals(Object)}
-	 *         or {@link Triple#hashCode()}.
-	 */
-	public JenaGeneralizedTripleLike createGeneralizedTriple(
-			RDFTerm subject, RDFTerm predicate, RDFTerm object) {
-		return internalJenaFactory.createGeneralizedTriple(subject, predicate, object);
-	}
-
-	/**
-	 * Create a generalized Jena quad.
-	 * <p>
-	 * The <em>generalized quad</em> supports any {@link RDFTerm} as its
-	 * {@link QuadLike#getSubject()} {@link QuadLike#getPredicate()},
-	 * {@link QuadLike#getObject()} or {@link QuadLike#getObject()}.
-	 * 
-	 * @see #createQuad(BlankNodeOrIRI, BlankNodeOrIRI, IRI, RDFTerm)
-	 * @see #createGeneralizedTriple(RDFTerm, RDFTerm, RDFTerm)
-	 * 
-	 * @param subject
-	 *            The subject of the statement
-	 * @param predicate
-	 *            The predicate of the statement
-	 * @param object
-	 *            The object of the statement
-	 * @param graphName
-	 *            The graph name of the statement
-	 * @return Generalized {@link QuadLike}. Note that the generalized quad does
-	 *         <strong>not</strong> implement {@link Quad#equals(Object)} or
-	 *         {@link Quad#hashCode()}.
-	 */
-	public JenaGeneralizedQuadLike createGeneralizedQuad(
-			RDFTerm subject, RDFTerm predicate, RDFTerm object, RDFTerm graphName) {
-		return internalJenaFactory.createGeneralizedQuad(subject, predicate, object, graphName);
-	}	
-	/**
-	 * Adapt an existing Jena Node to CommonsRDF {@link RDFTerm}.
-	 * <p>
-	 * If {@link Node#isLiteral()}, then the returned value is a {@link Literal}.
-	 * If {@link Node#isURI()}, the returned value is a IRI. If {$@link Node#isBlank()},
-	 * the returned value is a {@link BlankNode}, which will use a {@link UUID}
-	 * salt from this {@link JenaRDFTermFactory} instance in combination with
-	 * {@link Node#getBlankNodeId()} for the purpose of its
-	 * {@link BlankNode#uniqueReference()}.
-	 * 
-	 * @see #fromJena(RDFTermFactory, Node)
-	 * 
-	 * @param node
-	 *            The Jena Node to adapt. It's {@link Node#isConcrete()} must be
-	 *            <code>true</code>.
-	 * @return Adapted {@link JenaRDFTerm}
-	 * @throws ConversionException If the {@link Node} can't be represented as an {@link RDFTerm}, e.g.
-	 *             if the node is not concrete or represents a variable in Jena.
-	 */
-	public JenaRDFTerm fromJena(Node node) throws ConversionException {
-		return internalJenaFactory.fromJena(node, getSalt());
-	}
-
-	/**
-	 * Convert from Jena {@link Node} to any Commons RDF implementation.
-	 * <p>
-	 * Note that if the {@link Node#isBlank()}, then the factory's 
-	 * {@link RDFTermFactory#createBlankNode(String)} will be used, meaning
-	 * that care should be taken if reusing an {@link RDFTermFactory} instance
-	 * for multiple conversion sessions.
-	 * 
-	 * @see #fromJena(Node)
-	 * 
-	 * @param factory {@link RDFTermFactory} to use for creating {@link RDFTerm}.
-	 * @param node
-	 *            The Jena Node to adapt. It's {@link Node#isConcrete()} must be
-	 *            <code>true</code>.
-	 * @return Adapted {@link RDFTerm}
-	 * @throws ConversionException If the {@link Node} can't be represented as an {@link RDFTerm}, e.g.
-	 *             if the node is not concrete or represents a variable in Jena.
-	 */
-	public static RDFTerm fromJena(RDFTermFactory factory, Node node) {
-		if (node == null) {
-			return null;
-		}
-		if (factory instanceof JenaRDFTermFactory) {
-			// No need to convert, just wrap
-			return ((JenaRDFTermFactory) factory).fromJena(node);
-		}
-		if (node.isURI())
-			return factory.createIRI(node.getURI());
-		if (node.isLiteral()) {
-			String lang = node.getLiteralLanguage();
-			if (lang != null && !lang.isEmpty())
-				return factory.createLiteral(node.getLiteralLexicalForm(), lang);
-			if (node.getLiteralDatatype().equals(XSDDatatype.XSDstring))
-				return factory.createLiteral(node.getLiteralLexicalForm());
-			IRI dt = factory.createIRI(node.getLiteralDatatype().getURI());
-			return factory.createLiteral(node.getLiteralLexicalForm(), dt);
-		}
-		if (node.isBlank())
-			// The factory
-			return factory.createBlankNode(node.getBlankNodeLabel());
-		throw new ConversionException("Node is not a concrete RDF Term: " + node);
-	}	
-	
-	/**
-	 * Adapt an existing Jena Triple to CommonsRDF {@link Triple}.
-	 * <p>
-	 * If the triple contains any {@link Node#isBlank()}, then any corresponding
-	 * {@link BlankNode} will use a {@link UUID} salt from this
-	 * {@link JenaRDFTermFactory} instance in combination with
-	 * {@link Node#getBlankNodeId()} for the purpose of its
-	 * {@link BlankNode#uniqueReference()}.
-	 *
-	 * @see #fromJena(RDFTermFactory, org.apache.jena.graph.Triple)
-	 * 
-	 * @param triple
-	 *            Jena {@link org.apache.jena.graph.Triple} to adapt
-	 * @return Adapted {@link JenaTriple}
-	 * @throws ConversionException
-	 *             if any of the triple's nodes are not concrete or the triple
-	 *             is a generalized triple
-	 */
-	public JenaTriple fromJena(org.apache.jena.graph.Triple triple) throws ConversionException {
-		return internalJenaFactory.fromJena(triple, getSalt());
-	}
-
-	/**
-	 * Adapt a generalized Jena {@link org.apache.jena.graph.Triple} to a CommonsRDF {@link TripleLike}.
-	 * <p>
-	 * The generalized triple supports any {@link RDFTerm} as its {@link TripleLike#getSubject()}
-	 * {@link TripleLike#getPredicate()} or {@link TripleLike#getObject()}.
-	 * <p>
-	 * If the Jena triple contains any {@link Node#isBlank()}, then any corresponding
-	 * {@link BlankNode} will use a {@link UUID} salt from this
-	 * {@link JenaRDFTermFactory} instance in combination with
-	 * {@link Node#getBlankNodeId()} for the purpose of its
-	 * {@link BlankNode#uniqueReference()}.
-	 *
-	 * @see #fromJena(RDFTermFactory, org.apache.jena.graph.Triple)
-	 * 
-	 * @param triple
-	 *            Jena triple
-	 * @return Adapted {@link TripleLike}. Note that the generalized triple does
-	 *         <strong>not</strong> implement {@link Triple#equals(Object)} or
-	 *         {@link Triple#hashCode()}.
-	 * @throws ConversionException
-	 *             if any of the triple's nodes are not concrete
-	 */
-	public JenaTripleLike fromJenaGeneralized(org.apache.jena.graph.Triple triple) throws ConversionException {
-		return internalJenaFactory.fromJenaGeneralized(triple, getSalt());
-	}
-
-	/**
-	 * Adapt a generalized Jena {@link org.apache.jena.sparql.core.Quad} to a CommonsRDF {@link QuadLike}.
-	 * <p>
-	 * The generalized quad supports any {@link RDFTerm} as its 
-	 * {@link QuadLike#getGraphName()}, 
-	 * {@link QuadLike#getSubject()}
-	 * {@link QuadLike#getPredicate()} or 
-	 * {@link QuadLike#getObject()}. 
-	 * <p>
-	 * If the Jena quad contains any {@link Node#isBlank()}, then any corresponding
-	 * {@link BlankNode} will use a {@link UUID} salt from this
-	 * {@link JenaRDFTermFactory} instance in combination with
-	 * {@link Node#getBlankNodeId()} for the purpose of its
-	 * {@link BlankNode#uniqueReference()}.
-	 *
-	 * @see #fromJena(org.apache.jena.sparql.core.Quad)
-	 * @see #fromJenaGeneralized(org.apache.jena.graph.Triple)
-	 * 
-	 * @param quad
-	 *            Jena quad
-	 * @return Adapted {@link QuadLike}. Note that the generalized quad does
-	 *         <strong>not</strong> implement {@link Quad#equals(Object)} or
-	 *         {@link Quad#hashCode()}.
-	 * @throws ConversionException
-	 *             if any of the quad nodes are not concrete
-	 */
-	public JenaQuadLike<RDFTerm> fromJenaGeneralized(org.apache.jena.sparql.core.Quad quad) throws ConversionException {
-		return internalJenaFactory.fromJenaGeneralized(quad, getSalt());
-	}
-	
-	/**
-	 * Convert from Jena {@link org.apache.jena.graph.Triple} to a Commons RDF
-	 * {@link Triple}.
-	 * <p>
-	 * Note that if any of the triple's nodes {@link Node#isBlank()}, then the factory's 
-	 * {@link RDFTermFactory#createBlankNode(String)} will be used, meaning
-	 * that care should be taken if reusing an {@link RDFTermFactory} instance
-	 * for multiple conversion sessions.
-	 * 
-	 * @see #fromJena(org.apache.jena.graph.Triple)
-	 *
-	 * @param factory {@link RDFTermFactory} to use for creating the {@link Triple} and its
-	 * {@link RDFTerm}s.
-	 * @param triple
-	 *            Jena triple
-	 * @return Converted triple
-	 * @throws ConversionException
-	 *             if any of the triple's nodes are not concrete or the triple
-	 *             is a generalized triple
-	 */
-	public static Triple fromJena(RDFTermFactory factory, org.apache.jena.graph.Triple triple) 
-			throws ConversionException{
-		if (factory instanceof JenaRDFTermFactory) {
-			// No need to convert, just wrap
-			return ((JenaRDFTermFactory) factory).fromJena(triple);
-		}
-		final BlankNodeOrIRI subject;
-		final IRI predicate;
-		try {
-			subject = (BlankNodeOrIRI) fromJena(factory, triple.getSubject());
-			predicate = (IRI) fromJena(factory, triple.getPredicate());
-		} catch (ClassCastException ex) {
-			throw new ConversionException("Can't convert generalized triple: " + triple, ex);
-		}
-		RDFTerm object = fromJena(factory, triple.getObject());
-		return factory.createTriple(subject, predicate, object);
-	}
-
-	/**
-	 * Adapt an existing Jena {@link org.apache.jena.sparql.core.Quad} to CommonsRDF {@link Quad}.
-	 * <p>
-	 * If the quad contains any {@link Node#isBlank()}, then any corresponding
-	 * {@link BlankNode} will use a {@link UUID} salt from this 
-	 * {@link JenaRDFTermFactory} instance
-	 * in combination with {@link Node#getBlankNodeId()} 
-	 * for the purpose of its {@link BlankNode#uniqueReference()}.
-	 * 
-	 * @param quad
-	 *            Jena quad
-	 * @return Adapted quad
-	 */	
-	public JenaQuad fromJena(org.apache.jena.sparql.core.Quad quad) {
-		return internalJenaFactory.fromJena(quad, getSalt());
-	}
-
-	/**
-	 * Adapt an existing Jena {@link org.apache.jena.graph.Graph} to CommonsRDF
-	 * {@link Graph}.
-	 * <p>
-	 * This does not take a copy, changes to the CommonsRDF Graph are reflected
-	 * in the jena graph, which is accessible from
-	 * {@link JenaGraph#asJenaGraph()}.
-	 * <p>
-	 * If the graph contains any {@link Node#isBlank()}, then any corresponding
-	 * {@link BlankNode} will use a {@link UUID} salt from this
-	 * {@link JenaRDFTermFactory} instance in combination with
-	 * {@link Node#getBlankNodeId()} for the purpose of its
-	 * {@link BlankNode#uniqueReference()}.
-	 * 
-	 * @param graph
-	 *            Jena {@link org.apache.jena.graph.Graph} to adapt
-	 * @return Adapted {@link JenaGraph}
-	 */
-	public JenaGraph fromJena(org.apache.jena.graph.Graph graph) {
-		return internalJenaFactory.fromJena(graph, getSalt());
-	}
-
-	/**
-	 * Adapt an existing Jena {@link org.apache.jena.rdf.model.Model} to CommonsRDF {@link Graph}. 
-	 * <p>
-	 * This does not ake a copy, changes to the CommonsRDF Graph are reflected in the jena
-	 * graph, which is accessible from {@link JenaGraph#asJenaGraph()}.
-	 * <p>
-	 * If the graph contains any {@link Node#isBlank()}, then any corresponding
-	 * {@link BlankNode} will use a {@link UUID} salt from this 
-	 * {@link JenaRDFTermFactory} instance
-	 * in combination with {@link Node#getBlankNodeId()} 
-	 * for the purpose of its {@link BlankNode#uniqueReference()}.
-	 * @param model
-	 *            Jena {@link org.apache.jena.rdf.model.Model} to adapt
-	 * @return Adapted {@link JenaGraph}
-	 */
-	public JenaGraph fromJena(org.apache.jena.rdf.model.Model model) {
-		return internalJenaFactory.fromJena(model, getSalt());
-	}	
-
-	/**
-	 * Adapt an existing Jena {@link DatasetGraph} to CommonsRDF {@link Dataset}. 
-	 * <p>
-	 * This does not
-	 * take a copy, changes to the CommonsRDF Dataset are reflected in the jena
-	 * dataset graph, which is accessible from {@link JenaDataset#asJenaDatasetGraph()}.
-	 * <p>
-	 * If the dataset contains any {@link Node#isBlank()}, then any corresponding
-	 * {@link BlankNode} will use a {@link UUID} salt from this 
-	 * {@link JenaRDFTermFactory} instance
-	 * in combination with {@link Node#getBlankNodeId()} 
-	 * for the purpose of its {@link BlankNode#uniqueReference()}.
-	 * 
-	 * @param datasetGraph Jena {@link DatasetGraph} to adapt
-	 * @return Adapted {@link JenaDataset} 
-	 */
-	public JenaDataset fromJena(DatasetGraph datasetGraph) {
-		return internalJenaFactory.fromJena(datasetGraph, getSalt());
-	}	
-	
-	/**
-	 * Adapt an existing Jena {@link org.apache.jena.query.Dataset} to CommonsRDF {@link Dataset}. 
-	 * <p>
-	 * This does not
-	 * take a copy, changes to the CommonsRDF Dataset are reflected in the jena
-	 * dataset graph, which is accessible from {@link JenaDataset#asJenaDatasetGraph()}.
-	 * <p>
-	 * If the dataset contains any {@link Node#isBlank()}, then any corresponding
-	 * {@link BlankNode} will use a {@link UUID} salt from this 
-	 * {@link JenaRDFTermFactory} instance
-	 * in combination with {@link Node#getBlankNodeId()} 
-	 * for the purpose of its {@link BlankNode#uniqueReference()}.
-	 * 
-	 * @param datasetGraph Jena {@link org.apache.jena.query.Dataset} to adapt
-	 * @return Adapted {@link JenaDataset} 
-	 */
-	public JenaDataset fromJena(org.apache.jena.query.Dataset datasetGraph) {
-		return internalJenaFactory.fromJena(datasetGraph.asDatasetGraph(), getSalt());
-	}		
-
-	/**
-	 * Convert from Jena {@link org.apache.jena.sparql.core.Quad} to a Commons
-	 * RDF {@link Quad}.
-	 * <p>
-	 * Note that if any of the quad's nodes {@link Node#isBlank()}, then the
-	 * factory's {@link RDFTermFactory#createBlankNode(String)} will be used,
-	 * meaning that care should be taken if reusing an {@link RDFTermFactory}
-	 * instance for multiple conversion sessions.
-	 * 
-	 * @see #fromJena(org.apache.jena.sparql.core.Quad)
-	 * @see #fromJenaGeneralized(org.apache.jena.sparql.core.Quad)
-	 *
-	 * @param factory
-	 *            {@link RDFTermFactory} to use for creating the {@link Triple}
-	 *            and its {@link RDFTerm}s.
-	 * @param quad
-	 *            Jena {@link org.apache.jena.sparql.core.Quad} to adapt
-	 * @return Converted {@link Quad}
-	 * @throws ConversionException
-	 *             if any of the quad's nodes are not concrete or the quad
-	 *             is a generalized quad
-	 */
-	public static Quad fromJena(RDFTermFactory factory, org.apache.jena.sparql.core.Quad quad) {
-		if (factory instanceof JenaRDFTermFactory) {
-			// No need to convert, just wrap
-			return ((JenaRDFTermFactory) factory).fromJena(quad);
-		}
-		BlankNodeOrIRI graphName = (BlankNodeOrIRI) (fromJena(factory, quad.getGraph()));
-		BlankNodeOrIRI subject = (BlankNodeOrIRI) (fromJena(factory, quad.getSubject()));
-		IRI predicate = (IRI) (fromJena(factory, quad.getPredicate()));
-		RDFTerm object = fromJena(factory, quad.getObject());
-		return factory.createQuad(graphName, subject, predicate, object);
-	}
-
-	/**
-	 * Return {@link RDFSyntax} corresponding to a Jena {@link Lang}.
-	 * 
-	 * @param lang {@link Lang} to convert
-	 * @return Matched {@link RDFSyntax}, otherwise {@link Optional#empty()}
-	 */
-	public Optional<RDFSyntax> langToRdfSyntax(Lang lang) {
-		return RDFSyntax.byMediaType(lang.getContentType().getContentType());
-	}
-
-	/**
-	 * Return Jena {@link Lang} corresponding to a {@link RDFSyntax}.
-	 * 
-	 * @param rdfSyntax {@link RDFSyntax} to convert
-	 * @return Matched {@link Lang}, otherwise {@link Optional#empty()}
-	 */
-	public Optional<Lang> rdfSyntaxToLang(RDFSyntax rdfSyntax) {
-		return Optional.ofNullable(RDFLanguages.contentTypeToLang(rdfSyntax.mediaType));
-	}
-
-	/**
-	 * Create a {@link StreamRDF} instance that inserts the converted
-	 * {@link Quad}s. into a the provided {@link Consumer}.
-	 * <p>
-	 * The returned {@link StreamRDF} can be used for instance with Jena's
-	 * {@link RDFDataMgr#parse(StreamRDF, String)}.
-	 * 
-	 * @param factory
-	 *            {@link RDFTermFactory} to use for creating {@link RDFTerm}s
-	 *            and {@link Quad}s.
-	 * @param consumer
-	 *            A {@link Consumer} of {@link Quad}s
-	 * @return A {@link StreamRDF} that will stream converted quads to the
-	 *         consumer
-	 */
-	public static StreamRDF streamJenaToCommonsRDF(RDFTermFactory factory, Consumer<Quad> consumer) {
-		return new StreamRDFBase() {
-			@Override
-			public void quad(org.apache.jena.sparql.core.Quad quad) {
-				consumer.accept(fromJena(factory, quad));
-			}
-		};
-	}
-	
-	/**
-	 * Create a {@link StreamRDF} instance that inserts generalized
-	 * {@link TripleLike}s. into a the provided {@link Consumer}.
-	 * <p>
-	 * A generalized triple allows any {@link RDFTerm} for
-	 * {@link TripleLike#getSubject()}, {@link TripleLike#getPredicate()} and
-	 * {@link TripleLike#getObject()}.
-	 * <p>
-	 * The returned {@link StreamRDF} can be used for instance with Jena's
-	 * {@link RDFDataMgr#parse(StreamRDF, String)}.
-	 * 
-	 * @param generalizedConsumer
-	 *            A {@link Consumer} of generalized {@link TripleLike}s
-	 * @return A {@link StreamRDF} that will stream generalized triples to the
-	 *         consumer
-	 */
-	public StreamRDF streamJenaToGeneralizedTriple(Consumer<TripleLike> generalizedConsumer) {
-		return new StreamRDFBase() {			
-			@Override
-			public void triple(org.apache.jena.graph.Triple triple) {
-				generalizedConsumer.accept(fromJenaGeneralized(triple));
-			}
-		};
-	}	
-
-	/**
-	 * Create a {@link StreamRDF} instance that inserts generalized
-	 * {@link QuadLike}s. into a the provided {@link Consumer}.
-	 * <p>
-	 * A generalized quad allows any {@link RDFTerm} for
-	 * {@link QuadLike#getSubject()}, {@link TripleLike#getPredicate()},
-	 * {@link QuadLike#getObject()} and {@link QuadLike#getGraphName()} .
-	 * <p>
-	 * The returned {@link StreamRDF} can be used for instance with Jena's
-	 * {@link RDFDataMgr#parse(StreamRDF, String)}.
-	 * 
-	 * @param generalizedConsumer
-	 *            A {@link Consumer} of generalized {@link QuadLike}s
-	 * @return A {@link StreamRDF} that will stream generalized quads to the
-	 *         consumer
-	 */
-	public StreamRDF streamJenaToGeneralizedQuad(Consumer<QuadLike<RDFTerm>> generalizedConsumer) {
-		return new StreamRDFBase() {
-			@Override
-			public void quad(org.apache.jena.sparql.core.Quad quad) {
-				generalizedConsumer.accept(fromJenaGeneralized(quad));
-			}
-		};
-	}	
-	
-	/**
-	 * Convert a CommonsRDF Graph to a Jena Graph. If the Graph was from Jena
-	 * originally, return that original object else create a copy using Jena
-	 * objects.
-	 * 
-	 * @param graph Commons RDF {@link Graph} to convert
-	 * @return Converted Jena {@link org.apache.jena.graph.Graph}
-	 */
-	public org.apache.jena.graph.Graph toJena(Graph graph) {
-		if (graph instanceof JenaGraph)
-			return ((JenaGraph) graph).asJenaGraph();
-		org.apache.jena.graph.Graph g = GraphFactory.createGraphMem();
-		graph.stream().forEach(t -> g.add(toJena(t)));
-		return g;
-	}
-
-	/**
-	 * Convert a CommonsRDF RDFTerm to a Jena Node. If the RDFTerm was from Jena
-	 * originally, return that original object, else create a copy using Jena
-	 * objects.
-	 * 
-	 * @param term Commons RDF {@link RDFTerm} to convert
-	 * @return Converted Jena {@link Node}
-	 */
-	public Node toJena(RDFTerm term) {
-		if (term == null) {
-			return null;
-		}
-		if (term instanceof JenaRDFTerm)
-			// TODO: What if it's a JenaBlankNodeImpl with
-			// a different salt? Do we need to rewrite the
-			// jena blanknode identifier?
-			return ((JenaRDFTerm) term).asJenaNode();
-
-		if (term instanceof IRI)
-			return NodeFactory.createURI(((IRI) term).getIRIString());
-
-		if (term instanceof Literal) {
-			Literal lit = (Literal) term;
-			RDFDatatype dt = NodeFactory.getType(lit.getDatatype().getIRIString());
-			String lang = lit.getLanguageTag().orElse("");
-			return NodeFactory.createLiteral(lit.getLexicalForm(), lang, dt);
-		}
-
-		if (term instanceof BlankNode) {
-			String id = ((BlankNode) term).uniqueReference();
-			return NodeFactory.createBlankNode(id);
-		}
-		throw new ConversionException("Not a concrete RDF Term: " + term);
-	}
-
-	/**
-	 * Convert a CommonsRDF {@link Triple} to a Jena
-	 * {@link org.apache.jena.graph.Triple}.
-	 * <p>
-	 * If the triple was from Jena originally, return that original object, else
-	 * create a copy using Jena objects.
-	 * 
-	 * @param triple Commons RDF {@link Triple} to convert
-	 * @return Converted Jena {@link org.apache.jena.graph.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(
-				toJena(triple.getSubject()), 
-				toJena(triple.getPredicate()),
-				toJena(triple.getObject()));
-	}
-
-
-	/**
-	 * Convert a CommonsRDF {@link Quad} to a Jena
-	 * {@link org.apache.jena.sparql.core.Quad}.
-	 * <p>
-	 * If the quad was from Jena originally, return that original object,
-	 * otherwise create a copy using Jena objects.
-	 *
-	 * @param quad Commons RDF {@link Quad} to convert
-	 * @return Converted Jena {@link org.apache.jena.sparql.core.Quad}
-	 */
-	public org.apache.jena.sparql.core.Quad toJena(Quad quad) {
-		if (quad instanceof JenaQuad) {
-			return ((JenaQuad) quad).asJenaQuad();
-		}
-		return org.apache.jena.sparql.core.Quad.create(
-				toJena(quad.getGraphName().orElse(null)),
-				toJena(quad.getSubject()), 
-				toJena(quad.getPredicate()), 
-				toJena(quad.getObject()));
-	}
-
-	// Some simple validations - full IRI parsing is not cheap.
-	private void validateIRI(String iri) {
-		if (iri.contains(" "))
-			throw new IllegalArgumentException();
-		if (iri.contains("<"))
-			throw new IllegalArgumentException();
-		if (iri.contains(">"))
-			throw new IllegalArgumentException();
-	}
-
-	private static void validateLang(String languageTag) {
-		if (languageTag.contains(" "))
-			throw new IllegalArgumentException("Invalid language tag: " + languageTag);
-	}
-
-	/**
-	 * Return the {@link UUID} salt used by this factory.
-	 * <p>
-	 * The salt is used for the purposes of {@link BlankNode} identity, see
-	 * {@link BlankNode#uniqueReference()} for details.
-	 * <p>
-	 * This salt can be used with the constructor 
-	 * {@link JenaRDFTermFactory#JenaRDFTermFactory(UUID)}
-	 * if consistent or reproducible {@link BlankNode}s are desirable. 
-	 * 
-	 * @return The {@link UUID} used as salt
-	 */
-	public UUID getSalt() {
-		return salt;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java b/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
index 89d2884..19a8a63 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
@@ -30,7 +30,7 @@ import org.apache.commons.rdf.api.RDFTermFactory;
 import org.apache.commons.rdf.api.TripleLike;
 import org.apache.commons.rdf.experimental.RDFParser;
 import org.apache.commons.rdf.jena.JenaGraph;
-import org.apache.commons.rdf.jena.JenaRDFTermFactory;
+import org.apache.commons.rdf.jena.JenaFactory;
 import org.apache.commons.rdf.simple.experimental.AbstractRDFParser;
 import org.apache.jena.graph.Graph;
 import org.apache.jena.riot.Lang;
@@ -44,7 +44,7 @@ public class JenaRDFParser extends AbstractRDFParser<JenaRDFParser> implements R
 	private Consumer<QuadLike<RDFTerm>> generalizedConsumerQuad;
 
 	protected RDFTermFactory createRDFTermFactory() {
-		return new JenaRDFTermFactory();
+		return new JenaFactory();
 	}
 
 	public JenaRDFParser targetGeneralizedTriple(Consumer<TripleLike> consumer) {
@@ -71,7 +71,7 @@ public class JenaRDFParser extends AbstractRDFParser<JenaRDFParser> implements R
 	@Override
 	protected void parseSynchronusly() throws IOException {
 		StreamRDF dest;
-		JenaRDFTermFactory jenaFactory = getJenaFactory();
+		JenaFactory jenaFactory = getJenaFactory();
 		if (getTargetGraph().isPresent() && getTargetGraph().get() instanceof JenaGraph) {
 			Graph jenaGraph = ((JenaGraph) getTargetGraph().get()).asJenaGraph();
 			dest = StreamRDFLib.graph(jenaGraph);
@@ -81,7 +81,7 @@ public class JenaRDFParser extends AbstractRDFParser<JenaRDFParser> implements R
 			} else if (generalizedConsumerTriple != null) {				
 				dest = jenaFactory.streamJenaToGeneralizedTriple(generalizedConsumerTriple);			
 			} else {
-				dest = JenaRDFTermFactory.streamJenaToCommonsRDF(getRdfTermFactory().get(), getTarget());
+				dest = JenaFactory.streamJenaToCommonsRDF(getRdfTermFactory().get(), getTarget());
 			}
 		}
 
@@ -99,9 +99,9 @@ public class JenaRDFParser extends AbstractRDFParser<JenaRDFParser> implements R
 		}
 	}
 
-	private JenaRDFTermFactory getJenaFactory() {
-		return (JenaRDFTermFactory) getRdfTermFactory()
-				.filter(JenaRDFTermFactory.class::isInstance)
+	private JenaFactory getJenaFactory() {
+		return (JenaFactory) getRdfTermFactory()
+				.filter(JenaFactory.class::isInstance)
 				.orElseGet(this::createRDFTermFactory);		
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/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 1846fc0..c66a1da 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
@@ -26,7 +26,7 @@ import org.apache.commons.rdf.api.QuadLike;
 import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.jena.JenaQuad;
 import org.apache.commons.rdf.jena.JenaQuadLike;
-import org.apache.commons.rdf.jena.JenaRDFTermFactory;
+import org.apache.commons.rdf.jena.JenaFactory;
 import org.apache.commons.rdf.jena.JenaTriple;
 import org.apache.jena.graph.Triple;
 import org.apache.jena.sparql.core.Quad;
@@ -86,7 +86,7 @@ abstract class AbstractQuadLike<S extends RDFTerm, P extends RDFTerm, O extends
 
 	@Override
 	public org.apache.jena.sparql.core.Quad asJenaQuad() {
-		JenaRDFTermFactory factory = new JenaRDFTermFactory();
+		JenaFactory factory = new JenaFactory();
 		if (quad == null) {
 			quad = org.apache.jena.sparql.core.Quad.create(
 					factory.toJena(graphName.orElse(null)),
@@ -99,7 +99,7 @@ abstract class AbstractQuadLike<S extends RDFTerm, P extends RDFTerm, O extends
 
 	@Override
 	public org.apache.jena.graph.Triple asJenaTriple() {
-		JenaRDFTermFactory factory = new JenaRDFTermFactory();
+		JenaFactory factory = new JenaFactory();
 		if (triple == null) {
 			triple = org.apache.jena.graph.Triple.create(
 				factory.toJena(subject), 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/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
index eb09d67..67fccb7 100644
--- 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
@@ -35,7 +35,7 @@ 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.JenaFactory;
 import org.apache.commons.rdf.jena.JenaTriple;
 import org.apache.jena.graph.Node;
 import org.apache.jena.graph.NodeFactory;
@@ -49,7 +49,7 @@ import org.apache.jena.sparql.graph.GraphFactory;
  * <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}.
+ * instead use {@link JenaFactory}.
  * <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

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/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 5c410ee..67b2988 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
@@ -32,7 +32,7 @@ import org.apache.commons.rdf.api.Quad;
 import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.jena.JenaDataset;
 import org.apache.commons.rdf.jena.JenaGraph;
-import org.apache.commons.rdf.jena.JenaRDFTermFactory;
+import org.apache.commons.rdf.jena.JenaFactory;
 import org.apache.jena.atlas.iterator.Iter;
 import org.apache.jena.graph.Node;
 import org.apache.jena.riot.Lang;
@@ -44,12 +44,12 @@ class JenaDatasetImpl implements JenaDataset {
 
 	private DatasetGraph graph;
 	private UUID salt;
-	private JenaRDFTermFactory factory;
+	private JenaFactory factory;
 
 	JenaDatasetImpl(DatasetGraph graph, UUID salt) {
 		this.graph = graph;
 		this.salt = salt;
-		this.factory = new JenaRDFTermFactory(salt);
+		this.factory = new JenaFactory(salt);
 	}
 
 	@Override
@@ -136,14 +136,14 @@ class JenaDatasetImpl implements JenaDataset {
 
 	@Override
 	public Stream<? extends Quad> stream() {
-		JenaRDFTermFactory factory = new JenaRDFTermFactory(salt);
+		JenaFactory factory = new JenaFactory(salt);
 		return Iter.asStream(graph.find(ANY, ANY, ANY, ANY), true)
 				.map(factory::fromJena);
 	}
 
 	@Override
 	public Stream<? extends Quad> stream(Optional<BlankNodeOrIRI> g, BlankNodeOrIRI s, IRI p, RDFTerm o) {
-		JenaRDFTermFactory factory = new JenaRDFTermFactory(salt);
+		JenaFactory factory = new JenaFactory(salt);
 		return Iter.asStream(graph.find(toJenaPattern(g), toJenaPattern(s), toJenaPattern(p), toJenaPattern(o)), true)
 				.map(factory::fromJena);
 	}
@@ -175,14 +175,14 @@ class JenaDatasetImpl implements JenaDataset {
 
 	@Override
 	public Stream<BlankNodeOrIRI> getGraphNames() {
-		JenaRDFTermFactory factory = new JenaRDFTermFactory(salt);
+		JenaFactory factory = new JenaFactory(salt);
 		return Iter.asStream(graph.listGraphNodes()).map(node -> 
 			(BlankNodeOrIRI) factory.fromJena(node));		
 	}
 
 	@Override
 	public Iterable<Quad> iterate() {
-		final JenaRDFTermFactory factory = new JenaRDFTermFactory(salt);
+		final JenaFactory factory = new JenaFactory(salt);
 		return Iter.asStream(graph.find(), false)
 				.map(q -> (Quad) factory.fromJena(q))
 				::iterator;

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/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 09cc2ab..bad996a 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
@@ -27,7 +27,7 @@ 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.JenaGraph;
-import org.apache.commons.rdf.jena.JenaRDFTermFactory;
+import org.apache.commons.rdf.jena.JenaFactory;
 import org.apache.jena.atlas.iterator.Iter;
 import org.apache.jena.graph.Node;
 import org.apache.jena.rdf.model.Model;
@@ -39,20 +39,20 @@ class JenaGraphImpl implements JenaGraph {
 
 	private final org.apache.jena.graph.Graph graph;
 	private final UUID salt;
-	private final transient JenaRDFTermFactory factory;
+	private final transient JenaFactory factory;
 	private Model model;
 
 	JenaGraphImpl(org.apache.jena.graph.Graph graph, UUID salt) {
 		this.graph = graph;
 		this.salt = salt;
-		this.factory = new JenaRDFTermFactory(salt);
+		this.factory = new JenaFactory(salt);
 	}
 
 	JenaGraphImpl(Model model, UUID salt) {
 		this.model = model;
 		this.graph = model.getGraph();
 		this.salt = salt;
-		this.factory = new JenaRDFTermFactory(salt);
+		this.factory = new JenaFactory(salt);
 	}
 
 	@Override
@@ -116,13 +116,13 @@ class JenaGraphImpl implements JenaGraph {
 
 	@Override
 	public Stream<? extends Triple> stream() {
-		JenaRDFTermFactory factory = new JenaRDFTermFactory(salt);
+		JenaFactory factory = new JenaFactory(salt);
 		return Iter.asStream(graph.find(null, null, null), true).map(factory::fromJena);
 	}
 
 	@Override
 	public Stream<? extends Triple> stream(BlankNodeOrIRI s, IRI p, RDFTerm o) {
-		JenaRDFTermFactory factory = new JenaRDFTermFactory(salt);
+		JenaFactory factory = new JenaFactory(salt);
 		return Iter.asStream(graph.find(toJenaAny(s), toJenaAny(p), toJenaAny(o)), true)
 				.map(factory::fromJena);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java
index e2749bb..ebccc6e 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestGraphJena.java
@@ -25,7 +25,7 @@ public class TestGraphJena extends AbstractGraphTest {
 
     @Override
     public RDFTermFactory createFactory() {
-        return new JenaRDFTermFactory() ;
+        return new JenaFactory() ;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
index 2668343..1a7b4e0 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
@@ -56,10 +56,10 @@ public class TestJenaGraphToCommonsRDFGraph {
         RDFDataMgr.read(jGraph, turtleFile.toUri().toString()) ;
         
         // "graph" is a CommonsRDF graph 
-        Graph graph = new JenaRDFTermFactory().fromJena(jGraph) ;
+        Graph graph = new JenaFactory().fromJena(jGraph) ;
         
         // Add to CommonsRDF Graph
-        RDFTermFactory rft = new JenaRDFTermFactory() ;
+        RDFTermFactory rft = new JenaFactory() ;
         graph.add(rft.createIRI("http://example/s2"),
                   rft.createIRI("http://example/p2"),
                   rft.createLiteral("foo")) ;

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java
index cd57a0e..b5b3363 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFParserBuilder.java
@@ -54,7 +54,7 @@ public class TestRDFParserBuilder {
 
 	@Test
 	public void parseTurtle() throws Exception {
-		Graph g = new JenaRDFTermFactory().createGraph();
+		Graph g = new JenaFactory().createGraph();
 		Future<ParseResult> gFuture = new JenaRDFParser().contentType(RDFSyntax.TURTLE).source(turtleFile)
 				.target(g).parse();
 		gFuture.get(5, TimeUnit.SECONDS);

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFTermFactoryJena.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFTermFactoryJena.java b/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFTermFactoryJena.java
index 4baec9c..ae423da 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFTermFactoryJena.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestRDFTermFactoryJena.java
@@ -25,7 +25,7 @@ public class TestRDFTermFactoryJena extends AbstractRDFTermFactoryTest {
 	
     @Override
     public RDFTermFactory createFactory() {
-        return new JenaRDFTermFactory() ;
+        return new JenaFactory() ;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/ec8a4aca/src/site/markdown/implementations.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/implementations.md b/src/site/markdown/implementations.md
index 0e4ab9b..f518861 100644
--- a/src/site/markdown/implementations.md
+++ b/src/site/markdown/implementations.md
@@ -92,15 +92,15 @@ Graph graph = rdfTermFactory.createGraph();
 ```java
 import org.apache.commons.rdf.api.Graph;
 import org.apache.commons.rdf.api.RDFTermFactory;
-import org.apache.commons.rdf.jena.JenaRDFTermFactory;
+import org.apache.commons.rdf.jena.JenaFactory;
 
-RDFTermFactory rdfTermFactory = new JenaRDFTermFactory();
+RDFTermFactory rdfTermFactory = new JenaFactory();
 Graph graph = rdfTermFactory.createGraph();
 ```
 
-Objects created with  [JenaRDFTermFactory](apidocs/org/apache/commons/rdf/jena/JenaRDFTermFactory.html) implement interfaces like [JenaQuad](apidocs/org/apache/commons/rdf/jena/JenaQuad.html) and [JenaLiteral](apidocs/org/apache/commons/rdf/jena/JenaLiteral.html) which give access to the underlying Jena objects through methods like [asJenaNode()](apidocs/org/apache/commons/rdf/jena/JenaRDFTerm.html#asJenaNode--) and [asJenaGraph()](apidocs/org/apache/commons/rdf/jena/JenaGraph.html#asJenaGraph--).
+Objects created with  [JenaFactory](apidocs/org/apache/commons/rdf/jena/JenaFactory.html) implement interfaces like [JenaQuad](apidocs/org/apache/commons/rdf/jena/JenaQuad.html) and [JenaLiteral](apidocs/org/apache/commons/rdf/jena/JenaLiteral.html) which give access to the underlying Jena objects through methods like [asJenaNode()](apidocs/org/apache/commons/rdf/jena/JenaRDFTerm.html#asJenaNode--) and [asJenaGraph()](apidocs/org/apache/commons/rdf/jena/JenaGraph.html#asJenaGraph--).
 
-`JenaRDFTermFactory` includes additional methods for converting from/to Apache Jena and Commons RDF, like [fromJena(Node)](apidocs/org/apache/commons/rdf/jena/JenaRDFTermFactory.html#fromJena-org.apache.jena.graph.Node-) and [toJena(RDFTerm)](apidocs/org/apache/commons/rdf/jena/JenaRDFTermFactory.html#toJena-org.apache.commons.rdf.api.RDFTerm-).
+`JenaFactory` includes additional methods for converting from/to Apache Jena and Commons RDF, like [fromJena(Node)](apidocs/org/apache/commons/rdf/jena/JenaFactory.html#fromJena-org.apache.jena.graph.Node-) and [toJena(RDFTerm)](apidocs/org/apache/commons/rdf/jena/JenaFactory.html#toJena-org.apache.commons.rdf.api.RDFTerm-).
 
 #### Generalized RDF
 
@@ -108,7 +108,7 @@ Apache Jena can support [generalized RDF](https://www.w3.org/TR/rdf11-concepts/#
 
 > A generalized RDF triple is a triple having a subject, a predicate, and object, where each can be an IRI, a blank node or a literal.
 
-Within Commons RDF it is possible to create [generalized triples](apidocs/org/apache/commons/rdf/jena/JenaRDFTermFactory.html#createGeneralizedTriple-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-) and [quads](apidocs/org/apache/commons/rdf/jena/JenaRDFTermFactory.html#createGeneralizedQuad-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-) using `JenaRDFTermFactory` - however note that the returned [JenaGeneralizedTripleLike](apidocs/org/apache/commons/rdf/jena/JenaGeneralizedTripleLike.html) and
+Within Commons RDF it is possible to create [generalized triples](apidocs/org/apache/commons/rdf/jena/JenaFactory.html#createGeneralizedTriple-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-) and [quads](apidocs/org/apache/commons/rdf/jena/JenaFactory.html#createGeneralizedQuad-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-org.apache.commons.rdf.api.RDFTerm-) using `JenaFactory` - however note that the returned [JenaGeneralizedTripleLike](apidocs/org/apache/commons/rdf/jena/JenaGeneralizedTripleLike.html) and
 [JenaGeneralizedQuadLike](apidocs/org/apache/commons/rdf/jena/JenaGeneralizedQuadLike.html)
  do not have the [equality semantics of Triple](apidocs/org/apache/commons/rdf/api/Triple.html#equals-java.lang.Object-) or [Quad](apidocs/org/apache/commons/rdf/api/Quad.html#equals-java.lang.Object-) and thus can't be used with the regular [Graph](apidocs/org/apache/commons/rdf/api/Graph.html) or [Dataset](apidocs/org/apache/commons/rdf/api/Dataset.html) methods.