commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [1/3] incubator-commonsrdf git commit: ModelGraphImpl
Date Fri, 03 Jun 2016 13:56:31 GMT
Repository: incubator-commonsrdf
Updated Branches:
  refs/heads/rdf4j 99bd16f65 -> 6c5988d80


ModelGraphImpl


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

Branch: refs/heads/rdf4j
Commit: b03ee87294091fb89b00ed21a40ff5747af0ee91
Parents: 99bd16f
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Jun 3 14:29:23 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Jun 3 14:29:23 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/rdf4j/RDF4JTermFactory.java     |   4 +-
 .../commons/rdf/rdf4j/impl/GraphImpl.java       | 127 -------------------
 .../commons/rdf/rdf4j/impl/ModelGraphImpl.java  | 127 +++++++++++++++++++
 3 files changed, 129 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/b03ee872/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
index 125a46c..1b59c6f 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
@@ -30,7 +30,7 @@ import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.api.RDFTermFactory;
 import org.apache.commons.rdf.api.Triple;
 import org.apache.commons.rdf.rdf4j.impl.BlankNodeImpl;
-import org.apache.commons.rdf.rdf4j.impl.GraphImpl;
+import org.apache.commons.rdf.rdf4j.impl.ModelGraphImpl;
 import org.apache.commons.rdf.rdf4j.impl.IRIImpl;
 import org.apache.commons.rdf.rdf4j.impl.LiteralImpl;
 import org.apache.commons.rdf.rdf4j.impl.QuadImpl;
@@ -172,7 +172,7 @@ public class RDF4JTermFactory implements RDFTermFactory {
 	 * @return Adapted {@link Graph}.
 	 */
 	public RDF4JGraph asRDFTermGraph(Model model) {
-		return new GraphImpl(model);
+		return new ModelGraphImpl(model);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/b03ee872/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/GraphImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/GraphImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/GraphImpl.java
deleted file mode 100644
index bf3aad2..0000000
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/GraphImpl.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.rdf.rdf4j.impl;
-
-import java.util.Optional;
-import java.util.stream.Stream;
-
-import org.apache.commons.rdf.api.BlankNodeOrIRI;
-import org.apache.commons.rdf.api.RDFTerm;
-import org.apache.commons.rdf.api.Triple;
-import org.apache.commons.rdf.rdf4j.RDF4JGraph;
-import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
-import org.apache.commons.rdf.rdf4j.RDF4JTriple;
-import org.eclipse.rdf4j.model.Model;
-import org.eclipse.rdf4j.model.Resource;
-import org.eclipse.rdf4j.repository.Repository;
-
-public final class GraphImpl implements RDF4JGraph {
-	
-	private Model model;
-	private RDF4JTermFactory rdf4jTermFactory;
-
-	public GraphImpl(Model model) {
-		this.model = model;	
-		this.rdf4jTermFactory = new RDF4JTermFactory();
-	}
-
-	public GraphImpl(Model model, RDF4JTermFactory 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);
-	}
-	
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/b03ee872/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
new file mode 100644
index 0000000..d016837
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rdf.rdf4j.impl;
+
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.Triple;
+import org.apache.commons.rdf.rdf4j.RDF4JGraph;
+import org.apache.commons.rdf.rdf4j.RDF4JTermFactory;
+import org.apache.commons.rdf.rdf4j.RDF4JTriple;
+import org.eclipse.rdf4j.model.Model;
+import org.eclipse.rdf4j.model.Resource;
+import org.eclipse.rdf4j.repository.Repository;
+
+public final class ModelGraphImpl implements RDF4JGraph {
+	
+	private Model model;
+	private RDF4JTermFactory rdf4jTermFactory;
+
+	public ModelGraphImpl(Model model) {
+		this.model = model;	
+		this.rdf4jTermFactory = new RDF4JTermFactory();
+	}
+
+	public ModelGraphImpl(Model model, RDF4JTermFactory 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);
+	}
+	
+}
\ No newline at end of file


Mime
View raw message