commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [42/49] incubator-commonsrdf git commit: Reformat tab -> spaces
Date Fri, 28 Oct 2016 13:15:04 GMT
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
index 37487b4..2398194 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
@@ -28,49 +28,48 @@ import org.eclipse.rdf4j.model.Statement;
 import org.eclipse.rdf4j.repository.Repository;
 import org.eclipse.rdf4j.repository.RepositoryConnection;
 
-abstract class AbstractRepositoryGraphLike<T extends TripleLike>
-		implements RDF4JGraphLike<T> {
+abstract class AbstractRepositoryGraphLike<T extends TripleLike> implements RDF4JGraphLike<T> {
 
-	protected final Repository repository;
-	protected final boolean includeInferred;
-	protected final boolean handleInitAndShutdown;
-	protected final RDF4J rdf4jTermFactory;
-	protected final UUID salt;
+    protected final Repository repository;
+    protected final boolean includeInferred;
+    protected final boolean handleInitAndShutdown;
+    protected final RDF4J rdf4jTermFactory;
+    protected final UUID salt;
 
-	AbstractRepositoryGraphLike(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred) {
-		this.repository = repository;
-		this.salt = salt;
-		this.includeInferred = includeInferred;
-		this.handleInitAndShutdown = handleInitAndShutdown;
-		if (handleInitAndShutdown && !repository.isInitialized()) {
-			repository.initialize();
-		}
-		rdf4jTermFactory = new RDF4J(repository.getValueFactory(), salt);
-	}	
-	
-	@Override
-	public void close() throws Exception {
-		if (handleInitAndShutdown) {
-			repository.shutDown();
-		}
-		// else: repository was initialized outside, so we should not shut it
-		// down
-	}
+    AbstractRepositoryGraphLike(Repository repository, UUID salt, boolean handleInitAndShutdown,
+            boolean includeInferred) {
+        this.repository = repository;
+        this.salt = salt;
+        this.includeInferred = includeInferred;
+        this.handleInitAndShutdown = handleInitAndShutdown;
+        if (handleInitAndShutdown && !repository.isInitialized()) {
+            repository.initialize();
+        }
+        rdf4jTermFactory = new RDF4J(repository.getValueFactory(), salt);
+    }
 
-	
-	protected abstract T asTripleLike(Statement s);
+    @Override
+    public void close() throws Exception {
+        if (handleInitAndShutdown) {
+            repository.shutDown();
+        }
+        // else: repository was initialized outside, so we should not shut it
+        // down
+    }
 
-	protected RepositoryConnection getRepositoryConnection() {
-		return repository.getConnection();
-	}
+    protected abstract T asTripleLike(Statement s);
 
-	public Optional<Repository> asRepository() {
-		return Optional.of(repository);
-	}
+    protected RepositoryConnection getRepositoryConnection() {
+        return repository.getConnection();
+    }
 
-	@Override
-	public Optional<Model> asModel() {
-		return Optional.empty();
-	}
+    public Optional<Repository> asRepository() {
+        return Optional.of(repository);
+    }
+
+    @Override
+    public Optional<Model> asModel() {
+        return Optional.empty();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
index bdb82d1..8c5fc30 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
@@ -25,69 +25,68 @@ import org.apache.commons.rdf.rdf4j.RDF4JBlankNode;
 import org.eclipse.rdf4j.model.BNode;
 import org.eclipse.rdf4j.rio.turtle.TurtleUtil;
 
-final class BlankNodeImpl extends AbstractRDFTerm<BNode>
-	implements RDF4JBlankNode {
-	
-	private transient int hashCode = 0;
-	private long saltUUIDleast;
-	private long saltUUIDmost;
-	
-	BlankNodeImpl(BNode bNode, UUID salt) {
-		super(bNode);			
-		// Space-efficient storage of salt UUID
-		saltUUIDmost = salt.getMostSignificantBits();
-		saltUUIDleast = salt.getLeastSignificantBits();
-	}
-	
-	public boolean equals(Object obj) { 
-		if (obj == this) { 
-			return true;
-		}
-		// NOTE: Do NOT use Bnode.equals() as it has a more generous
-		// equality based only on the value.getID();			
-		if (obj instanceof BlankNode) {
-			BlankNode blankNode = (BlankNode) obj;
-			return uniqueReference().equals(blankNode.uniqueReference());								
-		}
-		return false;
-	}
+final class BlankNodeImpl extends AbstractRDFTerm<BNode> implements RDF4JBlankNode {
 
-	@Override
-	public int hashCode() {
-		if (hashCode != 0) {
-			return hashCode;
-		}
-		return hashCode = uniqueReference().hashCode();
-	}
+    private transient int hashCode = 0;
+    private long saltUUIDleast;
+    private long saltUUIDmost;
 
-	private boolean isValidBlankNodeLabel(String id) {
-		// FIXME: Replace with a regular expression?			
-		if (id.isEmpty()) { 
-			return false;
-		}
-		if (! TurtleUtil.isBLANK_NODE_LABEL_StartChar(id.codePointAt(0)))  {
-			return false;
-		}
-		for (int i=1; i<id.length(); i++) { 
-			if (! TurtleUtil.isBLANK_NODE_LABEL_Char(id.codePointAt(i))) { 
-				return false;
-			}
-		}
-		return true;
-	}
+    BlankNodeImpl(BNode bNode, UUID salt) {
+        super(bNode);
+        // Space-efficient storage of salt UUID
+        saltUUIDmost = salt.getMostSignificantBits();
+        saltUUIDleast = salt.getLeastSignificantBits();
+    }
 
-	@Override
-	public String ntriplesString() {
-		if (isValidBlankNodeLabel(value.getID())) { 
-			return "_:" + value.getID();
-		} else {
-			return "_:" + UUID.nameUUIDFromBytes(value.getID().getBytes(StandardCharsets.UTF_8));
-		}
-	}
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        // NOTE: Do NOT use Bnode.equals() as it has a more generous
+        // equality based only on the value.getID();
+        if (obj instanceof BlankNode) {
+            BlankNode blankNode = (BlankNode) obj;
+            return uniqueReference().equals(blankNode.uniqueReference());
+        }
+        return false;
+    }
 
-	@Override
-	public String uniqueReference() {
-		UUID uuid = new UUID(saltUUIDmost, saltUUIDleast);
-		return "urn:uuid:" + uuid + "#" + value.getID();
-	}
+    @Override
+    public int hashCode() {
+        if (hashCode != 0) {
+            return hashCode;
+        }
+        return hashCode = uniqueReference().hashCode();
+    }
+
+    private boolean isValidBlankNodeLabel(String id) {
+        // FIXME: Replace with a regular expression?
+        if (id.isEmpty()) {
+            return false;
+        }
+        if (!TurtleUtil.isBLANK_NODE_LABEL_StartChar(id.codePointAt(0))) {
+            return false;
+        }
+        for (int i = 1; i < id.length(); i++) {
+            if (!TurtleUtil.isBLANK_NODE_LABEL_Char(id.codePointAt(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public String ntriplesString() {
+        if (isValidBlankNodeLabel(value.getID())) {
+            return "_:" + value.getID();
+        } else {
+            return "_:" + UUID.nameUUIDFromBytes(value.getID().getBytes(StandardCharsets.UTF_8));
+        }
+    }
+
+    @Override
+    public String uniqueReference() {
+        UUID uuid = new UUID(saltUUIDmost, saltUUIDleast);
+        return "urn:uuid:" + uuid + "#" + value.getID();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ConvertedStatements.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ConvertedStatements.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ConvertedStatements.java
index 4c8478a..f199b8f 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ConvertedStatements.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ConvertedStatements.java
@@ -29,43 +29,43 @@ import org.eclipse.rdf4j.repository.RepositoryConnection;
 import org.eclipse.rdf4j.repository.RepositoryResult;
 
 final class ConvertedStatements<T> implements ClosableIterable<T> {
-	
-	private RepositoryConnection conn;
-	private RepositoryResult<Statement> results;
-	private Function<Statement, T> statementAdapter;
 
-	ConvertedStatements(Supplier<RepositoryConnection> repositoryConnector, Function<Statement, T> statementAdapter,
-			Resource subj, org.eclipse.rdf4j.model.IRI pred, Value obj, Resource... contexts) {
-		this.statementAdapter = statementAdapter;
-		this.conn = repositoryConnector.get();
-		this.results = conn.getStatements(subj, pred, obj, contexts);
-	}
+    private RepositoryConnection conn;
+    private RepositoryResult<Statement> results;
+    private Function<Statement, T> statementAdapter;
 
-	@Override
-	public Iterator<T> iterator() {
-		return new ConvertedIterator();
-	}
+    ConvertedStatements(Supplier<RepositoryConnection> repositoryConnector, Function<Statement, T> statementAdapter,
+            Resource subj, org.eclipse.rdf4j.model.IRI pred, Value obj, Resource... contexts) {
+        this.statementAdapter = statementAdapter;
+        this.conn = repositoryConnector.get();
+        this.results = conn.getStatements(subj, pred, obj, contexts);
+    }
 
-	@Override
-	public void close() {
-		results.close();
-		conn.close();
-	}
+    @Override
+    public Iterator<T> iterator() {
+        return new ConvertedIterator();
+    }
 
-	private final class ConvertedIterator implements Iterator<T> {
-		@Override
-		public boolean hasNext() {
-			boolean hasNext = results.hasNext();
-			if (!hasNext) {
-				close();
-			}
-			return hasNext;
-		}
+    @Override
+    public void close() {
+        results.close();
+        conn.close();
+    }
 
-		@Override
-		public T next() {
-			return statementAdapter.apply(results.next());
-		}
-	}
+    private final class ConvertedIterator implements Iterator<T> {
+        @Override
+        public boolean hasNext() {
+            boolean hasNext = results.hasNext();
+            if (!hasNext) {
+                close();
+            }
+            return hasNext;
+        }
+
+        @Override
+        public T next() {
+            return statementAdapter.apply(results.next());
+        }
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/IRIImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/IRIImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/IRIImpl.java
index e88ac27..f566c21 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/IRIImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/IRIImpl.java
@@ -19,43 +19,46 @@ package org.apache.commons.rdf.rdf4j.impl;
 
 import org.apache.commons.rdf.rdf4j.RDF4JIRI;
 
-final class IRIImpl extends AbstractRDFTerm<org.eclipse.rdf4j.model.IRI> 
-	implements RDF4JIRI {
-
-	IRIImpl(org.eclipse.rdf4j.model.IRI iri) {
-		super(iri);			
-	}
-	@Override
-	public boolean equals(Object obj) {
-		if (obj == this) { return true; }
-		if (obj instanceof IRIImpl) {
-			IRIImpl impl = (IRIImpl) obj; 
-			return asValue().equals(impl.asValue());
-		}
-		if (obj instanceof org.apache.commons.rdf.api.IRI) {
-			org.apache.commons.rdf.api.IRI iri = (org.apache.commons.rdf.api.IRI) obj;
-			return value.toString().equals(iri.getIRIString());
-		}
-		return false;
-	}
-
-	@Override
-	public String getIRIString() {
-		return value.toString();
-	}
-
-	public int hashCode() {
-		// Same definition
-		return value.hashCode();
-	}
-
-	@Override
-	public String ntriplesString() {
-		return "<" + value.toString() +  ">";
-	}
-	@Override
-	public String toString() {
-		return value.toString();
-	}
-	
+final class IRIImpl extends AbstractRDFTerm<org.eclipse.rdf4j.model.IRI> implements RDF4JIRI {
+
+    IRIImpl(org.eclipse.rdf4j.model.IRI iri) {
+        super(iri);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        if (obj instanceof IRIImpl) {
+            IRIImpl impl = (IRIImpl) obj;
+            return asValue().equals(impl.asValue());
+        }
+        if (obj instanceof org.apache.commons.rdf.api.IRI) {
+            org.apache.commons.rdf.api.IRI iri = (org.apache.commons.rdf.api.IRI) obj;
+            return value.toString().equals(iri.getIRIString());
+        }
+        return false;
+    }
+
+    @Override
+    public String getIRIString() {
+        return value.toString();
+    }
+
+    public int hashCode() {
+        // Same definition
+        return value.hashCode();
+    }
+
+    @Override
+    public String ntriplesString() {
+        return "<" + value.toString() + ">";
+    }
+
+    @Override
+    public String toString() {
+        return value.toString();
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
index b6d6b29..25a7620 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
@@ -43,8 +43,7 @@ import org.eclipse.rdf4j.repository.Repository;
  * <p>
  * <strong>Internal class:</strong> This "abstract" class is intended for
  * internal use by Commons RDF and may change in any minor update. Use instead
- * {@link RDF4J} methods like
- * {@link RDF4J#createBlankNode()},
+ * {@link RDF4J} methods like {@link RDF4J#createBlankNode()},
  * {@link RDF4J#asRDFTerm(org.eclipse.rdf4j.model.Value)} and
  * {@link RDF4J#asGraph(Repository, Option...)}
  * <p>
@@ -57,128 +56,129 @@ import org.eclipse.rdf4j.repository.Repository;
  */
 public abstract class InternalRDF4JFactory {
 
-	/**
-	 * Construct a {@link RDF4JBlankNode} from a RDF4J {@link BNode}.
-	 * 
-	 * @param bNode
-	 *            RDF4J {@link BNode} to adapt
-	 * @param salt
-	 *            {@link UUID} to use for {@link BlankNode#uniqueReference()} in
-	 *            combination with {@link BNode#getID()}
-	 * @return Adapted {@link RDF4JBlankNode}
-	 */
-	public RDF4JBlankNode createBlankNodeImpl(BNode bNode, UUID salt) {
-		return new BlankNodeImpl(bNode, salt);
-	}
+    /**
+     * Construct a {@link RDF4JBlankNode} from a RDF4J {@link BNode}.
+     * 
+     * @param bNode
+     *            RDF4J {@link BNode} to adapt
+     * @param salt
+     *            {@link UUID} to use for {@link BlankNode#uniqueReference()} in
+     *            combination with {@link BNode#getID()}
+     * @return Adapted {@link RDF4JBlankNode}
+     */
+    public RDF4JBlankNode createBlankNodeImpl(BNode bNode, UUID salt) {
+        return new BlankNodeImpl(bNode, salt);
+    }
 
-	/**
-	 * Construct a {@link RDF4JIRI} from a RDF4J {@link IRI}.
-	 * 
-	 * @param iri
-	 *            RDF4J {@link IRI} to adapt
-	 * @return Adapted {@link RDF4JIRI}
-	 */
-	public RDF4JIRI createIRIImpl(IRI iri) {
-		return new IRIImpl(iri);
-	}
+    /**
+     * Construct a {@link RDF4JIRI} from a RDF4J {@link IRI}.
+     * 
+     * @param iri
+     *            RDF4J {@link IRI} to adapt
+     * @return Adapted {@link RDF4JIRI}
+     */
+    public RDF4JIRI createIRIImpl(IRI iri) {
+        return new IRIImpl(iri);
+    }
 
-	/**
-	 * Construct a {@link RDF4JLiteral} from a RDF4J {@link Literal}.
-	 * 
-	 * @param literal
-	 *            RDF4J {@link Literal}
-	 * @return Adapted {@link RDF4JLiteral}
-	 */
-	public RDF4JLiteral createLiteralImpl(Literal literal) {
-		return new LiteralImpl(literal);
-	}
+    /**
+     * Construct a {@link RDF4JLiteral} from a RDF4J {@link Literal}.
+     * 
+     * @param literal
+     *            RDF4J {@link Literal}
+     * @return Adapted {@link RDF4JLiteral}
+     */
+    public RDF4JLiteral createLiteralImpl(Literal literal) {
+        return new LiteralImpl(literal);
+    }
 
-	/**
-	 * Construct a {@link RDF4JGraph} from a RDF4J {@link Model}.
-	 * <p>
-	 * Changes in the graph will be reflected in the model, and vice versa.
-	 * 
-	 * @param model
-	 *            RDF4J {@link Model} to adapt
-	 * @param rdf4jTermFactory
-	 *            factory to use for adapting graph triples
-	 * @return Adapted {@link RDF4JGraph}
-	 */
-	public RDF4JGraph createModelGraphImpl(Model model, RDF4J rdf4jTermFactory) {
-		return new ModelGraphImpl(model, rdf4jTermFactory);
-	}
+    /**
+     * Construct a {@link RDF4JGraph} from a RDF4J {@link Model}.
+     * <p>
+     * Changes in the graph will be reflected in the model, and vice versa.
+     * 
+     * @param model
+     *            RDF4J {@link Model} to adapt
+     * @param rdf4jTermFactory
+     *            factory to use for adapting graph triples
+     * @return Adapted {@link RDF4JGraph}
+     */
+    public RDF4JGraph createModelGraphImpl(Model model, RDF4J rdf4jTermFactory) {
+        return new ModelGraphImpl(model, rdf4jTermFactory);
+    }
 
-	/**
-	 * Construct a {@link RDF4JQuad} from a RDF4J {@link Statement}.
-	 * 
-	 * @param statement
-	 *            RDF4J {@link Statement} to adapt
-	 * @param salt
-	 *            {@link UUID} for adapting any {@link BNode}s
-	 * @return Adapted {@link RDF4JQuad}
-	 */
-	public RDF4JQuad createQuadImpl(Statement statement, UUID salt) {
-		return new QuadImpl(statement, salt);
-	}
+    /**
+     * Construct a {@link RDF4JQuad} from a RDF4J {@link Statement}.
+     * 
+     * @param statement
+     *            RDF4J {@link Statement} to adapt
+     * @param salt
+     *            {@link UUID} for adapting any {@link BNode}s
+     * @return Adapted {@link RDF4JQuad}
+     */
+    public RDF4JQuad createQuadImpl(Statement statement, UUID salt) {
+        return new QuadImpl(statement, salt);
+    }
 
-	/**
-	 * Construct a {@link RDF4JDataset} from a RDF4J {@link Repository}.
-	 * <p>
-	 * Changes in the dataset will be reflected in the repsitory, and vice
-	 * versa.
-	 * 
-	 * @param repository
-	 *            RDF4J {@link Repository} to adapt
-	 * @param handleInitAndShutdown
-	 *            If <code>true</code>, the {@link RDF4JDataset} will initialize
-	 *            the repository (if needed), and shut it down on
-	 *            {@link RDF4JDataset#close()}.
-	 * @param includeInferred
-	 *            If true, any inferred quads are included in the dataset
-	 * 
-	 * @return Adapted {@link RDF4JDataset}
-	 */
-	public RDF4JDataset createRepositoryDatasetImpl(Repository repository, boolean handleInitAndShutdown,
-			boolean includeInferred) {
-		return new RepositoryDatasetImpl(repository, UUID.randomUUID(), handleInitAndShutdown, includeInferred);
-	}
+    /**
+     * Construct a {@link RDF4JDataset} from a RDF4J {@link Repository}.
+     * <p>
+     * Changes in the dataset will be reflected in the repsitory, and vice
+     * versa.
+     * 
+     * @param repository
+     *            RDF4J {@link Repository} to adapt
+     * @param handleInitAndShutdown
+     *            If <code>true</code>, the {@link RDF4JDataset} will initialize
+     *            the repository (if needed), and shut it down on
+     *            {@link RDF4JDataset#close()}.
+     * @param includeInferred
+     *            If true, any inferred quads are included in the dataset
+     * 
+     * @return Adapted {@link RDF4JDataset}
+     */
+    public RDF4JDataset createRepositoryDatasetImpl(Repository repository, boolean handleInitAndShutdown,
+            boolean includeInferred) {
+        return new RepositoryDatasetImpl(repository, UUID.randomUUID(), handleInitAndShutdown, includeInferred);
+    }
 
-	/**
-	 * Construct a {@link RDF4JGraph} from a RDF4J {@link Model}.
-	 * <p>
-	 * Changes in the graph will be reflected in the model, and vice versa.
-	 * 
-	 * @param repository
-	 *            RDF4J {@link Repository} to adapt
-	 * @param handleInitAndShutdown
-	 *            If <code>true</code>, the {@link RDF4JGraph} will initialize
-	 *            the repository (if needed), and shut it down on
-	 *            {@link RDF4JGraph#close()}.
-	 * @param includeInferred
-	 *            If true, any inferred quads are included in the dataset
-	 * @param contextMask
-	 *            Zero or more {@link Resource}s contexts. The array may contain
-	 *            the value <code>null</code> for the default graph - however
-	 *            care must be taken to not provide a null-array
-	 *            <code>(Resource[]) null</code>.
-	 * @return Adapted {@link RDF4JGraph}
-	 */
-	public RDF4JGraph createRepositoryGraphImpl(Repository repository, boolean handleInitAndShutdown,
-			boolean includeInferred, Resource... contextMask) {
-		return new RepositoryGraphImpl(repository, UUID.randomUUID(), handleInitAndShutdown, includeInferred, contextMask);
-	}
+    /**
+     * Construct a {@link RDF4JGraph} from a RDF4J {@link Model}.
+     * <p>
+     * Changes in the graph will be reflected in the model, and vice versa.
+     * 
+     * @param repository
+     *            RDF4J {@link Repository} to adapt
+     * @param handleInitAndShutdown
+     *            If <code>true</code>, the {@link RDF4JGraph} will initialize
+     *            the repository (if needed), and shut it down on
+     *            {@link RDF4JGraph#close()}.
+     * @param includeInferred
+     *            If true, any inferred quads are included in the dataset
+     * @param contextMask
+     *            Zero or more {@link Resource}s contexts. The array may contain
+     *            the value <code>null</code> for the default graph - however
+     *            care must be taken to not provide a null-array
+     *            <code>(Resource[]) null</code>.
+     * @return Adapted {@link RDF4JGraph}
+     */
+    public RDF4JGraph createRepositoryGraphImpl(Repository repository, boolean handleInitAndShutdown,
+            boolean includeInferred, Resource... contextMask) {
+        return new RepositoryGraphImpl(repository, UUID.randomUUID(), handleInitAndShutdown, includeInferred,
+                contextMask);
+    }
 
-	/**
-	 * Construct a {@link RDF4JTriple} from a RDF4J {@link Statement}.
-	 * 
-	 * @param statement
-	 *            RDF4J {@link Statement} to adapt
-	 * @param salt
-	 *            {@link UUID} for adapting any {@link BNode}s
-	 * @return Adapted {@link RDF4JTriple}
-	 */
-	public RDF4JTriple createTripleImpl(Statement statement, UUID salt) {
-		return new TripleImpl(statement, salt);
-	}
+    /**
+     * Construct a {@link RDF4JTriple} from a RDF4J {@link Statement}.
+     * 
+     * @param statement
+     *            RDF4J {@link Statement} to adapt
+     * @param salt
+     *            {@link UUID} for adapting any {@link BNode}s
+     * @return Adapted {@link RDF4JTriple}
+     */
+    public RDF4JTriple createTripleImpl(Statement statement, UUID salt) {
+        return new TripleImpl(statement, salt);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/LiteralImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/LiteralImpl.java
index aef298d..9fa93b1 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/LiteralImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/LiteralImpl.java
@@ -24,62 +24,62 @@ import org.apache.commons.rdf.rdf4j.RDF4JLiteral;
 import org.eclipse.rdf4j.model.vocabulary.XMLSchema;
 import org.eclipse.rdf4j.rio.turtle.TurtleUtil;
 
-final class LiteralImpl 
-	extends AbstractRDFTerm<org.eclipse.rdf4j.model.Literal>
-    implements RDF4JLiteral {		
+final class LiteralImpl extends AbstractRDFTerm<org.eclipse.rdf4j.model.Literal> implements RDF4JLiteral {
 
-	private static final String QUOTE = "\"";
-	
-	LiteralImpl(org.eclipse.rdf4j.model.Literal literal) {
-		super(literal);			
-	}
-	@Override
-	public boolean equals(Object obj) {
-		if (obj == this) { return true; }
-		if (obj instanceof org.apache.commons.rdf.api.Literal) {
-			org.apache.commons.rdf.api.Literal other = (org.apache.commons.rdf.api.Literal) obj;
-			return getLexicalForm().equals(other.getLexicalForm()) &&
-					getDatatype().equals(other.getDatatype()) && 
-					getLanguageTag().equals(other.getLanguageTag());
-			
-		}
-		return false;
-	}
+    private static final String QUOTE = "\"";
 
-	@Override
-	public org.apache.commons.rdf.api.IRI getDatatype() {
-		return new IRIImpl(value.getDatatype());
-	}
+    LiteralImpl(org.eclipse.rdf4j.model.Literal literal) {
+        super(literal);
+    }
 
-	@Override
-	public Optional<String> getLanguageTag() {
-		return value.getLanguage();
-	}
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        if (obj instanceof org.apache.commons.rdf.api.Literal) {
+            org.apache.commons.rdf.api.Literal other = (org.apache.commons.rdf.api.Literal) obj;
+            return getLexicalForm().equals(other.getLexicalForm()) && getDatatype().equals(other.getDatatype())
+                    && getLanguageTag().equals(other.getLanguageTag());
 
-	@Override
-	public String getLexicalForm() {
-		return value.getLabel();
-	}
+        }
+        return false;
+    }
 
-	public int hashCode() {
-		return Objects.hash(value.getLabel(), value.getDatatype(), value.getLanguage());
-	}
+    @Override
+    public org.apache.commons.rdf.api.IRI getDatatype() {
+        return new IRIImpl(value.getDatatype());
+    }
 
-	@Override
-	public String ntriplesString() {
-		// TODO: Use a more efficient StringBuffer
-		String escaped = QUOTE + TurtleUtil.encodeString(value.getLabel()) + QUOTE;
-		if (value.getLanguage().isPresent()) {
-			return escaped + "@" + value.getLanguage().get();
-		}
-		if (value.getDatatype().equals(XMLSchema.STRING)) { 
-			return escaped;
-		}
-		return escaped + "^^<" + TurtleUtil.encodeURIString(value.getDatatype().toString()) + ">";
-	}
+    @Override
+    public Optional<String> getLanguageTag() {
+        return value.getLanguage();
+    }
 
-	@Override
-	public String toString() {
-		return ntriplesString();
-	}
+    @Override
+    public String getLexicalForm() {
+        return value.getLabel();
+    }
+
+    public int hashCode() {
+        return Objects.hash(value.getLabel(), value.getDatatype(), value.getLanguage());
+    }
+
+    @Override
+    public String ntriplesString() {
+        // TODO: Use a more efficient StringBuffer
+        String escaped = QUOTE + TurtleUtil.encodeString(value.getLabel()) + QUOTE;
+        if (value.getLanguage().isPresent()) {
+            return escaped + "@" + value.getLanguage().get();
+        }
+        if (value.getDatatype().equals(XMLSchema.STRING)) {
+            return escaped;
+        }
+        return escaped + "^^<" + TurtleUtil.encodeURIString(value.getDatatype().toString()) + ">";
+    }
+
+    @Override
+    public String toString() {
+        return ntriplesString();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
index ced9c99..7debacc 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
@@ -38,121 +38,115 @@ import org.eclipse.rdf4j.model.Resource;
 import org.eclipse.rdf4j.repository.Repository;
 
 final class ModelGraphImpl implements RDF4JGraph {
-	
-	private Model model;
-	private RDF4J rdf4jTermFactory;
-
-	ModelGraphImpl(Model model, RDF4J rdf4jTermFactory) {
-		this.model = model;	
-		this.rdf4jTermFactory = rdf4jTermFactory;
-	}
-	
-	@Override
-	public void add(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object) {
-		model.add(
-				(Resource)rdf4jTermFactory.asValue(subject), 
-				(org.eclipse.rdf4j.model.IRI)rdf4jTermFactory.asValue(predicate), 
-				rdf4jTermFactory.asValue(object));				
-	}
-	
-	@Override
-	public void add(Triple triple) {
-		model.add(rdf4jTermFactory.asStatement(triple));
-	}
-
-	public Optional<Model> asModel() { 
-		return Optional.of(model);
-	}
-
-	@Override
-	public Optional<Repository> asRepository() {
-		return Optional.empty();
-	}
-	
-	@Override
-	public void clear() {
-		model.clear();
-	}
-
-	@Override
-	public boolean contains(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object) {
-		return model.contains(
-				(Resource)rdf4jTermFactory.asValue(subject), 
-				(org.eclipse.rdf4j.model.IRI)rdf4jTermFactory.asValue(predicate), 
-				rdf4jTermFactory.asValue(object));
-	}
-
-	@Override
-	public boolean contains(Triple triple) {
-		return model.contains(rdf4jTermFactory.asStatement(triple));
-	}
-
-	@Override
-	public void remove(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object) {
-		model.remove(
-				(Resource)rdf4jTermFactory.asValue(subject), 
-				(org.eclipse.rdf4j.model.IRI)rdf4jTermFactory.asValue(predicate), 
-				rdf4jTermFactory.asValue(object));		
-	}
-
-	@Override
-	public void remove(Triple triple) { 
-		model.remove(rdf4jTermFactory.asStatement(triple));
-	}
-
-	@Override
-	public long size() {
-		int size = model.size();
-		if (size < Integer.MAX_VALUE) {
-			return size;
-		} else {
-			// TODO: Check if this can really happen with RDF4J models
-			// Collection.size() can't help us, we'll have to count
-			return model.parallelStream().count();
-		}				
-	}
-
-	@Override
-	public Stream<RDF4JTriple> stream() {
-		return model.parallelStream().map(rdf4jTermFactory::asTriple);
-	}
-
-	@Override
-	public Stream<RDF4JTriple> stream(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object) {
-		return model.filter(
-				(Resource)rdf4jTermFactory.asValue(subject), 
-				(org.eclipse.rdf4j.model.IRI)rdf4jTermFactory.asValue(predicate), 
-				rdf4jTermFactory.asValue(object)).parallelStream()
-			.map(rdf4jTermFactory::asTriple);
-	}
-	
-	@Override
-	public Set<RDF4JBlankNodeOrIRI> getContextMask() {
-		// ModelGraph always do the unionGraph
-		return Collections.emptySet();
-		// TODO: Should we support contextMask like in RepositoryGraphImpl?
-	}
-
-	@Override
-	public ClosableIterable<Triple> iterate(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		return new ClosableIterable<Triple>() {		
-			@SuppressWarnings("unchecked")
-			@Override
-			public Iterator<Triple> iterator() {
-				// double-cast to fight Java generics..
-				Stream<? extends Triple> s = stream(subject, predicate, object);
-				return (Iterator<Triple>) s.iterator();
-			}
-			@Override
-			public void close() throws Exception {
-				// no-op as Model don't have transaction
-			}
-		};
-	}
-	
-	@Override
-	public ClosableIterable<Triple> iterate() throws ConcurrentModificationException, IllegalStateException {
-		return iterate(null, null, null);
-	}
-	
+
+    private Model model;
+    private RDF4J rdf4jTermFactory;
+
+    ModelGraphImpl(Model model, RDF4J rdf4jTermFactory) {
+        this.model = model;
+        this.rdf4jTermFactory = rdf4jTermFactory;
+    }
+
+    @Override
+    public void add(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object) {
+        model.add((Resource) rdf4jTermFactory.asValue(subject),
+                (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate), rdf4jTermFactory.asValue(object));
+    }
+
+    @Override
+    public void add(Triple triple) {
+        model.add(rdf4jTermFactory.asStatement(triple));
+    }
+
+    public Optional<Model> asModel() {
+        return Optional.of(model);
+    }
+
+    @Override
+    public Optional<Repository> asRepository() {
+        return Optional.empty();
+    }
+
+    @Override
+    public void clear() {
+        model.clear();
+    }
+
+    @Override
+    public boolean contains(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object) {
+        return model.contains((Resource) rdf4jTermFactory.asValue(subject),
+                (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate), rdf4jTermFactory.asValue(object));
+    }
+
+    @Override
+    public boolean contains(Triple triple) {
+        return model.contains(rdf4jTermFactory.asStatement(triple));
+    }
+
+    @Override
+    public void remove(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, RDFTerm object) {
+        model.remove((Resource) rdf4jTermFactory.asValue(subject),
+                (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate), rdf4jTermFactory.asValue(object));
+    }
+
+    @Override
+    public void remove(Triple triple) {
+        model.remove(rdf4jTermFactory.asStatement(triple));
+    }
+
+    @Override
+    public long size() {
+        int size = model.size();
+        if (size < Integer.MAX_VALUE) {
+            return size;
+        } else {
+            // TODO: Check if this can really happen with RDF4J models
+            // Collection.size() can't help us, we'll have to count
+            return model.parallelStream().count();
+        }
+    }
+
+    @Override
+    public Stream<RDF4JTriple> stream() {
+        return model.parallelStream().map(rdf4jTermFactory::asTriple);
+    }
+
+    @Override
+    public Stream<RDF4JTriple> stream(BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate,
+            RDFTerm object) {
+        return model.filter((Resource) rdf4jTermFactory.asValue(subject),
+                (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate), rdf4jTermFactory.asValue(object))
+                .parallelStream().map(rdf4jTermFactory::asTriple);
+    }
+
+    @Override
+    public Set<RDF4JBlankNodeOrIRI> getContextMask() {
+        // ModelGraph always do the unionGraph
+        return Collections.emptySet();
+        // TODO: Should we support contextMask like in RepositoryGraphImpl?
+    }
+
+    @Override
+    public ClosableIterable<Triple> iterate(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        return new ClosableIterable<Triple>() {
+            @SuppressWarnings("unchecked")
+            @Override
+            public Iterator<Triple> iterator() {
+                // double-cast to fight Java generics..
+                Stream<? extends Triple> s = stream(subject, predicate, object);
+                return (Iterator<Triple>) s.iterator();
+            }
+
+            @Override
+            public void close() throws Exception {
+                // no-op as Model don't have transaction
+            }
+        };
+    }
+
+    @Override
+    public ClosableIterable<Triple> iterate() throws ConcurrentModificationException, IllegalStateException {
+        return iterate(null, null, null);
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java
index 8da29b6..6962803 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/QuadImpl.java
@@ -30,70 +30,69 @@ import org.apache.commons.rdf.rdf4j.RDF4J;
 import org.eclipse.rdf4j.model.Statement;
 
 final class QuadImpl implements Quad, RDF4JQuad {
-		private transient int hashCode = 0;	
-		private UUID salt;
-		private final Statement statement;
-		
-		QuadImpl(Statement statement, UUID salt) {
-			this.statement = statement;
-			this.salt = salt;
-		}
-	
-		@Override
-		public Statement asStatement() { 
-			return statement;
-		}
-		
-		@Override
-		public Triple asTriple() {
-			return new TripleImpl(statement, salt);
-		}
-	
-		@Override
-		public boolean equals(Object obj) {
-			if (obj instanceof Triple) {
-				Triple triple = (Triple) obj;
-				return getSubject().equals(triple.getSubject()) &&
-						getPredicate().equals(triple.getPredicate()) && 
-						getObject().equals(triple.getObject());
-			}
-			return false;
-		}
-	
-		@Override
-		public Optional<BlankNodeOrIRI> getGraphName() {
-			if (statement.getContext() == null) { 
-				return Optional.empty();
-			}			
-			BlankNodeOrIRI g = (BlankNodeOrIRI) RDF4J.asRDFTerm(statement.getContext(), salt);
-			return Optional.of(g);
-		}
-		
-		@Override
-		public RDFTerm getObject() {
-			return RDF4J.asRDFTerm(statement.getObject(), salt);
-		}
-	
-		@Override
-		public org.apache.commons.rdf.api.IRI getPredicate() {
-			return (org.apache.commons.rdf.api.IRI) RDF4J.asRDFTerm(statement.getPredicate(), null);
-		}
-		
-		@Override
-		public BlankNodeOrIRI getSubject() {
-			return (BlankNodeOrIRI) RDF4J.asRDFTerm(statement.getSubject(), salt);
-		}
+    private transient int hashCode = 0;
+    private UUID salt;
+    private final Statement statement;
 
-		@Override
-		public int hashCode() {
-			if (hashCode  != 0) {
-				return hashCode;
-			}
-			return hashCode = Objects.hash(getSubject(), getPredicate(), getObject(), getGraphName());
-		}
-		
-		@Override
-		public String toString() {
-			return statement.toString();
-		}
+    QuadImpl(Statement statement, UUID salt) {
+        this.statement = statement;
+        this.salt = salt;
+    }
+
+    @Override
+    public Statement asStatement() {
+        return statement;
+    }
+
+    @Override
+    public Triple asTriple() {
+        return new TripleImpl(statement, salt);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof Triple) {
+            Triple triple = (Triple) obj;
+            return getSubject().equals(triple.getSubject()) && getPredicate().equals(triple.getPredicate())
+                    && getObject().equals(triple.getObject());
+        }
+        return false;
+    }
+
+    @Override
+    public Optional<BlankNodeOrIRI> getGraphName() {
+        if (statement.getContext() == null) {
+            return Optional.empty();
+        }
+        BlankNodeOrIRI g = (BlankNodeOrIRI) RDF4J.asRDFTerm(statement.getContext(), salt);
+        return Optional.of(g);
+    }
+
+    @Override
+    public RDFTerm getObject() {
+        return RDF4J.asRDFTerm(statement.getObject(), salt);
+    }
+
+    @Override
+    public org.apache.commons.rdf.api.IRI getPredicate() {
+        return (org.apache.commons.rdf.api.IRI) RDF4J.asRDFTerm(statement.getPredicate(), null);
+    }
+
+    @Override
+    public BlankNodeOrIRI getSubject() {
+        return (BlankNodeOrIRI) RDF4J.asRDFTerm(statement.getSubject(), salt);
+    }
+
+    @Override
+    public int hashCode() {
+        if (hashCode != 0) {
+            return hashCode;
+        }
+        return hashCode = Objects.hash(getSubject(), getPredicate(), getObject(), getGraphName());
+    }
+
+    @Override
+    public String toString() {
+        return statement.toString();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
index 64f3bbd..8c266a9 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
@@ -41,183 +41,188 @@ import org.eclipse.rdf4j.repository.RepositoryResult;
 
 class RepositoryDatasetImpl extends AbstractRepositoryGraphLike<Quad> implements RDF4JDataset, Dataset {
 
-	RepositoryDatasetImpl(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred) {
-		super(repository, salt, handleInitAndShutdown, includeInferred);
-	}
-
-	@Override
-	public void add(Quad tripleLike) {
-		Statement statement = rdf4jTermFactory.asStatement(tripleLike);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.add(statement);
-			conn.commit();
-		}
-	}
-
-
-	@Override
-	public boolean contains(Quad tripleLike) {
-		Statement statement = rdf4jTermFactory.asStatement(tripleLike);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			return conn.hasStatement(statement, includeInferred);
-		}
-	}
-
-	@Override
-	public void remove(Quad tripleLike) {
-		Statement statement = rdf4jTermFactory.asStatement(tripleLike);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.remove(statement);
-			conn.commit();
-		}
-	}
-
-	@Override
-	public void clear() {
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.clear();
-			conn.commit();
-		}
-	}
-
-	@Override
-	public long size() {
-		if (includeInferred) {
-			// We'll need to count them all
-			return stream().count();
-		}
-		// else: Ask directly
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			return conn.size();
-		}
-	}
-
-	@Override
-	public void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Resource context = (Resource) rdf4jTermFactory.asValue(graphName);
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.add(subj, pred, obj,  context);
-			conn.commit();
-		}
-	}
-
-	@Override
-	public boolean contains(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		Resource[] contexts = asContexts(graphName);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			return conn.hasStatement(subj, pred, obj, includeInferred, contexts);
-		}
-	}
-
-	private Resource[] asContexts(Optional<BlankNodeOrIRI> graphName) {
-		Resource[] contexts;
-		if (graphName == null) {
-			// no contexts == any contexts
-			 contexts = new Resource[0];
-		} else {
-			BlankNodeOrIRI g = graphName.orElse(null);
-			Resource context = (Resource) rdf4jTermFactory.asValue(g);
-			contexts = new Resource[] { context };
-		}
-		return contexts;
-	}
-
-	@Override
-	public void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		Resource[] contexts = asContexts(graphName);
-
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.remove(subj, pred, obj, contexts);
-			conn.commit();
-		}
-	}
-
-	@Override
-	public Stream<RDF4JQuad> stream() {
-		return stream(null, null, null, null);
-	}
-
-	@Override
-	public Stream<RDF4JQuad> stream(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		Resource[] contexts = asContexts(graphName);
-
-		// NOTE: We can't do the usual try..with closing of the
-		// RepositoryConnection here as it will have to be closed outside
-		// by the user of the returned stream
-		RepositoryConnection conn = getRepositoryConnection();
-		Stream<RDF4JQuad> stream = null;
-		try {
-			RepositoryResult<Statement> statements = conn.getStatements(subj, pred, obj, includeInferred, contexts);
-			// NOTE: Iterations.stream should close RepositoryResult as long as our caller closes the stream
-			stream = Iterations.stream(statements).map(rdf4jTermFactory::asQuad);
-		} finally {
-			if (stream == null) {
-				// Some exception before we made the stream, close connection here
-				conn.close();
-			}
-		}
-		// Make sure the RepositoryConnection is closed
-		return stream.onClose(conn::close);
-
-	}
-
-
-	@Override
-	public ClosableIterable<Quad> iterate() throws ConcurrentModificationException, IllegalStateException {
-		return iterate(null, null, null, null);
-	}
-	
-	@Override
-	public ClosableIterable<Quad> iterate(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
-			throws ConcurrentModificationException, IllegalStateException {
-		Resource[] contexts = asContexts(graphName);
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		return new ConvertedStatements<Quad>(this::getRepositoryConnection, 
-				rdf4jTermFactory::asQuad, subj, pred, obj, contexts);
-	}	
-	
-	@Override
-	protected RDF4JQuad asTripleLike(Statement s) {
-		return rdf4jTermFactory.asQuad(s);
-	}
-
-	@Override
-	public Graph getGraph() {
-		// default context only
-		// NOTE: We carry over the 'salt' as the graph's BlankNode should be equal to our BlankNodes
-		return new RepositoryGraphImpl(repository, salt, false, includeInferred, (Resource)null);
-	}
-
-	@Override
-	public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
-		// NOTE: May be null to indicate default context
-		Resource context = (Resource) rdf4jTermFactory.asValue(graphName);
-		// NOTE: We carry over the 'salt' as the graph's BlankNode should be equal to our BlankNodes
-		return Optional.of(new RepositoryGraphImpl(repository, salt, false, includeInferred, context));
-	}
-
-	@Override
-	public Stream<BlankNodeOrIRI> getGraphNames() {
-		// FIXME: Will the below close the connection before the stream has been consumed outside? 
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			RepositoryResult<Resource> contexts = conn.getContextIDs();
-			// NOTE: connection will be closed outside by the Iterations.stream()
-			return Iterations.stream(contexts).map(g -> (BlankNodeOrIRI) rdf4jTermFactory.asRDFTerm(g));
-		}
-	}
+    RepositoryDatasetImpl(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred) {
+        super(repository, salt, handleInitAndShutdown, includeInferred);
+    }
+
+    @Override
+    public void add(Quad tripleLike) {
+        Statement statement = rdf4jTermFactory.asStatement(tripleLike);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.add(statement);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public boolean contains(Quad tripleLike) {
+        Statement statement = rdf4jTermFactory.asStatement(tripleLike);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            return conn.hasStatement(statement, includeInferred);
+        }
+    }
+
+    @Override
+    public void remove(Quad tripleLike) {
+        Statement statement = rdf4jTermFactory.asStatement(tripleLike);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.remove(statement);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public void clear() {
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.clear();
+            conn.commit();
+        }
+    }
+
+    @Override
+    public long size() {
+        if (includeInferred) {
+            // We'll need to count them all
+            return stream().count();
+        }
+        // else: Ask directly
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            return conn.size();
+        }
+    }
+
+    @Override
+    public void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        Resource context = (Resource) rdf4jTermFactory.asValue(graphName);
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.add(subj, pred, obj, context);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public boolean contains(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        Resource[] contexts = asContexts(graphName);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            return conn.hasStatement(subj, pred, obj, includeInferred, contexts);
+        }
+    }
+
+    private Resource[] asContexts(Optional<BlankNodeOrIRI> graphName) {
+        Resource[] contexts;
+        if (graphName == null) {
+            // no contexts == any contexts
+            contexts = new Resource[0];
+        } else {
+            BlankNodeOrIRI g = graphName.orElse(null);
+            Resource context = (Resource) rdf4jTermFactory.asValue(g);
+            contexts = new Resource[] { context };
+        }
+        return contexts;
+    }
+
+    @Override
+    public void remove(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        Resource[] contexts = asContexts(graphName);
+
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.remove(subj, pred, obj, contexts);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public Stream<RDF4JQuad> stream() {
+        return stream(null, null, null, null);
+    }
+
+    @Override
+    public Stream<RDF4JQuad> stream(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate,
+            RDFTerm object) {
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        Resource[] contexts = asContexts(graphName);
+
+        // NOTE: We can't do the usual try..with closing of the
+        // RepositoryConnection here as it will have to be closed outside
+        // by the user of the returned stream
+        RepositoryConnection conn = getRepositoryConnection();
+        Stream<RDF4JQuad> stream = null;
+        try {
+            RepositoryResult<Statement> statements = conn.getStatements(subj, pred, obj, includeInferred, contexts);
+            // NOTE: Iterations.stream should close RepositoryResult as long as
+            // our caller closes the stream
+            stream = Iterations.stream(statements).map(rdf4jTermFactory::asQuad);
+        } finally {
+            if (stream == null) {
+                // Some exception before we made the stream, close connection
+                // here
+                conn.close();
+            }
+        }
+        // Make sure the RepositoryConnection is closed
+        return stream.onClose(conn::close);
+
+    }
+
+    @Override
+    public ClosableIterable<Quad> iterate() throws ConcurrentModificationException, IllegalStateException {
+        return iterate(null, null, null, null);
+    }
+
+    @Override
+    public ClosableIterable<Quad> iterate(Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate,
+            RDFTerm object) throws ConcurrentModificationException, IllegalStateException {
+        Resource[] contexts = asContexts(graphName);
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        return new ConvertedStatements<Quad>(this::getRepositoryConnection, rdf4jTermFactory::asQuad, subj, pred, obj,
+                contexts);
+    }
+
+    @Override
+    protected RDF4JQuad asTripleLike(Statement s) {
+        return rdf4jTermFactory.asQuad(s);
+    }
+
+    @Override
+    public Graph getGraph() {
+        // default context only
+        // NOTE: We carry over the 'salt' as the graph's BlankNode should be
+        // equal to our BlankNodes
+        return new RepositoryGraphImpl(repository, salt, false, includeInferred, (Resource) null);
+    }
+
+    @Override
+    public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
+        // NOTE: May be null to indicate default context
+        Resource context = (Resource) rdf4jTermFactory.asValue(graphName);
+        // NOTE: We carry over the 'salt' as the graph's BlankNode should be
+        // equal to our BlankNodes
+        return Optional.of(new RepositoryGraphImpl(repository, salt, false, includeInferred, context));
+    }
+
+    @Override
+    public Stream<BlankNodeOrIRI> getGraphNames() {
+        // FIXME: Will the below close the connection before the stream has been
+        // consumed outside?
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            RepositoryResult<Resource> contexts = conn.getContextIDs();
+            // NOTE: connection will be closed outside by the
+            // Iterations.stream()
+            return Iterations.stream(contexts).map(g -> (BlankNodeOrIRI) rdf4jTermFactory.asRDFTerm(g));
+        }
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
index 55b909e..ca07f9e 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
@@ -43,152 +43,153 @@ import org.eclipse.rdf4j.repository.RepositoryConnection;
 import org.eclipse.rdf4j.repository.RepositoryResult;
 
 class RepositoryGraphImpl extends AbstractRepositoryGraphLike<Triple> implements Graph, RDF4JGraph {
-	
-	private final Resource[] contextMask;
-
-	RepositoryGraphImpl(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred, Resource... contextMask) {
-		super(repository, salt, handleInitAndShutdown, includeInferred);
-		this.contextMask = Objects.requireNonNull(contextMask);
-	}
-
-
-	@Override
-	public void add(Triple tripleLike) {
-		Statement statement = rdf4jTermFactory.asStatement(tripleLike);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.add(statement, contextMask);
-			conn.commit();
-		}
-	}
-
-
-	@Override
-	public boolean contains(Triple tripleLike) {
-		Statement statement = rdf4jTermFactory.asStatement(tripleLike);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			return conn.hasStatement(statement, includeInferred, contextMask);
-		}
-	}
-
-	@Override
-	public void remove(Triple tripleLike) {
-		Statement statement = rdf4jTermFactory.asStatement(tripleLike);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.remove(statement, contextMask);
-			conn.commit();
-		}
-	}
-
-	@Override
-	public void clear() {
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.clear(contextMask);
-			conn.commit();
-		}
-	}
-
-	@Override
-	public long size() {
-		if (!includeInferred && contextMask.length == 0) {
-			try (RepositoryConnection conn = getRepositoryConnection()) {
-				return conn.size();
-			}
-		} else {
-			try (Stream<RDF4JTriple> stream = stream()) {
-				return stream.count();
-			}
-		}
-	}
-	
-	@Override
-	public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.add(subj, pred, obj, contextMask);
-			conn.commit();
-		}
-	}
-
-	@Override
-	public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			return conn.hasStatement(subj, pred, obj, includeInferred, contextMask);
-		}
-	}
-
-	@Override
-	public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		try (RepositoryConnection conn = getRepositoryConnection()) {
-			conn.remove(subj, pred, obj, contextMask);
-			conn.commit();
-		}
-	}
-	
-	@Override
-	public ClosableIterable<Triple> iterate() throws ConcurrentModificationException, IllegalStateException {
-		return iterate(null, null, null);
-	}
-	
-	@Override
-	public ClosableIterable<Triple> iterate(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
-			throws ConcurrentModificationException, IllegalStateException {
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		return new ConvertedStatements<Triple>(this::getRepositoryConnection, rdf4jTermFactory::asTriple, 
-				subj, pred, obj, contextMask);
-	}
-
-	@Override
-	public Stream<RDF4JTriple> stream() {
-		return stream(null, null, null);
-	}
-	
-	@Override
-	public Stream<RDF4JTriple> stream(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-		Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
-		org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
-		Value obj = rdf4jTermFactory.asValue(object);
-		
-		// NOTE: We can't do the usual try..with closing of the
-		// RepositoryConnection here as it will have to be closed outside
-		// by the user of the returned stream
-		RepositoryConnection conn = getRepositoryConnection();
-		Stream<RDF4JTriple> stream = null;
-		try {
-			RepositoryResult<Statement> statements = conn.getStatements(subj, pred, obj, includeInferred, contextMask);
-			// NOTE: Iterations.stream should close RepositoryResult as long as our caller closes the stream
-			stream = Iterations.stream(statements).map(this::asTripleLike);
-		} finally {
-			if (stream == null) {
-				// Some exception before we made the stream, close connection here
-				conn.close();
-			}
-		}
-		// Make sure the RepositoryConnection is closed
-		return stream.onClose(conn::close);
-	}
-	
-	@Override
-	protected RDF4JTriple asTripleLike(Statement statement) {
-		return rdf4jTermFactory.asTriple(statement);
-	}
-
-	@Override
-	public Set<RDF4JBlankNodeOrIRI> getContextMask() {		
-		Set<RDF4JBlankNodeOrIRI> mask = new HashSet<>();
-		for (Resource s : contextMask) {
-			mask.add((RDF4JBlankNodeOrIRI) rdf4jTermFactory.asRDFTerm(s));
-		}
-		return Collections.unmodifiableSet(mask);
-	}
-	
+
+    private final Resource[] contextMask;
+
+    RepositoryGraphImpl(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred,
+            Resource... contextMask) {
+        super(repository, salt, handleInitAndShutdown, includeInferred);
+        this.contextMask = Objects.requireNonNull(contextMask);
+    }
+
+    @Override
+    public void add(Triple tripleLike) {
+        Statement statement = rdf4jTermFactory.asStatement(tripleLike);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.add(statement, contextMask);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public boolean contains(Triple tripleLike) {
+        Statement statement = rdf4jTermFactory.asStatement(tripleLike);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            return conn.hasStatement(statement, includeInferred, contextMask);
+        }
+    }
+
+    @Override
+    public void remove(Triple tripleLike) {
+        Statement statement = rdf4jTermFactory.asStatement(tripleLike);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.remove(statement, contextMask);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public void clear() {
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.clear(contextMask);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public long size() {
+        if (!includeInferred && contextMask.length == 0) {
+            try (RepositoryConnection conn = getRepositoryConnection()) {
+                return conn.size();
+            }
+        } else {
+            try (Stream<RDF4JTriple> stream = stream()) {
+                return stream.count();
+            }
+        }
+    }
+
+    @Override
+    public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.add(subj, pred, obj, contextMask);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            return conn.hasStatement(subj, pred, obj, includeInferred, contextMask);
+        }
+    }
+
+    @Override
+    public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        try (RepositoryConnection conn = getRepositoryConnection()) {
+            conn.remove(subj, pred, obj, contextMask);
+            conn.commit();
+        }
+    }
+
+    @Override
+    public ClosableIterable<Triple> iterate() throws ConcurrentModificationException, IllegalStateException {
+        return iterate(null, null, null);
+    }
+
+    @Override
+    public ClosableIterable<Triple> iterate(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
+            throws ConcurrentModificationException, IllegalStateException {
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+        return new ConvertedStatements<Triple>(this::getRepositoryConnection, rdf4jTermFactory::asTriple, subj, pred,
+                obj, contextMask);
+    }
+
+    @Override
+    public Stream<RDF4JTriple> stream() {
+        return stream(null, null, null);
+    }
+
+    @Override
+    public Stream<RDF4JTriple> stream(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+        Resource subj = (Resource) rdf4jTermFactory.asValue(subject);
+        org.eclipse.rdf4j.model.IRI pred = (org.eclipse.rdf4j.model.IRI) rdf4jTermFactory.asValue(predicate);
+        Value obj = rdf4jTermFactory.asValue(object);
+
+        // NOTE: We can't do the usual try..with closing of the
+        // RepositoryConnection here as it will have to be closed outside
+        // by the user of the returned stream
+        RepositoryConnection conn = getRepositoryConnection();
+        Stream<RDF4JTriple> stream = null;
+        try {
+            RepositoryResult<Statement> statements = conn.getStatements(subj, pred, obj, includeInferred, contextMask);
+            // NOTE: Iterations.stream should close RepositoryResult as long as
+            // our caller closes the stream
+            stream = Iterations.stream(statements).map(this::asTripleLike);
+        } finally {
+            if (stream == null) {
+                // Some exception before we made the stream, close connection
+                // here
+                conn.close();
+            }
+        }
+        // Make sure the RepositoryConnection is closed
+        return stream.onClose(conn::close);
+    }
+
+    @Override
+    protected RDF4JTriple asTripleLike(Statement statement) {
+        return rdf4jTermFactory.asTriple(statement);
+    }
+
+    @Override
+    public Set<RDF4JBlankNodeOrIRI> getContextMask() {
+        Set<RDF4JBlankNodeOrIRI> mask = new HashSet<>();
+        for (Resource s : contextMask) {
+            mask.add((RDF4JBlankNodeOrIRI) rdf4jTermFactory.asRDFTerm(s));
+        }
+        return Collections.unmodifiableSet(mask);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java
index 0526c77..4ed3946 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/TripleImpl.java
@@ -28,52 +28,51 @@ import org.apache.commons.rdf.rdf4j.RDF4JTriple;
 import org.eclipse.rdf4j.model.Statement;
 
 final class TripleImpl implements Triple, RDF4JTriple {
-		private UUID salt;	
-		private final Statement statement;
-		
-		TripleImpl(Statement statement, UUID salt) {
-			this.statement = statement;
-			this.salt = salt;
-		}
-	
-		@Override
-		public Statement asStatement() { 
-			return statement;
-		}
-		
-		@Override
-		public boolean equals(Object obj) {
-			if (obj instanceof Triple) {
-				Triple triple = (Triple) obj;
-				return getSubject().equals(triple.getSubject()) &&
-						getPredicate().equals(triple.getPredicate()) && 
-						getObject().equals(triple.getObject());
-			}
-			return false;
-		}
-	
-		@Override
-		public RDFTerm getObject() {
-			return RDF4J.asRDFTerm(statement.getObject(), salt);
-		}
-	
-		@Override
-		public org.apache.commons.rdf.api.IRI getPredicate() {
-			return (org.apache.commons.rdf.api.IRI) RDF4J.asRDFTerm(statement.getPredicate(), null);
-		}
-		
-		@Override
-		public BlankNodeOrIRI getSubject() {
-			return (BlankNodeOrIRI) RDF4J.asRDFTerm(statement.getSubject(), salt);
-		}
-	
-		@Override
-		public int hashCode() {
-			return Objects.hash(getSubject(), getPredicate(), getObject());
-		}
-		
-		@Override
-		public String toString() {
-			return statement.toString();
-		}
+    private UUID salt;
+    private final Statement statement;
+
+    TripleImpl(Statement statement, UUID salt) {
+        this.statement = statement;
+        this.salt = salt;
+    }
+
+    @Override
+    public Statement asStatement() {
+        return statement;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj instanceof Triple) {
+            Triple triple = (Triple) obj;
+            return getSubject().equals(triple.getSubject()) && getPredicate().equals(triple.getPredicate())
+                    && getObject().equals(triple.getObject());
+        }
+        return false;
+    }
+
+    @Override
+    public RDFTerm getObject() {
+        return RDF4J.asRDFTerm(statement.getObject(), salt);
+    }
+
+    @Override
+    public org.apache.commons.rdf.api.IRI getPredicate() {
+        return (org.apache.commons.rdf.api.IRI) RDF4J.asRDFTerm(statement.getPredicate(), null);
+    }
+
+    @Override
+    public BlankNodeOrIRI getSubject() {
+        return (BlankNodeOrIRI) RDF4J.asRDFTerm(statement.getSubject(), salt);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(getSubject(), getPredicate(), getObject());
+    }
+
+    @Override
+    public String toString() {
+        return statement.toString();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
index f4bfb7a..e40e985 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
@@ -18,39 +18,33 @@
 /**
  * Commons RDF integration with <a href="http://rdf4j.org/">RDF4J</a>.
  * <p>
- * Use the {@link RDF4J} to convert
- * between Commons RDF and RDF4J types, for instance
- * {@link RDF4J#asQuad(org.eclipse.rdf4j.model.Statement)}
- * converts a RDF4J {@link org.eclipse.rdf4j.model.Statement} to a
+ * Use the {@link RDF4J} to convert between Commons RDF and RDF4J types, for
+ * instance {@link RDF4J#asQuad(org.eclipse.rdf4j.model.Statement)} converts a
+ * RDF4J {@link org.eclipse.rdf4j.model.Statement} to a
  * {@link org.apache.commons.rdf.api.Quad}. Converted RDF terms implement the
- * {@link RDF4JTerm} interface, and converted
- * statements the {@link RDF4JTripleLike}
- * interface, which provide convenience access to the underlying RDF4J
- * implementations.
+ * {@link RDF4JTerm} interface, and converted statements the
+ * {@link RDF4JTripleLike} interface, which provide convenience access to the
+ * underlying RDF4J implementations.
  * <p>
  * RDF4J {@link org.eclipse.rdf4j.model.Model}s and
  * {@link org.eclipse.rdf4j.repository.Repository} instances can be adapted to
- * Commons RDF {@link Graph} and
- * {@link Dataset}, e.g. using
- * {@link RDF4J#asGraph(org.eclipse.rdf4j.model.Model)}
- * or
+ * Commons RDF {@link Graph} and {@link Dataset}, e.g. using
+ * {@link RDF4J#asGraph(org.eclipse.rdf4j.model.Model)} or
  * {@link RDF4J#asDataset(org.eclipse.rdf4j.repository.Repository, RDF4J.Option...)}
  * The returned adapted graph/dataset is directly mapped, so changes are
  * propagated both ways. For convenience, the marker interface
- * {@link RDF4JGraph} and
- * {@link RDF4JDataset} provide access to the
- * underlying RDF4J implementations.
+ * {@link RDF4JGraph} and {@link RDF4JDataset} provide access to the underlying
+ * RDF4J implementations.
  * <p>
- * The {@link RDF4JParser} can be used to
- * parse RDF files using RDF4j. It should be most efficient if used with
- * {@link RDF4JParser#target(Dataset)}
- * and an adapted {@link RDF4JDataset}, or
- * {@link RDF4JParser#target(Graph)}
- * and a an adapted {@link RDF4JGraph}
+ * The {@link RDF4JParser} can be used to parse RDF files using RDF4j. It should
+ * be most efficient if used with {@link RDF4JParser#target(Dataset)} and an
+ * adapted {@link RDF4JDataset}, or {@link RDF4JParser#target(Graph)} and a an
+ * adapted {@link RDF4JGraph}
  * 
  *
  */
 package org.apache.commons.rdf.rdf4j;
+
 // Imports for Javadoc, do not remove
 import org.apache.commons.rdf.api.Dataset;
 import org.apache.commons.rdf.api.Graph;

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java
index d31c24d..f068040 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/BlankNodeTest.java
@@ -22,16 +22,16 @@ import org.apache.commons.rdf.api.BlankNode;
 
 public class BlankNodeTest extends AbstractBlankNodeTest {
 
-	RDF4J factory = new RDF4J();
-	
-	@Override
-	protected BlankNode getBlankNode() {
-		return factory.createBlankNode();
-	}
+    RDF4J factory = new RDF4J();
 
-	@Override
-	protected BlankNode getBlankNode(String identifier) {
-		return factory.createBlankNode(identifier);
-	}
+    @Override
+    protected BlankNode getBlankNode() {
+        return factory.createBlankNode();
+    }
+
+    @Override
+    protected BlankNode getBlankNode(String identifier) {
+        return factory.createBlankNode(identifier);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java
index 4ad8969..81c77da 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/GraphTest.java
@@ -20,11 +20,11 @@ package org.apache.commons.rdf.rdf4j;
 import org.apache.commons.rdf.api.AbstractGraphTest;
 import org.apache.commons.rdf.api.RDF;
 
-public class GraphTest extends AbstractGraphTest{
+public class GraphTest extends AbstractGraphTest {
 
-	@Override
-	public RDF createFactory() {
-		return new RDF4J();
-	}
+    @Override
+    public RDF createFactory() {
+        return new RDF4J();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java
index ab7a459..9d9c802 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryGraphTest.java
@@ -33,57 +33,57 @@ import org.eclipse.rdf4j.sail.memory.model.MemValueFactory;
 
 public class MemoryGraphTest extends AbstractGraphTest {
 
-	public static final class MemoryStoreRDF implements RDF {
-
-		RDF4J rdf4jFactory = new RDF4J(new MemValueFactory());
-
-		public RDF4JBlankNode createBlankNode() {
-			return rdf4jFactory.createBlankNode();
-		}
-
-		public RDF4JBlankNode createBlankNode(String name) {
-			return rdf4jFactory.createBlankNode(name);
-		}
-
-		public Dataset createDataset() {
-			return rdf4jFactory.createDataset();
-		}
-
-		public RDF4JIRI createIRI(String iri) throws IllegalArgumentException, UnsupportedOperationException {
-			return rdf4jFactory.createIRI(iri);
-		}
-
-		public RDF4JLiteral createLiteral(String lexicalForm) {
-			return rdf4jFactory.createLiteral(lexicalForm);
-		}
-
-		public Literal createLiteral(String lexicalForm, IRI dataType) {
-			return rdf4jFactory.createLiteral(lexicalForm, dataType);
-		}
-
-		public Literal createLiteral(String lexicalForm, String languageTag) {
-			return rdf4jFactory.createLiteral(lexicalForm, languageTag);
-		}
-
-		public RDF4JTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-			return rdf4jFactory.createTriple(subject, predicate, object);
-		}
-
-		public Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
-			return rdf4jFactory.createQuad(graphName, subject, predicate, object);
-		}
-
-		public RDF4JGraph createGraph() {
-			Sail sail = new MemoryStore();
-			Repository repository = new SailRepository(sail);
-			repository.initialize();
-			return rdf4jFactory.asGraph(repository);
-		}
-	}
-
-	@Override
-	public RDF createFactory() {
-		return new MemoryStoreRDF();
-	}
+    public static final class MemoryStoreRDF implements RDF {
+
+        RDF4J rdf4jFactory = new RDF4J(new MemValueFactory());
+
+        public RDF4JBlankNode createBlankNode() {
+            return rdf4jFactory.createBlankNode();
+        }
+
+        public RDF4JBlankNode createBlankNode(String name) {
+            return rdf4jFactory.createBlankNode(name);
+        }
+
+        public Dataset createDataset() {
+            return rdf4jFactory.createDataset();
+        }
+
+        public RDF4JIRI createIRI(String iri) throws IllegalArgumentException, UnsupportedOperationException {
+            return rdf4jFactory.createIRI(iri);
+        }
+
+        public RDF4JLiteral createLiteral(String lexicalForm) {
+            return rdf4jFactory.createLiteral(lexicalForm);
+        }
+
+        public Literal createLiteral(String lexicalForm, IRI dataType) {
+            return rdf4jFactory.createLiteral(lexicalForm, dataType);
+        }
+
+        public Literal createLiteral(String lexicalForm, String languageTag) {
+            return rdf4jFactory.createLiteral(lexicalForm, languageTag);
+        }
+
+        public RDF4JTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+            return rdf4jFactory.createTriple(subject, predicate, object);
+        }
+
+        public Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+            return rdf4jFactory.createQuad(graphName, subject, predicate, object);
+        }
+
+        public RDF4JGraph createGraph() {
+            Sail sail = new MemoryStore();
+            Repository repository = new SailRepository(sail);
+            repository.initialize();
+            return rdf4jFactory.asGraph(repository);
+        }
+    }
+
+    @Override
+    public RDF createFactory() {
+        return new MemoryStoreRDF();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/413dd09a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryStoreRDFTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryStoreRDFTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryStoreRDFTest.java
index fd4efcb..5954d13 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryStoreRDFTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/MemoryStoreRDFTest.java
@@ -23,15 +23,15 @@ import org.junit.Assume;
 
 public class MemoryStoreRDFTest extends AbstractRDFTest {
 
-	@Override
-	public RDF createFactory() {
-		return new MemoryGraphTest.MemoryStoreRDF();
-	}
-	
-	@Override
-	public void testInvalidLiteralLang() throws Exception {
-		Assume.assumeTrue("RDF4J doesn't check Lang strings",false);
-		super.testInvalidLiteralLang();
-	}
-	
+    @Override
+    public RDF createFactory() {
+        return new MemoryGraphTest.MemoryStoreRDF();
+    }
+
+    @Override
+    public void testInvalidLiteralLang() throws Exception {
+        Assume.assumeTrue("RDF4J doesn't check Lang strings", false);
+        super.testInvalidLiteralLang();
+    }
+
 }


Mime
View raw message