commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [44/50] [abbrv] incubator-commonsrdf git commit: Reformat tab -> spaces
Date Fri, 28 Oct 2016 13:08:22 GMT
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDF.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDF.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDF.java
index a550b06..b49656f 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
@@ -50,12 +50,11 @@ import org.apache.jena.sparql.graph.GraphFactory;
 /**
  * Apache Jena RDF implementation.
  * <p>
- * 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)}.
+ * 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>
  * Note that Commons RDF objects created by this class implement the
  * specializations interfaces like {@link JenaRDFTerm}, {@link JenaGraph} and
@@ -67,676 +66,686 @@ import org.apache.jena.sparql.graph.GraphFactory;
  * {@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 JenaRDF#JenaRDF(UUID)} -
- * note that such consistency is only guaranteed within the same minor version
- * of Commons RDF.
+ * {@link #salt()} for subsequent use with {@link JenaRDF#JenaRDF(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 #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(salt());
-	}
-
-	@Override
-	public JenaBlankNode createBlankNode(String name) {
-		return internalJenaFactory.createBlankNode(name, salt());
-	}
-	
-	@Override
-	public JenaDataset createDataset() {
-		return internalJenaFactory.createDataset(salt());
-	}
-
-	@Override
-	public JenaGraph createGraph() {
-		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 #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 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 #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 asRDFTerm(RDF factory, Node node) {
-		if (node == null) {
-			return null;
-		}
-		if (factory instanceof JenaRDF) {
-			// No need to convert, just wrap
-			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 #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 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 #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 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 #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> 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 #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 asTriple(RDF factory, org.apache.jena.graph.Triple triple) 
-			throws ConversionException{
-		if (factory instanceof JenaRDF) {
-			// No need to convert, just wrap
-			return ((JenaRDF) factory).asTriple(triple);
-		}
-		final BlankNodeOrIRI subject;
-		final IRI predicate;
-		try {
-			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 = 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 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 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 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 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 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 #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 asQuad(RDF factory, org.apache.jena.sparql.core.Quad quad) {
-		if (factory instanceof JenaRDF) {
-			// No need to convert, just wrap
-			return ((JenaRDF) factory).asQuad(quad);
-		}
-		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> 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> 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 streamJenaToQuad(RDF factory, Consumer<Quad> consumer) {
-		return new StreamRDFBase() {
-			@Override
-			public void quad(org.apache.jena.sparql.core.Quad 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(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(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 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(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 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 asJenaTriple(Triple triple) {
-		if (triple instanceof JenaTriple)
-			return ((JenaTriple) triple).asJenaTriple();
-		return org.apache.jena.graph.Triple.create(
-				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 asJenaQuad(Quad quad) {
-		if (quad instanceof JenaQuad) {
-			return ((JenaQuad) quad).asJenaQuad();
-		}
-		return org.apache.jena.sparql.core.Quad.create(
-				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 salt() {
-		return salt;
-	}
+    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 #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(salt());
+    }
+
+    @Override
+    public JenaBlankNode createBlankNode(String name) {
+        return internalJenaFactory.createBlankNode(name, salt());
+    }
+
+    @Override
+    public JenaDataset createDataset() {
+        return internalJenaFactory.createDataset(salt());
+    }
+
+    @Override
+    public JenaGraph createGraph() {
+        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 #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 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 #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 asRDFTerm(RDF factory, Node node) {
+        if (node == null) {
+            return null;
+        }
+        if (factory instanceof JenaRDF) {
+            // No need to convert, just wrap
+            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 #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 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 #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 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 #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> 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 #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 asTriple(RDF factory, org.apache.jena.graph.Triple triple) throws ConversionException {
+        if (factory instanceof JenaRDF) {
+            // No need to convert, just wrap
+            return ((JenaRDF) factory).asTriple(triple);
+        }
+        final BlankNodeOrIRI subject;
+        final IRI predicate;
+        try {
+            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 = 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 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 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 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 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 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 #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 asQuad(RDF factory, org.apache.jena.sparql.core.Quad quad) {
+        if (factory instanceof JenaRDF) {
+            // No need to convert, just wrap
+            return ((JenaRDF) factory).asQuad(quad);
+        }
+        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> 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> 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 streamJenaToQuad(RDF factory, Consumer<Quad> consumer) {
+        return new StreamRDFBase() {
+            @Override
+            public void quad(org.apache.jena.sparql.core.Quad 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(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(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 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(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 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 asJenaTriple(Triple triple) {
+        if (triple instanceof JenaTriple)
+            return ((JenaTriple) triple).asJenaTriple();
+        return org.apache.jena.graph.Triple.create(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 asJenaQuad(Quad quad) {
+        if (quad instanceof JenaQuad) {
+            return ((JenaQuad) quad).asJenaQuad();
+        }
+        return org.apache.jena.sparql.core.Quad.create(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 salt() {
+        return salt;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTerm.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTerm.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTerm.java
index 0bbe26b..bd854d1 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTerm.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTerm.java
@@ -31,5 +31,5 @@ import org.apache.jena.graph.Node;
  * @see JenaBlankNode
  */
 public interface JenaRDFTerm extends RDFTerm {
-	public Node asJenaNode();
+    public Node asJenaNode();
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/JenaTriple.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaTriple.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaTriple.java
index 09fe76d..c73e018 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaTriple.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/JenaTriple.java
@@ -17,11 +17,11 @@
  */
 package org.apache.commons.rdf.jena;
 
-/** 
+/**
  * A Jena-backed {@link org.apache.commons.rdf.api.Triple}.
  * <p>
- * The underlying Jena {@link org.apache.jena.graph.Triple}
- * can be accessed with {@link #asJenaTriple()}.
+ * The underlying Jena {@link org.apache.jena.graph.Triple} can be accessed with
+ * {@link #asJenaTriple()}.
  */
 public interface JenaTriple extends org.apache.commons.rdf.api.Triple, JenaTripleLike {
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/JenaTripleLike.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaTripleLike.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaTripleLike.java
index 96daa02..49a8eb5 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaTripleLike.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/JenaTripleLike.java
@@ -34,13 +34,12 @@ import org.apache.jena.graph.Triple;
  * @see JenaGeneralizedQuadLike
  * 
  */
-public interface JenaTripleLike 
-	extends org.apache.commons.rdf.api.TripleLike {
+public interface JenaTripleLike extends org.apache.commons.rdf.api.TripleLike {
 
-	/**
-	 * Return the adapted Jena triple
-	 * 
-	 * @return Adapted Jena {@link Triple}.
-	 */
-	Triple asJenaTriple();
+    /**
+     * Return the adapted Jena triple
+     * 
+     * @return Adapted Jena {@link Triple}.
+     */
+    Triple asJenaTriple();
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/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 81069f0..bf2b4bf 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
@@ -40,69 +40,67 @@ import org.apache.jena.riot.system.StreamRDFLib;
 
 public class JenaRDFParser extends AbstractRDFParser<JenaRDFParser> implements RDFParser {
 
-	private Consumer<TripleLike> generalizedConsumerTriple;
-	private Consumer<QuadLike<RDFTerm>> generalizedConsumerQuad;
+    private Consumer<TripleLike> generalizedConsumerTriple;
+    private Consumer<QuadLike<RDFTerm>> generalizedConsumerQuad;
 
-	protected RDF createRDFTermFactory() {
-		return new JenaRDF();
-	}
+    protected RDF createRDFTermFactory() {
+        return new JenaRDF();
+    }
 
-	public JenaRDFParser targetGeneralizedTriple(Consumer<TripleLike> consumer) {
-		JenaRDFParser c = this.clone();
-		c.resetTarget();		
-		c.generalizedConsumerTriple = consumer;
-		return c;
-	}
+    public JenaRDFParser targetGeneralizedTriple(Consumer<TripleLike> consumer) {
+        JenaRDFParser c = this.clone();
+        c.resetTarget();
+        c.generalizedConsumerTriple = consumer;
+        return c;
+    }
 
-	public JenaRDFParser targetGeneralizedQuad(Consumer<QuadLike<RDFTerm>> consumer) {
-		JenaRDFParser c = this.clone();
-		c.resetTarget();		
-		c.generalizedConsumerQuad = consumer;
-		return c;
-	}
-	
-	@Override
-	protected void resetTarget() {		
-		super.resetTarget();
-		this.generalizedConsumerTriple = null;
-		this.generalizedConsumerQuad = null;
-	}
-	
-	@Override
-	protected void parseSynchronusly() throws IOException {
-		StreamRDF dest;
-		JenaRDF jenaRDF = getJenaFactory();
-		if (getTargetGraph().isPresent() && getTargetGraph().get() instanceof JenaGraph) {
-			Graph jenaGraph = ((JenaGraph) getTargetGraph().get()).asJenaGraph();
-			dest = StreamRDFLib.graph(jenaGraph);
-		} else {
-			if (generalizedConsumerQuad != null) {				
-				dest = jenaRDF.streamJenaToGeneralizedQuad(generalizedConsumerQuad);			
-			} else if (generalizedConsumerTriple != null) {				
-				dest = jenaRDF.streamJenaToGeneralizedTriple(generalizedConsumerTriple);			
-			} else {
-				dest = JenaRDF.streamJenaToQuad(getRdfTermFactory().get(), getTarget());
-			}
-		}
+    public JenaRDFParser targetGeneralizedQuad(Consumer<QuadLike<RDFTerm>> consumer) {
+        JenaRDFParser c = this.clone();
+        c.resetTarget();
+        c.generalizedConsumerQuad = consumer;
+        return c;
+    }
 
-		Lang lang = getContentTypeSyntax().flatMap(jenaRDF::asJenaLang).orElse(null);
-		String baseStr = getBase().map(IRI::getIRIString).orElse(null);
+    @Override
+    protected void resetTarget() {
+        super.resetTarget();
+        this.generalizedConsumerTriple = null;
+        this.generalizedConsumerQuad = null;
+    }
 
-		if (getSourceIri().isPresent()) {
-			RDFDataMgr.parse(dest, getSourceIri().get().toString(), baseStr, lang, null);
-		} else if (getSourceFile().isPresent()) {
-			try (InputStream s = Files.newInputStream(getSourceFile().get())) {
-				RDFDataMgr.parse(dest, s, baseStr, lang, null);
-			}
-		} else {
-			RDFDataMgr.parse(dest, getSourceInputStream().get(), baseStr, lang, null);
-		}
-	}
+    @Override
+    protected void parseSynchronusly() throws IOException {
+        StreamRDF dest;
+        JenaRDF jenaRDF = getJenaFactory();
+        if (getTargetGraph().isPresent() && getTargetGraph().get() instanceof JenaGraph) {
+            Graph jenaGraph = ((JenaGraph) getTargetGraph().get()).asJenaGraph();
+            dest = StreamRDFLib.graph(jenaGraph);
+        } else {
+            if (generalizedConsumerQuad != null) {
+                dest = jenaRDF.streamJenaToGeneralizedQuad(generalizedConsumerQuad);
+            } else if (generalizedConsumerTriple != null) {
+                dest = jenaRDF.streamJenaToGeneralizedTriple(generalizedConsumerTriple);
+            } else {
+                dest = JenaRDF.streamJenaToQuad(getRdfTermFactory().get(), getTarget());
+            }
+        }
 
-	private JenaRDF getJenaFactory() {
-		return (JenaRDF) getRdfTermFactory()
-				.filter(JenaRDF.class::isInstance)
-				.orElseGet(this::createRDFTermFactory);		
-	}
+        Lang lang = getContentTypeSyntax().flatMap(jenaRDF::asJenaLang).orElse(null);
+        String baseStr = getBase().map(IRI::getIRIString).orElse(null);
+
+        if (getSourceIri().isPresent()) {
+            RDFDataMgr.parse(dest, getSourceIri().get().toString(), baseStr, lang, null);
+        } else if (getSourceFile().isPresent()) {
+            try (InputStream s = Files.newInputStream(getSourceFile().get())) {
+                RDFDataMgr.parse(dest, s, baseStr, lang, null);
+            }
+        } else {
+            RDFDataMgr.parse(dest, getSourceInputStream().get(), baseStr, lang, null);
+        }
+    }
+
+    private JenaRDF getJenaFactory() {
+        return (JenaRDF) getRdfTermFactory().filter(JenaRDF.class::isInstance).orElseGet(this::createRDFTermFactory);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java b/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java
index aa2201d..10a1f11 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/experimental/package-info.java
@@ -18,15 +18,13 @@
 /**
  * Experimental Commons RDF Jena implementations.
  * <p>
- * Classes in this package should be considered <strong>at
- * risk</strong>; they might change or be removed in the next minor update of
- * Commons RDF.
+ * Classes in this package should be considered <strong>at risk</strong>; they
+ * might change or be removed in the next minor update of Commons RDF.
  * <p>
  * When a class has stabilized, it will move to the
  * {@link org.apache.commons.rdf.jena} package.
  * <ul>
- * <li>{@link JenaRDFParser} - a Jena-backed
- * implementations of 
+ * <li>{@link JenaRDFParser} - a Jena-backed implementations of
  * {@link org.apache.commons.rdf.experimental.RDFParser}.</li>
  * </ul>
  */

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractJenaRDFTerm.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractJenaRDFTerm.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractJenaRDFTerm.java
index fd117a2..a4e3f1e 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractJenaRDFTerm.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/AbstractJenaRDFTerm.java
@@ -24,24 +24,24 @@ import org.apache.jena.graph.Node;
 import org.apache.jena.riot.out.NodeFmtLib;
 
 class AbstractJenaRDFTerm implements JenaRDFTerm, RDFTerm {
-	private Node node;
-	// static private PrefixMapping empty = new PrefixMappingImpl();
+    private Node node;
+    // static private PrefixMapping empty = new PrefixMappingImpl();
 
-	protected AbstractJenaRDFTerm(Node node) {
-		this.node = node;
-	}
+    protected AbstractJenaRDFTerm(Node node) {
+        this.node = node;
+    }
 
-	@Override
-	public Node asJenaNode() {
-		return node;
-	}
+    @Override
+    public Node asJenaNode() {
+        return node;
+    }
 
-	public String ntriplesString() {
-		return NodeFmtLib.str(node);
-	}
+    public String ntriplesString() {
+        return NodeFmtLib.str(node);
+    }
 
-	@Override
-	public String toString() {
-		return ntriplesString();
-	}
+    @Override
+    public String toString() {
+        return ntriplesString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/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 10dc069..691eeee 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
@@ -32,110 +32,107 @@ import org.apache.jena.graph.Triple;
 import org.apache.jena.sparql.core.Quad;
 
 /**
- * A generalized {@link QuadLike}, backed by a Jena {@link Quad} or {@link Triple}.
+ * A generalized {@link QuadLike}, backed by a Jena {@link Quad} or
+ * {@link Triple}.
  * <p>
  * This class does not implement any particular {@link #equals(Object)} or
- * {@link #hashCode()} but can otherwise be used as a base class for both
- * a {@link JenaTriple} and a {@link JenaQuad}.
+ * {@link #hashCode()} but can otherwise be used as a base class for both a
+ * {@link JenaTriple} and a {@link JenaQuad}.
  * 
  * @see JenaTripleImpl
  * @see JenaQuadImpl
  * @see internalJenaFactory#createGeneralizedTriple(RDFTerm, RDFTerm, RDFTerm)
- * @see internalJenaFactory#createGeneralizedQuad(RDFTerm, RDFTerm, RDFTerm, RDFTerm)
+ * @see internalJenaFactory#createGeneralizedQuad(RDFTerm, RDFTerm, RDFTerm,
+ *      RDFTerm)
  *
  */
-abstract class AbstractQuadLike<S extends RDFTerm, P extends RDFTerm, O extends RDFTerm, G extends RDFTerm> implements JenaQuadLike<G> {
-
-	private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory(){};
-	
-	final Optional<G> graphName;
-	final S subject;
-	final P predicate;
-	final O object;
-	org.apache.jena.sparql.core.Quad quad = null;
-	org.apache.jena.graph.Triple triple = null;
-	
-	AbstractQuadLike(S subject, P predicate, O object, Optional<G> graphName) {
-		this.subject = Objects.requireNonNull(subject);
-		this.predicate = Objects.requireNonNull(predicate);
-		this.object = Objects.requireNonNull(object);
-		this.graphName = Objects.requireNonNull(graphName);
-	}
-
-	AbstractQuadLike(S subject, P predicate, O object) {
-		this(subject, predicate, object, Optional.empty());
-	}
-	 
-	@SuppressWarnings("unchecked")
-	AbstractQuadLike(org.apache.jena.sparql.core.Quad quad, UUID salt) {
-		this.quad = Objects.requireNonNull(quad);
-		this.subject = (S) internalJenaFactory.createRDFTerm(quad.getSubject(), salt);
-		this.predicate = (P) internalJenaFactory.createRDFTerm(quad.getPredicate(), salt);
-		this.object = (O)internalJenaFactory.createRDFTerm(quad.getObject(), salt);
-		this.graphName = Optional.of((G) internalJenaFactory.createRDFTerm(quad.getGraph(), salt));		
-	}
-
-	@SuppressWarnings("unchecked")
-	AbstractQuadLike(org.apache.jena.graph.Triple triple, UUID salt) {
-		this.triple = Objects.requireNonNull(triple);		
-		this.subject = (S) internalJenaFactory.createRDFTerm(triple.getSubject(), salt);
-		this.predicate = (P) internalJenaFactory.createRDFTerm(triple.getPredicate(), salt);
-		this.object = (O)internalJenaFactory.createRDFTerm(triple.getObject(), salt);
-		this.graphName = Optional.empty();
-	}
-
-	@Override
-	public org.apache.jena.sparql.core.Quad asJenaQuad() {
-		JenaRDF factory = new JenaRDF();
-		if (quad == null) {
-			quad = org.apache.jena.sparql.core.Quad.create(
-					factory.asJenaNode(graphName.orElse(null)),
-					factory.asJenaNode(subject), 
-					factory.asJenaNode(predicate),
-					factory.asJenaNode(object));
-		}
-		return quad;
-	}
-
-	@Override
-	public org.apache.jena.graph.Triple asJenaTriple() {
-		JenaRDF factory = new JenaRDF();
-		if (triple == null) {
-			triple = org.apache.jena.graph.Triple.create(
-				factory.asJenaNode(subject), 
-				factory.asJenaNode(predicate),
-				factory.asJenaNode(object));
-		}
-		return triple;
-	}	
-	
-	@Override
-	public S getSubject() {
-		return subject;
-	}
-
-	@Override
-	public P getPredicate() {
-		return predicate;
-	}
-	
-	@Override
-	public O getObject() {
-		return object;
-	}
-
-	@Override
-	public Optional<G> getGraphName() {
-		return graphName;
-	}
-
-	@Override
-	public String toString() {
-		// kind of nquad syntax
-		return getSubject().ntriplesString() + " " + 
-				getPredicate().ntriplesString() + " "
-				+ getObject().ntriplesString() + " " + 
-				getGraphName().map(RDFTerm::ntriplesString).orElse("") + ".";
-	}
+abstract class AbstractQuadLike<S extends RDFTerm, P extends RDFTerm, O extends RDFTerm, G extends RDFTerm>
+        implements JenaQuadLike<G> {
+
+    private static InternalJenaFactory internalJenaFactory = new InternalJenaFactory() {
+    };
+
+    final Optional<G> graphName;
+    final S subject;
+    final P predicate;
+    final O object;
+    org.apache.jena.sparql.core.Quad quad = null;
+    org.apache.jena.graph.Triple triple = null;
+
+    AbstractQuadLike(S subject, P predicate, O object, Optional<G> graphName) {
+        this.subject = Objects.requireNonNull(subject);
+        this.predicate = Objects.requireNonNull(predicate);
+        this.object = Objects.requireNonNull(object);
+        this.graphName = Objects.requireNonNull(graphName);
+    }
+
+    AbstractQuadLike(S subject, P predicate, O object) {
+        this(subject, predicate, object, Optional.empty());
+    }
+
+    @SuppressWarnings("unchecked")
+    AbstractQuadLike(org.apache.jena.sparql.core.Quad quad, UUID salt) {
+        this.quad = Objects.requireNonNull(quad);
+        this.subject = (S) internalJenaFactory.createRDFTerm(quad.getSubject(), salt);
+        this.predicate = (P) internalJenaFactory.createRDFTerm(quad.getPredicate(), salt);
+        this.object = (O) internalJenaFactory.createRDFTerm(quad.getObject(), salt);
+        this.graphName = Optional.of((G) internalJenaFactory.createRDFTerm(quad.getGraph(), salt));
+    }
+
+    @SuppressWarnings("unchecked")
+    AbstractQuadLike(org.apache.jena.graph.Triple triple, UUID salt) {
+        this.triple = Objects.requireNonNull(triple);
+        this.subject = (S) internalJenaFactory.createRDFTerm(triple.getSubject(), salt);
+        this.predicate = (P) internalJenaFactory.createRDFTerm(triple.getPredicate(), salt);
+        this.object = (O) internalJenaFactory.createRDFTerm(triple.getObject(), salt);
+        this.graphName = Optional.empty();
+    }
+
+    @Override
+    public org.apache.jena.sparql.core.Quad asJenaQuad() {
+        JenaRDF factory = new JenaRDF();
+        if (quad == null) {
+            quad = org.apache.jena.sparql.core.Quad.create(factory.asJenaNode(graphName.orElse(null)),
+                    factory.asJenaNode(subject), factory.asJenaNode(predicate), factory.asJenaNode(object));
+        }
+        return quad;
+    }
+
+    @Override
+    public org.apache.jena.graph.Triple asJenaTriple() {
+        JenaRDF factory = new JenaRDF();
+        if (triple == null) {
+            triple = org.apache.jena.graph.Triple.create(factory.asJenaNode(subject), factory.asJenaNode(predicate),
+                    factory.asJenaNode(object));
+        }
+        return triple;
+    }
+
+    @Override
+    public S getSubject() {
+        return subject;
+    }
+
+    @Override
+    public P getPredicate() {
+        return predicate;
+    }
+
+    @Override
+    public O getObject() {
+        return object;
+    }
+
+    @Override
+    public Optional<G> getGraphName() {
+        return graphName;
+    }
+
+    @Override
+    public String toString() {
+        // kind of nquad syntax
+        return getSubject().ntriplesString() + " " + getPredicate().ntriplesString() + " "
+                + getObject().ntriplesString() + " " + getGraphName().map(RDFTerm::ntriplesString).orElse("") + ".";
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/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 7da2d1e..aa11572 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
@@ -58,105 +58,107 @@ import org.apache.jena.sparql.graph.GraphFactory;
  */
 public abstract class InternalJenaFactory {
 
-	public JenaBlankNode createBlankNode(String id, UUID salt) {
-		return new JenaBlankNodeImpl(NodeFactory.createBlankNode(id), salt);
-	}
-
-	public JenaBlankNode createBlankNode(UUID salt) {
-		return new JenaBlankNodeImpl(NodeFactory.createBlankNode(), salt);
-	}
-	public JenaDataset createDataset(DatasetGraph datasetGraph, UUID salt) {
-		return new JenaDatasetImpl(datasetGraph, salt);
-	}
-
-	public JenaDataset createDataset(UUID salt) {
-		DatasetGraph dg = DatasetGraphFactory.createGeneral();
-		// Or which createMethod() -- a bit confusing with lots of choice..
-		return new JenaDatasetImpl(dg, salt);
-	}
-
-	public JenaGeneralizedQuadLike createGeneralizedQuad(org.apache.jena.sparql.core.Quad quad, UUID salt) {
-		return new JenaGeneralizedQuadLikeImpl(quad, salt);
-	}
-
-	public JenaGeneralizedQuadLike createGeneralizedQuad(RDFTerm subject, RDFTerm predicate, RDFTerm object, RDFTerm graphName) {
-		return new JenaGeneralizedQuadLikeImpl(subject, predicate, object, Optional.ofNullable(graphName));
-	}
-
-	public JenaGeneralizedTripleLike createGeneralizedTriple(org.apache.jena.graph.Triple triple, UUID salt) {
-		return new JenaGeneralizedTripleLikeImpl(triple, salt);
-	}
-
-	public JenaGeneralizedTripleLike createGeneralizedTriple(RDFTerm subject, RDFTerm predicate, RDFTerm object) {
-		return new JenaGeneralizedTripleLikeImpl(subject, predicate, object);
-	}
-
-	public JenaGraph createGraph(Model model, UUID salt) {
-		return new JenaGraphImpl(model, salt);
-	}
-
-	public JenaGraph createGraph(org.apache.jena.graph.Graph graph, UUID salt) {
-		return new JenaGraphImpl(graph, salt);
-	}
-
-	public JenaGraph createGraph(UUID salt) {
-		return new JenaGraphImpl(GraphFactory.createDefaultGraph(), salt);
-	}
-
-	public JenaIRI createIRI(String iriStr) {
-		return new JenaIRIImpl(iriStr);
-	}
-	
-	public JenaLiteral createLiteral(String lexStr) {
-		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr));
-	}
-
-	public JenaLiteral createLiteralDT(String lexStr, String datatypeIRI) {
-		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, NodeFactory.getType(datatypeIRI)));
-	}
-
-	public JenaLiteral createLiteralLang(String lexStr, String langTag) {
-		return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, langTag));
-	}
-
-	public JenaQuad createQuad(BlankNodeOrIRI subject, IRI predicate, RDFTerm object, BlankNodeOrIRI graphName) {
-		return new JenaQuadImpl(subject, predicate, object, Optional.ofNullable(graphName));
-	}
-	
-	public JenaQuad createQuad(org.apache.jena.sparql.core.Quad quad, UUID salt) {
-		return new JenaQuadImpl(quad, salt);
-	}
-
-	public JenaRDFTerm createRDFTerm(Node node, UUID salt) throws ConversionException {
-		if (! node.isConcrete()) {
-			throw new ConversionException("Node is not a concrete RDF Term: " + node); 
-		}
-		if (node.isURI()) {
-			return new JenaIRIImpl(node);
-		}
-		if (node.isLiteral()) {
-			return new JenaLiteralImpl(node);
-		}
-		if (node.isBlank()) {
-			return new JenaBlankNodeImpl(node, salt);
-		}
-		if (node.equals(Node.ANY)) {
-			// NOTE: JenaAny no longer supported by Commons RDF
-			//return JenaAnyImpl.Singleton.instance;
-		}
-		if (node.isVariable()) {
-			// NOTE: JenaVariable no longer supported by Commons RDF
-			//return new JenaVariableImpl(node);
-		}
-		throw new ConversionException("Unrecognized node type: " + node);
-	}
-
-	public JenaTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return new JenaTripleImpl(subject, predicate, object);
-	}
-	
-	public JenaTriple createTriple(org.apache.jena.graph.Triple triple, UUID salt) {
-		return new JenaTripleImpl(triple, salt);
-	}
+    public JenaBlankNode createBlankNode(String id, UUID salt) {
+        return new JenaBlankNodeImpl(NodeFactory.createBlankNode(id), salt);
+    }
+
+    public JenaBlankNode createBlankNode(UUID salt) {
+        return new JenaBlankNodeImpl(NodeFactory.createBlankNode(), salt);
+    }
+
+    public JenaDataset createDataset(DatasetGraph datasetGraph, UUID salt) {
+        return new JenaDatasetImpl(datasetGraph, salt);
+    }
+
+    public JenaDataset createDataset(UUID salt) {
+        DatasetGraph dg = DatasetGraphFactory.createGeneral();
+        // Or which createMethod() -- a bit confusing with lots of choice..
+        return new JenaDatasetImpl(dg, salt);
+    }
+
+    public JenaGeneralizedQuadLike createGeneralizedQuad(org.apache.jena.sparql.core.Quad quad, UUID salt) {
+        return new JenaGeneralizedQuadLikeImpl(quad, salt);
+    }
+
+    public JenaGeneralizedQuadLike createGeneralizedQuad(RDFTerm subject, RDFTerm predicate, RDFTerm object,
+            RDFTerm graphName) {
+        return new JenaGeneralizedQuadLikeImpl(subject, predicate, object, Optional.ofNullable(graphName));
+    }
+
+    public JenaGeneralizedTripleLike createGeneralizedTriple(org.apache.jena.graph.Triple triple, UUID salt) {
+        return new JenaGeneralizedTripleLikeImpl(triple, salt);
+    }
+
+    public JenaGeneralizedTripleLike createGeneralizedTriple(RDFTerm subject, RDFTerm predicate, RDFTerm object) {
+        return new JenaGeneralizedTripleLikeImpl(subject, predicate, object);
+    }
+
+    public JenaGraph createGraph(Model model, UUID salt) {
+        return new JenaGraphImpl(model, salt);
+    }
+
+    public JenaGraph createGraph(org.apache.jena.graph.Graph graph, UUID salt) {
+        return new JenaGraphImpl(graph, salt);
+    }
+
+    public JenaGraph createGraph(UUID salt) {
+        return new JenaGraphImpl(GraphFactory.createDefaultGraph(), salt);
+    }
+
+    public JenaIRI createIRI(String iriStr) {
+        return new JenaIRIImpl(iriStr);
+    }
+
+    public JenaLiteral createLiteral(String lexStr) {
+        return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr));
+    }
+
+    public JenaLiteral createLiteralDT(String lexStr, String datatypeIRI) {
+        return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, NodeFactory.getType(datatypeIRI)));
+    }
+
+    public JenaLiteral createLiteralLang(String lexStr, String langTag) {
+        return new JenaLiteralImpl(NodeFactory.createLiteral(lexStr, langTag));
+    }
+
+    public JenaQuad createQuad(BlankNodeOrIRI subject, IRI predicate, RDFTerm object, BlankNodeOrIRI graphName) {
+        return new JenaQuadImpl(subject, predicate, object, Optional.ofNullable(graphName));
+    }
+
+    public JenaQuad createQuad(org.apache.jena.sparql.core.Quad quad, UUID salt) {
+        return new JenaQuadImpl(quad, salt);
+    }
+
+    public JenaRDFTerm createRDFTerm(Node node, UUID salt) throws ConversionException {
+        if (!node.isConcrete()) {
+            throw new ConversionException("Node is not a concrete RDF Term: " + node);
+        }
+        if (node.isURI()) {
+            return new JenaIRIImpl(node);
+        }
+        if (node.isLiteral()) {
+            return new JenaLiteralImpl(node);
+        }
+        if (node.isBlank()) {
+            return new JenaBlankNodeImpl(node, salt);
+        }
+        if (node.equals(Node.ANY)) {
+            // NOTE: JenaAny no longer supported by Commons RDF
+            // return JenaAnyImpl.Singleton.instance;
+        }
+        if (node.isVariable()) {
+            // NOTE: JenaVariable no longer supported by Commons RDF
+            // return new JenaVariableImpl(node);
+        }
+        throw new ConversionException("Unrecognized node type: " + node);
+    }
+
+    public JenaTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        return new JenaTripleImpl(subject, predicate, object);
+    }
+
+    public JenaTriple createTriple(org.apache.jena.graph.Triple triple, UUID salt) {
+        return new JenaTripleImpl(triple, salt);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaBlankNodeImpl.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaBlankNodeImpl.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaBlankNodeImpl.java
index a4cc3af..6e4d966 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaBlankNodeImpl.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaBlankNodeImpl.java
@@ -26,36 +26,36 @@ import org.apache.jena.graph.Node;
 
 class JenaBlankNodeImpl extends AbstractJenaRDFTerm implements JenaBlankNode {
 
-	private UUID salt;
-
-	JenaBlankNodeImpl(Node node, UUID salt) {
-		super(node);
-		if (! node.isBlank()) {
-			throw new IllegalArgumentException("Node is not a blank node: " + node);
-		}				
-		this.salt = salt;
-	}
-
-	@Override
-	public boolean equals(Object other) {
-		if (other == this)
-			return true;
-		if (other == null)
-			return false;
-		if (!(other instanceof BlankNode))
-			return false;
-		BlankNode bNode = (BlankNode) other;
-		return uniqueReference().equals(bNode.uniqueReference());
-	}
-
-	@Override
-	public int hashCode() {
-		return uniqueReference().hashCode();
-	}
-
-	@Override
-	public String uniqueReference() {
-		return salt + asJenaNode().getBlankNodeLabel();
-	}
+    private UUID salt;
+
+    JenaBlankNodeImpl(Node node, UUID salt) {
+        super(node);
+        if (!node.isBlank()) {
+            throw new IllegalArgumentException("Node is not a blank node: " + node);
+        }
+        this.salt = salt;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other == this)
+            return true;
+        if (other == null)
+            return false;
+        if (!(other instanceof BlankNode))
+            return false;
+        BlankNode bNode = (BlankNode) other;
+        return uniqueReference().equals(bNode.uniqueReference());
+    }
+
+    @Override
+    public int hashCode() {
+        return uniqueReference().hashCode();
+    }
+
+    @Override
+    public String uniqueReference() {
+        return salt + asJenaNode().getBlankNodeLabel();
+    }
 
 }


Mime
View raw message