commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [2/6] incubator-commonsrdf git commit: Added RDF4J interfaces
Date Tue, 03 May 2016 23:36:25 GMT
Added RDF4J interfaces

to expose asValue(), asModel(), asStatement()


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

Branch: refs/heads/rdf4j
Commit: 71b5893f1772f37f3ad980e98935c1ce088bc578
Parents: d55717a
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Wed May 4 00:03:15 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Wed May 4 00:03:15 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/rdf4j/RDF4JBlankNode.java       | 23 ++++++++++
 .../apache/commons/rdf/rdf4j/RDF4JGraph.java    | 25 +++++++++++
 .../org/apache/commons/rdf/rdf4j/RDF4JIRI.java  | 22 ++++++++++
 .../apache/commons/rdf/rdf4j/RDF4JLiteral.java  | 22 ++++++++++
 .../org/apache/commons/rdf/rdf4j/RDF4JTerm.java | 25 +++++++++++
 .../apache/commons/rdf/rdf4j/RDF4JTriple.java   | 25 +++++++++++
 .../commons/rdf/rdf4j/Rdf4JRDFTermFactory.java  | 46 ++++++++++----------
 .../commons/rdf/rdf4j/MemoryGraphTest.java      |  5 ---
 8 files changed, 166 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/71b5893f/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java
new file mode 100644
index 0000000..1e28228
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JBlankNode.java
@@ -0,0 +1,23 @@
+/**
+ * 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;
+
+public interface RDF4JBlankNode 
+	extends RDF4JTerm<org.openrdf.model.BNode>, org.apache.commons.rdf.api.BlankNode {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/71b5893f/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
new file mode 100644
index 0000000..1d81282
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
@@ -0,0 +1,25 @@
+/**
+ * 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;
+
+import org.apache.commons.rdf.api.Graph;
+import org.openrdf.model.Model;
+
+public interface RDF4JGraph extends Graph {
+	public Model asModel();
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/71b5893f/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java
new file mode 100644
index 0000000..fd117eb
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JIRI.java
@@ -0,0 +1,22 @@
+/**
+ * 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;
+
+public interface RDF4JIRI 
+	extends RDF4JTerm<org.openrdf.model.IRI>, org.apache.commons.rdf.api.IRI {
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/71b5893f/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java
new file mode 100644
index 0000000..8a3877d
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JLiteral.java
@@ -0,0 +1,22 @@
+/**
+ * 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;
+
+public interface RDF4JLiteral 
+	extends RDF4JTerm<org.openrdf.model.Literal>, org.apache.commons.rdf.api.Literal {
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/71b5893f/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTerm.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTerm.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTerm.java
new file mode 100644
index 0000000..4fee79c
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTerm.java
@@ -0,0 +1,25 @@
+/**
+ * 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;
+
+import org.apache.commons.rdf.api.RDFTerm;
+import org.openrdf.model.Value;
+
+public interface RDF4JTerm<T extends Value> extends RDFTerm {
+	public T asValue();
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/71b5893f/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java
new file mode 100644
index 0000000..dfe9419
--- /dev/null
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTriple.java
@@ -0,0 +1,25 @@
+/**
+ * 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;
+
+import org.apache.commons.rdf.api.Triple;
+import org.openrdf.model.Statement;
+
+public interface RDF4JTriple extends Triple {
+	public Statement asStatement();
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/71b5893f/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactory.java
index 938aae1..963f6d2 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/Rdf4JRDFTermFactory.java
@@ -45,7 +45,7 @@ import org.openrdf.rio.turtle.TurtleUtil;
 
 public class Rdf4JRDFTermFactory implements RDFTermFactory {
 	
-	public abstract class RDFTermImpl<T extends Value> implements RDFTerm {
+	private abstract class RDFTermImpl<T extends Value> implements RDF4JTerm<T>
{
 		T value;
 
 		public T asValue() { 
@@ -57,7 +57,7 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 		}
 	}
 	
-	public final class GraphImpl implements org.apache.commons.rdf.api.Graph {
+	private final class GraphImpl implements RDF4JGraph {
 		
 		private Model model;
 
@@ -143,7 +143,7 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 		}
 	}
 
-	public final class TripleImpl implements Triple {
+	private final class TripleImpl implements Triple, RDF4JTriple {
 		private final Statement statement;
 
 		TripleImpl(Statement statement) {
@@ -191,8 +191,8 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 		}
 	}
 
-	public final class IRIImpl extends RDFTermImpl<org.openrdf.model.IRI> 
-		implements org.apache.commons.rdf.api.IRI {
+	private final class IRIImpl extends RDFTermImpl<org.openrdf.model.IRI> 
+		implements RDF4JIRI {
 
 		IRIImpl(org.openrdf.model.IRI iri) {
 			super(iri);			
@@ -232,10 +232,12 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 		
 	}
 
-	public final class LiteralImpl 
+	private final class LiteralImpl 
 		extends RDFTermImpl<org.openrdf.model.Literal>
-		implements org.apache.commons.rdf.api.Literal {
+	    implements RDF4JLiteral {		
 
+		private static final String QUOTE = "\"";
+		
 		LiteralImpl(org.openrdf.model.Literal literal) {
 			super(literal);			
 		}
@@ -290,8 +292,8 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 		}
 	}
 
-	public final class BlankNodeImpl extends RDFTermImpl<BNode>
-		implements BlankNode {
+	private final class BlankNodeImpl extends RDFTermImpl<BNode>
+		implements RDF4JBlankNode {
 		
 		BlankNodeImpl(BNode bNode) {
 			super(bNode);			
@@ -346,7 +348,7 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 		}
 	}
 
-	private static final String QUOTE = "\"";
+	
 
 	private ValueFactory valueFactory;
 	
@@ -361,21 +363,21 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 	}	
 	
 	@Override
-	public BlankNode createBlankNode() throws UnsupportedOperationException {
+	public BlankNodeImpl createBlankNode() throws UnsupportedOperationException {
 		BNode bnode = valueFactory.createBNode();
-		return (BlankNode)asRDFTerm(bnode);
+		return (BlankNodeImpl)asRDFTerm(bnode);
 	}
 	
 	@Override
-	public BlankNode createBlankNode(String name) throws UnsupportedOperationException {
+	public BlankNodeImpl createBlankNode(String name) throws UnsupportedOperationException {
 		BNode bnode = valueFactory.createBNode(name);
-		return (BlankNode)asRDFTerm(bnode);
+		return (BlankNodeImpl)asRDFTerm(bnode);
 	}
 	
 	@Override
-	public org.apache.commons.rdf.api.Literal createLiteral(String lexicalForm) throws IllegalArgumentException,
UnsupportedOperationException {
+	public LiteralImpl createLiteral(String lexicalForm) throws IllegalArgumentException, UnsupportedOperationException
{
 		org.openrdf.model.Literal lit = valueFactory.createLiteral(lexicalForm);
-		return (org.apache.commons.rdf.api.Literal)asRDFTerm(lit);
+		return (LiteralImpl)asRDFTerm(lit);
 	}
 
 	@Override
@@ -394,12 +396,12 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 	}
 	
 	@Override
-	public org.apache.commons.rdf.api.IRI createIRI(String iri) throws IllegalArgumentException,
UnsupportedOperationException {
-		return (org.apache.commons.rdf.api.IRI) asRDFTerm(valueFactory.createIRI(iri));
+	public RDF4JIRI createIRI(String iri) throws IllegalArgumentException, UnsupportedOperationException
{
+		return (RDF4JIRI) asRDFTerm(valueFactory.createIRI(iri));
 	}
 	
 	@Override
-	public org.apache.commons.rdf.api.Graph createGraph() throws UnsupportedOperationException
{
+	public GraphImpl createGraph() throws UnsupportedOperationException {
 		return asRDFTermGraph(new LinkedHashModel());
 	}
 	
@@ -453,15 +455,15 @@ public class Rdf4JRDFTermFactory implements RDFTermFactory {
 		throw new IllegalArgumentException("RDFTerm was not an IRI, Literal or BlankNode: " + object.getClass());
 	}
 
-	public org.apache.commons.rdf.api.Graph asRDFTermGraph(Model model) {
+	public GraphImpl asRDFTermGraph(Model model) {
 		return new GraphImpl(model);
 	}
 
-	public Triple asTriple(final Statement statement) {
+	public RDF4JTriple asTriple(final Statement statement) {
 		return new TripleImpl(statement);
 	}
 
-	public RDFTerm asRDFTerm(final org.openrdf.model.Value value) {		
+	public RDF4JTerm<?> asRDFTerm(final org.openrdf.model.Value value) {		
 		if (value instanceof BNode) {
 			return new BlankNodeImpl((BNode) value);
 		}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/71b5893f/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 4666c60..8757193 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
@@ -18,13 +18,8 @@
 package org.apache.commons.rdf.rdf4j;
 
 import org.apache.commons.rdf.api.AbstractGraphTest;
-import org.apache.commons.rdf.api.Graph;
 import org.apache.commons.rdf.api.RDFTermFactory;
-import org.junit.Ignore;
-import org.openrdf.sail.NotifyingSailConnection;
-import org.openrdf.sail.memory.MemoryStore;
 import org.openrdf.sail.memory.model.MemValueFactory;
-import org.openrdf.sail.model.SailModel;
 
 public class MemoryGraphTest extends AbstractGraphTest {
 


Mime
View raw message