You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commonsrdf.apache.org by wi...@apache.org on 2015/03/27 19:15:06 UTC
[08/50] [abbrv] incubator-commonsrdf git commit: Rename source code
directories to be shorter
Rename source code directories to be shorter
Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/88e701d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/88e701d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/88e701d3
Branch: refs/heads/master
Commit: 88e701d3d2882119c779390e637de0d765ac022e
Parents: e41ce2a
Author: Peter Ansell <p_...@yahoo.com>
Authored: Mon Jan 26 15:24:01 2015 +1100
Committer: Peter Ansell <p_...@yahoo.com>
Committed: Mon Jan 26 15:25:06 2015 +1100
----------------------------------------------------------------------
api/pom.xml | 95 +++++
.../com/github/commonsrdf/api/BlankNode.java | 80 ++++
.../github/commonsrdf/api/BlankNodeOrIRI.java | 22 ++
.../java/com/github/commonsrdf/api/Graph.java | 143 +++++++
.../java/com/github/commonsrdf/api/IRI.java | 33 ++
.../java/com/github/commonsrdf/api/Literal.java | 69 ++++
.../java/com/github/commonsrdf/api/RDFTerm.java | 36 ++
.../github/commonsrdf/api/RDFTermFactory.java | 256 +++++++++++++
.../java/com/github/commonsrdf/api/Triple.java | 58 +++
api/src/main/patches/java6.patch | 53 +++
.../resources/commons-rdf-class-diagram.png | Bin 0 -> 10257 bytes
.../commonsrdf/api/AbstractGraphTest.java | 275 ++++++++++++++
.../api/AbstractRDFTermFactoryTest.java | 377 +++++++++++++++++++
commons-rdf-api/pom.xml | 95 -----
.../com/github/commonsrdf/api/BlankNode.java | 80 ----
.../github/commonsrdf/api/BlankNodeOrIRI.java | 22 --
.../java/com/github/commonsrdf/api/Graph.java | 143 -------
.../java/com/github/commonsrdf/api/IRI.java | 33 --
.../java/com/github/commonsrdf/api/Literal.java | 69 ----
.../java/com/github/commonsrdf/api/RDFTerm.java | 36 --
.../github/commonsrdf/api/RDFTermFactory.java | 256 -------------
.../java/com/github/commonsrdf/api/Triple.java | 58 ---
commons-rdf-api/src/main/patches/java6.patch | 53 ---
.../resources/commons-rdf-class-diagram.png | Bin 10257 -> 0 bytes
.../commonsrdf/api/AbstractGraphTest.java | 275 --------------
.../api/AbstractRDFTermFactoryTest.java | 377 -------------------
commons-rdf-simple/pom.xml | 45 ---
.../github/commonsrdf/simple/BlankNodeImpl.java | 102 -----
.../com/github/commonsrdf/simple/GraphImpl.java | 135 -------
.../com/github/commonsrdf/simple/IRIImpl.java | 64 ----
.../github/commonsrdf/simple/LiteralImpl.java | 130 -------
.../commonsrdf/simple/SimpleRDFTermFactory.java | 77 ----
.../github/commonsrdf/simple/TripleImpl.java | 138 -------
.../github/commonsrdf/simple/package-info.java | 31 --
.../commonsrdf/simple/DefaultGraphTest.java | 48 ---
.../simple/DefaultRDFTermFactoryTest.java | 33 --
.../commonsrdf/simple/SimpleGraphTest.java | 30 --
.../SimpleNoRelativeIRIRDFTermFactoryTest.java | 44 ---
.../simple/SimpleRDFTermFactoryTest.java | 26 --
.../commonsrdf/simple/TestWritingGraph.java | 96 -----
pom.xml | 10 +-
simple/pom.xml | 45 +++
.../github/commonsrdf/simple/BlankNodeImpl.java | 102 +++++
.../com/github/commonsrdf/simple/GraphImpl.java | 135 +++++++
.../com/github/commonsrdf/simple/IRIImpl.java | 64 ++++
.../github/commonsrdf/simple/LiteralImpl.java | 130 +++++++
.../commonsrdf/simple/SimpleRDFTermFactory.java | 77 ++++
.../github/commonsrdf/simple/TripleImpl.java | 138 +++++++
.../github/commonsrdf/simple/package-info.java | 31 ++
.../commonsrdf/simple/DefaultGraphTest.java | 48 +++
.../simple/DefaultRDFTermFactoryTest.java | 33 ++
.../commonsrdf/simple/SimpleGraphTest.java | 30 ++
.../SimpleNoRelativeIRIRDFTermFactoryTest.java | 44 +++
.../simple/SimpleRDFTermFactoryTest.java | 26 ++
.../commonsrdf/simple/TestWritingGraph.java | 96 +++++
55 files changed, 2501 insertions(+), 2501 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/pom.xml
----------------------------------------------------------------------
diff --git a/api/pom.xml b/api/pom.xml
new file mode 100644
index 0000000..2da2f8e
--- /dev/null
+++ b/api/pom.xml
@@ -0,0 +1,95 @@
+<!--
+
+ Licensed 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>com.github.commons-rdf</groupId>
+ <artifactId>commons-rdf</artifactId>
+ <version>0.0.3-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>commons-rdf-api</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Commons RDF: API</name>
+ <description>Commons Java API for RDF 1.1</description>
+
+ <profiles>
+ <profile>
+ <id>java6</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-patch-plugin</artifactId>
+ <version>1.1.1</version>
+ <configuration>
+ <strip>1</strip>
+ <patches>
+ <patch>java6.patch</patch>
+ </patches>
+ </configuration>
+ <executions>
+ <execution>
+ <id>patch</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>apply</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.3.1</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <executable>git</executable>
+ <arguments>
+ <argument>checkout</argument>
+ <argument>src/main/java/com/github/commonsrdf/api/Graph.java</argument>
+ <argument>src/main/java/com/github/commonsrdf/api/Literal.java</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>17.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/java/com/github/commonsrdf/api/BlankNode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/BlankNode.java b/api/src/main/java/com/github/commonsrdf/api/BlankNode.java
new file mode 100644
index 0000000..399381a
--- /dev/null
+++ b/api/src/main/java/com/github/commonsrdf/api/BlankNode.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+/**
+ * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node" >RDF-1.1
+ * Blank Node</a>, as defined by <a href=
+ * "http://www.w3.org/TR/rdf11-concepts/#section-blank-nodes" >RDF-1.1 Concepts
+ * and Abstract Syntax</a>, a W3C Recommendation published on 25 February 2014.<br>
+ *
+ * Note that: Blank nodes are disjoint from IRIs and literals. Otherwise,
+ * the set of possible blank nodes is arbitrary. RDF makes no reference to any
+ * internal structure of blank nodes.
+ *
+ * Also note that: Blank node identifiers are local identifiers that are
+ * used in some concrete RDF syntaxes or RDF store implementations. They are
+ * always locally scoped to the file or RDF store, and are not persistent or
+ * portable identifiers for blank nodes. Blank node identifiers are not part of
+ * the RDF abstract syntax, but are entirely dependent on the concrete syntax or
+ * implementation. The syntactic restrictions on blank node identifiers, if any,
+ * therefore also depend on the concrete RDF syntax or implementation.
+ * Implementations that handle blank node identifiers in concrete syntaxes need
+ * to be careful not to create the same blank node from multiple occurrences of
+ * the same blank node identifier except in situations where this is supported
+ * by the syntax.
+ *
+ * @see <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node">RDF-1.1
+ * Blank Node</a>
+ */
+public interface BlankNode extends BlankNodeOrIRI {
+
+ /**
+ * Return a <a href=
+ * "http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier">label</a>
+ * for the blank node. This is not a serialization/syntax label. It should
+ * be uniquely identifying within the local scope it is created in but has
+ * no uniqueness guarantees other than that.
+ *
+ * In particular, the existence of two objects of type {@link BlankNode}
+ * with the same value returned from {@link #internalIdentifier()} are not
+ * equivalent unless they are known to have been created in the same local
+ * scope.
+ *
+ * An example of a local scope may be an instance of a Java Virtual Machine
+ * (JVM). In the context of a JVM instance, an implementor may support
+ * insertion and removal of {@link Triple} objects containing Blank Nodes
+ * without modifying the blank node labels.
+ *
+ * Another example of a local scope may be a <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#section-rdf-graph">Graph</a>
+ * or <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#section-dataset">Dataset</a>
+ * created from a single document. In this context, an implementor should
+ * reasonably guarantee that the label returned by getLabel only maps to
+ * equivalent blank nodes in the same Graph or Dataset, but they may not
+ * guarantee that it is unique for the JVM instance. In this case, the
+ * implementor may support a mechanism to provide a mapping for blank nodes
+ * between Graph or Dataset instances to guarantee their uniqueness.
+ *
+ * If implementors support <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#section-skolemization"
+ * >Skolemisation</a>, they may map instances of {@link BlankNode} objects
+ * to {@link IRI} objects to reduce scoping issues.
+ *
+ * @return An internal, system identifier for the {@link BlankNode}.
+ */
+ String internalIdentifier();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/java/com/github/commonsrdf/api/BlankNodeOrIRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/BlankNodeOrIRI.java b/api/src/main/java/com/github/commonsrdf/api/BlankNodeOrIRI.java
new file mode 100644
index 0000000..38d5ef6
--- /dev/null
+++ b/api/src/main/java/com/github/commonsrdf/api/BlankNodeOrIRI.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+/**
+ * This interface represents the {@link RDFTerm}s that may be used in the
+ * subject position of an RDF-1.1 {@link Triple}, including {@link BlankNode}
+ * and {@link IRI}.
+ */
+public interface BlankNodeOrIRI extends RDFTerm {
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/java/com/github/commonsrdf/api/Graph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/Graph.java b/api/src/main/java/com/github/commonsrdf/api/Graph.java
new file mode 100644
index 0000000..4ba45e9
--- /dev/null
+++ b/api/src/main/java/com/github/commonsrdf/api/Graph.java
@@ -0,0 +1,143 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+import java.util.stream.Stream;
+
+/**
+ * An <a href="http://www.w3.org/TR/rdf11-concepts/#section-rdf-graph"> RDF 1.1
+ * Graph</a>, a set of RDF triples, as defined by <a
+ * href="http://www.w3.org/TR/rdf11-concepts/" >RDF-1.1 Concepts and Abstract
+ * Syntax</a>, a W3C Recommendation published on 25 February 2014.
+ */
+public interface Graph {
+
+ /**
+ * Add a triple to the graph.
+ *
+ * @param triple
+ * The triple to add
+ */
+ void add(Triple triple);
+
+ /**
+ * Add a triple to the graph.
+ *
+ * @param subject
+ * The triple subject
+ * @param predicate
+ * The triple predicate
+ * @param object
+ * The triple object
+ */
+ void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
+
+ /**
+ * Check if graph contains triple.
+ *
+ * @param triple
+ * The triple to check.
+ * @return True if the Graph contains the given Triple.
+ */
+ boolean contains(Triple triple);
+
+ /**
+ * Check if graph contains a pattern of triples.
+ *
+ * @param subject
+ * The triple subject (null is a wildcard)
+ * @param predicate
+ * The triple predicate (null is a wildcard)
+ * @param object
+ * The triple object (null is a wildcard)
+ * @return True if the Graph contains any Triples that match
+ * the given pattern.
+ */
+ boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
+
+ /**
+ * Remove a concrete triple from the graph.
+ *
+ * @param triple
+ * triple to remove
+ */
+ void remove(Triple triple);
+
+ /**
+ * Remove a concrete pattern of triples from the graph.
+ *
+ * @param subject
+ * The triple subject (null is a wildcard)
+ * @param predicate
+ * The triple predicate (null is a wildcard)
+ * @param object
+ * The triple object (null is a wildcard)
+ */
+ void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
+
+ /**
+ * Clear the graph, removing all triples.
+ *
+ */
+ void clear();
+
+ /**
+ * Number of triples contained by the graph.
+ * <p>
+ * The count of a set does not include duplicates, as determined by
+ * {@link Triple#equals(Object)}.
+ *
+ * @return The number of triples in the graph
+ */
+ long size();
+
+ /**
+ * Get all triples contained by the graph.<br>
+ * <p>
+ * The iteration does not contain any duplicate triples, as determined by
+ * {@link Triple#equals(Object)}.
+ * <p>
+ * The behaviour of the Stream is not specified if add, remove, or clear,
+ * are called on the Stream before it terminates.<br>
+ * <p>
+ * Implementations may throw ConcurrentModificationException from Stream
+ * methods if they detect a conflict while the Stream is active.
+ *
+ * @return A {@link Stream} over all of the triples in the graph
+ */
+ Stream<? extends Triple> getTriples();
+
+ /**
+ * Get all triples contained by the graph matched with the pattern.
+ * <p>
+ * The iteration does not contain any duplicate triples, as determined by
+ * {@link Triple#equals(Object)}.
+ * <p>
+ * The behaviour of the Stream is not specified if add, remove, or clear,
+ * are called on the Stream before it terminates.<br>
+ * <p>
+ * Implementations may throw ConcurrentModificationException from Stream
+ * methods if they detect a conflict while the Stream is active.
+ *
+ * @param subject
+ * The triple subject (null is a wildcard)
+ * @param predicate
+ * The triple predicate (null is a wildcard)
+ * @param object
+ * The triple object (null is a wildcard)
+ * @return A {@link Stream} over the matched triples.
+ */
+ Stream<? extends Triple> getTriples(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/java/com/github/commonsrdf/api/IRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/IRI.java b/api/src/main/java/com/github/commonsrdf/api/IRI.java
new file mode 100644
index 0000000..7f9e35c
--- /dev/null
+++ b/api/src/main/java/com/github/commonsrdf/api/IRI.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+/**
+ * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-iri"
+ * >RDF-1.1 IRI</a>, as defined by <a href=
+ * "http://www.w3.org/TR/rdf11-concepts/" >RDF-1.1 Concepts
+ * and Abstract Syntax</a>, a W3C Recommendation published on 25 February 2014.<br>
+ */
+public interface IRI extends BlankNodeOrIRI {
+
+ /**
+ * Returns the IRI encoded as a native Unicode String.<br>
+ *
+ * The returned string must not include URL-encoding to escape
+ * non-ASCII characters.
+ *
+ * @return The IRI encoded as a native Unicode String.
+ */
+ String getIRIString();
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/java/com/github/commonsrdf/api/Literal.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/Literal.java b/api/src/main/java/com/github/commonsrdf/api/Literal.java
new file mode 100644
index 0000000..91485d9
--- /dev/null
+++ b/api/src/main/java/com/github/commonsrdf/api/Literal.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+import java.util.Optional;
+
+/**
+ * An RDF-1.1 Literal, as defined by <a href=
+ * "http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal" >RDF-1.1
+ * Concepts and Abstract Syntax</a>, a W3C Recommendation published on 25
+ * February 2014
+ */
+public interface Literal extends RDFTerm {
+
+ /**
+ * The lexical form of this literal, represented by a <a
+ * href="http://www.unicode.org/versions/latest/">Unicode string</a>.
+ *
+ * @return The lexical form of this literal.
+ * @see <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form">RDF-1.1
+ * Literal lexical form</a>
+ */
+ String getLexicalForm();
+
+ /**
+ * The IRI identifying the datatype that determines how the lexical form
+ * maps to a literal value.
+ *
+ * @return The datatype IRI for this literal.
+ * @see <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri">RDF-1.1
+ * Literal datatype IRI</a>
+ */
+ IRI getDatatype();
+
+ /**
+ * If and only if the datatype IRI is <a
+ * href="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
+ * >http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</a>, the language
+ * tag for this Literal is a non-empty language tag as defined by <a
+ * href="http://tools.ietf.org/html/bcp47">BCP47</a>.<br>
+ * If the datatype IRI is not <a
+ * href="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
+ * >http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</a>, this method
+ * must return {@link Optional#empty()}.
+ *
+ * @return The {@link Optional} language tag for this literal. If
+ * {@link Optional#isPresent()} returns true, the value returned by
+ * {@link Optional#get()} must be a non-empty string conforming to
+ * BCP47.
+ * @see <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#dfn-language-tag">RDF-1.1
+ * Literal language tag</a>
+ */
+ Optional<String> getLanguageTag();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/java/com/github/commonsrdf/api/RDFTerm.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/RDFTerm.java b/api/src/main/java/com/github/commonsrdf/api/RDFTerm.java
new file mode 100644
index 0000000..5530e67
--- /dev/null
+++ b/api/src/main/java/com/github/commonsrdf/api/RDFTerm.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+/**
+ * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term" >RDF-1.1
+ * Term</a>, as defined by <a href= "http://www.w3.org/TR/rdf11-concepts/"
+ * >RDF-1.1 Concepts and Abstract Syntax</a>, a W3C Recommendation published on
+ * 25 February 2014.<br>
+ *
+ * @see <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term" >RDF-1.1
+ * Term</a>
+ */
+public interface RDFTerm {
+
+ /**
+ * Return the term serialised as specified by the RDF-1.1 N-Triples Canonical form.
+ *
+ * @return The term serialised as RDF-1.1 N-Triples.
+ * @see <a href="http://www.w3.org/TR/n-triples/#canonical-ntriples">
+ * RDF-1.1 N-Triples Canonical form</a>
+ */
+ String ntriplesString();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java b/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java
new file mode 100644
index 0000000..29486c9
--- /dev/null
+++ b/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java
@@ -0,0 +1,256 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+import java.util.Locale;
+
+/**
+ * Factory for creating RDFTerm and Graph instances.
+ * <p>
+ * It is not specified how an implementation should provide a RDFTermFactory.
+ * <p>
+ * If an implementation does not support a particular method (e.g. it requires
+ * additional parameters or can't create graphs), then it MAY throw
+ * UnsupportedOperationException, as provided by the default implementations
+ * here.
+ * <p>
+ * If a factory method does not allow or support a provided parameter, e.g.
+ * because an IRI is considered invalid, then it SHOULD throw
+ * IllegalArgumentException.
+ *
+ *
+ * @see RDFTerm
+ * @see Graph
+ *
+ */
+public interface RDFTermFactory {
+
+ /**
+ * Create a new blank node.
+ * <p>
+ * Two BlankNodes created with this method MUST NOT be equal.
+ * <p>
+ * If supported, the {@link BlankNode#internalIdentifier()} of the returned
+ * blank node MUST be an auto-generated value.
+ *
+ * @return A new BlankNode
+ * @throws UnsupportedOperationException
+ */
+ default BlankNode createBlankNode() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "createBlankNode() not supported");
+ }
+
+ /**
+ * Create a blank node for the given internal identifier.
+ * <p>
+ * Two BlankNodes created with the same identifier using this method MUST be
+ * equal if they are in the same local scope (e.g. in the same Graph). See
+ * {@link BlankNode#equals(Object)}.
+ * <p>
+ * If supported, the {@link BlankNode#internalIdentifier()} of the returned
+ * blank node SHOULD be equal to the provided identifier.
+ *
+ * @param identifier
+ * An internal identifier for the blank node.
+ * @return A BlankNode for the given identifier
+ * @throws IllegalArgumentException
+ * if the identifier is not acceptable, e.g. was empty or
+ * contained unsupported characters.
+ * @throws UnsupportedOperationException
+ * if createBlankNode(String) is not implemented or supported.
+ */
+ default BlankNode createBlankNode(String identifier)
+ throws IllegalArgumentException, UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "createBlankNode(String) not supported");
+ }
+
+ /**
+ * Create a new graph.
+ * <p>
+ * It is undefined if the graph will be persisted by any underlying storage
+ * mechanism.
+ *
+ * @return A new Graph
+ * @throws UnsupportedOperationException
+ * if createGraph() is not implemented or supported
+ */
+ default Graph createGraph() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("createGraph() not supported");
+ }
+
+ /**
+ * Create an IRI from a (possibly escaped) String.
+ * <p>
+ * The provided iri string MUST be valid according to the <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#dfn-iri">W3C RDF-1.1 IRI</a>
+ * definition.
+ *
+ * @param iri
+ * Internationalized Resource Identifier
+ * @return A new IRI
+ * @throws IllegalArgumentException
+ * If the provided string is not acceptable, e.g. does not
+ * conform to the RFC3987 syntax.
+ * @throws UnsupportedOperationException
+ * If the createIRI(String) method is not implemented or
+ * supported. If the method is supported, but not for the
+ * particular iri string provided (e.g. if only absolute ASCII
+ * URIs are supported by the implementation), then an
+ * IllegalArgumentException should be thrown.
+ */
+ default IRI createIRI(String iri) throws IllegalArgumentException,
+ UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "createIRI(String) not supported");
+ }
+
+ /**
+ * Create a simple literal.
+ * <p>
+ * The provided lexical form should not be escaped in any sense, e.g. should
+ * not include "quotes" unless those are part of the literal value.
+ * <p>
+ * The returned Literal MUST have a {@link Literal#getLexicalForm()} that is
+ * equal to the provided lexical form, MUST NOT have a
+ * {@link Literal#getLanguageTag()} present, and SHOULD return a
+ * {@link Literal#getDatatype()} that is equal to the IRI
+ * <code>http://www.w3.org/2001/XMLSchema#string</code>.
+ *
+ *
+ * @param lexicalForm
+ * The literal value in plain text
+ * @return The created Literal
+ * @throws IllegalArgumentException
+ * If the provided lexicalForm is not acceptable, e.g. because
+ * it is too large for an underlying storage.
+ * @throws UnsupportedOperationException
+ * If the createLiteral(String) method is not implemented or
+ * supported.
+ */
+ default Literal createLiteral(String lexicalForm)
+ throws IllegalArgumentException, UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "createLiteral(String) not supported");
+ }
+
+ /**
+ * Create a literal with the specified data type.
+ * <p>
+ * The provided lexical form should not be escaped in any sense, e.g. should
+ * not include "quotes" unless those are part of the literal value.
+ * <p>
+ * It is RECOMMENDED that the provided dataType is one of the <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#xsd-datatypes">RDF-compatible
+ * XSD types</a>.
+ * <p>
+ * The provided lexical form SHOULD be in the <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#dfn-lexical-space">lexical
+ * space</a> of the provided dataType.
+ * <p>
+ * The returned Literal SHOULD have a {@link Literal#getLexicalForm()} that
+ * is equal to the provided lexicalForm, MUST NOT have a
+ * {@link Literal#getLanguageTag()} present, and SHOULD return a
+ * {@link Literal#getDatatype()} that is equal to the provided dataType IRI.
+ *
+ * @param lexicalForm
+ * The literal value
+ * @param dataType
+ * The data type IRI for the literal value, e.g.
+ * <code>http://www.w3.org/2001/XMLSchema#integer</code>
+ * @return The created Literal
+ * @throws IllegalArgumentException
+ * If any of the provided arguments are not acceptable, e.g.
+ * because the provided dataType is not permitted.
+ * @throws UnsupportedOperationException
+ * If the createLiteral(String,IRI) method is not implemented or
+ * supported.
+ */
+ default Literal createLiteral(String lexicalForm, IRI dataType)
+ throws IllegalArgumentException, UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "createLiteral(String) not supported");
+ }
+
+ /**
+ * Create a language-tagged literal.
+ * <p>
+ * The provided lexical form should not be escaped in any sense, e.g. should
+ * not include "quotes" unless those are part of the literal value.
+ * <p>
+ * The provided language tag MUST be valid according to <a
+ * href"http://tools.ietf.org/html/bcp47">BCP47</a>, e.g. <code>en</code>.
+ * <p>
+ * The provided language tag <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string"
+ * >MAY be converted to lower case</a>.
+ * <p>
+ * The returned Literal SHOULD have a {@link Literal#getLexicalForm()} which
+ * is equal to the provided lexicalForm, MUST return a
+ * {@link Literal#getDatatype()} that is equal to the IRI
+ * <code>http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</code>, and
+ * MUST have a {@link Literal#getLanguageTag()} present which SHOULD be
+ * equal to the provided language tag (compared as
+ * {@link String#toLowerCase(Locale)} in {@link Locale#ENGLISH}).
+ *
+ * @param lexicalForm
+ * The literal value
+ * @param languageTag
+ * The non-empty language tag as defined by <a
+ * href"http://tools.ietf.org/html/bcp47">BCP47</a>
+ * @return The created Literal
+ * @throws IllegalArgumentException
+ * If the provided values are not acceptable, e.g. because the
+ * languageTag was syntactically invalid.
+ * @throws UnsupportedOperationException
+ * If the createLiteral(String,String) method is not implemented
+ * or supported.
+ */
+ default Literal createLiteral(String lexicalForm, String languageTag)
+ throws IllegalArgumentException, UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "createLiteral(String,String) not supported");
+ }
+
+ /**
+ * Create a triple.
+ * <p>
+ * The returned Triple SHOULD have a {@link Triple#getSubject()} that is
+ * equal to the provided subject, a {@link Triple#getPredicate()} that is
+ * equal to the provided predicate, and a {@link Triple#getObject()} that is
+ * equal to the provided object.
+ *
+ * @param subject
+ * The IRI or BlankNode that is the subject of the triple
+ * @param predicate
+ * The IRI that is the predicate of the triple
+ * @param object
+ * The IRI, BlankNode or Literal that is the object of the triple
+ * @return The created Triple
+ * @throws IllegalArgumentException
+ * If any of the provided arguments are not acceptable, e.g.
+ * because a Literal has a lexicalForm that is too large for an
+ * underlying storage.
+ * @throws UnsupportedOperationException
+ * if createTriple is not supported
+ */
+ default Triple createTriple(BlankNodeOrIRI subject, IRI predicate,
+ RDFTerm object) throws IllegalArgumentException,
+ UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "createTriple(BlankNodeOrIRI,IRI,RDFTerm) not supported");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/java/com/github/commonsrdf/api/Triple.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/Triple.java b/api/src/main/java/com/github/commonsrdf/api/Triple.java
new file mode 100644
index 0000000..4997aec
--- /dev/null
+++ b/api/src/main/java/com/github/commonsrdf/api/Triple.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+/**
+ * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple" >RDF-1.1
+ * Triple</a>, as defined by <a href= "http://www.w3.org/TR/rdf11-concepts/"
+ * >RDF-1.1 Concepts and Abstract Syntax</a>, a W3C Recommendation published on
+ * 25 February 2014.<br>
+ *
+ * @see <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple" >RDF-1.1
+ * Triple</a>
+ */
+public interface Triple {
+
+ /**
+ * The subject of this triple, 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.
+ * @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.
+ *
+ * @return The predicate {@link IRI} of this triple.
+ * @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, 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.
+ * @see <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-object">RDF-1.1
+ * Triple object</a>
+ */
+ RDFTerm getObject();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/patches/java6.patch
----------------------------------------------------------------------
diff --git a/api/src/main/patches/java6.patch b/api/src/main/patches/java6.patch
new file mode 100644
index 0000000..87f8e87
--- /dev/null
+++ b/api/src/main/patches/java6.patch
@@ -0,0 +1,53 @@
+diff --git a/com/github/commonsrdf/api/Graph.java b/com/github/commonsrdf/api/Graph.java
+index d55fb8c..71aca8d 100644
+--- a/com/github/commonsrdf/api/Graph.java
++++ b/com/github/commonsrdf/api/Graph.java
+@@ -1,6 +1,6 @@
+ package com.github.commonsrdf.api;
+
+-import java.util.stream.Stream;
++import java.util.Iterator;
+
+ /**
+ * An <a href="http://www.w3.org/TR/rdf11-concepts/#section-rdf-graph"> RDF 1.1
+@@ -88,15 +88,9 @@ public interface Graph {
+ /**
+ * Get all triples contained by the graph.<br>
+ *
+- * The behaviour of the Stream is not specified if add, remove, or clear,
+- * are called on the Stream before it terminates.<br>
+- *
+- * Implementations may throw ConcurrentModificationException from Stream
+- * methods if they detect a conflict while the Stream is active.
+- *
+- * @return A {@link Stream} over all of the triples in the graph.
++ * @return A {@link Iterator} over all of the triples in the graph.
+ */
+- Stream<? extends Triple> getTriples();
++ Iterator<? extends Triple> getTriples();
+
+ /**
+ * Get all triples contained by the graph matched with the pattern.
+@@ -113,8 +107,8 @@ public interface Graph {
+ * The triple predicate (null is a wildcard)
+ * @param object
+ * The triple object (null is a wildcard)
+- * @return A {@link Stream} over the matched triples.
++ * @return A {@link Iterator} over the matched triples.
+ */
+- Stream<? extends Triple> getTriples(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
++ Iterator<? extends Triple> getTriples(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
+
+ }
+diff --git a/com/github/commonsrdf/api/Literal.java b/com/github/commonsrdf/api/Literal.java
+index 30505a3..e5638f7 100644
+--- a/com/github/commonsrdf/api/Literal.java
++++ b/com/github/commonsrdf/api/Literal.java
+@@ -1,6 +1,6 @@
+ package com.github.commonsrdf.api;
+
+-import java.util.Optional;
++import com.google.common.base.Optional;
+
+ /**
+ * An RDF-1.1 Literal, as defined by <a href=
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/main/resources/commons-rdf-class-diagram.png
----------------------------------------------------------------------
diff --git a/api/src/main/resources/commons-rdf-class-diagram.png b/api/src/main/resources/commons-rdf-class-diagram.png
new file mode 100644
index 0000000..6cdd194
Binary files /dev/null and b/api/src/main/resources/commons-rdf-class-diagram.png differ
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/test/java/com/github/commonsrdf/api/AbstractGraphTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/github/commonsrdf/api/AbstractGraphTest.java b/api/src/test/java/com/github/commonsrdf/api/AbstractGraphTest.java
new file mode 100644
index 0000000..be7dfe4
--- /dev/null
+++ b/api/src/test/java/com/github/commonsrdf/api/AbstractGraphTest.java
@@ -0,0 +1,275 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Optional;
+
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test Graph implementation
+ * <p>
+ * To add to your implementation's tests, create a subclass with a name ending
+ * in <code>Test</code> and provide {@link #createFactory()} which minimally
+ * must support {@link RDFTermFactory#createGraph()} and
+ * {@link RDFTermFactory#createIRI(String)}, but ideally support all operations.
+ *
+ * @see Graph
+ * @see RDFTermFactory
+ * @see com.github.commonsrdf.simple.SimpleGraphTest
+ */
+public abstract class AbstractGraphTest {
+
+ private RDFTermFactory factory;
+ private Graph graph;
+ private IRI alice;
+ private IRI bob;
+ private IRI name;
+ private IRI knows;
+ private IRI member;
+ private BlankNode org1;
+ private BlankNode org2;
+ private Literal aliceName;
+ private Literal bobName;
+ private Literal secretClubName;
+ private Literal companyName;
+ private Triple bobNameTriple;
+
+ public abstract RDFTermFactory createFactory();
+
+ @Before
+ public void createGraphAndAdd() {
+ factory = createFactory();
+ graph = factory.createGraph();
+ assertEquals(0, graph.size());
+
+ alice = factory.createIRI("http://example.com/alice");
+ bob = factory.createIRI("http://example.com/bob");
+ name = factory.createIRI("http://xmlns.com/foaf/0.1/name");
+ knows = factory.createIRI("http://xmlns.com/foaf/0.1/knows");
+ member = factory.createIRI("http://xmlns.com/foaf/0.1/member");
+ try {
+ org1 = factory.createBlankNode("org1");
+ org2 = factory.createBlankNode("org2");
+ } catch (UnsupportedOperationException ex) {
+ // leave as null
+ }
+
+ try {
+ secretClubName = factory.createLiteral("The Secret Club");
+ companyName = factory.createLiteral("A company");
+ aliceName = factory.createLiteral("Alice");
+ bobName = factory.createLiteral("Bob", "en-US");
+ } catch (UnsupportedOperationException ex) {
+ // leave as null
+ }
+
+ if (aliceName != null) {
+ graph.add(alice, name, aliceName);
+ }
+ graph.add(alice, knows, bob);
+
+ if (org1 != null) {
+ graph.add(alice, member, org1);
+ }
+
+ if (bobName != null) {
+ try {
+ bobNameTriple = factory.createTriple(bob, name, bobName);
+ } catch (UnsupportedOperationException ex) {
+ // leave as null
+ }
+ if (bobNameTriple != null) {
+ graph.add(bobNameTriple);
+ }
+ }
+ if (org1 != null) {
+ graph.add(factory.createTriple(bob, member, org1));
+ graph.add(factory.createTriple(bob, member, org2));
+ if (secretClubName != null) {
+ graph.add(org1, name, secretClubName);
+ graph.add(org2, name, companyName);
+ }
+ }
+ }
+
+ @Test
+ public void graphToString() {
+ Assume.assumeNotNull(aliceName, companyName);
+ System.out.println(graph);
+ assertTrue(graph
+ .toString()
+ .startsWith(
+ "<http://example.com/alice> <http://xmlns.com/foaf/0.1/name> \"Alice\" ."));
+ assertTrue(graph.toString().endsWith(
+ "_:org2 <http://xmlns.com/foaf/0.1/name> \"A company\" ."));
+
+ }
+
+ @Test
+ public void size() throws Exception {
+ assertTrue(graph.size() > 0);
+ Assume.assumeNotNull(org1, org2, aliceName, bobName, secretClubName,
+ companyName, bobNameTriple);
+ // Can only reliably predict size if we could create all triples
+ assertEquals(8, graph.size());
+ }
+
+ @Test
+ public void contains() throws Exception {
+ assertFalse(graph.contains(bob, knows, alice)); // or so he claims..
+
+ assertTrue(graph.contains(alice, knows, bob));
+
+ Optional<? extends Triple> first = graph.getTriples().skip(4)
+ .findFirst();
+ Assume.assumeTrue(first.isPresent());
+ Triple existingTriple = first.get();
+ assertTrue(graph.contains(existingTriple));
+
+ Triple nonExistingTriple = factory.createTriple(bob, knows, alice);
+ assertFalse(graph.contains(nonExistingTriple));
+
+ Triple triple = null;
+ try {
+ triple = factory.createTriple(alice, knows, bob);
+ } catch (UnsupportedOperationException ex) {
+ }
+ if (triple != null) {
+ // FIXME: Should not this always be true?
+ // assertTrue(graph.contains(triple));
+ }
+ }
+
+ @Test
+ public void remove() throws Exception {
+ long fullSize = graph.size();
+ graph.remove(alice, knows, bob);
+ long shrunkSize = graph.size();
+ assertEquals(1, fullSize - shrunkSize);
+
+ graph.remove(alice, knows, bob);
+ assertEquals(shrunkSize, graph.size()); // unchanged
+
+ graph.add(alice, knows, bob);
+ graph.add(alice, knows, bob);
+ graph.add(alice, knows, bob);
+ // Undetermined size at this point -- but at least it
+ // should be bigger
+ assertTrue(graph.size() > shrunkSize);
+
+ // and after a single remove they should all be gone
+ graph.remove(alice, knows, bob);
+ assertEquals(shrunkSize, graph.size());
+
+ Optional<? extends Triple> anyTriple = graph.getTriples().findAny();
+ Assume.assumeTrue(anyTriple.isPresent());
+
+ Triple otherTriple = anyTriple.get();
+ graph.remove(otherTriple);
+ assertEquals(shrunkSize - 1, graph.size());
+ graph.remove(otherTriple);
+ assertEquals(shrunkSize - 1, graph.size()); // no change
+ graph.add(otherTriple);
+ assertEquals(shrunkSize, graph.size());
+ }
+
+ @Test
+ public void clear() throws Exception {
+ graph.clear();
+ assertFalse(graph.contains(alice, knows, bob));
+ assertEquals(0, graph.size());
+ graph.clear(); // no-op
+ assertEquals(0, graph.size());
+ }
+
+ @Test
+ public void getTriples() throws Exception {
+
+ long tripleCount = graph.getTriples().count();
+ assertTrue(tripleCount > 0);
+ assertTrue(graph.getTriples().allMatch(t -> graph.contains(t)));
+ // Check exact count
+ Assume.assumeNotNull(org1, org2, aliceName, bobName, secretClubName,
+ companyName, bobNameTriple);
+ assertEquals(8, tripleCount);
+ }
+
+ @Test
+ public void getTriplesQuery() throws Exception {
+
+ long aliceCount = graph.getTriples(alice, null, null).count();
+ assertTrue(aliceCount > 0);
+ Assume.assumeNotNull(aliceName);
+ assertEquals(3, aliceCount);
+
+ Assume.assumeNotNull(org1, org2, bobName, companyName, secretClubName);
+ assertEquals(4, graph.getTriples(null, name, null).count());
+ Assume.assumeNotNull(org1);
+ assertEquals(2, graph.getTriples(null, member, org1).count());
+ }
+
+ /**
+ * An attempt to use the Java 8 streams to look up a more complicated query.
+ *
+ * FYI, the equivalent SPARQL version (untested):
+ *
+ * <pre>
+ * SELECT ?orgName WHERE {
+ * ?org foaf:name ?orgName .
+ * ?alice foaf:member ?org .
+ * ?bob foaf:member ?org .
+ * ?alice foaf:knows ?bob .
+ * FILTER NOT EXIST { ?bob foaf:knows ?alice }
+ * }
+ * </pre>
+ *
+ * @throws Exception
+ */
+ @Test
+ public void whyJavaStreamsMightNotTakeOverFromSparql() throws Exception {
+ Assume.assumeNotNull(org1, org2, secretClubName);
+ // Find a secret organizations
+ assertEquals(
+ "\"The Secret Club\"",
+ graph.getTriples(null, knows, null)
+ // Find One-way "knows"
+ .filter(t -> !graph.contains(
+ (BlankNodeOrIRI) t.getObject(), knows,
+ t.getSubject()))
+ .map(knowsTriple -> graph
+ // and those they know, what are they member of?
+ .getTriples(
+ (BlankNodeOrIRI) knowsTriple
+ .getObject(), member, null)
+ // keep those which first-guy is a member of
+ .filter(memberTriple -> graph.contains(
+ knowsTriple.getSubject(), member,
+ // First hit is good enough
+ memberTriple.getObject())).findFirst()
+ .get().getObject())
+ // then look up the name of that org
+ .map(org -> graph
+ .getTriples((BlankNodeOrIRI) org, name, null)
+ .findFirst().get().getObject().ntriplesString())
+ .findFirst().get());
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java b/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java
new file mode 100644
index 0000000..56ec164
--- /dev/null
+++ b/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java
@@ -0,0 +1,377 @@
+/**
+ * Licensed 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 com.github.commonsrdf.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test RDFTermFactory implementation (and thus its RDFTerm implementations)
+ * <p>
+ * To add to your implementation's tests, create a subclass with a name ending
+ * in <code>Test</code> and provide {@link #createFactory()} which minimally
+ * supports one of the operations, but ideally supports all operations.
+ *
+ * @see RDFTermFactory
+ * @see com.github.commonsrdf.simple.SimpleRDFTermFactoryTest
+ */
+public abstract class AbstractRDFTermFactoryTest {
+
+ private RDFTermFactory factory;
+
+ @Test
+ public void createBlankNode() throws Exception {
+ BlankNode bnode;
+ try {
+ bnode = factory.createBlankNode();
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+ String ntriplesString = bnode.ntriplesString();
+ assertTrue("ntriples must start with _:",
+ ntriplesString.startsWith("_:"));
+ assertTrue("Internal identifier can't be empty", bnode
+ .internalIdentifier().length() > 0);
+ assertEquals("ntriples does not correspond with internal identifier",
+ bnode.internalIdentifier(),
+ ntriplesString.substring(2, ntriplesString.length()));
+
+ BlankNode bnode2 = factory.createBlankNode();
+ assertNotEquals(
+ "Second blank node has not got a unique internal identifier",
+ bnode.internalIdentifier(), bnode2.internalIdentifier());
+ }
+
+ @Test
+ public void createBlankNodeIdentifier() throws Exception {
+ BlankNode bnode;
+ try {
+ bnode = factory.createBlankNode("example1");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+ assertEquals("example1", bnode.internalIdentifier());
+ assertEquals("_:example1", bnode.ntriplesString());
+ }
+
+ public abstract RDFTermFactory createFactory();
+
+ @Test
+ public void createGraph() {
+ Graph graph;
+ try {
+ graph = factory.createGraph();
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+
+ assertEquals("Graph was not empty", 0, graph.size());
+ graph.add(factory.createBlankNode(),
+ factory.createIRI("http://example.com/"),
+ factory.createBlankNode());
+
+ Graph graph2 = factory.createGraph();
+ assertNotSame(graph, graph2);
+ assertEquals("Graph was empty after adding", 1, graph.size());
+ assertEquals("New graph was not empty", 0, graph2.size());
+ }
+
+ @Test
+ public void createIRI() throws Exception {
+ IRI example;
+ try {
+ example = factory.createIRI("http://example.com/");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException("createIRI not supported", ex);
+ return;
+ }
+
+ assertEquals("http://example.com/", example.getIRIString());
+ assertEquals("<http://example.com/>", example.ntriplesString());
+
+ IRI term = factory.createIRI("http://example.com/vocab#term");
+ assertEquals("http://example.com/vocab#term", term.getIRIString());
+ assertEquals("<http://example.com/vocab#term>", term.ntriplesString());
+
+ // and now for the international fun!
+
+ IRI latin1 = factory.createIRI("http://accént.example.com/première");
+ assertEquals("http://accént.example.com/première",
+ latin1.getIRIString());
+ assertEquals("<http://accént.example.com/première>",
+ latin1.ntriplesString());
+
+ IRI cyrillic = factory.createIRI("http://example.испытание/Кириллица");
+ assertEquals("http://example.испытание/Кириллица",
+ cyrillic.getIRIString());
+ assertEquals("<http://example.испытание/Кириллица>",
+ cyrillic.ntriplesString());
+
+ IRI deseret = factory.createIRI("http://𐐀.example.com/𐐀");
+ assertEquals("http://𐐀.example.com/𐐀", deseret.getIRIString());
+ assertEquals("<http://𐐀.example.com/𐐀>", deseret.ntriplesString());
+ }
+
+ @Test
+ public void createIRIRelative() throws Exception {
+ // Although relative IRIs are defined in
+ // http://www.w3.org/TR/rdf11-concepts/#section-IRIs
+ // it is not a requirement for an implementation to support
+ // it (all instances of an relative IRI should eventually
+ // be possible to resolve to an absolute IRI)
+ try {
+ factory.createIRI("../relative");
+ } catch (UnsupportedOperationException | IllegalArgumentException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+ IRI relative = factory.createIRI("../relative");
+ assertEquals("../relative", relative.getIRIString());
+ assertEquals("<../relative>", relative.ntriplesString());
+
+ IRI relativeTerm = factory.createIRI("../relative#term");
+ assertEquals("../relative#term", relativeTerm.getIRIString());
+ assertEquals("<../relative#term>", relativeTerm.ntriplesString());
+
+ IRI emptyRelative = factory.createIRI(""); // <> equals the base URI
+ assertEquals("", emptyRelative.getIRIString());
+ assertEquals("<>", emptyRelative.ntriplesString());
+ }
+
+ @Test
+ public void createLiteral() throws Exception {
+ Literal example;
+ try {
+ example = factory.createLiteral("Example");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+
+ assertEquals("Example", example.getLexicalForm());
+ assertFalse(example.getLanguageTag().isPresent());
+ assertEquals("http://www.w3.org/2001/XMLSchema#string", example
+ .getDatatype().getIRIString());
+ // http://lists.w3.org/Archives/Public/public-rdf-comments/2014Dec/0004.html
+ assertEquals("\"Example\"", example.ntriplesString());
+ }
+
+ @Test
+ public void createLiteralDateTime() throws Exception {
+ Literal dateTime;
+ try {
+ dateTime = factory.createLiteral(
+ "2014-12-27T00:50:00T-0600",
+ factory.createIRI("http://www.w3.org/2001/XMLSchema#dateTime"));
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+ assertEquals("2014-12-27T00:50:00T-0600", dateTime.getLexicalForm());
+ assertFalse(dateTime.getLanguageTag().isPresent());
+ assertEquals("http://www.w3.org/2001/XMLSchema#dateTime", dateTime
+ .getDatatype().getIRIString());
+ assertEquals(
+ "\"2014-12-27T00:50:00T-0600\"^^<http://www.w3.org/2001/XMLSchema#dateTime>",
+ dateTime.ntriplesString());
+ }
+
+ @Test
+ public void createLiteralLang() throws Exception {
+ Literal example;
+ try {
+ example = factory.createLiteral("Example", "en");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+
+ assertEquals("Example", example.getLexicalForm());
+ assertEquals("en", example.getLanguageTag().get());
+ assertEquals("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",
+ example.getDatatype().getIRIString());
+ assertEquals("\"Example\"@en", example.ntriplesString());
+ }
+
+ @Test
+ public void createLiteralLangISO693_3() throws Exception {
+ // see https://issues.apache.org/jira/browse/JENA-827
+ Literal vls;
+ try {
+ vls = factory.createLiteral("Herbert Van de Sompel", "vls"); // JENA-827
+ // reference
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+
+ assertEquals("vls", vls.getLanguageTag().get());
+ assertEquals("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",
+ vls.getDatatype().getIRIString());
+ assertEquals("\"Herbert Van de Sompel\"@vls", vls.ntriplesString());
+ }
+
+ @Test
+ public void createLiteralString() throws Exception {
+ Literal example;
+ try {
+ example = factory.createLiteral("Example", factory
+ .createIRI("http://www.w3.org/2001/XMLSchema#string"));
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+ assertEquals("Example", example.getLexicalForm());
+ assertFalse(example.getLanguageTag().isPresent());
+ assertEquals("http://www.w3.org/2001/XMLSchema#string", example
+ .getDatatype().getIRIString());
+ // http://lists.w3.org/Archives/Public/public-rdf-comments/2014Dec/0004.html
+ assertEquals("\"Example\"", example.ntriplesString());
+ }
+
+ @Test
+ public void createTripleBnodeBnode() {
+ BlankNode subject;
+ IRI predicate;
+ BlankNode object;
+ Triple triple;
+ try {
+ subject = factory.createBlankNode("b1");
+ predicate = factory.createIRI("http://example.com/pred");
+ object = factory.createBlankNode("b2");
+ triple = factory.createTriple(subject, predicate, object);
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+
+ // NOTE: We do not require object equivalence after insertion,
+ // but the ntriples should match
+ assertEquals(subject.ntriplesString(), triple.getSubject()
+ .ntriplesString());
+ assertEquals(predicate.ntriplesString(), triple.getPredicate()
+ .ntriplesString());
+ assertEquals(object.ntriplesString(), triple.getObject()
+ .ntriplesString());
+
+ }
+
+ @Test
+ public void createTripleBnodeIRI() {
+ BlankNode subject;
+ IRI predicate;
+ IRI object;
+ Triple triple;
+ try {
+ subject = factory.createBlankNode("b1");
+ predicate = factory.createIRI("http://example.com/pred");
+ object = factory.createIRI("http://example.com/obj");
+ triple = factory.createTriple(subject, predicate, object);
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+
+ // NOTE: We do not require object equivalence after insertion,
+ // but the ntriples should match
+ assertEquals(subject.ntriplesString(), triple.getSubject()
+ .ntriplesString());
+ assertEquals(predicate.ntriplesString(), triple.getPredicate()
+ .ntriplesString());
+ assertEquals(object.ntriplesString(), triple.getObject()
+ .ntriplesString());
+ }
+
+ @Test
+ public void createTripleBnodeTriple() {
+ BlankNode subject;
+ IRI predicate;
+ Literal object;
+ Triple triple;
+ try {
+ subject = factory.createBlankNode();
+ predicate = factory.createIRI("http://example.com/pred");
+ object = factory.createLiteral("Example", "en");
+ triple = factory.createTriple(subject, predicate, object);
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+
+ // NOTE: We do not require object equivalence after insertion,
+ // but the ntriples should match
+ assertEquals(subject.ntriplesString(), triple.getSubject()
+ .ntriplesString());
+ assertEquals(predicate.ntriplesString(), triple.getPredicate()
+ .ntriplesString());
+ assertEquals(object.ntriplesString(), triple.getObject()
+ .ntriplesString());
+ }
+
+ @Before
+ public void getFactory() {
+ factory = createFactory();
+ }
+
+ @Test(expected = Exception.class)
+ public void invalidBlankNode() throws Exception {
+ try {
+ factory.createBlankNode("with:colon").ntriplesString();
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException("createBlankNode(String) not supported",
+ ex);
+ return;
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void invalidIRI() throws Exception {
+ try {
+ factory.createIRI("<no_brackets>");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException("createIRI not supported", ex);
+ return;
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void invalidLiteralLang() throws Exception {
+ try {
+ factory.createLiteral("Example", "with space");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(
+ "createLiteral(String,String) not supported", ex);
+ return;
+ }
+ }
+
+ @Test(expected = Exception.class)
+ public void invalidTriplePredicate() {
+ BlankNode subject = factory.createBlankNode("b1");
+ BlankNode predicate = factory.createBlankNode("b2");
+ BlankNode object = factory.createBlankNode("b3");
+ factory.createTriple(subject, (IRI) predicate, object);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/commons-rdf-api/pom.xml
----------------------------------------------------------------------
diff --git a/commons-rdf-api/pom.xml b/commons-rdf-api/pom.xml
deleted file mode 100644
index 2da2f8e..0000000
--- a/commons-rdf-api/pom.xml
+++ /dev/null
@@ -1,95 +0,0 @@
-<!--
-
- Licensed 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>com.github.commons-rdf</groupId>
- <artifactId>commons-rdf</artifactId>
- <version>0.0.3-SNAPSHOT</version>
- </parent>
-
- <artifactId>commons-rdf-api</artifactId>
- <packaging>jar</packaging>
-
- <name>Commons RDF: API</name>
- <description>Commons Java API for RDF 1.1</description>
-
- <profiles>
- <profile>
- <id>java6</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-patch-plugin</artifactId>
- <version>1.1.1</version>
- <configuration>
- <strip>1</strip>
- <patches>
- <patch>java6.patch</patch>
- </patches>
- </configuration>
- <executions>
- <execution>
- <id>patch</id>
- <phase>process-sources</phase>
- <goals>
- <goal>apply</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.3.1</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <executable>git</executable>
- <arguments>
- <argument>checkout</argument>
- <argument>src/main/java/com/github/commonsrdf/api/Graph.java</argument>
- <argument>src/main/java/com/github/commonsrdf/api/Literal.java</argument>
- </arguments>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>17.0</version>
- <exclusions>
- <exclusion>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/commons-rdf-api/src/main/java/com/github/commonsrdf/api/BlankNode.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/BlankNode.java b/commons-rdf-api/src/main/java/com/github/commonsrdf/api/BlankNode.java
deleted file mode 100644
index 399381a..0000000
--- a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/BlankNode.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Licensed 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 com.github.commonsrdf.api;
-
-/**
- * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node" >RDF-1.1
- * Blank Node</a>, as defined by <a href=
- * "http://www.w3.org/TR/rdf11-concepts/#section-blank-nodes" >RDF-1.1 Concepts
- * and Abstract Syntax</a>, a W3C Recommendation published on 25 February 2014.<br>
- *
- * Note that: Blank nodes are disjoint from IRIs and literals. Otherwise,
- * the set of possible blank nodes is arbitrary. RDF makes no reference to any
- * internal structure of blank nodes.
- *
- * Also note that: Blank node identifiers are local identifiers that are
- * used in some concrete RDF syntaxes or RDF store implementations. They are
- * always locally scoped to the file or RDF store, and are not persistent or
- * portable identifiers for blank nodes. Blank node identifiers are not part of
- * the RDF abstract syntax, but are entirely dependent on the concrete syntax or
- * implementation. The syntactic restrictions on blank node identifiers, if any,
- * therefore also depend on the concrete RDF syntax or implementation.
- * Implementations that handle blank node identifiers in concrete syntaxes need
- * to be careful not to create the same blank node from multiple occurrences of
- * the same blank node identifier except in situations where this is supported
- * by the syntax.
- *
- * @see <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node">RDF-1.1
- * Blank Node</a>
- */
-public interface BlankNode extends BlankNodeOrIRI {
-
- /**
- * Return a <a href=
- * "http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier">label</a>
- * for the blank node. This is not a serialization/syntax label. It should
- * be uniquely identifying within the local scope it is created in but has
- * no uniqueness guarantees other than that.
- *
- * In particular, the existence of two objects of type {@link BlankNode}
- * with the same value returned from {@link #internalIdentifier()} are not
- * equivalent unless they are known to have been created in the same local
- * scope.
- *
- * An example of a local scope may be an instance of a Java Virtual Machine
- * (JVM). In the context of a JVM instance, an implementor may support
- * insertion and removal of {@link Triple} objects containing Blank Nodes
- * without modifying the blank node labels.
- *
- * Another example of a local scope may be a <a
- * href="http://www.w3.org/TR/rdf11-concepts/#section-rdf-graph">Graph</a>
- * or <a
- * href="http://www.w3.org/TR/rdf11-concepts/#section-dataset">Dataset</a>
- * created from a single document. In this context, an implementor should
- * reasonably guarantee that the label returned by getLabel only maps to
- * equivalent blank nodes in the same Graph or Dataset, but they may not
- * guarantee that it is unique for the JVM instance. In this case, the
- * implementor may support a mechanism to provide a mapping for blank nodes
- * between Graph or Dataset instances to guarantee their uniqueness.
- *
- * If implementors support <a
- * href="http://www.w3.org/TR/rdf11-concepts/#section-skolemization"
- * >Skolemisation</a>, they may map instances of {@link BlankNode} objects
- * to {@link IRI} objects to reduce scoping issues.
- *
- * @return An internal, system identifier for the {@link BlankNode}.
- */
- String internalIdentifier();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/commons-rdf-api/src/main/java/com/github/commonsrdf/api/BlankNodeOrIRI.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/BlankNodeOrIRI.java b/commons-rdf-api/src/main/java/com/github/commonsrdf/api/BlankNodeOrIRI.java
deleted file mode 100644
index 38d5ef6..0000000
--- a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/BlankNodeOrIRI.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Licensed 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 com.github.commonsrdf.api;
-
-/**
- * This interface represents the {@link RDFTerm}s that may be used in the
- * subject position of an RDF-1.1 {@link Triple}, including {@link BlankNode}
- * and {@link IRI}.
- */
-public interface BlankNodeOrIRI extends RDFTerm {
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/commons-rdf-api/src/main/java/com/github/commonsrdf/api/Graph.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/Graph.java b/commons-rdf-api/src/main/java/com/github/commonsrdf/api/Graph.java
deleted file mode 100644
index 4ba45e9..0000000
--- a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/Graph.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Licensed 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 com.github.commonsrdf.api;
-
-import java.util.stream.Stream;
-
-/**
- * An <a href="http://www.w3.org/TR/rdf11-concepts/#section-rdf-graph"> RDF 1.1
- * Graph</a>, a set of RDF triples, as defined by <a
- * href="http://www.w3.org/TR/rdf11-concepts/" >RDF-1.1 Concepts and Abstract
- * Syntax</a>, a W3C Recommendation published on 25 February 2014.
- */
-public interface Graph {
-
- /**
- * Add a triple to the graph.
- *
- * @param triple
- * The triple to add
- */
- void add(Triple triple);
-
- /**
- * Add a triple to the graph.
- *
- * @param subject
- * The triple subject
- * @param predicate
- * The triple predicate
- * @param object
- * The triple object
- */
- void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
-
- /**
- * Check if graph contains triple.
- *
- * @param triple
- * The triple to check.
- * @return True if the Graph contains the given Triple.
- */
- boolean contains(Triple triple);
-
- /**
- * Check if graph contains a pattern of triples.
- *
- * @param subject
- * The triple subject (null is a wildcard)
- * @param predicate
- * The triple predicate (null is a wildcard)
- * @param object
- * The triple object (null is a wildcard)
- * @return True if the Graph contains any Triples that match
- * the given pattern.
- */
- boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
-
- /**
- * Remove a concrete triple from the graph.
- *
- * @param triple
- * triple to remove
- */
- void remove(Triple triple);
-
- /**
- * Remove a concrete pattern of triples from the graph.
- *
- * @param subject
- * The triple subject (null is a wildcard)
- * @param predicate
- * The triple predicate (null is a wildcard)
- * @param object
- * The triple object (null is a wildcard)
- */
- void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
-
- /**
- * Clear the graph, removing all triples.
- *
- */
- void clear();
-
- /**
- * Number of triples contained by the graph.
- * <p>
- * The count of a set does not include duplicates, as determined by
- * {@link Triple#equals(Object)}.
- *
- * @return The number of triples in the graph
- */
- long size();
-
- /**
- * Get all triples contained by the graph.<br>
- * <p>
- * The iteration does not contain any duplicate triples, as determined by
- * {@link Triple#equals(Object)}.
- * <p>
- * The behaviour of the Stream is not specified if add, remove, or clear,
- * are called on the Stream before it terminates.<br>
- * <p>
- * Implementations may throw ConcurrentModificationException from Stream
- * methods if they detect a conflict while the Stream is active.
- *
- * @return A {@link Stream} over all of the triples in the graph
- */
- Stream<? extends Triple> getTriples();
-
- /**
- * Get all triples contained by the graph matched with the pattern.
- * <p>
- * The iteration does not contain any duplicate triples, as determined by
- * {@link Triple#equals(Object)}.
- * <p>
- * The behaviour of the Stream is not specified if add, remove, or clear,
- * are called on the Stream before it terminates.<br>
- * <p>
- * Implementations may throw ConcurrentModificationException from Stream
- * methods if they detect a conflict while the Stream is active.
- *
- * @param subject
- * The triple subject (null is a wildcard)
- * @param predicate
- * The triple predicate (null is a wildcard)
- * @param object
- * The triple object (null is a wildcard)
- * @return A {@link Stream} over the matched triples.
- */
- Stream<? extends Triple> getTriples(BlankNodeOrIRI subject, IRI predicate, RDFTerm object);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/commons-rdf-api/src/main/java/com/github/commonsrdf/api/IRI.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/IRI.java b/commons-rdf-api/src/main/java/com/github/commonsrdf/api/IRI.java
deleted file mode 100644
index 7f9e35c..0000000
--- a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/IRI.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed 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 com.github.commonsrdf.api;
-
-/**
- * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-iri"
- * >RDF-1.1 IRI</a>, as defined by <a href=
- * "http://www.w3.org/TR/rdf11-concepts/" >RDF-1.1 Concepts
- * and Abstract Syntax</a>, a W3C Recommendation published on 25 February 2014.<br>
- */
-public interface IRI extends BlankNodeOrIRI {
-
- /**
- * Returns the IRI encoded as a native Unicode String.<br>
- *
- * The returned string must not include URL-encoding to escape
- * non-ASCII characters.
- *
- * @return The IRI encoded as a native Unicode String.
- */
- String getIRIString();
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/commons-rdf-api/src/main/java/com/github/commonsrdf/api/Literal.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/Literal.java b/commons-rdf-api/src/main/java/com/github/commonsrdf/api/Literal.java
deleted file mode 100644
index 91485d9..0000000
--- a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/Literal.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Licensed 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 com.github.commonsrdf.api;
-
-import java.util.Optional;
-
-/**
- * An RDF-1.1 Literal, as defined by <a href=
- * "http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal" >RDF-1.1
- * Concepts and Abstract Syntax</a>, a W3C Recommendation published on 25
- * February 2014
- */
-public interface Literal extends RDFTerm {
-
- /**
- * The lexical form of this literal, represented by a <a
- * href="http://www.unicode.org/versions/latest/">Unicode string</a>.
- *
- * @return The lexical form of this literal.
- * @see <a
- * href="http://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form">RDF-1.1
- * Literal lexical form</a>
- */
- String getLexicalForm();
-
- /**
- * The IRI identifying the datatype that determines how the lexical form
- * maps to a literal value.
- *
- * @return The datatype IRI for this literal.
- * @see <a
- * href="http://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri">RDF-1.1
- * Literal datatype IRI</a>
- */
- IRI getDatatype();
-
- /**
- * If and only if the datatype IRI is <a
- * href="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
- * >http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</a>, the language
- * tag for this Literal is a non-empty language tag as defined by <a
- * href="http://tools.ietf.org/html/bcp47">BCP47</a>.<br>
- * If the datatype IRI is not <a
- * href="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
- * >http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</a>, this method
- * must return {@link Optional#empty()}.
- *
- * @return The {@link Optional} language tag for this literal. If
- * {@link Optional#isPresent()} returns true, the value returned by
- * {@link Optional#get()} must be a non-empty string conforming to
- * BCP47.
- * @see <a
- * href="http://www.w3.org/TR/rdf11-concepts/#dfn-language-tag">RDF-1.1
- * Literal language tag</a>
- */
- Optional<String> getLanguageTag();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88e701d3/commons-rdf-api/src/main/java/com/github/commonsrdf/api/RDFTerm.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/RDFTerm.java b/commons-rdf-api/src/main/java/com/github/commonsrdf/api/RDFTerm.java
deleted file mode 100644
index 5530e67..0000000
--- a/commons-rdf-api/src/main/java/com/github/commonsrdf/api/RDFTerm.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed 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 com.github.commonsrdf.api;
-
-/**
- * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term" >RDF-1.1
- * Term</a>, as defined by <a href= "http://www.w3.org/TR/rdf11-concepts/"
- * >RDF-1.1 Concepts and Abstract Syntax</a>, a W3C Recommendation published on
- * 25 February 2014.<br>
- *
- * @see <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term" >RDF-1.1
- * Term</a>
- */
-public interface RDFTerm {
-
- /**
- * Return the term serialised as specified by the RDF-1.1 N-Triples Canonical form.
- *
- * @return The term serialised as RDF-1.1 N-Triples.
- * @see <a href="http://www.w3.org/TR/n-triples/#canonical-ntriples">
- * RDF-1.1 N-Triples Canonical form</a>
- */
- String ntriplesString();
-
-}