commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [11/19] incubator-commonsrdf git commit: TripleOrQuad -> TripleLike, GraphLike
Date Mon, 05 Sep 2016 15:53:55 GMT
TripleOrQuad -> TripleLike, GraphLike

TripleLike is a generalized Triple (e.g. as seen in Jena), supporting
any RDFTerm in any of the subject/predicate/object positions.
This can be useful for parsers, and also serves as a common
super-type for Quad and Triple.

Equivalently, QuadLike extends TripleLike as a generalized Quad, supporting
any RDFTerm as its graphName.


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

Branch: refs/heads/master
Commit: bc639bbd3b65ed6802dfdac14a53c9f96162bf32
Parents: 839a642
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Thu Jun 2 11:41:04 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Thu Jun 2 11:41:04 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/api/Quad.java   |  2 +-
 .../org/apache/commons/rdf/api/QuadLike.java    | 63 +++++++++++++++++++
 .../java/org/apache/commons/rdf/api/Triple.java |  2 +-
 .../org/apache/commons/rdf/api/TripleLike.java  | 65 ++++++++++++++++++++
 .../apache/commons/rdf/api/TripleOrQuad.java    | 64 -------------------
 5 files changed, 130 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/bc639bbd/api/src/main/java/org/apache/commons/rdf/api/Quad.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/Quad.java b/api/src/main/java/org/apache/commons/rdf/api/Quad.java
index 7ccd0d1..fa9298e 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/Quad.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/Quad.java
@@ -32,7 +32,7 @@ import java.util.Optional;
  *      1.1: On Semantics of RDF Datasets</a>
  * @see <a href="http://www.w3.org/TR/rdf11-concepts/#section-dataset"> </a>
  */
-public interface Quad extends TripleOrQuad {
+public interface Quad extends QuadLike<BlankNodeOrIRI,IRI,RDFTerm,BlankNodeOrIRI> {
 
 	/**
 	 * The graph name (graph label) of this quad, if present.

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/bc639bbd/api/src/main/java/org/apache/commons/rdf/api/QuadLike.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/QuadLike.java b/api/src/main/java/org/apache/commons/rdf/api/QuadLike.java
new file mode 100644
index 0000000..a47e32b
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/QuadLike.java
@@ -0,0 +1,63 @@
+/**
+ * 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.api;
+
+import java.util.Optional;
+
+/**
+ * A generalised "quad-like" interface, extended by {@link Quad}.
+ * <p>
+ * A QuadLike has at least a 
+ * {@link #getSubject()}, {@link #getPredicate()} and 
+ * {@link #getObject()}, and a {@link #getGraphName()}, 
+ * but unlike a {@link Quad} does not have a
+ * formalised {@link Quad#equals(Object)} semantics, and allow
+ * generalised quads (e.g. a BlankNode as predicate).
+ * <p>
+ * Implementations should specialise which RDFTerm 
+ * subclasses they return for subject {@link S}, 
+ * predicate {@link P}, object {@link O} and graph name {@link G}.
+ * <p>
+ * @see Quad
+ */
+public interface QuadLike <S extends RDFTerm, P extends RDFTerm, O extends RDFTerm, G
extends RDFTerm> 
+	extends TripleLike<S,P,O> {
+
+
+	/**
+	 * The graph name (graph label) of this quad, if present.
+	 * 
+	 * If {@link Optional#isPresent()}, then the {@link Optional#get()} 
+	 * indicate the
+	 * <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-named-graph">graph
+	 * name of this Quad. If the graph name is not present (e.g. the value is
+	 * {@link Optional#empty()}), it indicates that this Quad is in the
+	 * <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph">default
+	 * graph.
+	 *
+	 * @return If {@link Optional#isPresent()}, the graph name
+	 *         of this quad, otherwise. The graph name is typically an
+	 *         {@link IRI} or {@link BlankNode}.
+	 *         {@link Optional#empty()}, indicating the default graph.
+	 * 
+	 * @see <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset">RDF-
+	 *      1.1 Dataset</a>
+	 */
+	Optional<G> getGraphName();
+	
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/bc639bbd/api/src/main/java/org/apache/commons/rdf/api/Triple.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/Triple.java b/api/src/main/java/org/apache/commons/rdf/api/Triple.java
index 0725913..dcbb509 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/Triple.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/Triple.java
@@ -28,7 +28,7 @@ import java.util.Objects;
  * @see <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple" >RDF-1.1
  * Triple</a>
  */
-public interface Triple extends TripleOrQuad {
+public interface Triple extends TripleLike<BlankNodeOrIRI, IRI, RDFTerm> {
 
     /**
      * The subject of this triple, which may be either a {@link BlankNode} or an

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/bc639bbd/api/src/main/java/org/apache/commons/rdf/api/TripleLike.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/TripleLike.java b/api/src/main/java/org/apache/commons/rdf/api/TripleLike.java
new file mode 100644
index 0000000..1ed75d0
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/TripleLike.java
@@ -0,0 +1,65 @@
+/**
+ * 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.api;
+
+/**
+ * A generalised "triple-like" interface, extended by {@link Triple} and {@link Quad}.
+ * <p>
+ * A TripleLike has at least a 
+ * {@link #getSubject()}, {@link #getPredicate()} and 
+ * {@link #getObject()}, but unlike a {@link Triple} does not have a
+ * formalised {@link Triple#equals(Object)} semantics, and allow
+ * generalised triples (e.g. a BlankNode as predicate).
+ * <p>
+ * Implementations should specialise which RDFTerms subclasses 
+ * they return for subject, predicate and object.
+ * <p>
+ * @see Triple
+ * @see Quad
+ * @see QuadLike
+ * 
+ */
+public interface TripleLike <S extends RDFTerm, P extends RDFTerm, O extends RDFTerm>
{
+
+    /**
+     * The subject of this statement.
+     *
+     * @return The subject, typically an {@link IRI} or {@link BlankNode}.
+     * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-subject">RDF-1.1
+     * Triple subject</a>
+     */
+    S getSubject();
+
+    /**
+     * The predicate of this statement.
+     *
+     * @return The predicate, typically an {@link IRI}.
+     * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-predicate">RDF-1.1
+     * Triple predicate</a>
+     */
+    P getPredicate();
+
+    /**
+     * The object of this statement.
+     *
+     * @return The object, typically an {@link IRI}, {@link BlankNode} or {@link Literal}.
+     * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-object">RDF-1.1
+     * Triple object</a>
+     */
+    O getObject();
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/bc639bbd/api/src/main/java/org/apache/commons/rdf/api/TripleOrQuad.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/TripleOrQuad.java b/api/src/main/java/org/apache/commons/rdf/api/TripleOrQuad.java
deleted file mode 100644
index 6a86447..0000000
--- a/api/src/main/java/org/apache/commons/rdf/api/TripleOrQuad.java
+++ /dev/null
@@ -1,64 +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.api;
-
-/**
- * Common "triple-like" interface for {@link Triple} and {@link Quad}
- * <p>
- * A TripleOrQuad has at least a 
- * {@link #getSubject()}, {@link #getPredicate()} and 
- * {@link #getObject()}, but unlike a {@link Triple} does not have a
- * formalised {@link Triple#equals(Object)} semantics, and does not 
- * necessarily have a {@link Quad#getGraphName()}
- * <p>
- * Implementations of this interface SHOULD also implement {@link Triple}
- * or {@link Quad}, but MUST NOT implement both interfaces.
- */
-public interface TripleOrQuad {
-
-    /**
-     * The subject of this triple/quad, which may be either a {@link BlankNode} or an
-     * {@link IRI}, which are represented in Commons RDF by the interface
-     * {@link BlankNodeOrIRI}.
-     *
-     * @return The subject {@link BlankNodeOrIRI} of this triple/quad.
-     * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-subject">RDF-1.1
-     * Triple subject</a>
-     */
-    BlankNodeOrIRI getSubject();
-
-    /**
-     * The predicate {@link IRI} of this triple/quad.
-     *
-     * @return The predicate {@link IRI} of this triple/quad.
-     * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-predicate">RDF-1.1
-     * Triple predicate</a>
-     */
-    IRI getPredicate();
-
-    /**
-     * The object of this triple/quad, which may be either a {@link BlankNode}, an
-     * {@link IRI}, or a {@link Literal}, which are represented in Commons RDF
-     * by the interface {@link RDFTerm}.
-     *
-     * @return The object {@link RDFTerm} of this triple/quad.
-     * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-object">RDF-1.1
-     * Triple object</a>
-     */
-    RDFTerm getObject();
-}


Mime
View raw message