commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [25/49] incubator-commonsrdf git commit: Merge branch 'master' into COMMONSRDF-46
Date Fri, 28 Oct 2016 13:14:47 GMT
Merge branch 'master' into COMMONSRDF-46


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

Branch: refs/heads/master
Commit: d6306ad47b151b20bde77a9bff70532f614f9285
Parents: 44b4b68 2a5dbf9
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Wed Oct 26 12:50:50 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Wed Oct 26 12:50:50 2016 +0100

----------------------------------------------------------------------
 api/pom.xml                                     |   7 -
 integration-tests/pom.xml                       |  60 +++++++
 .../rdf/integrationtests/AllToAllTest.java      | 178 +++++++++++++++++++
 jena/pom.xml                                    |   9 +-
 .../org/apache/commons/rdf/jena/JenaRDF.java    | 153 ++++++++--------
 .../rdf/jena/experimental/JenaRDFParser.java    |   4 +-
 .../commons/rdf/jena/impl/AbstractQuadLike.java |  28 +--
 .../rdf/jena/impl/InternalJenaFactory.java      |  72 ++++----
 .../commons/rdf/jena/impl/JenaDatasetImpl.java  |  28 +--
 .../commons/rdf/jena/impl/JenaGraphImpl.java    |  30 ++--
 .../services/org.apache.commons.rdf.api.RDF     |   1 +
 .../org.apache.commons.rdf.api.RDFFactory       |   1 -
 .../jena/TestJenaGraphToCommonsRDFGraph.java    |  86 +++++++--
 jena/src/test/resources/log4j.properties        |  33 ----
 jsonld-java/pom.xml                             |   7 +-
 .../services/org.apache.commons.rdf.api.RDF     |   1 +
 .../org.apache.commons.rdf.api.RDFFactory       |   1 -
 pom.xml                                         |  40 ++++-
 rdf4j/pom.xml                                   |  10 +-
 .../services/org.apache.commons.rdf.api.RDF     |   1 +
 .../org.apache.commons.rdf.api.RDFFactory       |   1 -
 simple/pom.xml                                  |   5 -
 .../services/org.apache.commons.rdf.api.RDF     |   1 +
 .../org.apache.commons.rdf.api.RDFFactory       |   1 -
 .../commons/rdf/simple/SimpleGraphTest.java     |   2 +-
 25 files changed, 517 insertions(+), 243 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/integration-tests/src/test/java/org/apache/commons/rdf/integrationtests/AllToAllTest.java
----------------------------------------------------------------------
diff --cc integration-tests/src/test/java/org/apache/commons/rdf/integrationtests/AllToAllTest.java
index 0000000,1b32e35..e90ea47
mode 000000,100644..100644
--- a/integration-tests/src/test/java/org/apache/commons/rdf/integrationtests/AllToAllTest.java
+++ b/integration-tests/src/test/java/org/apache/commons/rdf/integrationtests/AllToAllTest.java
@@@ -1,0 -1,178 +1,178 @@@
+ /**
+  * 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.integrationtests;
+ 
+ import static org.junit.Assert.assertEquals;
+ import static org.junit.Assert.assertTrue;
+ 
+ import java.util.ArrayList;
+ import java.util.Arrays;
+ import java.util.Collection;
+ import java.util.List;
+ 
+ import org.apache.commons.rdf.api.BlankNode;
+ 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.RDF;
+ import org.apache.commons.rdf.api.RDFTerm;
 -import org.apache.commons.rdf.api.RDFTermFactory;
+ import org.apache.commons.rdf.api.Triple;
 -import org.apache.commons.rdf.jena.JenaFactory;
 -import org.apache.commons.rdf.jsonldjava.JsonLdFactory;
 -import org.apache.commons.rdf.rdf4j.RDF4JFactory;
 -import org.apache.commons.rdf.simple.SimpleRDFTermFactory;
++import org.apache.commons.rdf.jena.JenaRDF;
++import org.apache.commons.rdf.jsonldjava.JsonLdRDF;
++import org.apache.commons.rdf.rdf4j.RDF4J;
++import org.apache.commons.rdf.simple.SimpleRDF;
+ import org.junit.Test;
+ import org.junit.runner.RunWith;
+ import org.junit.runners.Parameterized;
+ import org.junit.runners.Parameterized.Parameters;
+ 
+ @RunWith(Parameterized.class)
+ public class AllToAllTest {
+ 
 -	private RDFTermFactory nodeFactory;
 -	private RDFTermFactory graphFactory;
++	private RDF nodeFactory;
++	private RDF graphFactory;
+ 
+ 
+ 	public AllToAllTest(
 -			Class<? extends RDFTermFactory> from,
 -			Class<? extends RDFTermFactory> to) throws InstantiationException, IllegalAccessException {
++			Class<? extends RDF> from,
++			Class<? extends RDF> to) throws InstantiationException, IllegalAccessException {
+ 		this.nodeFactory = from.newInstance();
+ 		this.graphFactory = to.newInstance();
+ 	}
+ 
+ 	@SuppressWarnings("rawtypes")
+ 	@Parameters(name = "{index}: {0}->{1}")
+ 	public static Collection<Object[]> data() {
+ 		List<Class> factories = Arrays.asList(
 -						SimpleRDFTermFactory.class,
 -						JenaFactory.class,
 -						RDF4JFactory.class,
 -						JsonLdFactory.class);
++						SimpleRDF.class,
++						JenaRDF.class,
++						RDF4J.class,
++						JsonLdRDF.class);
+ 		Collection<Object[]>  allToAll = new ArrayList<>();
+ 		for (Class from : factories) {
+ 			for (Class to : factories) {
+ 				// NOTE: we deliberately include self-to-self here
+ 				// to test two instances of the same implementation
+ 				allToAll.add(new Object[]{from, to});
+ 			}
+ 		}
+ 		return allToAll;
+ 	}
+ 
+ 		/**
+ 	 * This test creates a {@link Graph} with the first
+ 	 * {@link RDFTermFactory}, then inserts/queries with
+ 	 * triples using {@link RDFTerm}s created with the second factory.
+ 	 *
+ 	 * @param nodeFactory Factory to create {@link RDFTerm} instances
+ 	 * @param graphFactory Factory to create {@link Graph}
+ 	 * @throws Exception
+ 	 */
+ 	@Test
+ 	public void addTermsFromOtherFactory() throws Exception {
+ 		Graph g = graphFactory.createGraph();
+ 		BlankNode s = nodeFactory.createBlankNode();
+ 		IRI p = nodeFactory.createIRI("http://example.com/p");
+ 		Literal o = nodeFactory.createLiteral("Hello");
+ 
+ 		g.add(s, p, o);
+ 
+ 		// blankNode should still work with g.contains()
+ 		assertTrue(g.contains(s, p, o));
+ 		Triple t1 = g.stream().findAny().get();
+ 
+ 		// Can't make assumptions about BlankNode equality - it might
+ 		// have been mapped to a different BlankNode.uniqueReference()
+ 		// assertEquals(s, t.getSubject());
+ 
+ 		assertEquals(p, t1.getPredicate());
+ 		assertEquals(o, t1.getObject());
+ 
+ 		IRI s2 = nodeFactory.createIRI("http://example.com/s2");
+ 		g.add(s2, p, s);
+ 		assertTrue(g.contains(s2, p, s));
+ 
+ 		// This should be mapped to the same BlankNode
+ 		// (even if it has a different identifier), e.g.
+ 		// we should be able to do:
+ 
+ 		Triple t2 = g.stream(s2, p, null).findAny().get();
+ 
+ 		BlankNode bnode = (BlankNode) t2.getObject();
+ 		// And that (possibly adapted) BlankNode object should
+ 		// match the subject of t1 statement
+ 		assertEquals(bnode, t1.getSubject());
+ 		// And can be used as a key:
+ 		Triple t3 = g.stream(bnode, p, null).findAny().get();
+ 		assertEquals(t1, t3);
+ 	}
+ 
+ 
+ 	/**
+ 	 * This is a variation of {@link #addTermsFromOtherFactory(RDFTermFactory, RDFTermFactory)},
+ 	 * but here {@link Triple} is created in the "foreign" nodeFactory before adding to the graph.
+ 	 *
+ 	 * @param nodeFactory Factory to create {@link RDFTerm} and {@link Triple}s
+ 	 * @param graphFactory Factory to create {@link Graph}
+ 	 * @throws Exception
+ 	 */
+ 	@Test
+ 	public void addTriplesFromOtherFactory() throws Exception {
+ 		Graph g = graphFactory.createGraph();
+ 		BlankNode s = nodeFactory.createBlankNode();
+ 		IRI p = nodeFactory.createIRI("http://example.com/p");
+ 		Literal o = nodeFactory.createLiteral("Hello");
+ 
+ 		Triple srcT1 = nodeFactory.createTriple(s, p, o);
+ 		// This should work even with BlankNode as they are from the same factory
+ 		assertEquals(s, srcT1.getSubject());
+ 		assertEquals(p, srcT1.getPredicate());
+ 		assertEquals(o, srcT1.getObject());
+ 		g.add(srcT1);
+ 
+ 		// what about the blankNode within?
+ 		assertTrue(g.contains(srcT1));
+ 		Triple t1 = g.stream().findAny().get();
+ 
+ 		// Can't make assumptions about BlankNode equality - it might
+ 		// have been mapped to a different BlankNode.uniqueReference()
+ 		//assertEquals(srcT1, t1);
+ 		//assertEquals(s, t1.getSubject());
+ 		assertEquals(p, t1.getPredicate());
+ 		assertEquals(o, t1.getObject());
+ 
+ 		IRI s2 = nodeFactory.createIRI("http://example.com/s2");
+ 		Triple srcT2 = nodeFactory.createTriple(s2, p, s);
+ 		g.add(srcT2);
+ 		assertTrue(g.contains(srcT2));
+ 
+ 		// This should be mapped to the same BlankNode
+ 		// (even if it has a different identifier), e.g.
+ 		// we should be able to do:
+ 
+ 		Triple t2 = g.stream(s2, p, null).findAny().get();
+ 
+ 		BlankNode bnode = (BlankNode) t2.getObject();
+ 		// And that (possibly adapted) BlankNode object should
+ 		// match the subject of t1 statement
+ 		assertEquals(bnode, t1.getSubject());
+ 		// And can be used as a key:
+ 		Triple t3 = g.stream(bnode, p, null).findAny().get();
+ 		assertEquals(t1, t3);
+ 	}
+ }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDF.java
----------------------------------------------------------------------
diff --cc jena/src/main/java/org/apache/commons/rdf/jena/JenaRDF.java
index 0a3f1b0,0000000..22db284
mode 100644,000000..100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDF.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDF.java
@@@ -1,729 -1,0 +1,742 @@@
 +/**
 + * 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.RDF;
 +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;
 +
 +/**
 + * Apache Jena RDF implementation.
 + * <p>
-  * Instances of JenaRDF can also convert existing objects from/to
-  * <code>org.apache.jena</code> types with methods like
-  * {@link #fromJena(org.apache.jena.graph.Graph)} and {@link #toJena(Graph)}.
++ * Instances of JenaRDF can also 
++ * convert existing objects from Jena with methods like
++ * {@link #asRDFTerm(Node)} and {@link #asGraph(org.apache.jena.graph.Graph)},
++ * and vice versa from any Commons RDF object to Jena with the
++ * <code>asJena*</code> methods like {@link #asJenaNode(RDFTerm)} and
++ * {@link #asJenaGraph(Graph)}.
 + * <p>
-  * For the purpose of {@link BlankNode} identity, JenaRDF instances use an
-  * internal {@link UUID} as a salt. See {@link BlankNode#uniqueReference()} for
-  * details.
++ * Note that Commons RDF objects created by this class implement the
++ * specializations interfaces like {@link JenaRDFTerm}, {@link JenaGraph} and
++ * {@link JenaTriple}, which provide access to the underlying Jena objects, e.g.
++ * with {@link JenaRDFTerm#asJenaNode()}.
++ * <p>
++ * For the purpose of {@link BlankNode} identity when using
++ * {@link #createBlankNode(String)} (see {@link BlankNode#equals(Object)} and
++ * {@link BlankNode#uniqueReference()}), each instance of JenaRDF uses an
++ * internal random state. If for some reason consistent/reproducible BlankNode
++ * identity is desired, it is possible to retrieve the state as a UUID using
++ * {@link #salt} for subsequent use with {@link JenaFactory#JenaFactory(UUID)} -
++ * note that such consistency is only guaranteed within the same minor version
++ * of Commons RDF.
 + * 
 + * @see RDF
 + */
 +public final class JenaRDF implements RDF {
 +
 +	private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
 +	
 +	private final UUID salt;
 +
 +	/**
 +	 * Create a JenaRDF.
 +	 * <p>
 +	 * This constructor will use a randomly generated {@link UUID} as a salt 
- 	 * for the purposes of {@link BlankNode} identity, see {@link #getSalt()}.
++	 * for the purposes of {@link BlankNode} identity, see {@link #salt()}.
 +	 */
 +	public JenaRDF() {
 +		this.salt = UUID.randomUUID();
 +	}
 +
 +	/**
 +	 * Create a JenaRDF.
 +	 * <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 JenaRDF(UUID salt) {
 +		this.salt = salt;
 +	}
 +
 +	@Override
 +	public JenaBlankNode createBlankNode() {
- 		return internalJenaFactory.createBlankNode(getSalt());
++		return internalJenaFactory.createBlankNode(salt());
 +	}
 +
 +	@Override
 +	public JenaBlankNode createBlankNode(String name) {
- 		return internalJenaFactory.createBlankNode(name, getSalt());
++		return internalJenaFactory.createBlankNode(name, salt());
 +	}
 +	
 +	@Override
 +	public JenaDataset createDataset() {
- 		return internalJenaFactory.createDataset(getSalt());
++		return internalJenaFactory.createDataset(salt());
 +	}
 +
 +	@Override
 +	public JenaGraph createGraph() {
- 		return internalJenaFactory.createGraph(getSalt());
++		return internalJenaFactory.createGraph(salt());
 +	}
 +
 +	@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 JenaRDF} instance in combination with
 +	 * {@link Node#getBlankNodeId()} for the purpose of its
 +	 * {@link BlankNode#uniqueReference()}.
 +	 * 
- 	 * @see #fromJena(RDF, Node)
++	 * @see #asRDFTerm(RDF, 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());
++	public JenaRDFTerm asRDFTerm(Node node) throws ConversionException {
++		return internalJenaFactory.createRDFTerm(node, salt());
 +	}
 +
 +	/**
 +	 * Convert from Jena {@link Node} to any Commons RDF implementation.
 +	 * <p>
 +	 * Note that if the {@link Node#isBlank()}, then the factory's 
 +	 * {@link RDF#createBlankNode(String)} will be used, meaning
 +	 * that care should be taken if reusing an {@link RDF} instance
 +	 * for multiple conversion sessions.
 +	 * 
- 	 * @see #fromJena(Node)
++	 * @see #asRDFTerm(Node)
 +	 * 
 +	 * @param factory {@link RDF} 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(RDF factory, Node node) {
++	public static RDFTerm asRDFTerm(RDF factory, Node node) {
 +		if (node == null) {
 +			return null;
 +		}
 +		if (factory instanceof JenaRDF) {
 +			// No need to convert, just wrap
- 			return ((JenaRDF) factory).fromJena(node);
++			return ((JenaRDF) factory).asRDFTerm(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 JenaRDF} instance in combination with
 +	 * {@link Node#getBlankNodeId()} for the purpose of its
 +	 * {@link BlankNode#uniqueReference()}.
 +	 *
- 	 * @see #fromJena(RDF, org.apache.jena.graph.Triple)
++	 * @see #asTriple(RDF, 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());
++	public JenaTriple asTriple(org.apache.jena.graph.Triple triple) throws ConversionException {
++		return internalJenaFactory.createTriple(triple, salt());
 +	}
 +
 +	/**
 +	 * 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 JenaRDF} instance in combination with
 +	 * {@link Node#getBlankNodeId()} for the purpose of its
 +	 * {@link BlankNode#uniqueReference()}.
 +	 *
- 	 * @see #fromJena(RDF, org.apache.jena.graph.Triple)
++	 * @see #asTriple(RDF, 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());
++	public JenaTripleLike asGeneralizedTriple(org.apache.jena.graph.Triple triple) throws ConversionException {
++		return internalJenaFactory.createGeneralizedTriple(triple, salt());
 +	}
 +
 +	/**
 +	 * 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 JenaRDF} 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)
++	 * @see #asQuad(org.apache.jena.sparql.core.Quad)
++	 * @see #asGeneralizedTriple(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());
++	public JenaQuadLike<RDFTerm> asGeneralizedQuad(org.apache.jena.sparql.core.Quad quad) throws ConversionException {
++		return internalJenaFactory.createGeneralizedQuad(quad, salt());
 +	}
 +	
 +	/**
 +	 * 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 RDF#createBlankNode(String)} will be used, meaning
 +	 * that care should be taken if reusing an {@link RDF} instance
 +	 * for multiple conversion sessions.
 +	 * 
- 	 * @see #fromJena(org.apache.jena.graph.Triple)
++	 * @see #asTriple(org.apache.jena.graph.Triple)
 +	 *
 +	 * @param factory {@link RDF} 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(RDF factory, org.apache.jena.graph.Triple triple) 
++	public static Triple asTriple(RDF factory, org.apache.jena.graph.Triple triple) 
 +			throws ConversionException{
 +		if (factory instanceof JenaRDF) {
 +			// No need to convert, just wrap
- 			return ((JenaRDF) factory).fromJena(triple);
++			return ((JenaRDF) factory).asTriple(triple);
 +		}
 +		final BlankNodeOrIRI subject;
 +		final IRI predicate;
 +		try {
- 			subject = (BlankNodeOrIRI) fromJena(factory, triple.getSubject());
- 			predicate = (IRI) fromJena(factory, triple.getPredicate());
++			subject = (BlankNodeOrIRI) asRDFTerm(factory, triple.getSubject());
++			predicate = (IRI) asRDFTerm(factory, triple.getPredicate());
 +		} catch (ClassCastException ex) {
 +			throw new ConversionException("Can't convert generalized triple: " + triple, ex);
 +		}
- 		RDFTerm object = fromJena(factory, triple.getObject());
++		RDFTerm object = asRDFTerm(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 JenaRDF} 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());
++	public JenaQuad asQuad(org.apache.jena.sparql.core.Quad quad) {
++		return internalJenaFactory.createQuad(quad, salt());
 +	}
 +
 +	/**
 +	 * 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 JenaRDF} 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());
++	public JenaGraph asGraph(org.apache.jena.graph.Graph graph) {
++		return internalJenaFactory.createGraph(graph, salt());
 +	}
 +
 +	/**
 +	 * 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 JenaRDF} 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());
++	public JenaGraph asGraph(org.apache.jena.rdf.model.Model model) {
++		return internalJenaFactory.createGraph(model, salt());
 +	}	
 +
 +	/**
 +	 * 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 JenaRDF} 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());
++	public JenaDataset asDataset(DatasetGraph datasetGraph) {
++		return internalJenaFactory.createDataset(datasetGraph, salt());
 +	}	
 +	
 +	/**
 +	 * 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 JenaRDF} 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());
++	public JenaDataset asDataset(org.apache.jena.query.Dataset datasetGraph) {
++		return internalJenaFactory.createDataset(datasetGraph.asDatasetGraph(), salt());
 +	}		
 +
 +	/**
 +	 * 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 RDF#createBlankNode(String)} will be used,
 +	 * meaning that care should be taken if reusing an {@link RDF}
 +	 * instance for multiple conversion sessions.
 +	 * 
- 	 * @see #fromJena(org.apache.jena.sparql.core.Quad)
- 	 * @see #fromJenaGeneralized(org.apache.jena.sparql.core.Quad)
++	 * @see #asQuad(org.apache.jena.sparql.core.Quad)
++	 * @see #asGeneralizedQuad(org.apache.jena.sparql.core.Quad)
 +	 *
 +	 * @param factory
 +	 *            {@link RDF} 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(RDF factory, org.apache.jena.sparql.core.Quad quad) {
++	public static Quad asQuad(RDF factory, org.apache.jena.sparql.core.Quad quad) {
 +		if (factory instanceof JenaRDF) {
 +			// No need to convert, just wrap
- 			return ((JenaRDF) factory).fromJena(quad);
++			return ((JenaRDF) factory).asQuad(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());
++		BlankNodeOrIRI graphName = (BlankNodeOrIRI) (asRDFTerm(factory, quad.getGraph()));
++		BlankNodeOrIRI subject = (BlankNodeOrIRI) (asRDFTerm(factory, quad.getSubject()));
++		IRI predicate = (IRI) (asRDFTerm(factory, quad.getPredicate()));
++		RDFTerm object = asRDFTerm(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) {
++	public Optional<RDFSyntax> asRDFSyntax(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) {
++	public Optional<Lang> asJenaLang(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 RDF} 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(RDF factory, Consumer<Quad> consumer) {
++	public static StreamRDF streamJenaToQuad(RDF factory, Consumer<Quad> consumer) {
 +		return new StreamRDFBase() {
 +			@Override
 +			public void quad(org.apache.jena.sparql.core.Quad quad) {
- 				consumer.accept(fromJena(factory, quad));
++				consumer.accept(asQuad(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));
++				generalizedConsumer.accept(asGeneralizedTriple(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));
++				generalizedConsumer.accept(asGeneralizedQuad(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) {
++	public org.apache.jena.graph.Graph asJenaGraph(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)));
++		graph.stream().forEach(t -> g.add(asJenaTriple(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) {
++	public Node asJenaNode(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) {
++	public org.apache.jena.graph.Triple asJenaTriple(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()));
++				asJenaNode(triple.getSubject()), 
++				asJenaNode(triple.getPredicate()),
++				asJenaNode(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) {
++	public org.apache.jena.sparql.core.Quad asJenaQuad(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()));
++				asJenaNode(quad.getGraphName().orElse(null)),
++				asJenaNode(quad.getSubject()), 
++				asJenaNode(quad.getPredicate()), 
++				asJenaNode(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 JenaRDF#JenaRDF(UUID)}
 +	 * if consistent or reproducible {@link BlankNode}s are desirable. 
 +	 * 
 +	 * @return The {@link UUID} used as salt
 +	 */
- 	public UUID getSalt() {
++	public UUID salt() {
 +		return salt;
 +	}
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
----------------------------------------------------------------------
diff --cc jena/src/main/java/org/apache/commons/rdf/jena/experimental/JenaRDFParser.java
index d78870c,14d13d9..81069f0
--- 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
@@@ -77,15 -77,15 +77,15 @@@ public class JenaRDFParser extends Abst
  			dest = StreamRDFLib.graph(jenaGraph);
  		} else {
  			if (generalizedConsumerQuad != null) {				
 -				dest = jenaFactory.streamJenaToGeneralizedQuad(generalizedConsumerQuad);			
 +				dest = jenaRDF.streamJenaToGeneralizedQuad(generalizedConsumerQuad);			
  			} else if (generalizedConsumerTriple != null) {				
 -				dest = jenaFactory.streamJenaToGeneralizedTriple(generalizedConsumerTriple);			
 +				dest = jenaRDF.streamJenaToGeneralizedTriple(generalizedConsumerTriple);			
  			} else {
- 				dest = JenaRDF.streamJenaToCommonsRDF(getRdfTermFactory().get(), getTarget());
 -				dest = JenaFactory.streamJenaToQuad(getRdfTermFactory().get(), getTarget());
++				dest = JenaRDF.streamJenaToQuad(getRdfTermFactory().get(), getTarget());
  			}
  		}
  
- 		Lang lang = getContentTypeSyntax().flatMap(jenaRDF::rdfSyntaxToLang).orElse(null);
 -		Lang lang = getContentTypeSyntax().flatMap(jenaFactory::asJenaLang).orElse(null);
++		Lang lang = getContentTypeSyntax().flatMap(jenaRDF::asJenaLang).orElse(null);
  		String baseStr = getBase().map(IRI::getIRIString).orElse(null);
  
  		if (getSourceIri().isPresent()) {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractQuadLike.java
----------------------------------------------------------------------
diff --cc jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractQuadLike.java
index d538076,9166731..10dc069
--- 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
@@@ -86,25 -86,25 +86,25 @@@ abstract class AbstractQuadLike<S exten
  
  	@Override
  	public org.apache.jena.sparql.core.Quad asJenaQuad() {
 -		JenaFactory factory = new JenaFactory();
 +		JenaRDF factory = new JenaRDF();
  		if (quad == null) {
  			quad = org.apache.jena.sparql.core.Quad.create(
- 					factory.toJena(graphName.orElse(null)),
- 					factory.toJena(subject), 
- 					factory.toJena(predicate),
- 					factory.toJena(object));
+ 					factory.asJenaNode(graphName.orElse(null)),
+ 					factory.asJenaNode(subject), 
+ 					factory.asJenaNode(predicate),
+ 					factory.asJenaNode(object));
  		}
  		return quad;
  	}
  
  	@Override
  	public org.apache.jena.graph.Triple asJenaTriple() {
 -		JenaFactory factory = new JenaFactory();
 +		JenaRDF factory = new JenaRDF();
  		if (triple == null) {
  			triple = org.apache.jena.graph.Triple.create(
- 				factory.toJena(subject), 
- 				factory.toJena(predicate),
- 				factory.toJena(object));
+ 				factory.asJenaNode(subject), 
+ 				factory.asJenaNode(predicate),
+ 				factory.asJenaNode(object));
  		}
  		return triple;
  	}	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jena/src/main/java/org/apache/commons/rdf/jena/impl/InternalJenaFactory.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
----------------------------------------------------------------------
diff --cc jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaDatasetImpl.java
index 81c9a07,17e4e0b..17cb641
--- 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
@@@ -136,16 -136,16 +136,16 @@@ class JenaDatasetImpl implements JenaDa
  
  	@Override
  	public Stream<? extends Quad> stream() {
 -		JenaFactory factory = new JenaFactory(salt);
 +		JenaRDF factory = new JenaRDF(salt);
  		return Iter.asStream(graph.find(ANY, ANY, ANY, ANY), true)
- 				.map(factory::fromJena);
+ 				.map(factory::asQuad);
  	}
  
  	@Override
  	public Stream<? extends Quad> stream(Optional<BlankNodeOrIRI> g, BlankNodeOrIRI s, IRI p, RDFTerm o) {
 -		JenaFactory factory = new JenaFactory(salt);
 +		JenaRDF factory = new JenaRDF(salt);
  		return Iter.asStream(graph.find(toJenaPattern(g), toJenaPattern(s), toJenaPattern(p), toJenaPattern(o)), true)
- 				.map(factory::fromJena);
+ 				.map(factory::asQuad);
  	}
  
  	@Override
@@@ -175,16 -175,16 +175,16 @@@
  
  	@Override
  	public Stream<BlankNodeOrIRI> getGraphNames() {
 -		JenaFactory factory = new JenaFactory(salt);
 +		JenaRDF factory = new JenaRDF(salt);
  		return Iter.asStream(graph.listGraphNodes()).map(node -> 
- 			(BlankNodeOrIRI) factory.fromJena(node));		
+ 			(BlankNodeOrIRI) factory.asRDFTerm(node));		
  	}
  
  	@Override
  	public Iterable<Quad> iterate() {
 -		final JenaFactory factory = new JenaFactory(salt);
 +		final JenaRDF factory = new JenaRDF(salt);
  		return Iter.asStream(graph.find(), false)
- 				.map(q -> (Quad) factory.fromJena(q))
+ 				.map(q -> (Quad) factory.asQuad(q))
  				::iterator;
  	}
  

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
----------------------------------------------------------------------
diff --cc jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaGraphImpl.java
index eab4089,ab56505..fd2f6c4
--- 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
@@@ -116,15 -116,15 +116,15 @@@ class JenaGraphImpl implements JenaGrap
  
  	@Override
  	public Stream<? extends Triple> stream() {
 -		JenaFactory factory = new JenaFactory(salt);
 +		JenaRDF factory = new JenaRDF(salt);
- 		return Iter.asStream(graph.find(null, null, null), true).map(factory::fromJena);
+ 		return Iter.asStream(graph.find(null, null, null), true).map(factory::asTriple);
  	}
  
  	@Override
  	public Stream<? extends Triple> stream(BlankNodeOrIRI s, IRI p, RDFTerm o) {
 -		JenaFactory factory = new JenaFactory(salt);
 +		JenaRDF factory = new JenaRDF(salt);
  		return Iter.asStream(graph.find(toJenaAny(s), toJenaAny(p), toJenaAny(o)), true)
- 				.map(factory::fromJena);
+ 				.map(factory::asTriple);
  	}
  
  	private Node toJenaAny(RDFTerm term) {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jena/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
----------------------------------------------------------------------
diff --cc jena/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
index 0000000,0000000..afe6af3
new file mode 100644
--- /dev/null
+++ b/jena/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
@@@ -1,0 -1,0 +1,1 @@@
++org.apache.commons.rdf.jena.JenaRDF

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
----------------------------------------------------------------------
diff --cc jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
index 16e3e67,728bba2..51cfa4c
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
@@@ -18,14 -18,22 +18,21 @@@
  
  package org.apache.commons.rdf.jena;
  
+ import static org.junit.Assert.assertEquals;
 -import static org.junit.Assert.assertFalse;
+ import static org.junit.Assert.assertTrue;
+ 
  import java.io.IOException;
  import java.nio.file.Files;
  import java.nio.file.Path;
  import java.nio.file.StandardCopyOption;
  
+ import org.apache.commons.rdf.api.BlankNode;
+ import org.apache.commons.rdf.api.BlankNodeOrIRI;
  import org.apache.commons.rdf.api.Graph ;
- import org.apache.commons.rdf.api.RDF ;
+ import org.apache.commons.rdf.api.RDFTerm;
+ import org.apache.commons.rdf.api.Triple;
+ import org.apache.commons.rdf.simple.Types;
 -import org.apache.jena.riot.Lang;
 +import org.apache.jena.riot.Lang ;
  import org.apache.jena.riot.RDFDataMgr ;
  import org.apache.jena.sparql.graph.GraphFactory ;
  import org.junit.After;
@@@ -55,20 -64,72 +63,72 @@@ public class TestJenaGraphToCommonsRDFG
          org.apache.jena.graph.Graph jGraph = GraphFactory.createGraphMem() ;        
          RDFDataMgr.read(jGraph, turtleFile.toUri().toString()) ;
          
 -        JenaFactory factory = new JenaFactory() ;
++        JenaRDF factory = new JenaRDF() ;
+         
          // "graph" is a CommonsRDF graph 
-         Graph graph = new JenaRDF().fromJena(jGraph) ;
+         Graph graph = factory.asGraph(jGraph) ;
+         
+         
+         
+         // The below check expected statements from D.ttl
+         
+         JenaIRI p = factory.createIRI("http://example.com/p");
+ 		JenaIRI s = factory.createIRI("http://example.com/s");
+ 		JenaLiteral literal123 = factory.createLiteral("123", Types.XSD_INTEGER);
+ 		assertTrue(graph.contains(s, p, literal123));
+         
+         JenaIRI p1 = factory.createIRI("http://example.com/p1");
+         // Let's look up the BlankNode
+ 		BlankNodeOrIRI bnode1 = graph.stream(null, p1, null)
+         		.findFirst().map(Triple::getSubject).get();
+         assertTrue(bnode1 instanceof BlankNode);
+         
+         // Verify we can use BlankNode in query again
+         RDFTerm obj = graph.stream(bnode1, p1, null).findFirst().map(Triple::getObject).get();
          
+         // Let's look up also that nested blank node
+         assertTrue(obj instanceof BlankNode);
+         BlankNode bnode2 = (BlankNode)obj;
+         
+         
+         
+         JenaIRI q = factory.createIRI("http://example.com/q");
+         JenaLiteral literalR = factory.createLiteral("r", "en");
+ 		assertTrue(graph.contains(bnode2, q, literalR));
+         
+ 
+ 		// Can we add the same triple again as s/p/o 
+ 		// without affecting graph size?
+ 		// Just to be evil we add a blanknode-iri-blanknode statement
+         assertEquals(3, graph.size());
+ 		graph.add(bnode1, p1, bnode2);
+ 		assertEquals(3, graph.size());
+         
+ 		// Add the same Triple again
+ 		graph.stream(bnode2,null,null).findFirst().ifPresent(graph::add);
+ 		assertEquals(3, graph.size());
+ 		
+ 		
          // Add to CommonsRDF Graph
-         RDF rft = new JenaRDF() ;
-         graph.add(rft.createIRI("http://example/s2"),
-                   rft.createIRI("http://example/p2"),
-                   rft.createLiteral("foo")) ;
-         System.out.println("==== Write CommonsRDF graph\n") ;
-         graph.stream().forEach(System.out::println) ;
-         
-         System.out.println("\n==== Write Jena graph directly\n") ;
-         // And its in the Jena graph
-         RDFDataMgr.write(System.out, jGraph, Lang.TTL) ;
+         JenaIRI s2 = factory.createIRI("http://example/s2");
+ 		JenaIRI p2 = factory.createIRI("http://example/p2");
+ 		JenaLiteral foo = factory.createLiteral("foo");
+ 		graph.add(s2,
+         		  p2,
+         		  foo) ;
+ 		assertEquals(4, graph.size());
+ 		assertTrue(graph.contains(s2,p2,foo));
+         
+         // Verify the corresponding Jena Nodes are in Jena graph
+         assertTrue(jGraph.contains(s2.asJenaNode(), p2.asJenaNode(), foo.asJenaNode()));
+         
+         if (DEBUG) {
+ 	        System.out.println("==== Write CommonsRDF graph\n") ;
+ 	        graph.stream().forEach(System.out::println) ;        
+ 	        // And its in the Jena graph
+ 	        System.out.println("\n==== Write Jena graph directly\n") ;
+ 	        RDFDataMgr.write(System.out, jGraph, Lang.TTL) ;
+         }
      }
  }
  

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
----------------------------------------------------------------------
diff --cc jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
index 0000000,0000000..2c97ca5
new file mode 100644
--- /dev/null
+++ b/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
@@@ -1,0 -1,0 +1,1 @@@
++org.apache.commons.rdf.jsonldjava.JsonLdRDF

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/rdf4j/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
----------------------------------------------------------------------
diff --cc rdf4j/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
index 0000000,0000000..f8a94bb
new file mode 100644
--- /dev/null
+++ b/rdf4j/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
@@@ -1,0 -1,0 +1,1 @@@
++org.apache.commons.rdf.rdf4j.RDF4J

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/simple/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
----------------------------------------------------------------------
diff --cc simple/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
index 0000000,0000000..4003034
new file mode 100644
--- /dev/null
+++ b/simple/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDF
@@@ -1,0 -1,0 +1,1 @@@
++org.apache.commons.rdf.simple.SimpleRDF

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d6306ad4/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java
----------------------------------------------------------------------


Mime
View raw message