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:44:43 UTC
[1/7] incubator-commonsrdf git commit: COMMONSRDF-2: refactorized
maven artifacts
Repository: incubator-commonsrdf
Updated Branches:
refs/heads/master 2bfe31612 -> 7d06fdbf3
COMMONSRDF-2: refactorized maven artifacts
Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/4076688a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/4076688a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/4076688a
Branch: refs/heads/master
Commit: 4076688a604ec3df6b5bc9b99ec912604e568c6a
Parents: 2bfe316
Author: Sergio Fernández <wi...@apache.org>
Authored: Fri Mar 27 19:37:07 2015 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Fri Mar 27 19:37:07 2015 +0100
----------------------------------------------------------------------
api/pom.xml | 4 +--
pom.xml | 73 ++++++++++++++++++++++++++++++++++++++++-------------
simple/pom.xml | 9 ++++---
3 files changed, 63 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/4076688a/api/pom.xml
----------------------------------------------------------------------
diff --git a/api/pom.xml b/api/pom.xml
index d6a473b..272f279 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -18,8 +18,8 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>com.github.commons-rdf</groupId>
- <artifactId>commons-rdf</artifactId>
+ <groupId>org.apache.commons.rdf</groupId>
+ <artifactId>commonsrdf</artifactId>
<version>0.0.3-SNAPSHOT</version>
</parent>
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/4076688a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f34c209..bdc47c6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,32 +17,38 @@
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>
+ <!--
+ temporally disable until we clariffy the usage
+ of animal-sniffer-maven-plugin
<parent>
- <groupId>org.sonatype.oss</groupId>
- <artifactId>oss-parent</artifactId>
- <version>9</version>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-parent</artifactId>
+ <version>37</version>
</parent>
+ -->
- <groupId>com.github.commons-rdf</groupId>
- <artifactId>commons-rdf</artifactId>
+ <groupId>org.apache.commons.rdf</groupId>
+ <artifactId>commonsrdf</artifactId>
<version>0.0.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Commons RDF</name>
<description>Commons Java API for RDF 1.1</description>
- <inceptionYear>2014</inceptionYear>
+ <url>http://commonsrdf.incubator.apache.org</url>
+
+ <inceptionYear>2015</inceptionYear>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
- <url>http://commons-rdf.github.io/</url>
<scm>
- <connection>scm:git:https://github.com/commons-rdf/commons-rdf.git</connection>
- <developerConnection>scm:git:git@github.com:commons-rdf/commons-rdf.git</developerConnection>
- <url>https://github.com/commons-rdf/commons-rdf/</url>
+ <url>https://git-wip-us.apache.org/repos/asf/incubator-commonsrdf.git</url>
+ <connection>scm:git:https://git-wip-us.apache.org/repos/asf/incubator-commonsrdf.git</connection>
+ <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/incubator-commonsrdf.git</developerConnection>
+ <tag>HEAD</tag>
</scm>
<licenses>
@@ -55,28 +61,59 @@
<developers>
<developer>
+ <id>lewismc</id>
+ <name>Lewis John McGibbney</name>
+ <email>lewismc@apache.org</email>
+ </developer>
+ <developer>
+ <id>rvesse</id>
+ <name>Rob Vesse</name>
+ <email>rvesse@apache.org</email>
+ </developer>
+ <developer>
+ <id>johndament</id>
+ <name>John D Ament</name>
+ <email>johndament@apache.org</email>
+ </developer>
+ <developer>
+ <id>ggregory</id>
+ <name>Gary Gregory</name>
+ <email>ggregory@apache.org</email>
+ </developer>
+ <developer>
<id>wikier</id>
<name>Sergio Fernández</name>
<email>wikier@apache.org</email>
- <organization>Apache Software Foundation</organization>
</developer>
<developer>
<id>andy</id>
<name>Andy Seaborne</name>
<email>andy@apache.org</email>
- <organization>Apache Software Foundation</organization>
</developer>
<developer>
<id>ansell</id>
<name>Peter Ansell</name>
- <email>p_ansell@yahoo.com</email>
- <organization>OpenRDF</organization>
+ <email>ansell@apache.org</email>
+ </developer>
+ <developer>
+ <id>stain</id>
+ <name>Stian Soiland-Reyes</name>
+ <email>stain@apache.org</email>
+ </developer>
+ <developer>
+ <id>reto</id>
+ <name>Reto Gmür</name>
+ <email>reto@apache.org</email>
+ </developer>
+ <developer>
+ <id>enridaga</id>
+ <name>Enrico Daga</name>
+ <email>enridaga@apache.org</email>
</developer>
<developer>
- <id>betehess</id>
- <name>Alexandre Bertails</name>
- <email>alexandre@bertails.org</email>
- <organization>W3C</organization>
+ <id>britter</id>
+ <name>Benedikt Ritter</name>
+ <email>britter@apache.org</email>
</developer>
</developers>
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/4076688a/simple/pom.xml
----------------------------------------------------------------------
diff --git a/simple/pom.xml b/simple/pom.xml
index e85f275..6ccc6d1 100644
--- a/simple/pom.xml
+++ b/simple/pom.xml
@@ -16,15 +16,17 @@
<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>
+ <groupId>org.apache.commons.rdf</groupId>
+ <artifactId>commonsrdf</artifactId>
<version>0.0.3-SNAPSHOT</version>
</parent>
+
<artifactId>commons-rdf-simple</artifactId>
<packaging>jar</packaging>
- <name>Commons RDF: Simple impl</name>
+ <name>Commons RDF: Simple Implementation</name>
<description>Simple (if not naive) implementation of Commons RDF API</description>
<dependencies>
@@ -41,4 +43,5 @@
<scope>test</scope>
</dependency>
</dependencies>
+
</project>
[6/7] incubator-commonsrdf git commit: COMMONSRDF-2: switch to the
asf header
Posted by wi...@apache.org.
COMMONSRDF-2: switch to the asf header
Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/b649f4b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/b649f4b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/b649f4b1
Branch: refs/heads/master
Commit: b649f4b163a7155e12b7883f0f666513964db841
Parents: f3a452e
Author: Sergio Fernández <wi...@apache.org>
Authored: Fri Mar 27 19:42:47 2015 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Fri Mar 27 19:42:47 2015 +0100
----------------------------------------------------------------------
src/etc/header.txt | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/b649f4b1/src/etc/header.txt
----------------------------------------------------------------------
diff --git a/src/etc/header.txt b/src/etc/header.txt
index 51fca54..4a75f87 100644
--- a/src/etc/header.txt
+++ b/src/etc/header.txt
@@ -1,6 +1,10 @@
-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
+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
[5/7] incubator-commonsrdf git commit: COMMONSRDF-2: refactorized
simple impl java packages
Posted by wi...@apache.org.
COMMONSRDF-2: refactorized simple impl java packages
Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/f3a452ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/f3a452ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/f3a452ea
Branch: refs/heads/master
Commit: f3a452ea26a1e140f7e30d33ff1b71b5fd2d4b04
Parents: fa5321e
Author: Sergio Fernández <wi...@apache.org>
Authored: Fri Mar 27 19:41:52 2015 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Fri Mar 27 19:41:52 2015 +0100
----------------------------------------------------------------------
.../github/commonsrdf/simple/BlankNodeImpl.java | 104 ----------
.../com/github/commonsrdf/simple/GraphImpl.java | 141 --------------
.../com/github/commonsrdf/simple/IRIImpl.java | 64 -------
.../github/commonsrdf/simple/LiteralImpl.java | 125 ------------
.../commonsrdf/simple/SimpleRDFTermFactory.java | 79 --------
.../github/commonsrdf/simple/TripleImpl.java | 138 -------------
.../com/github/commonsrdf/simple/Types.java | 192 -------------------
.../github/commonsrdf/simple/package-info.java | 31 ---
.../commons/rdf/simple/BlankNodeImpl.java | 103 ++++++++++
.../apache/commons/rdf/simple/GraphImpl.java | 141 ++++++++++++++
.../org/apache/commons/rdf/simple/IRIImpl.java | 64 +++++++
.../apache/commons/rdf/simple/LiteralImpl.java | 125 ++++++++++++
.../rdf/simple/SimpleRDFTermFactory.java | 79 ++++++++
.../apache/commons/rdf/simple/TripleImpl.java | 138 +++++++++++++
.../org/apache/commons/rdf/simple/Types.java | 192 +++++++++++++++++++
.../apache/commons/rdf/simple/package-info.java | 31 +++
.../commonsrdf/simple/BlankNodeImplTest.java | 38 ----
.../commonsrdf/simple/DefaultGraphTest.java | 48 -----
.../commonsrdf/simple/SimpleGraphTest.java | 30 ---
.../SimpleNoRelativeIRIRDFTermFactoryTest.java | 44 -----
.../simple/SimpleRDFTermFactoryTest.java | 26 ---
.../commonsrdf/simple/TestWritingGraph.java | 96 ----------
.../com/github/commonsrdf/simple/TypesTest.java | 69 -------
.../commons/rdf/simple/BlankNodeImplTest.java | 38 ++++
.../commons/rdf/simple/DefaultGraphTest.java | 48 +++++
.../commons/rdf/simple/SimpleGraphTest.java | 30 +++
.../SimpleNoRelativeIRIRDFTermFactoryTest.java | 44 +++++
.../rdf/simple/SimpleRDFTermFactoryTest.java | 26 +++
.../commons/rdf/simple/TestWritingGraph.java | 96 ++++++++++
.../apache/commons/rdf/simple/TypesTest.java | 67 +++++++
30 files changed, 1222 insertions(+), 1225 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java b/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java
deleted file mode 100644
index 709a5b9..0000000
--- a/simple/src/main/java/com/github/commonsrdf/simple/BlankNodeImpl.java
+++ /dev/null
@@ -1,104 +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.simple;
-
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicLong;
-
-import com.github.commonsrdf.api.BlankNode;
-import com.github.commonsrdf.api.Graph;
-
-/**
- * A simple implementation of BlankNode.
- *
- */
-class BlankNodeImpl implements BlankNode {
-
- private static AtomicLong bnodeCounter = new AtomicLong();
- private final String id;
- private final Optional<Graph> localScope;
-
- public BlankNodeImpl() {
- this(Optional.empty(), "b:" + bnodeCounter.incrementAndGet());
- }
-
- public BlankNodeImpl(Optional<Graph> localScope, String id) {
- this.localScope = Objects.requireNonNull(localScope);
- if (Objects.requireNonNull(id).isEmpty()) {
- throw new IllegalArgumentException("Invalid blank node id: " + id);
- // NOTE: It is valid for the id to not be a valid ntriples bnode id.
- // See ntriplesString().
- }
- this.id = id;
- }
-
- @Override
- public String internalIdentifier() {
- return id;
- }
-
- @Override
- public String ntriplesString() {
- if (id.contains(":")) {
- return "_:u"
- + UUID.nameUUIDFromBytes(id
- .getBytes(StandardCharsets.UTF_8));
- }
- return "_:" + id;
- }
-
- @Override
- public String toString() {
- return ntriplesString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(localScope, id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof BlankNodeImpl)) {
- return false;
- }
- BlankNodeImpl other = (BlankNodeImpl) obj;
- if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
- if (localScope == null) {
- if (other.localScope != null) {
- return false;
- }
- } else if (!localScope.equals(other.localScope)) {
- return false;
- }
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/com/github/commonsrdf/simple/GraphImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/GraphImpl.java b/simple/src/main/java/com/github/commonsrdf/simple/GraphImpl.java
deleted file mode 100644
index f0a05ed..0000000
--- a/simple/src/main/java/com/github/commonsrdf/simple/GraphImpl.java
+++ /dev/null
@@ -1,141 +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.simple;
-
-import java.util.LinkedHashSet;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import com.github.commonsrdf.api.BlankNodeOrIRI;
-import com.github.commonsrdf.api.Graph;
-import com.github.commonsrdf.api.IRI;
-import com.github.commonsrdf.api.RDFTerm;
-import com.github.commonsrdf.api.Triple;
-
-/**
- * A simple, memory-based implementation of Graph.
- * <p>
- * {@link Triple}s in the graph are kept in a {@link Set}.
- * <p>
- * All Stream operations are performed using parallel and unordered directives.
- */
-class GraphImpl implements Graph {
-
- private static final int TO_STRING_MAX = 10;
- protected final Set<Triple> triples = new LinkedHashSet<Triple>();
-
- @Override
- public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
- add(new TripleImpl(Objects.requireNonNull(subject),
- Objects.requireNonNull(predicate),
- Objects.requireNonNull(object)));
-
- }
-
- @Override
- public void add(Triple triple) {
- triples.add(new TripleImpl(Optional.of(this), Objects
- .requireNonNull(triple)));
- }
-
- @Override
- public void clear() {
- triples.clear();
- }
-
- @Override
- public boolean contains(BlankNodeOrIRI subject, IRI predicate,
- RDFTerm object) {
- return getTriples(subject, predicate, object).findFirst().isPresent();
- }
-
- @Override
- public boolean contains(Triple triple) {
- return triples.contains(Objects.requireNonNull(triple));
- }
-
- @Override
- public Stream<Triple> getTriples() {
- return triples.parallelStream();
- }
-
- @Override
- public Stream<Triple> getTriples(final BlankNodeOrIRI subject,
- final IRI predicate, final RDFTerm object) {
- Predicate<Triple> match = new Predicate<Triple>() {
- @Override
- public boolean test(Triple t) {
- // Lacking the requirement for .equals() we have to be silly
- // and test ntriples string equivalance
- if (subject != null
- && !t.getSubject().ntriplesString()
- .equals(subject.ntriplesString())) {
- return false;
- }
- if (predicate != null
- && !t.getPredicate().ntriplesString()
- .equals(predicate.ntriplesString())) {
- return false;
- }
- if (object != null
- && !t.getObject().ntriplesString()
- .equals(object.ntriplesString())) {
- return false;
- }
- return true;
- }
- };
- return getTriples(match);
- }
-
- @Override
- public Stream<Triple> getTriples(final Predicate<Triple> filter) {
- return getTriples().unordered().filter(filter);
- }
-
- @Override
- public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
- Stream<Triple> toRemove = getTriples(subject, predicate, object);
- for (Triple t : toRemove.collect(Collectors.toList())) {
- // Avoid ConcurrentModificationException in ArrayList
- remove(t);
- }
- }
-
- @Override
- public void remove(Triple triple) {
- triples.remove(Objects.requireNonNull(triple));
- }
-
- @Override
- public long size() {
- return triples.size();
- }
-
- @Override
- public String toString() {
- String s = getTriples().limit(TO_STRING_MAX).map(Object::toString)
- .collect(Collectors.joining("\n"));
- if (size() > TO_STRING_MAX) {
- return s + "\n# ... +" + (size() - TO_STRING_MAX) + " more";
- } else {
- return s;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/com/github/commonsrdf/simple/IRIImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/IRIImpl.java b/simple/src/main/java/com/github/commonsrdf/simple/IRIImpl.java
deleted file mode 100644
index 5b5994a..0000000
--- a/simple/src/main/java/com/github/commonsrdf/simple/IRIImpl.java
+++ /dev/null
@@ -1,64 +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.simple;
-
-import java.net.URI;
-
-import com.github.commonsrdf.api.IRI;
-
-/**
- * A simple implementation of IRI.
- *
- */
-class IRIImpl implements IRI {
-
- protected String iri;
-
- public IRIImpl(String iri) {
- // should throw IllegalArgumentException on most illegal IRIs
- URI.create(iri);
- // NOTE: We don't keep the URI as it uses outdated RFC2396 and will get some IDNs wrong
- this.iri = iri;
- }
-
- @Override
- public String getIRIString() {
- return iri;
- }
-
- @Override
- public String ntriplesString() {
- return "<" + getIRIString() + ">";
- }
-
- @Override
- public String toString() {
- return ntriplesString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof IRI)) {
- return false;
- }
- IRI other = (IRI) obj;
- return getIRIString().equals(other.getIRIString());
- }
-
- @Override
- public int hashCode() {
- return iri.hashCode();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/com/github/commonsrdf/simple/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/LiteralImpl.java b/simple/src/main/java/com/github/commonsrdf/simple/LiteralImpl.java
deleted file mode 100644
index 059f153..0000000
--- a/simple/src/main/java/com/github/commonsrdf/simple/LiteralImpl.java
+++ /dev/null
@@ -1,125 +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.simple;
-
-import java.util.IllformedLocaleException;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.Optional;
-
-import com.github.commonsrdf.api.IRI;
-import com.github.commonsrdf.api.Literal;
-
-/**
- * A simple implementation of Literal.
- *
- */
-class LiteralImpl implements Literal {
-
- private static final String QUOTE = "\"";
-
- private IRI dataType;
- private Optional<String> languageTag;
- private String lexicalForm;
-
- public LiteralImpl(String literal) {
- this(literal, Types.XSD_STRING);
- }
-
- public LiteralImpl(String lexicalForm, IRI dataType) {
- this.lexicalForm = Objects.requireNonNull(lexicalForm);
- this.dataType = Types.get(Objects.requireNonNull(dataType)).orElse(
- dataType);
- this.languageTag = Optional.empty();
- }
-
- public LiteralImpl(String literal, String languageTag) {
- this.lexicalForm = Objects.requireNonNull(literal);
- this.languageTag = Optional.of(languageTag.toLowerCase(Locale.ENGLISH));
- if (languageTag.isEmpty()) {
- // TODO: Check against
- // http://www.w3.org/TR/n-triples/#n-triples-grammar
- throw new IllegalArgumentException("Language tag can't be null");
- }
- try {
- new Locale.Builder().setLanguageTag(languageTag);
- } catch (IllformedLocaleException ex) {
- throw new IllegalArgumentException("Invalid languageTag: "
- + languageTag, ex);
- }
-
- // System.out.println(aLocale);
- this.dataType = Types.RDF_LANGSTRING;
- }
-
- @Override
- public IRI getDatatype() {
- return dataType;
- }
-
- @Override
- public Optional<String> getLanguageTag() {
- return languageTag;
- }
-
- @Override
- public String getLexicalForm() {
- return lexicalForm;
- }
-
- @Override
- public String ntriplesString() {
- StringBuilder sb = new StringBuilder();
- sb.append(QUOTE);
- // Escape special characters
- sb.append(getLexicalForm().replace("\\", "\\\\"). // escaped to \\
- replace("\"", "\\\""). // escaped to \"
- replace("\r", "\\r"). // escaped to \r
- replace("\n", "\\n")); // escaped to \n
- sb.append(QUOTE);
-
- // getLanguageTag().ifPresent(s -> sb.append("@" + s));
- if (getLanguageTag().isPresent()) {
- sb.append("@");
- sb.append(getLanguageTag().get());
-
- } else if (!getDatatype().equals(Types.XSD_STRING)) {
- sb.append("^^");
- sb.append(getDatatype().ntriplesString());
- }
- return sb.toString();
- }
-
- @Override
- public String toString() {
- return ntriplesString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(dataType, lexicalForm, languageTag);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Literal)) {
- return false;
- }
- Literal literal = (Literal) obj;
- return getDatatype().equals(literal.getDatatype())
- && getLexicalForm().equals(literal.getLexicalForm())
- && getLanguageTag().equals(literal.getLanguageTag());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/com/github/commonsrdf/simple/SimpleRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/SimpleRDFTermFactory.java b/simple/src/main/java/com/github/commonsrdf/simple/SimpleRDFTermFactory.java
deleted file mode 100644
index 1e4d307..0000000
--- a/simple/src/main/java/com/github/commonsrdf/simple/SimpleRDFTermFactory.java
+++ /dev/null
@@ -1,79 +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.simple;
-
-import java.util.Optional;
-
-import com.github.commonsrdf.api.BlankNode;
-import com.github.commonsrdf.api.BlankNodeOrIRI;
-import com.github.commonsrdf.api.Graph;
-import com.github.commonsrdf.api.IRI;
-import com.github.commonsrdf.api.Literal;
-import com.github.commonsrdf.api.RDFTerm;
-import com.github.commonsrdf.api.RDFTermFactory;
-import com.github.commonsrdf.api.Triple;
-
-/**
- * A simple implementation of RDFTermFactory.
- * <p>
- * The {@link RDFTerm} and {@link Graph} instances created by this factory are
- * simple in-memory Implementations that are not thread-safe or efficient, but
- * which may be useful for testing and prototyping purposes.
- *
- */
-public class SimpleRDFTermFactory implements RDFTermFactory {
-
- @Override
- public BlankNode createBlankNode() {
- return new BlankNodeImpl();
- }
-
- @Override
- public BlankNode createBlankNode(String identifier) {
- return new BlankNodeImpl(Optional.empty(), identifier);
- }
-
- @Override
- public Graph createGraph() {
- return new GraphImpl();
- }
-
- @Override
- public IRI createIRI(String iri) {
- IRI result = new IRIImpl(iri);
- // Reuse any IRI objects already created in Types
- return Types.get(result).orElse(result);
- }
-
- @Override
- public Literal createLiteral(String literal) {
- return new LiteralImpl(literal);
- }
-
- @Override
- public Literal createLiteral(String literal, IRI dataType) {
- return new LiteralImpl(literal, dataType);
- }
-
- @Override
- public Literal createLiteral(String literal, String language) {
- return new LiteralImpl(literal, language);
- }
-
- @Override
- public Triple createTriple(BlankNodeOrIRI subject, IRI predicate,
- RDFTerm object) {
- return new TripleImpl(subject, predicate, object);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/com/github/commonsrdf/simple/TripleImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/TripleImpl.java b/simple/src/main/java/com/github/commonsrdf/simple/TripleImpl.java
deleted file mode 100644
index 18f9508..0000000
--- a/simple/src/main/java/com/github/commonsrdf/simple/TripleImpl.java
+++ /dev/null
@@ -1,138 +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.simple;
-
-import java.util.Objects;
-import java.util.Optional;
-
-import com.github.commonsrdf.api.BlankNode;
-import com.github.commonsrdf.api.BlankNodeOrIRI;
-import com.github.commonsrdf.api.Graph;
-import com.github.commonsrdf.api.IRI;
-import com.github.commonsrdf.api.Literal;
-import com.github.commonsrdf.api.RDFTerm;
-import com.github.commonsrdf.api.Triple;
-
-/**
- * A simple implementation of Triple.
- *
- */
-class TripleImpl implements Triple {
-
- private BlankNodeOrIRI subject;
- private IRI predicate;
- private RDFTerm object;
-
- /**
- * Construct Triple from its constituent parts.
- * <p>
- * The parts may be copied to ensure they are in scope.
- *
- * @param subject subject of triple
- * @param predicate predicate of triple
- * @param object object of triple
- */
- public TripleImpl(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
- this.subject = (BlankNodeOrIRI) inScope(Optional.empty(),
- Objects.requireNonNull(subject));
- this.predicate = (IRI) inScope(null, Objects.requireNonNull(predicate));
- this.object = inScope(Optional.empty(), Objects.requireNonNull(object));
- }
-
- /**
- * Construct Triple by cloning another Triple and its constituent parts.
- * <p>
- * The parts of the triple may be copied to ensure they are in scope.
- *
- * @param localScope
- * Scope to create new triple in.
- * @param triple
- * Triple to clone
- */
- public TripleImpl(Optional<Graph> localScope, Triple triple) {
- Objects.requireNonNull(localScope);
- Objects.requireNonNull(triple);
-
- this.subject = (BlankNodeOrIRI) inScope(localScope, triple.getSubject());
- this.predicate = (IRI) inScope(localScope, triple.getPredicate());
- this.object = inScope(localScope, triple.getObject());
- }
-
- private RDFTerm inScope(Optional<Graph> localScope, RDFTerm object) {
- if (!(object instanceof BlankNode) && !(object instanceof IRI)
- & !(object instanceof Literal)) {
- throw new IllegalArgumentException(
- "RDFTerm must be BlankNode, IRI or Literal");
- }
- if (object instanceof BlankNode) {
- BlankNode blankNode = (BlankNode) object;
- return new BlankNodeImpl(Objects.requireNonNull(localScope),
- blankNode.internalIdentifier());
- } else if (object instanceof IRI && !(object instanceof IRIImpl)) {
- IRI iri = (IRI) object;
- return new IRIImpl(iri.getIRIString());
- } else if (object instanceof Literal
- && !(object instanceof LiteralImpl)) {
- Literal literal = (Literal) object;
- if (literal.getLanguageTag().isPresent()) {
- return new LiteralImpl(literal.getLexicalForm(), literal
- .getLanguageTag().get());
- } else {
- IRI dataType = (IRI) inScope(localScope, literal.getDatatype());
- return new LiteralImpl(literal.getLexicalForm(), dataType);
- }
- } else {
- return object;
- }
- }
-
- @Override
- public BlankNodeOrIRI getSubject() {
- return subject;
- }
-
- @Override
- public IRI getPredicate() {
- return predicate;
- }
-
- @Override
- public RDFTerm getObject() {
- return object;
- }
-
- @Override
- public String toString() {
- return getSubject().ntriplesString() + " "
- + getPredicate().ntriplesString() + " "
- + getObject().ntriplesString() + " .";
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(subject, predicate, object);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Triple)) {
- return false;
- }
- Triple other = (Triple) obj;
- return getSubject().equals(other.getSubject())
- && getPredicate().equals(other.getPredicate())
- && getObject().equals(other.getObject());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/com/github/commonsrdf/simple/Types.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/Types.java b/simple/src/main/java/com/github/commonsrdf/simple/Types.java
deleted file mode 100644
index 60b5a4a..0000000
--- a/simple/src/main/java/com/github/commonsrdf/simple/Types.java
+++ /dev/null
@@ -1,192 +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.simple;
-
-import java.util.Optional;
-
-import com.github.commonsrdf.api.IRI;
-
-/**
- * Types from the RDF and XML Schema vocabularies.
- *
- * @author Peter Ansell p_ansell@yahoo.com
- */
-public enum Types implements IRI {
-
- /** <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML</tt> */
- RDF_HTML("http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML"),
-
- /** <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</tt> */
- RDF_LANGSTRING("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),
-
- /**
- * <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral</tt>
- *
- * @deprecated Not used in RDF-1.1
- */
- @Deprecated
- RDF_PLAINLITERAL("http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral"),
-
- /** <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral</tt> */
- RDF_XMLLITERAL("http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#anyURI</tt> */
- XSD_ANYURI("http://www.w3.org/2001/XMLSchema#anyURI"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#base64Binary</tt> */
- XSD_BASE64BINARY("http://www.w3.org/2001/XMLSchema#base64Binary"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#boolean</tt> */
- XSD_BOOLEAN("http://www.w3.org/2001/XMLSchema#boolean"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#byte</tt> */
- XSD_BYTE("http://www.w3.org/2001/XMLSchema#byte"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#date</tt> */
- XSD_DATE("http://www.w3.org/2001/XMLSchema#date"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#dateTime</tt> */
- XSD_DATETIME("http://www.w3.org/2001/XMLSchema#dateTime"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#dayTimeDuration</tt> */
- XSD_DAYTIMEDURATION("http://www.w3.org/2001/XMLSchema#dayTimeDuration"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#decimal</tt> */
- XSD_DECIMAL("http://www.w3.org/2001/XMLSchema#decimal"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#double</tt> */
- XSD_DOUBLE("http://www.w3.org/2001/XMLSchema#double"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#duration</tt> */
- XSD_DURATION("http://www.w3.org/2001/XMLSchema#duration"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#float</tt> */
- XSD_FLOAT("http://www.w3.org/2001/XMLSchema#float"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#gDay</tt> */
- XSD_GDAY("http://www.w3.org/2001/XMLSchema#gDay"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#gMonth</tt> */
- XSD_GMONTH("http://www.w3.org/2001/XMLSchema#gMonth"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#gMonthDay</tt> */
- XSD_GMONTHDAY("http://www.w3.org/2001/XMLSchema#gMonthDay"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#gYear</tt> */
- XSD_GYEAR("http://www.w3.org/2001/XMLSchema#gYear"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#gYearMonth</tt> */
- XSD_GYEARMONTH("http://www.w3.org/2001/XMLSchema#gYearMonth"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#hexBinary</tt> */
- XSD_HEXBINARY("http://www.w3.org/2001/XMLSchema#hexBinary"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#int</tt> */
- XSD_INT("http://www.w3.org/2001/XMLSchema#int"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#integer</tt> */
- XSD_INTEGER("http://www.w3.org/2001/XMLSchema#integer"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#language</tt> */
- XSD_LANGUAGE("http://www.w3.org/2001/XMLSchema#language"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#long</tt> */
- XSD_LONG("http://www.w3.org/2001/XMLSchema#long"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#Name</tt> */
- XSD_NAME("http://www.w3.org/2001/XMLSchema#Name"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#NCName</tt> */
- XSD_NCNAME("http://www.w3.org/2001/XMLSchema#NCName"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#negativeInteger</tt> */
- XSD_NEGATIVEINTEGER("http://www.w3.org/2001/XMLSchema#negativeInteger"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#NMTOKEN</tt> */
- XSD_NMTOKEN("http://www.w3.org/2001/XMLSchema#NMTOKEN"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#nonNegativeInteger</tt> */
- XSD_NONNEGATIVEINTEGER(
- "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#nonPositiveInteger</tt> */
- XSD_NONPOSITIVEINTEGER(
- "http://www.w3.org/2001/XMLSchema#nonPositiveInteger"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#normalizedString</tt> */
- XSD_NORMALIZEDSTRING("http://www.w3.org/2001/XMLSchema#normalizedString"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#positiveInteger</tt> */
- XSD_POSITIVEINTEGER("http://www.w3.org/2001/XMLSchema#positiveInteger"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#short</tt> */
- XSD_SHORT("http://www.w3.org/2001/XMLSchema#short"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#string</tt> */
- XSD_STRING("http://www.w3.org/2001/XMLSchema#string"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#time</tt> */
- XSD_TIME("http://www.w3.org/2001/XMLSchema#time"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#token</tt> */
- XSD_TOKEN("http://www.w3.org/2001/XMLSchema#token"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#unsignedByte</tt> */
- XSD_UNSIGNEDBYTE("http://www.w3.org/2001/XMLSchema#unsignedByte"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#unsignedInt</tt> */
- XSD_UNSIGNEDINT("http://www.w3.org/2001/XMLSchema#unsignedInt"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#unsignedLong</tt> */
- XSD_UNSIGNEDLONG("http://www.w3.org/2001/XMLSchema#unsignedLong"),
-
- /** <tt>http://www.w3.org/2001/XMLSchema#unsignedShort</tt> */
- XSD_UNSIGNEDSHORT("http://www.w3.org/2001/XMLSchema#unsignedShort"),
-
- ;
-
- private final IRI field;
-
- Types(String field) {
- this.field = new IRIImpl(field);
- }
-
- @Override
- public String getIRIString() {
- return this.field.getIRIString();
- }
-
- @Override
- public String ntriplesString() {
- return this.field.ntriplesString();
- }
-
- /**
- * Get the IRI from this enum if it is present, or return
- * {@link Optional#empty()} otherwise.
- *
- * @param nextIRI
- * The IRI to look for.
- * @return An {@link Optional} containing the IRI from this enum or
- * {@link Optional#empty()} if it is not present here.
- */
- public static Optional<IRI> get(IRI nextIRI) {
- for (Types nextType : values()) {
- if (nextType.field.equals(nextIRI)) {
- return Optional.of(nextType);
- }
- }
- return Optional.empty();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/com/github/commonsrdf/simple/package-info.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/com/github/commonsrdf/simple/package-info.java b/simple/src/main/java/com/github/commonsrdf/simple/package-info.java
deleted file mode 100644
index 2e053ae..0000000
--- a/simple/src/main/java/com/github/commonsrdf/simple/package-info.java
+++ /dev/null
@@ -1,31 +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.
- */
-/**
- * A simple in-memory implementation of the Commons RDF API.
- * <p>
- * This package contains a simple (if not naive) implementation of the Commons RDF API
- * using in-memory POJO objects.
- * <p>
- * Note that although this module fully implements the commons-rdf API,
- * it should *not* be considered a reference implementation.
- * It is not thread-safe nor scalable, but may be useful for testing
- * and simple usage (e.g. output from an independent RDF parser).
- * <p>
- * To use this implementation, create an instance of {@link SimpleRDFTermFactory}
- * and use methods like {@link SimpleRDFTermFactory#createGraph} and
- * {@link SimpleRDFTermFactory#createIRI(String)}.
- *
- */
-package com.github.commonsrdf.simple;
-
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java
new file mode 100644
index 0000000..b164dce
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java
@@ -0,0 +1,103 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.Graph;
+
+/**
+ * A simple implementation of BlankNode.
+ *
+ */
+class BlankNodeImpl implements BlankNode {
+
+ private static AtomicLong bnodeCounter = new AtomicLong();
+ private final String id;
+ private final Optional<Graph> localScope;
+
+ public BlankNodeImpl() {
+ this(Optional.empty(), "b:" + bnodeCounter.incrementAndGet());
+ }
+
+ public BlankNodeImpl(Optional<Graph> localScope, String id) {
+ this.localScope = Objects.requireNonNull(localScope);
+ if (Objects.requireNonNull(id).isEmpty()) {
+ throw new IllegalArgumentException("Invalid blank node id: " + id);
+ // NOTE: It is valid for the id to not be a valid ntriples bnode id.
+ // See ntriplesString().
+ }
+ this.id = id;
+ }
+
+ @Override
+ public String internalIdentifier() {
+ return id;
+ }
+
+ @Override
+ public String ntriplesString() {
+ if (id.contains(":")) {
+ return "_:u"
+ + UUID.nameUUIDFromBytes(id
+ .getBytes(StandardCharsets.UTF_8));
+ }
+ return "_:" + id;
+ }
+
+ @Override
+ public String toString() {
+ return ntriplesString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localScope, id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof BlankNodeImpl)) {
+ return false;
+ }
+ BlankNodeImpl other = (BlankNodeImpl) obj;
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+ if (localScope == null) {
+ if (other.localScope != null) {
+ return false;
+ }
+ } else if (!localScope.equals(other.localScope)) {
+ return false;
+ }
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
new file mode 100644
index 0000000..a28267e
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
@@ -0,0 +1,141 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.util.LinkedHashSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.Triple;
+
+/**
+ * A simple, memory-based implementation of Graph.
+ * <p>
+ * {@link Triple}s in the graph are kept in a {@link Set}.
+ * <p>
+ * All Stream operations are performed using parallel and unordered directives.
+ */
+class GraphImpl implements Graph {
+
+ private static final int TO_STRING_MAX = 10;
+ protected final Set<Triple> triples = new LinkedHashSet<Triple>();
+
+ @Override
+ public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+ add(new TripleImpl(Objects.requireNonNull(subject),
+ Objects.requireNonNull(predicate),
+ Objects.requireNonNull(object)));
+
+ }
+
+ @Override
+ public void add(Triple triple) {
+ triples.add(new TripleImpl(Optional.of(this), Objects
+ .requireNonNull(triple)));
+ }
+
+ @Override
+ public void clear() {
+ triples.clear();
+ }
+
+ @Override
+ public boolean contains(BlankNodeOrIRI subject, IRI predicate,
+ RDFTerm object) {
+ return getTriples(subject, predicate, object).findFirst().isPresent();
+ }
+
+ @Override
+ public boolean contains(Triple triple) {
+ return triples.contains(Objects.requireNonNull(triple));
+ }
+
+ @Override
+ public Stream<Triple> getTriples() {
+ return triples.parallelStream();
+ }
+
+ @Override
+ public Stream<Triple> getTriples(final BlankNodeOrIRI subject,
+ final IRI predicate, final RDFTerm object) {
+ Predicate<Triple> match = new Predicate<Triple>() {
+ @Override
+ public boolean test(Triple t) {
+ // Lacking the requirement for .equals() we have to be silly
+ // and test ntriples string equivalance
+ if (subject != null
+ && !t.getSubject().ntriplesString()
+ .equals(subject.ntriplesString())) {
+ return false;
+ }
+ if (predicate != null
+ && !t.getPredicate().ntriplesString()
+ .equals(predicate.ntriplesString())) {
+ return false;
+ }
+ if (object != null
+ && !t.getObject().ntriplesString()
+ .equals(object.ntriplesString())) {
+ return false;
+ }
+ return true;
+ }
+ };
+ return getTriples(match);
+ }
+
+ @Override
+ public Stream<Triple> getTriples(final Predicate<Triple> filter) {
+ return getTriples().unordered().filter(filter);
+ }
+
+ @Override
+ public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+ Stream<Triple> toRemove = getTriples(subject, predicate, object);
+ for (Triple t : toRemove.collect(Collectors.toList())) {
+ // Avoid ConcurrentModificationException in ArrayList
+ remove(t);
+ }
+ }
+
+ @Override
+ public void remove(Triple triple) {
+ triples.remove(Objects.requireNonNull(triple));
+ }
+
+ @Override
+ public long size() {
+ return triples.size();
+ }
+
+ @Override
+ public String toString() {
+ String s = getTriples().limit(TO_STRING_MAX).map(Object::toString)
+ .collect(Collectors.joining("\n"));
+ if (size() > TO_STRING_MAX) {
+ return s + "\n# ... +" + (size() - TO_STRING_MAX) + " more";
+ } else {
+ return s;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
new file mode 100644
index 0000000..078c3a8
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
@@ -0,0 +1,64 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.net.URI;
+
+import org.apache.commons.rdf.api.IRI;
+
+/**
+ * A simple implementation of IRI.
+ *
+ */
+class IRIImpl implements IRI {
+
+ protected String iri;
+
+ public IRIImpl(String iri) {
+ // should throw IllegalArgumentException on most illegal IRIs
+ URI.create(iri);
+ // NOTE: We don't keep the URI as it uses outdated RFC2396 and will get some IDNs wrong
+ this.iri = iri;
+ }
+
+ @Override
+ public String getIRIString() {
+ return iri;
+ }
+
+ @Override
+ public String ntriplesString() {
+ return "<" + getIRIString() + ">";
+ }
+
+ @Override
+ public String toString() {
+ return ntriplesString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof IRI)) {
+ return false;
+ }
+ IRI other = (IRI) obj;
+ return getIRIString().equals(other.getIRIString());
+ }
+
+ @Override
+ public int hashCode() {
+ return iri.hashCode();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
new file mode 100644
index 0000000..ee2e6bd
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
@@ -0,0 +1,125 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.util.IllformedLocaleException;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Literal;
+
+/**
+ * A simple implementation of Literal.
+ *
+ */
+class LiteralImpl implements Literal {
+
+ private static final String QUOTE = "\"";
+
+ private IRI dataType;
+ private Optional<String> languageTag;
+ private String lexicalForm;
+
+ public LiteralImpl(String literal) {
+ this(literal, Types.XSD_STRING);
+ }
+
+ public LiteralImpl(String lexicalForm, IRI dataType) {
+ this.lexicalForm = Objects.requireNonNull(lexicalForm);
+ this.dataType = Types.get(Objects.requireNonNull(dataType)).orElse(
+ dataType);
+ this.languageTag = Optional.empty();
+ }
+
+ public LiteralImpl(String literal, String languageTag) {
+ this.lexicalForm = Objects.requireNonNull(literal);
+ this.languageTag = Optional.of(languageTag.toLowerCase(Locale.ENGLISH));
+ if (languageTag.isEmpty()) {
+ // TODO: Check against
+ // http://www.w3.org/TR/n-triples/#n-triples-grammar
+ throw new IllegalArgumentException("Language tag can't be null");
+ }
+ try {
+ new Locale.Builder().setLanguageTag(languageTag);
+ } catch (IllformedLocaleException ex) {
+ throw new IllegalArgumentException("Invalid languageTag: "
+ + languageTag, ex);
+ }
+
+ // System.out.println(aLocale);
+ this.dataType = Types.RDF_LANGSTRING;
+ }
+
+ @Override
+ public IRI getDatatype() {
+ return dataType;
+ }
+
+ @Override
+ public Optional<String> getLanguageTag() {
+ return languageTag;
+ }
+
+ @Override
+ public String getLexicalForm() {
+ return lexicalForm;
+ }
+
+ @Override
+ public String ntriplesString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(QUOTE);
+ // Escape special characters
+ sb.append(getLexicalForm().replace("\\", "\\\\"). // escaped to \\
+ replace("\"", "\\\""). // escaped to \"
+ replace("\r", "\\r"). // escaped to \r
+ replace("\n", "\\n")); // escaped to \n
+ sb.append(QUOTE);
+
+ // getLanguageTag().ifPresent(s -> sb.append("@" + s));
+ if (getLanguageTag().isPresent()) {
+ sb.append("@");
+ sb.append(getLanguageTag().get());
+
+ } else if (!getDatatype().equals(Types.XSD_STRING)) {
+ sb.append("^^");
+ sb.append(getDatatype().ntriplesString());
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public String toString() {
+ return ntriplesString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(dataType, lexicalForm, languageTag);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Literal)) {
+ return false;
+ }
+ Literal literal = (Literal) obj;
+ return getDatatype().equals(literal.getDatatype())
+ && getLexicalForm().equals(literal.getLexicalForm())
+ && getLanguageTag().equals(literal.getLanguageTag());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java b/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java
new file mode 100644
index 0000000..2dc1d45
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java
@@ -0,0 +1,79 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Literal;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.RDFTermFactory;
+import org.apache.commons.rdf.api.Triple;
+
+/**
+ * A simple implementation of RDFTermFactory.
+ * <p>
+ * The {@link RDFTerm} and {@link Graph} instances created by this factory are
+ * simple in-memory Implementations that are not thread-safe or efficient, but
+ * which may be useful for testing and prototyping purposes.
+ *
+ */
+public class SimpleRDFTermFactory implements RDFTermFactory {
+
+ @Override
+ public BlankNode createBlankNode() {
+ return new BlankNodeImpl();
+ }
+
+ @Override
+ public BlankNode createBlankNode(String identifier) {
+ return new BlankNodeImpl(Optional.empty(), identifier);
+ }
+
+ @Override
+ public Graph createGraph() {
+ return new GraphImpl();
+ }
+
+ @Override
+ public IRI createIRI(String iri) {
+ IRI result = new IRIImpl(iri);
+ // Reuse any IRI objects already created in Types
+ return Types.get(result).orElse(result);
+ }
+
+ @Override
+ public Literal createLiteral(String literal) {
+ return new LiteralImpl(literal);
+ }
+
+ @Override
+ public Literal createLiteral(String literal, IRI dataType) {
+ return new LiteralImpl(literal, dataType);
+ }
+
+ @Override
+ public Literal createLiteral(String literal, String language) {
+ return new LiteralImpl(literal, language);
+ }
+
+ @Override
+ public Triple createTriple(BlankNodeOrIRI subject, IRI predicate,
+ RDFTerm object) {
+ return new TripleImpl(subject, predicate, object);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
new file mode 100644
index 0000000..4841992
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
@@ -0,0 +1,138 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.util.Objects;
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Literal;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.Triple;
+
+/**
+ * A simple implementation of Triple.
+ *
+ */
+class TripleImpl implements Triple {
+
+ private BlankNodeOrIRI subject;
+ private IRI predicate;
+ private RDFTerm object;
+
+ /**
+ * Construct Triple from its constituent parts.
+ * <p>
+ * The parts may be copied to ensure they are in scope.
+ *
+ * @param subject subject of triple
+ * @param predicate predicate of triple
+ * @param object object of triple
+ */
+ public TripleImpl(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+ this.subject = (BlankNodeOrIRI) inScope(Optional.empty(),
+ Objects.requireNonNull(subject));
+ this.predicate = (IRI) inScope(null, Objects.requireNonNull(predicate));
+ this.object = inScope(Optional.empty(), Objects.requireNonNull(object));
+ }
+
+ /**
+ * Construct Triple by cloning another Triple and its constituent parts.
+ * <p>
+ * The parts of the triple may be copied to ensure they are in scope.
+ *
+ * @param localScope
+ * Scope to create new triple in.
+ * @param triple
+ * Triple to clone
+ */
+ public TripleImpl(Optional<Graph> localScope, Triple triple) {
+ Objects.requireNonNull(localScope);
+ Objects.requireNonNull(triple);
+
+ this.subject = (BlankNodeOrIRI) inScope(localScope, triple.getSubject());
+ this.predicate = (IRI) inScope(localScope, triple.getPredicate());
+ this.object = inScope(localScope, triple.getObject());
+ }
+
+ private RDFTerm inScope(Optional<Graph> localScope, RDFTerm object) {
+ if (!(object instanceof BlankNode) && !(object instanceof IRI)
+ & !(object instanceof Literal)) {
+ throw new IllegalArgumentException(
+ "RDFTerm must be BlankNode, IRI or Literal");
+ }
+ if (object instanceof BlankNode) {
+ BlankNode blankNode = (BlankNode) object;
+ return new BlankNodeImpl(Objects.requireNonNull(localScope),
+ blankNode.internalIdentifier());
+ } else if (object instanceof IRI && !(object instanceof IRIImpl)) {
+ IRI iri = (IRI) object;
+ return new IRIImpl(iri.getIRIString());
+ } else if (object instanceof Literal
+ && !(object instanceof LiteralImpl)) {
+ Literal literal = (Literal) object;
+ if (literal.getLanguageTag().isPresent()) {
+ return new LiteralImpl(literal.getLexicalForm(), literal
+ .getLanguageTag().get());
+ } else {
+ IRI dataType = (IRI) inScope(localScope, literal.getDatatype());
+ return new LiteralImpl(literal.getLexicalForm(), dataType);
+ }
+ } else {
+ return object;
+ }
+ }
+
+ @Override
+ public BlankNodeOrIRI getSubject() {
+ return subject;
+ }
+
+ @Override
+ public IRI getPredicate() {
+ return predicate;
+ }
+
+ @Override
+ public RDFTerm getObject() {
+ return object;
+ }
+
+ @Override
+ public String toString() {
+ return getSubject().ntriplesString() + " "
+ + getPredicate().ntriplesString() + " "
+ + getObject().ntriplesString() + " .";
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(subject, predicate, object);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Triple)) {
+ return false;
+ }
+ Triple other = (Triple) obj;
+ return getSubject().equals(other.getSubject())
+ && getPredicate().equals(other.getPredicate())
+ && getObject().equals(other.getObject());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/org/apache/commons/rdf/simple/Types.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/Types.java b/simple/src/main/java/org/apache/commons/rdf/simple/Types.java
new file mode 100644
index 0000000..e2bff79
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/Types.java
@@ -0,0 +1,192 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.IRI;
+
+/**
+ * Types from the RDF and XML Schema vocabularies.
+ *
+ * @author Peter Ansell p_ansell@yahoo.com
+ */
+public enum Types implements IRI {
+
+ /** <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML</tt> */
+ RDF_HTML("http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML"),
+
+ /** <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</tt> */
+ RDF_LANGSTRING("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),
+
+ /**
+ * <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral</tt>
+ *
+ * @deprecated Not used in RDF-1.1
+ */
+ @Deprecated
+ RDF_PLAINLITERAL("http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral"),
+
+ /** <tt>http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral</tt> */
+ RDF_XMLLITERAL("http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#anyURI</tt> */
+ XSD_ANYURI("http://www.w3.org/2001/XMLSchema#anyURI"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#base64Binary</tt> */
+ XSD_BASE64BINARY("http://www.w3.org/2001/XMLSchema#base64Binary"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#boolean</tt> */
+ XSD_BOOLEAN("http://www.w3.org/2001/XMLSchema#boolean"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#byte</tt> */
+ XSD_BYTE("http://www.w3.org/2001/XMLSchema#byte"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#date</tt> */
+ XSD_DATE("http://www.w3.org/2001/XMLSchema#date"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#dateTime</tt> */
+ XSD_DATETIME("http://www.w3.org/2001/XMLSchema#dateTime"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#dayTimeDuration</tt> */
+ XSD_DAYTIMEDURATION("http://www.w3.org/2001/XMLSchema#dayTimeDuration"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#decimal</tt> */
+ XSD_DECIMAL("http://www.w3.org/2001/XMLSchema#decimal"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#double</tt> */
+ XSD_DOUBLE("http://www.w3.org/2001/XMLSchema#double"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#duration</tt> */
+ XSD_DURATION("http://www.w3.org/2001/XMLSchema#duration"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#float</tt> */
+ XSD_FLOAT("http://www.w3.org/2001/XMLSchema#float"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#gDay</tt> */
+ XSD_GDAY("http://www.w3.org/2001/XMLSchema#gDay"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#gMonth</tt> */
+ XSD_GMONTH("http://www.w3.org/2001/XMLSchema#gMonth"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#gMonthDay</tt> */
+ XSD_GMONTHDAY("http://www.w3.org/2001/XMLSchema#gMonthDay"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#gYear</tt> */
+ XSD_GYEAR("http://www.w3.org/2001/XMLSchema#gYear"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#gYearMonth</tt> */
+ XSD_GYEARMONTH("http://www.w3.org/2001/XMLSchema#gYearMonth"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#hexBinary</tt> */
+ XSD_HEXBINARY("http://www.w3.org/2001/XMLSchema#hexBinary"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#int</tt> */
+ XSD_INT("http://www.w3.org/2001/XMLSchema#int"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#integer</tt> */
+ XSD_INTEGER("http://www.w3.org/2001/XMLSchema#integer"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#language</tt> */
+ XSD_LANGUAGE("http://www.w3.org/2001/XMLSchema#language"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#long</tt> */
+ XSD_LONG("http://www.w3.org/2001/XMLSchema#long"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#Name</tt> */
+ XSD_NAME("http://www.w3.org/2001/XMLSchema#Name"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#NCName</tt> */
+ XSD_NCNAME("http://www.w3.org/2001/XMLSchema#NCName"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#negativeInteger</tt> */
+ XSD_NEGATIVEINTEGER("http://www.w3.org/2001/XMLSchema#negativeInteger"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#NMTOKEN</tt> */
+ XSD_NMTOKEN("http://www.w3.org/2001/XMLSchema#NMTOKEN"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#nonNegativeInteger</tt> */
+ XSD_NONNEGATIVEINTEGER(
+ "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#nonPositiveInteger</tt> */
+ XSD_NONPOSITIVEINTEGER(
+ "http://www.w3.org/2001/XMLSchema#nonPositiveInteger"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#normalizedString</tt> */
+ XSD_NORMALIZEDSTRING("http://www.w3.org/2001/XMLSchema#normalizedString"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#positiveInteger</tt> */
+ XSD_POSITIVEINTEGER("http://www.w3.org/2001/XMLSchema#positiveInteger"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#short</tt> */
+ XSD_SHORT("http://www.w3.org/2001/XMLSchema#short"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#string</tt> */
+ XSD_STRING("http://www.w3.org/2001/XMLSchema#string"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#time</tt> */
+ XSD_TIME("http://www.w3.org/2001/XMLSchema#time"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#token</tt> */
+ XSD_TOKEN("http://www.w3.org/2001/XMLSchema#token"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#unsignedByte</tt> */
+ XSD_UNSIGNEDBYTE("http://www.w3.org/2001/XMLSchema#unsignedByte"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#unsignedInt</tt> */
+ XSD_UNSIGNEDINT("http://www.w3.org/2001/XMLSchema#unsignedInt"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#unsignedLong</tt> */
+ XSD_UNSIGNEDLONG("http://www.w3.org/2001/XMLSchema#unsignedLong"),
+
+ /** <tt>http://www.w3.org/2001/XMLSchema#unsignedShort</tt> */
+ XSD_UNSIGNEDSHORT("http://www.w3.org/2001/XMLSchema#unsignedShort"),
+
+ ;
+
+ private final IRI field;
+
+ Types(String field) {
+ this.field = new IRIImpl(field);
+ }
+
+ @Override
+ public String getIRIString() {
+ return this.field.getIRIString();
+ }
+
+ @Override
+ public String ntriplesString() {
+ return this.field.ntriplesString();
+ }
+
+ /**
+ * Get the IRI from this enum if it is present, or return
+ * {@link Optional#empty()} otherwise.
+ *
+ * @param nextIRI
+ * The IRI to look for.
+ * @return An {@link Optional} containing the IRI from this enum or
+ * {@link Optional#empty()} if it is not present here.
+ */
+ public static Optional<IRI> get(IRI nextIRI) {
+ for (Types nextType : values()) {
+ if (nextType.field.equals(nextIRI)) {
+ return Optional.of(nextType);
+ }
+ }
+ return Optional.empty();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java b/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java
new file mode 100644
index 0000000..367a455
--- /dev/null
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java
@@ -0,0 +1,31 @@
+/**
+ * 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.
+ */
+/**
+ * A simple in-memory implementation of the Commons RDF API.
+ * <p>
+ * This package contains a simple (if not naive) implementation of the Commons RDF API
+ * using in-memory POJO objects.
+ * <p>
+ * Note that although this module fully implements the commons-rdf API,
+ * it should *not* be considered a reference implementation.
+ * It is not thread-safe nor scalable, but may be useful for testing
+ * and simple usage (e.g. output from an independent RDF parser).
+ * <p>
+ * To use this implementation, create an instance of {@link SimpleRDFTermFactory}
+ * and use methods like {@link SimpleRDFTermFactory#createGraph} and
+ * {@link SimpleRDFTermFactory#createIRI(String)}.
+ *
+ */
+package org.apache.commons.rdf.simple;
+
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/com/github/commonsrdf/simple/BlankNodeImplTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/com/github/commonsrdf/simple/BlankNodeImplTest.java b/simple/src/test/java/com/github/commonsrdf/simple/BlankNodeImplTest.java
deleted file mode 100644
index c275ed7..0000000
--- a/simple/src/test/java/com/github/commonsrdf/simple/BlankNodeImplTest.java
+++ /dev/null
@@ -1,38 +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.simple;
-
-import java.util.Optional;
-
-import com.github.commonsrdf.api.AbstractBlankNodeTest;
-import com.github.commonsrdf.api.BlankNode;
-
-/**
- * Concrete implementation of BlankNodeImpl test.
- *
- * @author Peter Ansell p_ansell@yahoo.com
- */
-public class BlankNodeImplTest extends AbstractBlankNodeTest {
-
- @Override
- protected BlankNode getBlankNode() {
- return new BlankNodeImpl();
- }
-
- @Override
- protected BlankNode getBlankNode(String identifier) {
- return new BlankNodeImpl(Optional.empty(), identifier);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/com/github/commonsrdf/simple/DefaultGraphTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/com/github/commonsrdf/simple/DefaultGraphTest.java b/simple/src/test/java/com/github/commonsrdf/simple/DefaultGraphTest.java
deleted file mode 100644
index 1663de4..0000000
--- a/simple/src/test/java/com/github/commonsrdf/simple/DefaultGraphTest.java
+++ /dev/null
@@ -1,48 +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.simple;
-
-import com.github.commonsrdf.api.AbstractGraphTest;
-import com.github.commonsrdf.api.Graph;
-import com.github.commonsrdf.api.IRI;
-import com.github.commonsrdf.api.RDFTermFactory;
-
-/**
- * Ensure AbstractGraphTest does not crash if the RDFTermFactory throws
- * UnsupportedOperationException
- *
- */
-
-public class DefaultGraphTest extends AbstractGraphTest {
-
- @Override
- public RDFTermFactory createFactory() {
- // The most minimal RDFTermFactory that would still
- // make sense with a Graph
- return new RDFTermFactory() {
- @Override
- public Graph createGraph() throws UnsupportedOperationException {
- return new GraphImpl();
- }
-
- @Override
- public IRI createIRI(String iri)
- throws UnsupportedOperationException,
- IllegalArgumentException {
- return new IRIImpl(iri);
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/com/github/commonsrdf/simple/SimpleGraphTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/com/github/commonsrdf/simple/SimpleGraphTest.java b/simple/src/test/java/com/github/commonsrdf/simple/SimpleGraphTest.java
deleted file mode 100644
index d1bc435..0000000
--- a/simple/src/test/java/com/github/commonsrdf/simple/SimpleGraphTest.java
+++ /dev/null
@@ -1,30 +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.simple;
-
-import com.github.commonsrdf.api.AbstractGraphTest;
-import com.github.commonsrdf.api.RDFTermFactory;
-
-/**
- * Test SimpleRDFTermFactory with AbstractGraphTest
- *
- */
-public class SimpleGraphTest extends AbstractGraphTest {
-
- @Override
- public RDFTermFactory createFactory() {
- return new SimpleRDFTermFactory();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/com/github/commonsrdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/com/github/commonsrdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java b/simple/src/test/java/com/github/commonsrdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
deleted file mode 100644
index dccf72a..0000000
--- a/simple/src/test/java/com/github/commonsrdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
+++ /dev/null
@@ -1,44 +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.simple;
-
-import java.net.URI;
-
-import com.github.commonsrdf.api.AbstractRDFTermFactoryTest;
-import com.github.commonsrdf.api.IRI;
-import com.github.commonsrdf.api.RDFTermFactory;
-
-/**
- * Test simple IRI without relative IRI support.
- * <p?>
- * Ensures that {@link AbstractRDFTermFactoryTest#createIRIRelative()} is
- * correctly skipped (without causing an error.
- *
- */
-public class SimpleNoRelativeIRIRDFTermFactoryTest extends
- AbstractRDFTermFactoryTest {
- @Override
- public RDFTermFactory createFactory() {
- return new SimpleRDFTermFactory() {
- @Override
- public IRI createIRI(String iri) {
- if (!URI.create(iri).isAbsolute()) {
- throw new IllegalArgumentException("IRIs must be absolute");
- // ..in this subclass for testing purposes only :)
- }
- return super.createIRI(iri);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/com/github/commonsrdf/simple/SimpleRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/com/github/commonsrdf/simple/SimpleRDFTermFactoryTest.java b/simple/src/test/java/com/github/commonsrdf/simple/SimpleRDFTermFactoryTest.java
deleted file mode 100644
index 43b9515..0000000
--- a/simple/src/test/java/com/github/commonsrdf/simple/SimpleRDFTermFactoryTest.java
+++ /dev/null
@@ -1,26 +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.simple;
-
-import com.github.commonsrdf.api.AbstractRDFTermFactoryTest;
-import com.github.commonsrdf.api.RDFTermFactory;
-
-public class SimpleRDFTermFactoryTest extends AbstractRDFTermFactoryTest {
-
- @Override
- public RDFTermFactory createFactory() {
- return new SimpleRDFTermFactory();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/com/github/commonsrdf/simple/TestWritingGraph.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/com/github/commonsrdf/simple/TestWritingGraph.java b/simple/src/test/java/com/github/commonsrdf/simple/TestWritingGraph.java
deleted file mode 100644
index 34b8b40..0000000
--- a/simple/src/test/java/com/github/commonsrdf/simple/TestWritingGraph.java
+++ /dev/null
@@ -1,96 +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.simple;
-
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Optional;
-import java.util.stream.Stream;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.github.commonsrdf.api.BlankNode;
-import com.github.commonsrdf.api.IRI;
-
-public class TestWritingGraph {
-
- /*
- * 200k triples should do - about 7 MB on disk. Override with
- * -Dtriples=20000000 to exercise your memory banks.
- */
- private static final int TRIPLES = Integer.getInteger("triples", 200000);
-
- /** Run tests with -Dkeepfiles=true to inspect /tmp files **/
- private static boolean KEEP_FILES = Boolean.getBoolean("keepfiles");
-
- private static GraphImpl graph;
-
- @BeforeClass
- public static void createGraph() throws Exception {
- graph = new GraphImpl();
- BlankNode subject = new BlankNodeImpl(Optional.of(graph), "subj");
- IRI predicate = new IRIImpl("pred");
- for (int i = 0; i < TRIPLES; i++) {
- graph.add(subject, predicate, new LiteralImpl("Example " + i, "en"));
- }
- }
-
- @Test
- public void createGraphTiming() throws Exception {
- createGraph();
- }
-
- @Test
- public void countQuery() {
- BlankNode subject = new BlankNodeImpl(Optional.of(graph), "subj");
- IRI predicate = new IRIImpl("pred");
- long count = graph.getTriples(subject, predicate, null).unordered()
- .parallel().count();
- System.out.println("Counted - " + count);
- }
-
- @Test
- public void writeGraphFromStream() throws Exception {
- Path graphFile = Files.createTempFile("graph", ".nt");
- if (KEEP_FILES) {
- System.out.println("From stream: " + graphFile);
- } else {
- graphFile.toFile().deleteOnExit();
- }
-
- Stream<CharSequence> stream = graph.getTriples().unordered()
- .map(Object::toString);
- Files.write(graphFile, stream::iterator, Charset.forName("UTF-8"));
- }
-
- @Test
- public void writeGraphFromStreamFiltered() throws Exception {
- Path graphFile = Files.createTempFile("graph", ".nt");
- if (KEEP_FILES) {
- System.out.println("Filtered stream: " + graphFile);
- } else {
- graphFile.toFile().deleteOnExit();
- }
-
- BlankNode subject = new BlankNodeImpl(Optional.of(graph), "subj");
- IRI predicate = new IRIImpl("pred");
- Stream<CharSequence> stream = graph
- .getTriples(subject, predicate, null).map(Object::toString);
- Files.write(graphFile, stream::iterator, Charset.forName("UTF-8"));
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/com/github/commonsrdf/simple/TypesTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/com/github/commonsrdf/simple/TypesTest.java b/simple/src/test/java/com/github/commonsrdf/simple/TypesTest.java
deleted file mode 100644
index eb713f2..0000000
--- a/simple/src/test/java/com/github/commonsrdf/simple/TypesTest.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.simple;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests for the {@link Types} enumeration.
- *
- * @author Peter Ansell p_ansell@yahoo.com
- */
-public class TypesTest {
-
- /**
- * Test method for {@link com.github.commonsrdf.simple.Types#getIRIString()}
- * .
- */
- @Test
- public final void testGetIRIString() {
- assertEquals("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",
- Types.RDF_LANGSTRING.getIRIString());
- }
-
- /**
- * Test method for
- * {@link com.github.commonsrdf.simple.Types#ntriplesString()}.
- */
- @Test
- public final void testNtriplesString() {
- assertEquals("<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>",
- Types.RDF_LANGSTRING.ntriplesString());
- }
-
- /**
- * Test method for
- * {@link com.github.commonsrdf.simple.Types#get(com.github.commonsrdf.api.IRI)}
- * .
- */
- @Test
- public final void testGet() {
- assertTrue(Types.get(
- new IRIImpl("http://www.w3.org/2001/XMLSchema#boolean"))
- .isPresent());
- assertEquals(
- "http://www.w3.org/2001/XMLSchema#boolean",
- Types.get(
- new IRIImpl("http://www.w3.org/2001/XMLSchema#boolean"))
- .get().getIRIString());
- assertFalse(Types.get(
- new IRIImpl("http://www.w3.org/2001/XMLSchema#nonExistent"))
- .isPresent());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java
new file mode 100644
index 0000000..b619a93
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java
@@ -0,0 +1,38 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.util.Optional;
+
+import org.apache.commons.rdf.api.AbstractBlankNodeTest;
+import org.apache.commons.rdf.api.BlankNode;
+
+/**
+ * Concrete implementation of BlankNodeImpl test.
+ *
+ * @author Peter Ansell p_ansell@yahoo.com
+ */
+public class BlankNodeImplTest extends AbstractBlankNodeTest {
+
+ @Override
+ protected BlankNode getBlankNode() {
+ return new BlankNodeImpl();
+ }
+
+ @Override
+ protected BlankNode getBlankNode(String identifier) {
+ return new BlankNodeImpl(Optional.empty(), identifier);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
new file mode 100644
index 0000000..cdf49eb
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import org.apache.commons.rdf.api.AbstractGraphTest;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDFTermFactory;
+
+/**
+ * Ensure AbstractGraphTest does not crash if the RDFTermFactory throws
+ * UnsupportedOperationException
+ *
+ */
+
+public class DefaultGraphTest extends AbstractGraphTest {
+
+ @Override
+ public RDFTermFactory createFactory() {
+ // The most minimal RDFTermFactory that would still
+ // make sense with a Graph
+ return new RDFTermFactory() {
+ @Override
+ public Graph createGraph() throws UnsupportedOperationException {
+ return new GraphImpl();
+ }
+
+ @Override
+ public IRI createIRI(String iri)
+ throws UnsupportedOperationException,
+ IllegalArgumentException {
+ return new IRIImpl(iri);
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java
new file mode 100644
index 0000000..29ddc22
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java
@@ -0,0 +1,30 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import org.apache.commons.rdf.api.AbstractGraphTest;
+import org.apache.commons.rdf.api.RDFTermFactory;
+
+/**
+ * Test SimpleRDFTermFactory with AbstractGraphTest
+ *
+ */
+public class SimpleGraphTest extends AbstractGraphTest {
+
+ @Override
+ public RDFTermFactory createFactory() {
+ return new SimpleRDFTermFactory();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
new file mode 100644
index 0000000..015db78
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
@@ -0,0 +1,44 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.net.URI;
+
+import org.apache.commons.rdf.api.AbstractRDFTermFactoryTest;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.RDFTermFactory;
+
+/**
+ * Test simple IRI without relative IRI support.
+ * <p?>
+ * Ensures that {@link AbstractRDFTermFactoryTest#createIRIRelative()} is
+ * correctly skipped (without causing an error.
+ *
+ */
+public class SimpleNoRelativeIRIRDFTermFactoryTest extends
+ AbstractRDFTermFactoryTest {
+ @Override
+ public RDFTermFactory createFactory() {
+ return new SimpleRDFTermFactory() {
+ @Override
+ public IRI createIRI(String iri) {
+ if (!URI.create(iri).isAbsolute()) {
+ throw new IllegalArgumentException("IRIs must be absolute");
+ // ..in this subclass for testing purposes only :)
+ }
+ return super.createIRI(iri);
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java
new file mode 100644
index 0000000..db532b1
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java
@@ -0,0 +1,26 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import org.apache.commons.rdf.api.AbstractRDFTermFactoryTest;
+import org.apache.commons.rdf.api.RDFTermFactory;
+
+public class SimpleRDFTermFactoryTest extends AbstractRDFTermFactoryTest {
+
+ @Override
+ public RDFTermFactory createFactory() {
+ return new SimpleRDFTermFactory();
+ }
+
+}
[4/7] incubator-commonsrdf git commit: COMMONSRDF-2: refactorized
simple impl java packages
Posted by wi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
new file mode 100644
index 0000000..c434d45
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
@@ -0,0 +1,96 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.IRI;
+
+public class TestWritingGraph {
+
+ /*
+ * 200k triples should do - about 7 MB on disk. Override with
+ * -Dtriples=20000000 to exercise your memory banks.
+ */
+ private static final int TRIPLES = Integer.getInteger("triples", 200000);
+
+ /** Run tests with -Dkeepfiles=true to inspect /tmp files **/
+ private static boolean KEEP_FILES = Boolean.getBoolean("keepfiles");
+
+ private static GraphImpl graph;
+
+ @BeforeClass
+ public static void createGraph() throws Exception {
+ graph = new GraphImpl();
+ BlankNode subject = new BlankNodeImpl(Optional.of(graph), "subj");
+ IRI predicate = new IRIImpl("pred");
+ for (int i = 0; i < TRIPLES; i++) {
+ graph.add(subject, predicate, new LiteralImpl("Example " + i, "en"));
+ }
+ }
+
+ @Test
+ public void createGraphTiming() throws Exception {
+ createGraph();
+ }
+
+ @Test
+ public void countQuery() {
+ BlankNode subject = new BlankNodeImpl(Optional.of(graph), "subj");
+ IRI predicate = new IRIImpl("pred");
+ long count = graph.getTriples(subject, predicate, null).unordered()
+ .parallel().count();
+ System.out.println("Counted - " + count);
+ }
+
+ @Test
+ public void writeGraphFromStream() throws Exception {
+ Path graphFile = Files.createTempFile("graph", ".nt");
+ if (KEEP_FILES) {
+ System.out.println("From stream: " + graphFile);
+ } else {
+ graphFile.toFile().deleteOnExit();
+ }
+
+ Stream<CharSequence> stream = graph.getTriples().unordered()
+ .map(Object::toString);
+ Files.write(graphFile, stream::iterator, Charset.forName("UTF-8"));
+ }
+
+ @Test
+ public void writeGraphFromStreamFiltered() throws Exception {
+ Path graphFile = Files.createTempFile("graph", ".nt");
+ if (KEEP_FILES) {
+ System.out.println("Filtered stream: " + graphFile);
+ } else {
+ graphFile.toFile().deleteOnExit();
+ }
+
+ BlankNode subject = new BlankNodeImpl(Optional.of(graph), "subj");
+ IRI predicate = new IRIImpl("pred");
+ Stream<CharSequence> stream = graph
+ .getTriples(subject, predicate, null).map(Object::toString);
+ Files.write(graphFile, stream::iterator, Charset.forName("UTF-8"));
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f3a452ea/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java
new file mode 100644
index 0000000..25c118c
--- /dev/null
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java
@@ -0,0 +1,67 @@
+/**
+ * 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 org.apache.commons.rdf.simple;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Tests for the {@link Types} enumeration.
+ *
+ * @author Peter Ansell p_ansell@yahoo.com
+ */
+public class TypesTest {
+
+ /**
+ * Test method for {@link Types#getIRIString()}
+ * .
+ */
+ @Test
+ public final void testGetIRIString() {
+ assertEquals("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",
+ Types.RDF_LANGSTRING.getIRIString());
+ }
+
+ /**
+ * Test method for
+ * {@link Types#ntriplesString()}.
+ */
+ @Test
+ public final void testNtriplesString() {
+ assertEquals("<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>",
+ Types.RDF_LANGSTRING.ntriplesString());
+ }
+
+ /**
+ * Test method for
+ * {@link Types#get(org.apache.commons.rdf.api.IRI)}
+ * .
+ */
+ @Test
+ public final void testGet() {
+ assertTrue(Types.get(
+ new IRIImpl("http://www.w3.org/2001/XMLSchema#boolean"))
+ .isPresent());
+ assertEquals(
+ "http://www.w3.org/2001/XMLSchema#boolean",
+ Types.get(
+ new IRIImpl("http://www.w3.org/2001/XMLSchema#boolean"))
+ .get().getIRIString());
+ assertFalse(Types.get(
+ new IRIImpl("http://www.w3.org/2001/XMLSchema#nonExistent"))
+ .isPresent());
+ }
+
+}
[3/7] incubator-commonsrdf git commit: COMMONSRDF-2: refactorized api
java packages
Posted by wi...@apache.org.
COMMONSRDF-2: refactorized api java packages
Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/fa5321e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/fa5321e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/fa5321e4
Branch: refs/heads/master
Commit: fa5321e4589e4e6a49ddf15d8d0bdf173d84d803
Parents: 4076688
Author: Sergio Fernández <wi...@apache.org>
Authored: Fri Mar 27 19:40:21 2015 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Fri Mar 27 19:40:21 2015 +0100
----------------------------------------------------------------------
.../com/github/commonsrdf/api/BlankNode.java | 148 -------
.../github/commonsrdf/api/BlankNodeOrIRI.java | 22 -
.../java/com/github/commonsrdf/api/Graph.java | 179 ---------
.../java/com/github/commonsrdf/api/IRI.java | 74 ----
.../java/com/github/commonsrdf/api/Literal.java | 108 -----
.../java/com/github/commonsrdf/api/RDFTerm.java | 36 --
.../github/commonsrdf/api/RDFTermFactory.java | 252 ------------
.../java/com/github/commonsrdf/api/Triple.java | 97 -----
.../org/apache/commons/rdf/api/BlankNode.java | 148 +++++++
.../apache/commons/rdf/api/BlankNodeOrIRI.java | 22 +
.../java/org/apache/commons/rdf/api/Graph.java | 179 +++++++++
.../java/org/apache/commons/rdf/api/IRI.java | 74 ++++
.../org/apache/commons/rdf/api/Literal.java | 108 +++++
.../org/apache/commons/rdf/api/RDFTerm.java | 36 ++
.../apache/commons/rdf/api/RDFTermFactory.java | 252 ++++++++++++
.../java/org/apache/commons/rdf/api/Triple.java | 97 +++++
.../commonsrdf/api/AbstractBlankNodeTest.java | 222 ----------
.../commonsrdf/api/AbstractGraphTest.java | 275 -------------
.../api/AbstractRDFTermFactoryTest.java | 401 -------------------
.../api/DefaultRDFTermFactoryTest.java | 32 --
.../commons/rdf/api/AbstractBlankNodeTest.java | 222 ++++++++++
.../commons/rdf/api/AbstractGraphTest.java | 275 +++++++++++++
.../rdf/api/AbstractRDFTermFactoryTest.java | 401 +++++++++++++++++++
.../rdf/api/DefaultRDFTermFactoryTest.java | 30 ++
24 files changed, 1844 insertions(+), 1846 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/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
deleted file mode 100644
index 6ab326e..0000000
--- a/api/src/main/java/com/github/commonsrdf/api/BlankNode.java
+++ /dev/null
@@ -1,148 +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;
-
-/**
- * A <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>
- * <p>
- * Note:
- * <blockquote>
- * <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node">Blank nodes</a>
- * 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.
- * </blockquote>
- * <p>
- * Also note that:
- * <blockquote>
- * <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier">Blank node identifiers</a>
- * are local identifiers that are used in
- * some concrete RDF syntaxes or RDF store implementations. They are always
- * <em>locally scoped</em> to the file or RDF store, and are <em>not</em> persistent
- * or portable
- * identifiers for blank nodes. Blank node identifiers are <em>not</em>
- * 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.
- * <p>
- * 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.
- * </blockquote>
- *
- * @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.
- * <p>
- * 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 (see {@link #equals(Object)})
- * <p>
- * 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.
- * <p>
- * 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.
- * <p>
- * 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.
- * <p>
- * It is not a requirement for the internal identifier to be a part of the
- * {@link #ntriplesString()}, except that two BlankNode instances with the
- * same internalIdentifier() and same local scope should have the same
- * {@link #ntriplesString()}.
- *
- * @return An internal, system identifier for the {@link BlankNode}.
- */
- String internalIdentifier();
-
- /**
- * Check it this BlankNode is equal to another BlankNode. <blockquote> <a
- * href
- * ="http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier">Blank
- * node identifiers</a> 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 <em>not</em> persistent or portable
- * identifiers for blank nodes. Blank node identifiers are <em>not</em> 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.
- * <p>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.
- * </blockquote>
- * <p>
- * Implementations MUST check the local scope, as two BlankNode in different
- * Graphs MUST differ. On the other hand, two BlankNodes found in triples of
- * the same Graph instance MUST equal if and only if they have the same
- * {@link #internalIdentifier()}.
- * </p>
- * <p>
- * Implementations MUST also override {@link #hashCode()} so that two equal
- * Literals produce the same hash code.
- * </p>
- *
- * @see Object#equals(Object)
- *
- * @param other
- * Another object
- * @return true if other is a BlankNode, is in the same local scope and is
- * equal to this BlankNode
- */
- @Override
- public boolean equals(Object other);
-
- /**
- * Calculate a hash code for this BlankNode.
- * <p>
- * This method MUST be implemented when implementing {@link #equals(Object)}
- * so that two equal BlankNodes produce the same hash code.
- *
- * @see Object#hashCode()
- *
- * @return a hash code value for this BlankNode.
- */
- @Override
- public int hashCode();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/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
deleted file mode 100644
index 38d5ef6..0000000
--- a/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/fa5321e4/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
deleted file mode 100644
index 40f4808..0000000
--- a/api/src/main/java/com/github/commonsrdf/api/Graph.java
+++ /dev/null
@@ -1,179 +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.function.Predicate;
-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 extends AutoCloseable {
-
- /**
- * 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);
-
- /**
- * Close the graph, relinquishing any underlying resources.
- * <p>
- * For example, this would close any open file and network streams and free
- * database locks held by the Graph implementation.
- * <p>
- * The behaviour of the other Graph methods are undefined after closing the
- * graph.
- * <p>
- * Implementations might not need {@link #close()}, hence the default
- * implementation does nothing.
- */
- @Override
- default void close() throws Exception {
- }
-
- /**
- * 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 the
- * equals method for each {@link Triple}.
- *
- * @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
- * the equals method for each {@link Triple}.
- * <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
- * the equals method for each {@link Triple}.
- * <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);
-
- /**
- * Get all triples contained by the graph matched with the pattern.
- * <p>
- * The iteration does not contain any duplicate triples, as determined by
- * the equals method for each {@link Triple}.
- * <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 filter
- * A filter to match against each triple in the graph.
- * @return A {@link Stream} over the matched triples.
- */
- Stream<? extends Triple> getTriples(Predicate<Triple> filter);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/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
deleted file mode 100644
index 421d2a9..0000000
--- a/api/src/main/java/com/github/commonsrdf/api/IRI.java
+++ /dev/null
@@ -1,74 +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 {
-
- /**
- * Return 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();
-
- /**
- * Check it this IRI is equal to another IRI. <blockquote> <a
- * href="http://www.w3.org/TR/rdf11-concepts/#section-IRIs">IRI
- * equality</a>: Two IRIs are equal if and only if they are equivalent under
- * Simple String Comparison according to section 5.1 of [RFC3987]. Further
- * normalization MUST NOT be performed when comparing IRIs for equality.
- * </blockquote>
- * <p>
- * Two IRIs are equal are in the same local scope and their
- * {@link #getIRIString()} are equal.
- * </p>
- * <p>
- * Implementations MAY check the local scope for IRI comparison.
- * </p>
- * <p>
- * Implementations MUST also override {@link #hashCode()} so that two equal
- * IRIs produce the same hash code.
- * </p>
- *
- * @see Object#equals(Object)
- *
- * @param other
- * Another object
- * @return true if other is an IRI and is equal to this
- */
- @Override
- public boolean equals(Object other);
-
- /**
- * Calculate a hash code for this IRI.
- * <p>
- * This method MUST be implemented when implementing {@link #equals(Object)}
- * so that two equal IRIs produce the same hash code.
- *
- * @see Object#hashCode()
- *
- * @return a hash code value for this IRI.
- */
- @Override
- public int hashCode();
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/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
deleted file mode 100644
index 4982327..0000000
--- a/api/src/main/java/com/github/commonsrdf/api/Literal.java
+++ /dev/null
@@ -1,108 +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;
-
-/**
- * A 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();
-
- /**
- * Check it this Literal is equal to another Literal. <blockquote> <a
- * href="http://www.w3.org/TR/rdf11-concepts/#dfn-literal-term">Literal term
- * equality</a>: Two literals are term-equal (the same RDF literal) if and
- * only if the two lexical forms, the two datatype IRIs, and the two
- * language tags (if any) compare equal, character by character. Thus, two
- * literals can have the same value without being the same RDF term.
- * </blockquote>
- * <p>
- * Implementations MAY check the local scope for Literal comparison.
- * </p>
- * <p>
- * Implementations MUST also override {@link #hashCode()} so that two equal
- * Literals produce the same hash code.
- * </p>
- *
- * @see Object#equals(Object)
- *
- * @param other
- * Another object
- * @return true if other is a Literal and is equal to this
- */
- @Override
- public boolean equals(Object other);
-
- /**
- * Calculate a hash code for this Literal.
- * <p>
- * This method MUST be implemented when implementing {@link #equals(Object)}
- * so that two equal Literals produce the same hash code.
- * </p>
- *
- * @see Object#hashCode()
- *
- * @return a hash code value for this Literal.
- */
- @Override
- public int hashCode();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/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
deleted file mode 100644
index 5530e67..0000000
--- a/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();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/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
deleted file mode 100644
index 90592c6..0000000
--- a/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java
+++ /dev/null
@@ -1,252 +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.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
- * If the operation is not supported.
- */
- 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
- * the equals contract for {@link BlankNode} for more information.
- * <p>
- * If supported, the {@link BlankNode#internalIdentifier()} of the returned
- * blank node MAY be equal to the provided identifier.
- *
- * @param identifier
- * A non-empty String that is unique to this blank node in this
- * scope, and which may be used as the 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 the operation is not 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 the operation is not 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 operation is not supported.
- */
- 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 operation is not 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 operation is not 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 operation is not 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 the operation 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/fa5321e4/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
deleted file mode 100644
index 1cc8ec8..0000000
--- a/api/src/main/java/com/github/commonsrdf/api/Triple.java
+++ /dev/null
@@ -1,97 +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-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();
-
- /**
- * Check it this Triple is equal to another Triple.
- * <p>
- * Two Triples are equal if and only if their {@link #getSubject()},
- * {@link #getPredicate()} and {@link #getObject()} are equal.
- * </p>
- * <p>
- * Implementations MUST check the local scope for Triple comparison if
- * either the subject or object is a BlankNode, and MAY check the local
- * scope in other cases.
- * </p>
- * <p>
- * Implementations MUST also override {@link #hashCode()} so that two equal
- * Triples produce the same hash code.
- * </p>
- *
- * @see Object#equals(Object)
- *
- * @param other
- * Another object
- * @return true if other is a Triple and is equal to this
- */
- @Override
- public boolean equals(Object other);
-
- /**
- * Calculate a hash code for this Triple.
- * <p>
- * This method MUST be implemented when implementing {@link #equals(Object)}
- * so that two equal IRIs produce the same hash code.
- * </p>
- *
- * @see Object#hashCode()
- *
- * @return a hash code value for this Triple.
- */
- @Override
- public int hashCode();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java b/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
new file mode 100644
index 0000000..9a81002
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
@@ -0,0 +1,148 @@
+/**
+ * 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 org.apache.commons.rdf.api;
+
+/**
+ * A <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>
+ * <p>
+ * Note:
+ * <blockquote>
+ * <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node">Blank nodes</a>
+ * 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.
+ * </blockquote>
+ * <p>
+ * Also note that:
+ * <blockquote>
+ * <a href="http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier">Blank node identifiers</a>
+ * are local identifiers that are used in
+ * some concrete RDF syntaxes or RDF store implementations. They are always
+ * <em>locally scoped</em> to the file or RDF store, and are <em>not</em> persistent
+ * or portable
+ * identifiers for blank nodes. Blank node identifiers are <em>not</em>
+ * 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.
+ * <p>
+ * 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.
+ * </blockquote>
+ *
+ * @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.
+ * <p>
+ * 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 (see {@link #equals(Object)})
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ * <p>
+ * 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.
+ * <p>
+ * It is not a requirement for the internal identifier to be a part of the
+ * {@link #ntriplesString()}, except that two BlankNode instances with the
+ * same internalIdentifier() and same local scope should have the same
+ * {@link #ntriplesString()}.
+ *
+ * @return An internal, system identifier for the {@link BlankNode}.
+ */
+ String internalIdentifier();
+
+ /**
+ * Check it this BlankNode is equal to another BlankNode. <blockquote> <a
+ * href
+ * ="http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier">Blank
+ * node identifiers</a> 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 <em>not</em> persistent or portable
+ * identifiers for blank nodes. Blank node identifiers are <em>not</em> 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.
+ * <p>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.
+ * </blockquote>
+ * <p>
+ * Implementations MUST check the local scope, as two BlankNode in different
+ * Graphs MUST differ. On the other hand, two BlankNodes found in triples of
+ * the same Graph instance MUST equal if and only if they have the same
+ * {@link #internalIdentifier()}.
+ * </p>
+ * <p>
+ * Implementations MUST also override {@link #hashCode()} so that two equal
+ * Literals produce the same hash code.
+ * </p>
+ *
+ * @see Object#equals(Object)
+ *
+ * @param other
+ * Another object
+ * @return true if other is a BlankNode, is in the same local scope and is
+ * equal to this BlankNode
+ */
+ @Override
+ public boolean equals(Object other);
+
+ /**
+ * Calculate a hash code for this BlankNode.
+ * <p>
+ * This method MUST be implemented when implementing {@link #equals(Object)}
+ * so that two equal BlankNodes produce the same hash code.
+ *
+ * @see Object#hashCode()
+ *
+ * @return a hash code value for this BlankNode.
+ */
+ @Override
+ public int hashCode();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/api/src/main/java/org/apache/commons/rdf/api/BlankNodeOrIRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/BlankNodeOrIRI.java b/api/src/main/java/org/apache/commons/rdf/api/BlankNodeOrIRI.java
new file mode 100644
index 0000000..85a2e7b
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/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 org.apache.commons.rdf.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/fa5321e4/api/src/main/java/org/apache/commons/rdf/api/Graph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/Graph.java b/api/src/main/java/org/apache/commons/rdf/api/Graph.java
new file mode 100644
index 0000000..d12797a
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/Graph.java
@@ -0,0 +1,179 @@
+/**
+ * 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 org.apache.commons.rdf.api;
+
+import java.util.function.Predicate;
+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 extends AutoCloseable {
+
+ /**
+ * 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);
+
+ /**
+ * Close the graph, relinquishing any underlying resources.
+ * <p>
+ * For example, this would close any open file and network streams and free
+ * database locks held by the Graph implementation.
+ * <p>
+ * The behaviour of the other Graph methods are undefined after closing the
+ * graph.
+ * <p>
+ * Implementations might not need {@link #close()}, hence the default
+ * implementation does nothing.
+ */
+ @Override
+ default void close() throws Exception {
+ }
+
+ /**
+ * 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 the
+ * equals method for each {@link Triple}.
+ *
+ * @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
+ * the equals method for each {@link Triple}.
+ * <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
+ * the equals method for each {@link Triple}.
+ * <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);
+
+ /**
+ * Get all triples contained by the graph matched with the pattern.
+ * <p>
+ * The iteration does not contain any duplicate triples, as determined by
+ * the equals method for each {@link Triple}.
+ * <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 filter
+ * A filter to match against each triple in the graph.
+ * @return A {@link Stream} over the matched triples.
+ */
+ Stream<? extends Triple> getTriples(Predicate<Triple> filter);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/api/src/main/java/org/apache/commons/rdf/api/IRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/IRI.java b/api/src/main/java/org/apache/commons/rdf/api/IRI.java
new file mode 100644
index 0000000..041a7da
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/IRI.java
@@ -0,0 +1,74 @@
+/**
+ * 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 org.apache.commons.rdf.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 {
+
+ /**
+ * Return 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();
+
+ /**
+ * Check it this IRI is equal to another IRI. <blockquote> <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#section-IRIs">IRI
+ * equality</a>: Two IRIs are equal if and only if they are equivalent under
+ * Simple String Comparison according to section 5.1 of [RFC3987]. Further
+ * normalization MUST NOT be performed when comparing IRIs for equality.
+ * </blockquote>
+ * <p>
+ * Two IRIs are equal are in the same local scope and their
+ * {@link #getIRIString()} are equal.
+ * </p>
+ * <p>
+ * Implementations MAY check the local scope for IRI comparison.
+ * </p>
+ * <p>
+ * Implementations MUST also override {@link #hashCode()} so that two equal
+ * IRIs produce the same hash code.
+ * </p>
+ *
+ * @see Object#equals(Object)
+ *
+ * @param other
+ * Another object
+ * @return true if other is an IRI and is equal to this
+ */
+ @Override
+ public boolean equals(Object other);
+
+ /**
+ * Calculate a hash code for this IRI.
+ * <p>
+ * This method MUST be implemented when implementing {@link #equals(Object)}
+ * so that two equal IRIs produce the same hash code.
+ *
+ * @see Object#hashCode()
+ *
+ * @return a hash code value for this IRI.
+ */
+ @Override
+ public int hashCode();
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/api/src/main/java/org/apache/commons/rdf/api/Literal.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/Literal.java b/api/src/main/java/org/apache/commons/rdf/api/Literal.java
new file mode 100644
index 0000000..5c40ac4
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/Literal.java
@@ -0,0 +1,108 @@
+/**
+ * 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 org.apache.commons.rdf.api;
+
+import java.util.Optional;
+
+/**
+ * A 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();
+
+ /**
+ * Check it this Literal is equal to another Literal. <blockquote> <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#dfn-literal-term">Literal term
+ * equality</a>: Two literals are term-equal (the same RDF literal) if and
+ * only if the two lexical forms, the two datatype IRIs, and the two
+ * language tags (if any) compare equal, character by character. Thus, two
+ * literals can have the same value without being the same RDF term.
+ * </blockquote>
+ * <p>
+ * Implementations MAY check the local scope for Literal comparison.
+ * </p>
+ * <p>
+ * Implementations MUST also override {@link #hashCode()} so that two equal
+ * Literals produce the same hash code.
+ * </p>
+ *
+ * @see Object#equals(Object)
+ *
+ * @param other
+ * Another object
+ * @return true if other is a Literal and is equal to this
+ */
+ @Override
+ public boolean equals(Object other);
+
+ /**
+ * Calculate a hash code for this Literal.
+ * <p>
+ * This method MUST be implemented when implementing {@link #equals(Object)}
+ * so that two equal Literals produce the same hash code.
+ * </p>
+ *
+ * @see Object#hashCode()
+ *
+ * @return a hash code value for this Literal.
+ */
+ @Override
+ public int hashCode();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/api/src/main/java/org/apache/commons/rdf/api/RDFTerm.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/RDFTerm.java b/api/src/main/java/org/apache/commons/rdf/api/RDFTerm.java
new file mode 100644
index 0000000..0540bdd
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/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 org.apache.commons.rdf.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/fa5321e4/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java b/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java
new file mode 100644
index 0000000..7d0cef6
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java
@@ -0,0 +1,252 @@
+/**
+ * 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 org.apache.commons.rdf.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
+ * If the operation is not supported.
+ */
+ 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
+ * the equals contract for {@link BlankNode} for more information.
+ * <p>
+ * If supported, the {@link BlankNode#internalIdentifier()} of the returned
+ * blank node MAY be equal to the provided identifier.
+ *
+ * @param identifier
+ * A non-empty String that is unique to this blank node in this
+ * scope, and which may be used as the 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 the operation is not 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 the operation is not 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 operation is not supported.
+ */
+ 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 operation is not 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 operation is not 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 operation is not 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 the operation 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/fa5321e4/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
new file mode 100644
index 0000000..5981cdd
--- /dev/null
+++ b/api/src/main/java/org/apache/commons/rdf/api/Triple.java
@@ -0,0 +1,97 @@
+/**
+ * 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 org.apache.commons.rdf.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();
+
+ /**
+ * Check it this Triple is equal to another Triple.
+ * <p>
+ * Two Triples are equal if and only if their {@link #getSubject()},
+ * {@link #getPredicate()} and {@link #getObject()} are equal.
+ * </p>
+ * <p>
+ * Implementations MUST check the local scope for Triple comparison if
+ * either the subject or object is a BlankNode, and MAY check the local
+ * scope in other cases.
+ * </p>
+ * <p>
+ * Implementations MUST also override {@link #hashCode()} so that two equal
+ * Triples produce the same hash code.
+ * </p>
+ *
+ * @see Object#equals(Object)
+ *
+ * @param other
+ * Another object
+ * @return true if other is a Triple and is equal to this
+ */
+ @Override
+ public boolean equals(Object other);
+
+ /**
+ * Calculate a hash code for this Triple.
+ * <p>
+ * This method MUST be implemented when implementing {@link #equals(Object)}
+ * so that two equal IRIs produce the same hash code.
+ * </p>
+ *
+ * @see Object#hashCode()
+ *
+ * @return a hash code value for this Triple.
+ */
+ @Override
+ public int hashCode();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/api/src/test/java/com/github/commonsrdf/api/AbstractBlankNodeTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/github/commonsrdf/api/AbstractBlankNodeTest.java b/api/src/test/java/com/github/commonsrdf/api/AbstractBlankNodeTest.java
deleted file mode 100644
index 6a8e6f3..0000000
--- a/api/src/test/java/com/github/commonsrdf/api/AbstractBlankNodeTest.java
+++ /dev/null
@@ -1,222 +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 static org.junit.Assert.*;
-
-import org.junit.Test;
-
-/**
- * Abstract test class for the BlankNode interface.
- *
- * @author Peter Ansell p_ansell@yahoo.com
- */
-public abstract class AbstractBlankNodeTest {
-
- protected abstract BlankNode getBlankNode();
-
- /**
- * Gets a new blank node object based on the given identifier.
- * <p>
- * Subsequent calls to this method during a single test with the same
- * identifier must return BlankNode objects that are equals and have the
- * same hashCode. The objects returned from successive calls during a single
- * test may be the same object, or they may be different objects.
- * </p>
- *
- * @param identifier
- * The identifier to use as the reference for creating the blank
- * node that is returned.
- * @return A new blank node based on the
- */
- protected abstract BlankNode getBlankNode(String identifier);
-
- /**
- * Test method for
- * {@link com.github.commonsrdf.api.BlankNode#internalIdentifier()}.
- */
- @Test
- public final void testInternalIdentifier() {
- BlankNode testNull = new BlankNode() {
- @Override
- public String ntriplesString() {
- return null;
- }
-
- @Override
- public String internalIdentifier() {
- return null;
- }
- };
- BlankNode testAutomatic1 = getBlankNode();
- BlankNode testAutomatic2 = getBlankNode();
- BlankNode testManual3a = getBlankNode("3");
- BlankNode testManual3b = getBlankNode("3");
- BlankNode testManual4 = getBlankNode("4");
-
- // Test against our fake stub
- assertNotEquals(testNull.internalIdentifier(),
- testAutomatic1.internalIdentifier());
- assertNotEquals(testAutomatic1.internalIdentifier(),
- testNull.internalIdentifier());
- assertNotEquals(testNull.internalIdentifier(),
- testManual3a.internalIdentifier());
- assertNotEquals(testManual3a.internalIdentifier(),
- testNull.internalIdentifier());
-
- // Test the two imported instances against each other
- assertEquals(testAutomatic1.internalIdentifier(),
- testAutomatic1.internalIdentifier());
- assertEquals(testAutomatic2.internalIdentifier(),
- testAutomatic2.internalIdentifier());
- assertNotEquals(testAutomatic1.internalIdentifier(),
- testAutomatic2.internalIdentifier());
- assertNotEquals(testAutomatic2.internalIdentifier(),
- testAutomatic1.internalIdentifier());
- assertNotEquals(testAutomatic1.internalIdentifier(),
- testManual3a.internalIdentifier());
- assertEquals(testManual3b.internalIdentifier(),
- testManual3a.internalIdentifier());
- assertNotEquals(testManual3a.internalIdentifier(),
- testManual4.internalIdentifier());
- }
-
- /**
- * Test method for
- * {@link com.github.commonsrdf.api.BlankNode#equals(java.lang.Object)}.
- */
- @Test
- public final void testEquals() {
- BlankNode testNull = new BlankNode() {
- @Override
- public String ntriplesString() {
- return null;
- }
-
- @Override
- public String internalIdentifier() {
- return null;
- }
- };
- BlankNode testAutomatic1 = getBlankNode();
- BlankNode testAutomatic2 = getBlankNode();
- BlankNode testManual3a = getBlankNode("3");
- BlankNode testManual3b = getBlankNode("3");
- BlankNode testManual4 = getBlankNode("4");
-
- // Test against our fake stub
- assertNotEquals(testNull, testAutomatic1);
- assertNotEquals(testAutomatic1, testNull);
- assertNotEquals(testNull, testManual3a);
- assertNotEquals(testManual3a, testNull);
-
- // Test the two imported instances against each other
- assertEquals(testAutomatic1, testAutomatic1);
- assertEquals(testAutomatic2, testAutomatic2);
- assertNotEquals(testAutomatic1, testAutomatic2);
- assertNotEquals(testAutomatic2, testAutomatic1);
- assertNotEquals(testAutomatic1, testManual3a);
- assertEquals(testManual3b, testManual3a);
- assertNotEquals(testManual3a, testManual4);
- }
-
- /**
- * Test method for {@link com.github.commonsrdf.api.BlankNode#hashCode()}.
- */
- @Test
- public final void testHashCode() {
- BlankNode testNull = new BlankNode() {
- @Override
- public String ntriplesString() {
- return null;
- }
-
- @Override
- public String internalIdentifier() {
- return null;
- }
- };
- BlankNode testAutomatic1 = getBlankNode();
- BlankNode testAutomatic2 = getBlankNode();
- BlankNode testManual3a = getBlankNode("3");
- BlankNode testManual3b = getBlankNode("3");
- BlankNode testManual4 = getBlankNode("4");
-
- // Test against our fake stub
- assertNotEquals(testNull.hashCode(), testAutomatic1.hashCode());
- assertNotEquals(testAutomatic1.hashCode(), testNull.hashCode());
- assertNotEquals(testNull.hashCode(), testManual3a.hashCode());
- assertNotEquals(testManual3a.hashCode(), testNull.hashCode());
-
- // Test the two imported instances against each other
- assertEquals(testAutomatic1.hashCode(), testAutomatic1.hashCode());
- assertEquals(testAutomatic2.hashCode(), testAutomatic2.hashCode());
- assertNotEquals(testAutomatic1.hashCode(), testAutomatic2.hashCode());
- assertNotEquals(testAutomatic2.hashCode(), testAutomatic1.hashCode());
- assertNotEquals(testAutomatic1.hashCode(), testManual3a.hashCode());
- assertEquals(testManual3b.hashCode(), testManual3a.hashCode());
- assertNotEquals(testManual3a.hashCode(), testManual4.hashCode());
- }
-
- /**
- * Test method for
- * {@link com.github.commonsrdf.api.RDFTerm#ntriplesString()}.
- */
- @Test
- public final void testNtriplesString() {
- BlankNode testNull = new BlankNode() {
- @Override
- public String ntriplesString() {
- return null;
- }
-
- @Override
- public String internalIdentifier() {
- return null;
- }
- };
- BlankNode testAutomatic1 = getBlankNode();
- BlankNode testAutomatic2 = getBlankNode();
- BlankNode testManual3a = getBlankNode("3");
- BlankNode testManual3b = getBlankNode("3");
- BlankNode testManual4 = getBlankNode("4");
-
- // Test against our fake stub
- assertNotEquals(testNull.ntriplesString(),
- testAutomatic1.ntriplesString());
- assertNotEquals(testAutomatic1.ntriplesString(),
- testNull.ntriplesString());
- assertNotEquals(testNull.ntriplesString(),
- testManual3a.ntriplesString());
- assertNotEquals(testManual3a.ntriplesString(),
- testNull.ntriplesString());
-
- // Test the two imported instances against each other
- assertEquals(testAutomatic1.ntriplesString(),
- testAutomatic1.ntriplesString());
- assertEquals(testAutomatic2.ntriplesString(),
- testAutomatic2.ntriplesString());
- assertNotEquals(testAutomatic1.ntriplesString(),
- testAutomatic2.ntriplesString());
- assertNotEquals(testAutomatic2.ntriplesString(),
- testAutomatic1.ntriplesString());
- assertNotEquals(testAutomatic1.ntriplesString(),
- testManual3a.ntriplesString());
- assertEquals(testManual3b.ntriplesString(),
- testManual3a.ntriplesString());
- assertNotEquals(testManual3a.ntriplesString(),
- testManual4.ntriplesString());
- }
-
-}
[2/7] incubator-commonsrdf git commit: COMMONSRDF-2: refactorized api
java packages
Posted by wi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/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
deleted file mode 100644
index be7dfe4..0000000
--- a/api/src/test/java/com/github/commonsrdf/api/AbstractGraphTest.java
+++ /dev/null
@@ -1,275 +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 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/fa5321e4/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
deleted file mode 100644
index 36b2cb8..0000000
--- a/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java
+++ /dev/null
@@ -1,401 +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 static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotSame;
-
-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;
- }
-
- BlankNode bnode2 = factory.createBlankNode();
- assertNotEquals(
- "Second blank node has not got a unique internal identifier",
- bnode.internalIdentifier(), bnode2.internalIdentifier());
- }
-
- @Test
- public void createBlankNodeIdentifierEmpty() throws Exception {
- try {
- factory.createBlankNode("");
- } catch (UnsupportedOperationException e) {
- Assume.assumeNoException(e);
- } catch (IllegalArgumentException e) {
- // Expected exception
- }
- }
-
- @Test
- public void createBlankNodeIdentifier() throws Exception {
- BlankNode bnode;
- try {
- bnode = factory.createBlankNode("example1");
- } catch (UnsupportedOperationException ex) {
- Assume.assumeNoException(ex);
- return;
- }
- assertEquals("example1", bnode.internalIdentifier());
- // .. but we can't assume the internal identifier leaks into
- // ntriplesString
- // assertEquals("_:example1", bnode.ntriplesString());
- }
-
- @Test
- public void createBlankNodeIdentifierTwice() throws Exception {
- BlankNode bnode1, bnode2, bnode3;
- try {
- bnode1 = factory.createBlankNode("example1");
- bnode2 = factory.createBlankNode("example1");
- bnode3 = factory.createBlankNode("differ");
- } catch (UnsupportedOperationException ex) {
- Assume.assumeNoException(ex);
- return;
- }
- assertEquals(bnode1.internalIdentifier(), bnode2.internalIdentifier());
- // We don't know what the ntriplesString is, but it MUST be the same
- assertEquals(bnode1.ntriplesString(), bnode2.ntriplesString());
- // and here it MUST differ
- assertNotEquals(bnode1.ntriplesString(), bnode3.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;
- }
-
- // bnode equivalence should be OK as we used the same
- // factory and have not yet inserted Triple into a Graph
- assertEquals(subject, triple.getSubject());
- assertEquals(predicate, triple.getPredicate());
- assertEquals(object, triple.getObject());
- }
-
- @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;
- }
-
- // bnode equivalence should be OK as we used the same
- // factory and have not yet inserted Triple into a Graph
- assertEquals(subject, triple.getSubject());
- assertEquals(predicate, triple.getPredicate());
- assertEquals(object, triple.getObject());
- }
-
- @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;
- }
-
- // bnode equivalence should be OK as we used the same
- // factory and have not yet inserted Triple into a Graph
- assertEquals(subject, triple.getSubject());
- assertEquals(predicate, triple.getPredicate());
- assertEquals(object, triple.getObject());
- }
-
- @Before
- public void getFactory() {
- factory = createFactory();
- }
-
- @Test
- public void possiblyInvalidBlankNode() throws Exception {
- BlankNode withColon;
- try {
- withColon = factory.createBlankNode("with:colon");
- } catch (UnsupportedOperationException ex) {
- Assume.assumeNoException("createBlankNode(String) not supported",
- ex);
- return;
- } catch (IllegalArgumentException ex) {
- // Good!
- return;
- }
- // Factory allows :colon, which is OK as long as it's not causing an
- // invalid ntriplesString
- assertFalse(withColon.ntriplesString().contains("with:colon"));
-
- // and creating it twice gets the same ntriplesString
- assertEquals(withColon.ntriplesString(),
- factory.createBlankNode("with:colon").ntriplesString());
- }
-
- @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/fa5321e4/api/src/test/java/com/github/commonsrdf/api/DefaultRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/github/commonsrdf/api/DefaultRDFTermFactoryTest.java b/api/src/test/java/com/github/commonsrdf/api/DefaultRDFTermFactoryTest.java
deleted file mode 100644
index e314968..0000000
--- a/api/src/test/java/com/github/commonsrdf/api/DefaultRDFTermFactoryTest.java
+++ /dev/null
@@ -1,32 +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 com.github.commonsrdf.api.RDFTermFactory;
-
-/**
- * The default RDFTermFactory might be useless (every method throws
- * UnsupportedOperationException), but this test ensures that
- * AbstractRDFTermFactoryTest does not fall over on unsupported operations.
- *
- */
-public class DefaultRDFTermFactoryTest extends AbstractRDFTermFactoryTest {
-
- @Override
- public RDFTermFactory createFactory() {
- return new RDFTermFactory() {
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java b/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
new file mode 100644
index 0000000..2377d89
--- /dev/null
+++ b/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
@@ -0,0 +1,222 @@
+/**
+ * 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 org.apache.commons.rdf.api;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Abstract test class for the BlankNode interface.
+ *
+ * @author Peter Ansell p_ansell@yahoo.com
+ */
+public abstract class AbstractBlankNodeTest {
+
+ protected abstract BlankNode getBlankNode();
+
+ /**
+ * Gets a new blank node object based on the given identifier.
+ * <p>
+ * Subsequent calls to this method during a single test with the same
+ * identifier must return BlankNode objects that are equals and have the
+ * same hashCode. The objects returned from successive calls during a single
+ * test may be the same object, or they may be different objects.
+ * </p>
+ *
+ * @param identifier
+ * The identifier to use as the reference for creating the blank
+ * node that is returned.
+ * @return A new blank node based on the
+ */
+ protected abstract BlankNode getBlankNode(String identifier);
+
+ /**
+ * Test method for
+ * {@link BlankNode#internalIdentifier()}.
+ */
+ @Test
+ public final void testInternalIdentifier() {
+ BlankNode testNull = new BlankNode() {
+ @Override
+ public String ntriplesString() {
+ return null;
+ }
+
+ @Override
+ public String internalIdentifier() {
+ return null;
+ }
+ };
+ BlankNode testAutomatic1 = getBlankNode();
+ BlankNode testAutomatic2 = getBlankNode();
+ BlankNode testManual3a = getBlankNode("3");
+ BlankNode testManual3b = getBlankNode("3");
+ BlankNode testManual4 = getBlankNode("4");
+
+ // Test against our fake stub
+ assertNotEquals(testNull.internalIdentifier(),
+ testAutomatic1.internalIdentifier());
+ assertNotEquals(testAutomatic1.internalIdentifier(),
+ testNull.internalIdentifier());
+ assertNotEquals(testNull.internalIdentifier(),
+ testManual3a.internalIdentifier());
+ assertNotEquals(testManual3a.internalIdentifier(),
+ testNull.internalIdentifier());
+
+ // Test the two imported instances against each other
+ assertEquals(testAutomatic1.internalIdentifier(),
+ testAutomatic1.internalIdentifier());
+ assertEquals(testAutomatic2.internalIdentifier(),
+ testAutomatic2.internalIdentifier());
+ assertNotEquals(testAutomatic1.internalIdentifier(),
+ testAutomatic2.internalIdentifier());
+ assertNotEquals(testAutomatic2.internalIdentifier(),
+ testAutomatic1.internalIdentifier());
+ assertNotEquals(testAutomatic1.internalIdentifier(),
+ testManual3a.internalIdentifier());
+ assertEquals(testManual3b.internalIdentifier(),
+ testManual3a.internalIdentifier());
+ assertNotEquals(testManual3a.internalIdentifier(),
+ testManual4.internalIdentifier());
+ }
+
+ /**
+ * Test method for
+ * {@link BlankNode#equals(java.lang.Object)}.
+ */
+ @Test
+ public final void testEquals() {
+ BlankNode testNull = new BlankNode() {
+ @Override
+ public String ntriplesString() {
+ return null;
+ }
+
+ @Override
+ public String internalIdentifier() {
+ return null;
+ }
+ };
+ BlankNode testAutomatic1 = getBlankNode();
+ BlankNode testAutomatic2 = getBlankNode();
+ BlankNode testManual3a = getBlankNode("3");
+ BlankNode testManual3b = getBlankNode("3");
+ BlankNode testManual4 = getBlankNode("4");
+
+ // Test against our fake stub
+ assertNotEquals(testNull, testAutomatic1);
+ assertNotEquals(testAutomatic1, testNull);
+ assertNotEquals(testNull, testManual3a);
+ assertNotEquals(testManual3a, testNull);
+
+ // Test the two imported instances against each other
+ assertEquals(testAutomatic1, testAutomatic1);
+ assertEquals(testAutomatic2, testAutomatic2);
+ assertNotEquals(testAutomatic1, testAutomatic2);
+ assertNotEquals(testAutomatic2, testAutomatic1);
+ assertNotEquals(testAutomatic1, testManual3a);
+ assertEquals(testManual3b, testManual3a);
+ assertNotEquals(testManual3a, testManual4);
+ }
+
+ /**
+ * Test method for {@link BlankNode#hashCode()}.
+ */
+ @Test
+ public final void testHashCode() {
+ BlankNode testNull = new BlankNode() {
+ @Override
+ public String ntriplesString() {
+ return null;
+ }
+
+ @Override
+ public String internalIdentifier() {
+ return null;
+ }
+ };
+ BlankNode testAutomatic1 = getBlankNode();
+ BlankNode testAutomatic2 = getBlankNode();
+ BlankNode testManual3a = getBlankNode("3");
+ BlankNode testManual3b = getBlankNode("3");
+ BlankNode testManual4 = getBlankNode("4");
+
+ // Test against our fake stub
+ assertNotEquals(testNull.hashCode(), testAutomatic1.hashCode());
+ assertNotEquals(testAutomatic1.hashCode(), testNull.hashCode());
+ assertNotEquals(testNull.hashCode(), testManual3a.hashCode());
+ assertNotEquals(testManual3a.hashCode(), testNull.hashCode());
+
+ // Test the two imported instances against each other
+ assertEquals(testAutomatic1.hashCode(), testAutomatic1.hashCode());
+ assertEquals(testAutomatic2.hashCode(), testAutomatic2.hashCode());
+ assertNotEquals(testAutomatic1.hashCode(), testAutomatic2.hashCode());
+ assertNotEquals(testAutomatic2.hashCode(), testAutomatic1.hashCode());
+ assertNotEquals(testAutomatic1.hashCode(), testManual3a.hashCode());
+ assertEquals(testManual3b.hashCode(), testManual3a.hashCode());
+ assertNotEquals(testManual3a.hashCode(), testManual4.hashCode());
+ }
+
+ /**
+ * Test method for
+ * {@link RDFTerm#ntriplesString()}.
+ */
+ @Test
+ public final void testNtriplesString() {
+ BlankNode testNull = new BlankNode() {
+ @Override
+ public String ntriplesString() {
+ return null;
+ }
+
+ @Override
+ public String internalIdentifier() {
+ return null;
+ }
+ };
+ BlankNode testAutomatic1 = getBlankNode();
+ BlankNode testAutomatic2 = getBlankNode();
+ BlankNode testManual3a = getBlankNode("3");
+ BlankNode testManual3b = getBlankNode("3");
+ BlankNode testManual4 = getBlankNode("4");
+
+ // Test against our fake stub
+ assertNotEquals(testNull.ntriplesString(),
+ testAutomatic1.ntriplesString());
+ assertNotEquals(testAutomatic1.ntriplesString(),
+ testNull.ntriplesString());
+ assertNotEquals(testNull.ntriplesString(),
+ testManual3a.ntriplesString());
+ assertNotEquals(testManual3a.ntriplesString(),
+ testNull.ntriplesString());
+
+ // Test the two imported instances against each other
+ assertEquals(testAutomatic1.ntriplesString(),
+ testAutomatic1.ntriplesString());
+ assertEquals(testAutomatic2.ntriplesString(),
+ testAutomatic2.ntriplesString());
+ assertNotEquals(testAutomatic1.ntriplesString(),
+ testAutomatic2.ntriplesString());
+ assertNotEquals(testAutomatic2.ntriplesString(),
+ testAutomatic1.ntriplesString());
+ assertNotEquals(testAutomatic1.ntriplesString(),
+ testManual3a.ntriplesString());
+ assertEquals(testManual3b.ntriplesString(),
+ testManual3a.ntriplesString());
+ assertNotEquals(testManual3a.ntriplesString(),
+ testManual4.ntriplesString());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/fa5321e4/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java b/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java
new file mode 100644
index 0000000..97fc1b9
--- /dev/null
+++ b/api/src/test/java/org/apache/commons/rdf/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 org.apache.commons.rdf.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/fa5321e4/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java b/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java
new file mode 100644
index 0000000..7e1d545
--- /dev/null
+++ b/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java
@@ -0,0 +1,401 @@
+/**
+ * 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 org.apache.commons.rdf.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 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;
+ }
+
+ BlankNode bnode2 = factory.createBlankNode();
+ assertNotEquals(
+ "Second blank node has not got a unique internal identifier",
+ bnode.internalIdentifier(), bnode2.internalIdentifier());
+ }
+
+ @Test
+ public void createBlankNodeIdentifierEmpty() throws Exception {
+ try {
+ factory.createBlankNode("");
+ } catch (UnsupportedOperationException e) {
+ Assume.assumeNoException(e);
+ } catch (IllegalArgumentException e) {
+ // Expected exception
+ }
+ }
+
+ @Test
+ public void createBlankNodeIdentifier() throws Exception {
+ BlankNode bnode;
+ try {
+ bnode = factory.createBlankNode("example1");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+ assertEquals("example1", bnode.internalIdentifier());
+ // .. but we can't assume the internal identifier leaks into
+ // ntriplesString
+ // assertEquals("_:example1", bnode.ntriplesString());
+ }
+
+ @Test
+ public void createBlankNodeIdentifierTwice() throws Exception {
+ BlankNode bnode1, bnode2, bnode3;
+ try {
+ bnode1 = factory.createBlankNode("example1");
+ bnode2 = factory.createBlankNode("example1");
+ bnode3 = factory.createBlankNode("differ");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException(ex);
+ return;
+ }
+ assertEquals(bnode1.internalIdentifier(), bnode2.internalIdentifier());
+ // We don't know what the ntriplesString is, but it MUST be the same
+ assertEquals(bnode1.ntriplesString(), bnode2.ntriplesString());
+ // and here it MUST differ
+ assertNotEquals(bnode1.ntriplesString(), bnode3.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;
+ }
+
+ // bnode equivalence should be OK as we used the same
+ // factory and have not yet inserted Triple into a Graph
+ assertEquals(subject, triple.getSubject());
+ assertEquals(predicate, triple.getPredicate());
+ assertEquals(object, triple.getObject());
+ }
+
+ @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;
+ }
+
+ // bnode equivalence should be OK as we used the same
+ // factory and have not yet inserted Triple into a Graph
+ assertEquals(subject, triple.getSubject());
+ assertEquals(predicate, triple.getPredicate());
+ assertEquals(object, triple.getObject());
+ }
+
+ @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;
+ }
+
+ // bnode equivalence should be OK as we used the same
+ // factory and have not yet inserted Triple into a Graph
+ assertEquals(subject, triple.getSubject());
+ assertEquals(predicate, triple.getPredicate());
+ assertEquals(object, triple.getObject());
+ }
+
+ @Before
+ public void getFactory() {
+ factory = createFactory();
+ }
+
+ @Test
+ public void possiblyInvalidBlankNode() throws Exception {
+ BlankNode withColon;
+ try {
+ withColon = factory.createBlankNode("with:colon");
+ } catch (UnsupportedOperationException ex) {
+ Assume.assumeNoException("createBlankNode(String) not supported",
+ ex);
+ return;
+ } catch (IllegalArgumentException ex) {
+ // Good!
+ return;
+ }
+ // Factory allows :colon, which is OK as long as it's not causing an
+ // invalid ntriplesString
+ assertFalse(withColon.ntriplesString().contains("with:colon"));
+
+ // and creating it twice gets the same ntriplesString
+ assertEquals(withColon.ntriplesString(),
+ factory.createBlankNode("with:colon").ntriplesString());
+ }
+
+ @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/fa5321e4/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java b/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
new file mode 100644
index 0000000..b2f9697
--- /dev/null
+++ b/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
@@ -0,0 +1,30 @@
+/**
+ * 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 org.apache.commons.rdf.api;
+
+/**
+ * The default RDFTermFactory might be useless (every method throws
+ * UnsupportedOperationException), but this test ensures that
+ * AbstractRDFTermFactoryTest does not fall over on unsupported operations.
+ *
+ */
+public class DefaultRDFTermFactoryTest extends AbstractRDFTermFactoryTest {
+
+ @Override
+ public RDFTermFactory createFactory() {
+ return new RDFTermFactory() {
+ };
+ }
+
+}
[7/7] incubator-commonsrdf git commit: COMMONSRDF-2: updated license
headers
Posted by wi...@apache.org.
COMMONSRDF-2: updated license headers
Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/7d06fdbf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/7d06fdbf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/7d06fdbf
Branch: refs/heads/master
Commit: 7d06fdbf31604317111f7d29c05e4bbb80c6c4be
Parents: b649f4b
Author: Sergio Fernández <wi...@apache.org>
Authored: Fri Mar 27 19:44:30 2015 +0100
Committer: Sergio Fernández <wi...@apache.org>
Committed: Fri Mar 27 19:44:30 2015 +0100
----------------------------------------------------------------------
api/pom.xml | 19 +++++++++++++++++++
.../org/apache/commons/rdf/api/BlankNode.java | 17 +++++++++++++++++
.../apache/commons/rdf/api/BlankNodeOrIRI.java | 17 +++++++++++++++++
.../java/org/apache/commons/rdf/api/Graph.java | 17 +++++++++++++++++
.../java/org/apache/commons/rdf/api/IRI.java | 17 +++++++++++++++++
.../java/org/apache/commons/rdf/api/Literal.java | 17 +++++++++++++++++
.../java/org/apache/commons/rdf/api/RDFTerm.java | 17 +++++++++++++++++
.../apache/commons/rdf/api/RDFTermFactory.java | 17 +++++++++++++++++
.../java/org/apache/commons/rdf/api/Triple.java | 17 +++++++++++++++++
.../commons/rdf/api/AbstractBlankNodeTest.java | 17 +++++++++++++++++
.../commons/rdf/api/AbstractGraphTest.java | 17 +++++++++++++++++
.../rdf/api/AbstractRDFTermFactoryTest.java | 17 +++++++++++++++++
.../rdf/api/DefaultRDFTermFactoryTest.java | 17 +++++++++++++++++
pom.xml | 19 +++++++++++++++++++
simple/pom.xml | 19 +++++++++++++++++++
.../apache/commons/rdf/simple/BlankNodeImpl.java | 17 +++++++++++++++++
.../org/apache/commons/rdf/simple/GraphImpl.java | 17 +++++++++++++++++
.../org/apache/commons/rdf/simple/IRIImpl.java | 17 +++++++++++++++++
.../apache/commons/rdf/simple/LiteralImpl.java | 17 +++++++++++++++++
.../commons/rdf/simple/SimpleRDFTermFactory.java | 17 +++++++++++++++++
.../apache/commons/rdf/simple/TripleImpl.java | 17 +++++++++++++++++
.../org/apache/commons/rdf/simple/Types.java | 17 +++++++++++++++++
.../apache/commons/rdf/simple/package-info.java | 17 +++++++++++++++++
.../commons/rdf/simple/BlankNodeImplTest.java | 17 +++++++++++++++++
.../commons/rdf/simple/DefaultGraphTest.java | 17 +++++++++++++++++
.../commons/rdf/simple/SimpleGraphTest.java | 17 +++++++++++++++++
.../SimpleNoRelativeIRIRDFTermFactoryTest.java | 17 +++++++++++++++++
.../rdf/simple/SimpleRDFTermFactoryTest.java | 17 +++++++++++++++++
.../commons/rdf/simple/TestWritingGraph.java | 17 +++++++++++++++++
.../org/apache/commons/rdf/simple/TypesTest.java | 17 +++++++++++++++++
30 files changed, 516 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/pom.xml
----------------------------------------------------------------------
diff --git a/api/pom.xml b/api/pom.xml
index 272f279..25a8355 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -1,5 +1,24 @@
<!--
+ 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.
+
+-->
+<!--
+
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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java b/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
index 9a81002..b919efd 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/main/java/org/apache/commons/rdf/api/BlankNodeOrIRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/BlankNodeOrIRI.java b/api/src/main/java/org/apache/commons/rdf/api/BlankNodeOrIRI.java
index 85a2e7b..8386f95 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/BlankNodeOrIRI.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/BlankNodeOrIRI.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/main/java/org/apache/commons/rdf/api/Graph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/Graph.java b/api/src/main/java/org/apache/commons/rdf/api/Graph.java
index d12797a..108684c 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/Graph.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/Graph.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/main/java/org/apache/commons/rdf/api/IRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/IRI.java b/api/src/main/java/org/apache/commons/rdf/api/IRI.java
index 041a7da..0bf38ed 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/IRI.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/IRI.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/main/java/org/apache/commons/rdf/api/Literal.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/Literal.java b/api/src/main/java/org/apache/commons/rdf/api/Literal.java
index 5c40ac4..3e9ebe0 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/Literal.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/Literal.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/main/java/org/apache/commons/rdf/api/RDFTerm.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/RDFTerm.java b/api/src/main/java/org/apache/commons/rdf/api/RDFTerm.java
index 0540bdd..2d59d44 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/RDFTerm.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/RDFTerm.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java b/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java
index 7d0cef6..093eccf 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/RDFTermFactory.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/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 5981cdd..5123897 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
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java b/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
index 2377d89..8ea47d7 100644
--- a/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
+++ b/api/src/test/java/org/apache/commons/rdf/api/AbstractBlankNodeTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java b/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java
index 97fc1b9..b5b1442 100644
--- a/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java
+++ b/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java b/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java
index 7e1d545..6323416 100644
--- a/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java
+++ b/api/src/test/java/org/apache/commons/rdf/api/AbstractRDFTermFactoryTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java b/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
index b2f9697..c91fc83 100644
--- a/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
+++ b/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index bdc47c6..0407701 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,24 @@
<!--
+ 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.
+
+-->
+<!--
+
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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/pom.xml
----------------------------------------------------------------------
diff --git a/simple/pom.xml b/simple/pom.xml
index 6ccc6d1..7892ba2 100644
--- a/simple/pom.xml
+++ b/simple/pom.xml
@@ -1,5 +1,24 @@
<!--
+ 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.
+
+-->
+<!--
+
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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java
index b164dce..223f5ce 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/BlankNodeImpl.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
index a28267e..3b26531 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
index 078c3a8..c1fcf5e 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
index ee2e6bd..b2c2485 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java b/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java
index 2dc1d45..e75a61a 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/SimpleRDFTermFactory.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
index 4841992..97a4614 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/main/java/org/apache/commons/rdf/simple/Types.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/Types.java b/simple/src/main/java/org/apache/commons/rdf/simple/Types.java
index e2bff79..16ab124 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/Types.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/Types.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java b/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java
index 367a455..97a5747 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/package-info.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java
index b619a93..81ddaa2 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/BlankNodeImplTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
index cdf49eb..9f66530 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java
index 29ddc22..3635d17 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleGraphTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
index 015db78..76796ca 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleNoRelativeIRIRDFTermFactoryTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java
index db532b1..4ae849c 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleRDFTermFactoryTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
index c434d45..91d1f0f 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/7d06fdbf/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java
index 25c118c..289753f 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/TypesTest.java
@@ -1,4 +1,21 @@
/**
+ * 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.
+ */
+/**
* 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