commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [18/50] incubator-commonsrdf git commit: getContextFilter() -> getContextMask()
Date Fri, 07 Oct 2016 15:01:21 GMT
getContextFilter() -> getContextMask()

See
https://github.com/apache/incubator-commonsrdf/pull/24#discussion_r81248908


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

Branch: refs/heads/master
Commit: 055c7c97146d60a5708281f5e69ae74f75c6bc17
Parents: ed77aad
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Sat Oct 1 20:34:58 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Sat Oct 1 20:34:58 2016 +0100

----------------------------------------------------------------------
 .../apache/commons/rdf/rdf4j/RDF4JGraph.java    | 23 +++++++++++---------
 .../rdf/rdf4j/experimental/RDF4JParser.java     |  4 ++--
 .../rdf4j/impl/AbstractRepositoryGraphLike.java | 12 +++++-----
 .../commons/rdf/rdf4j/impl/ModelGraphImpl.java  |  2 +-
 .../rdf/rdf4j/impl/RepositoryGraphImpl.java     |  2 +-
 5 files changed, 23 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/055c7c97/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
index 396a39b..31c6278 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
@@ -37,30 +37,33 @@ import org.eclipse.rdf4j.repository.Repository;
 public interface RDF4JGraph extends Graph, RDF4JGraphLike<Triple> {
 	
 	/**
-	 * Return a copy of the context filter, if present.
+	 * Return a copy of the context mask, if present.
 	 * <p>
-	 * If {@link Optional#isPresent()}, the filter determines which
+	 * If {@link Optional#isPresent()}, the mask determines which
 	 * <em>contexts</em> in the corresponding RDF4J {@link Model} or
 	 * {@link Repository} that this graph reflect. Modifications to the graph
 	 * (e.g. {@link #add(Triple)} will be performed for all the specified
 	 * contexts, while retrieval (e.g. {@link #contains(Triple)}) will succeed
 	 * if the triple is in at least one of the specified contexts.
 	 * <p>
-	 * The context filter array may contain <code>null</code>, indicating the
-	 * default context (the <em>default graph</em> in RDF datasets).
+	 * The context mask array may contain the {@link Resource} 
+	 * <code>null</code>, indicating the default context 
+	 * (the <em>default graph</em> in RDF datasets).
 	 * <p>
-	 * If the context filter is {@link Optional#empty()}, then this is a
+	 * If the context mask is {@link Optional#empty()}, then this is a
 	 * <em>union graph</em> which triples reflecting statements in any contexts.
-	 * Triples added to the graph will be added in the default context
-	 * <code>null</code>.
+	 * Triples added to the graph will be added in the default context, e.g.
+	 * <code>new Resource[1]{null}</code>).
 	 * <p>
-	 * The filter array is a copy, and thus any modifications are not reflected
+	 * Note that the context mask itself cannot be <code>null</code>.
+	 * <p>
+	 * The mask array is a copy, and thus any modifications are not reflected
 	 * in the RDF4JGraph.
 	 * 
-	 * @return The context filter as an array of {@link Resource}s, or
+	 * @return The context mask as an array of {@link Resource}s, or
 	 *         {@link Optional#empty()} indicating the union graph (any
 	 *         context).
 	 */
-	public Optional<Resource[]> getContextFilter();
+	public Optional<Resource[]> getContextMask();
 	
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/055c7c97/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
index c185419..60692dc 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/experimental/RDF4JParser.java
@@ -180,10 +180,10 @@ public class RDF4JParser extends AbstractRDFParser<RDF4JParser>
implements RDFPa
 
 			if (graph.asRepository().isPresent()) {
 				RDFInserter inserter = new RDFInserter(graph.asRepository().get().getConnection());
-				graph.getContextFilter().ifPresent(inserter::enforceContext);
+				graph.getContextMask().ifPresent(inserter::enforceContext);
 				return inserter;
 			}
-			if (graph.asModel().isPresent() && graph.getContextFilter().isPresent()) {
+			if (graph.asModel().isPresent() && graph.getContextMask().isPresent()) {
 				Model model = graph.asModel().get();
 				return new AddToModel(model);
 			}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/055c7c97/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 04c77fd..4ae7d5b 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
@@ -33,10 +33,10 @@ import org.eclipse.rdf4j.repository.RepositoryConnection;
 public abstract class AbstractRepositoryGraphLike<T extends TripleLike<BlankNodeOrIRI,
IRI, RDFTerm>>
 		implements RDF4JGraphLike<T> {
 
-	protected Repository repository;
-	protected boolean includeInferred;
-	protected boolean handleInitAndShutdown = false;
-	protected RDF4JTermFactory rdf4jTermFactory;
+	protected final Repository repository;
+	protected final boolean includeInferred;
+	protected final boolean handleInitAndShutdown;
+	protected final RDF4JTermFactory rdf4jTermFactory;
 
 	public AbstractRepositoryGraphLike(Repository repository) {
 		this(repository, true, false);
@@ -45,9 +45,9 @@ public abstract class AbstractRepositoryGraphLike<T extends TripleLike<BlankNode
 	public AbstractRepositoryGraphLike(Repository repository, boolean handleInitAndShutdown,
boolean includeInferred) {
 		this.repository = repository;
 		this.includeInferred = includeInferred;
-		if (!repository.isInitialized()) {
+		this.handleInitAndShutdown = handleInitAndShutdown;
+		if (handleInitAndShutdown && !repository.isInitialized()) {
 			repository.initialize();
-			handleInitAndShutdown = true;
 		}
 		rdf4jTermFactory = new RDF4JTermFactory(repository.getValueFactory());
 	}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/055c7c97/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 10347e3..f24aede 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
@@ -125,7 +125,7 @@ public final class ModelGraphImpl implements RDF4JGraph {
 	}
 	
 	@Override
-	public Optional<Resource[]> getContextFilter() {
+	public Optional<Resource[]> getContextMask() {
 		// ModelGraph always do the unionGraph
 		return Optional.empty();
 		// TODO: Should we support contextFilter like in RepositoryGraphImpl?

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/055c7c97/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 e62fdc8..47591be 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
@@ -156,7 +156,7 @@ public class RepositoryGraphImpl extends AbstractRepositoryGraphLike<Triple>
imp
 		return rdf4jTermFactory.asTriple(statement);
 	}
 
-	public Optional<Resource[]> getContextFilter() {
+	public Optional<Resource[]> getContextMask() {
 		// Make sure we clone
 		return Optional.ofNullable(contextFilter).map(f -> f.clone());		
 	}


Mime
View raw message