You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2017/12/30 11:58:36 UTC
[4/4] clerezza git commit: Merged in clerezza-rdf-core
Merged in clerezza-rdf-core
Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/2109cae5
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/2109cae5
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/2109cae5
Branch: refs/heads/reunited
Commit: 2109cae59115b626f7b4bcffac03823dbd9b4e23
Parents: c9be8ca
Author: Reto Gmür <me...@farewellutopia.com>
Authored: Sat Dec 30 11:57:39 2017 +0000
Committer: Reto Gmür <me...@farewellutopia.com>
Committed: Sat Dec 30 11:57:39 2017 +0000
----------------------------------------------------------------------
.gitignore | 1 +
LICENSE.txt | 202 ++++++++
NOTICE.txt | 8 +
README.md | 72 +++
alerts.txt | 0
api/pom.xml | 65 +++
api/src/main/assembly/bin.xml | 75 +++
api/src/main/assembly/src.xml | 45 ++
.../apache/clerezza/commons/rdf/BlankNode.java | 41 ++
.../clerezza/commons/rdf/BlankNodeOrIRI.java | 30 ++
.../org/apache/clerezza/commons/rdf/Graph.java | 88 ++++
.../org/apache/clerezza/commons/rdf/IRI.java | 83 +++
.../clerezza/commons/rdf/ImmutableGraph.java | 55 ++
.../apache/clerezza/commons/rdf/Language.java | 63 +++
.../apache/clerezza/commons/rdf/Literal.java | 93 ++++
.../apache/clerezza/commons/rdf/RDFTerm.java | 32 ++
.../org/apache/clerezza/commons/rdf/Triple.java | 57 +++
.../clerezza/commons/rdf/WatchableGraph.java | 94 ++++
.../clerezza/commons/rdf/event/AddEvent.java | 37 ++
.../commons/rdf/event/FilterTriple.java | 86 ++++
.../clerezza/commons/rdf/event/GraphEvent.java | 59 +++
.../commons/rdf/event/GraphListener.java | 43 ++
.../clerezza/commons/rdf/event/RemoveEvent.java | 37 ++
.../clerezza/commons/rdf/package-info.java | 21 +
doap_rdf.rdf | 40 ++
impl.sparql/pom.xml | 123 +++++
.../commons/rdf/impl/sparql/SparqlBNode.java | 74 +++
.../commons/rdf/impl/sparql/SparqlClient.java | 79 +++
.../commons/rdf/impl/sparql/SparqlGraph.java | 507 +++++++++++++++++++
.../rdf/impl/sparql/SparqlResultParser.java | 225 ++++++++
.../rdf/impl/sparql/BNodeCircleTest.java | 118 +++++
.../commons/rdf/impl/sparql/BNodeTest.java | 139 +++++
.../commons/rdf/impl/sparql/Dadmin2Test.java | 94 ++++
.../commons/rdf/impl/sparql/DadminTest.java | 94 ++++
.../commons/rdf/impl/sparql/SimilarBNodes.java | 104 ++++
.../rdf/impl/sparql/SparqlClientTest.java | 104 ++++
.../rdf/impl/sparql/SparqlGraphTest.java | 113 +++++
.../commons/rdf/impl/sparql/bnode-circle.ttl | 7 +
.../clerezza/commons/rdf/impl/sparql/dadmin.ttl | 5 +
.../commons/rdf/impl/sparql/dadmin2.ttl | 17 +
.../commons/rdf/impl/sparql/grounded.ttl | 16 +
.../commons/rdf/impl/sparql/similar-bnodes.ttl | 8 +
.../commons/rdf/impl/sparql/simple-bnode.ttl | 7 +
impl.utils/pom.xml | 85 ++++
.../commons/rdf/impl/utils/AbstractGraph.java | 316 ++++++++++++
.../rdf/impl/utils/AbstractImmutableGraph.java | 112 ++++
.../commons/rdf/impl/utils/AbstractLiteral.java | 61 +++
.../rdf/impl/utils/DelayedNotificator.java | 113 +++++
.../commons/rdf/impl/utils/LiteralImpl.java | 82 +++
.../commons/rdf/impl/utils/LockingIterator.java | 73 +++
.../rdf/impl/utils/PlainLiteralImpl.java | 80 +++
.../commons/rdf/impl/utils/TripleImpl.java | 100 ++++
.../rdf/impl/utils/TypedLiteralImpl.java | 80 +++
.../rdf/impl/utils/WatchableGraphWrapper.java | 289 +++++++++++
.../rdf/impl/utils/debug/ReadLockDebug.java | 85 ++++
.../debug/ReentrantReadWriteLockTracker.java | 133 +++++
.../rdf/impl/utils/debug/WriteLockDebug.java | 89 ++++
.../impl/utils/graphmatching/GraphMatcher.java | 140 +++++
.../GraphNotIsomorphicException.java | 28 +
.../graphmatching/GroupMappingIterator.java | 102 ++++
.../impl/utils/graphmatching/HashMatching.java | 268 ++++++++++
.../utils/graphmatching/MappingIterator.java | 76 +++
.../graphmatching/PermutationIterator.java | 107 ++++
.../rdf/impl/utils/graphmatching/Utils.java | 82 +++
.../graphmatching/collections/IntHashMap.java | 377 ++++++++++++++
.../graphmatching/collections/IntHashSet.java | 62 +++
.../graphmatching/collections/IntIterator.java | 30 ++
.../utils/graphmatching/collections/IntSet.java | 35 ++
.../commons/rdf/impl/utils/package-info.java | 21 +
.../rdf/impl/utils/simple/SimpleGraph.java | 218 ++++++++
.../impl/utils/simple/SimpleImmutableGraph.java | 79 +++
.../rdf/impl/utils/simple/SimpleMGraph.java | 57 +++
.../utils/graphmatching/GraphMatcherTest.java | 211 ++++++++
.../utils/graphmatching/HashMatchingTest.java | 51 ++
.../graphmatching/PermutationIteratorTest.java | 78 +++
.../impl/utils/graphmatching/Utils4Testing.java | 51 ++
.../impl/utils/simple/PlainLiteralImplTest.java | 71 +++
.../rdf/impl/utils/simple/SimpleGraphTest.java | 109 ++++
.../rdf/impl/utils/simple/TripleImplTest.java | 57 +++
.../impl/utils/simple/TypedLiteralImplTest.java | 67 +++
pom.xml | 246 ++-------
81 files changed, 7379 insertions(+), 203 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 39dd015..b2a1ed9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ target/
.classpath
dependency-reduced-pom.xml
release.properties
+.svn
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/LICENSE.txt
----------------------------------------------------------------------
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/NOTICE.txt
----------------------------------------------------------------------
diff --git a/NOTICE.txt b/NOTICE.txt
new file mode 100644
index 0000000..66a6d0f
--- /dev/null
+++ b/NOTICE.txt
@@ -0,0 +1,8 @@
+Apache Commons RDF
+Copyright 2001-2014 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes software developed at
+https://github.com/commons-rdf/commons-rdf.
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5e05c3d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,72 @@
+## Building
+
+Build using Apache Maven with
+
+ mvn install
+
+## Documentation
+
+You can build the documentation with:
+
+ mvn site
+
+## FAQ
+
+Some more advanced questions focused on showing the differences to other proposed APIs.
+
+### Can I add RdfTerms from one implementation to another?
+
+Yes, any compliant implementation of BlankNode, Iri or Literal as well as Triple
+can be added to any implemenation of Graph, as long the Graph supports adding triples. Implementation
+may not require the nodes to be of a particular implementation of having been
+created with a specific factory.
+
+### How does it work?
+
+Implementation might need to map instances of BlankNode to their internal
+implementation. This should be done in a way that when there is no more reference
+to the BlankNode object (i.e. when the object can be garbage collected) the mapping
+to the internal implementation is removed from memory to. This can be achieved
+by using a java.util.WeakHashMap
+
+### Do I get back the same object that I added?
+
+For instances of Iri or Literals you get back an object that result equal to the
+originally added object, i.e. an object with the same HashCode and of which the
+equals method return true when compared with the originally added object. Ther
+is no guarantee that the same instance will be returned.
+For instances of BlankNode the above in only guaranteed as long as the original
+object is referenced. When the original object becomes eligible for garbage
+collection the implementation may start returning a different (an not equal)
+object. In practice this means BlankNode objects cannot safely be serialized
+(using Java serialization) or passed around via RMI.
+
+### Can an implementation remove redundant information from a Graph?
+
+Yes, as long as this doesn't affect any BlankNode instance that is currently
+reachable (i.e. the Java object is in memory and is not eligible for garbage
+collection).
+
+For example given the non-lean graph:
+
+ ex:a ex:p _:x .
+ _:y ex:p _:x .
+
+As long as there is no BlankNode instance referencing _:y the implementation can
+reduce the graph to:
+
+ ex:a ex:p _:x .
+
+removing the redundancy. If however there is a reachable BlankNode instance for
+_:y the implementation must not remove the redundancy as the code which has
+access to the object can go on adding a triple:
+
+ _:y ex:p2 ex:b .
+
+Thus creating a graph that doesn't contain any internal redundancy, namely:
+
+ ex:a ex:p _:x .
+ _:y ex:p _:x .
+ _:y ex:p2 ex:b .
+
+
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/alerts.txt
----------------------------------------------------------------------
diff --git a/alerts.txt b/alerts.txt
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/pom.xml
----------------------------------------------------------------------
diff --git a/api/pom.xml b/api/pom.xml
new file mode 100644
index 0000000..a58ef72
--- /dev/null
+++ b/api/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>clerezza</artifactId>
+ <version>7</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.apache.clerezza.commons-rdf</groupId>
+ <artifactId>commons-rdf-api</artifactId>
+ <version>0.3-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <name>Clerezza Commons RDF API</name>
+ <description>
+ Apache Clerezza Commons RDF provides an API modelling the RDF data model as defined by
+ http://www.w3.org/TR/rdf11-concepts/
+ </description>
+
+ <url>http://clerezza.apache.org/commons-rdf/</url>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>http://issues.apache.org/jira/browse/CLEREZZA</url>
+ </issueManagement>
+
+ <inceptionYear>2015</inceptionYear>
+ <scm>
+ <connection>scm:git:https://git-wip-us.apache.org/repos/asf/clerezza-rdf-core.git</connection>
+ <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/clerezza-rdf-core.git</developerConnection>
+ <url>https://git-wip-us.apache.org/repos/asf/clerezza-rdf-core.git</url>
+ <tag>HEAD</tag>
+ </scm>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/assembly/bin.xml
----------------------------------------------------------------------
diff --git a/api/src/main/assembly/bin.xml b/api/src/main/assembly/bin.xml
new file mode 100644
index 0000000..3c114dd
--- /dev/null
+++ b/api/src/main/assembly/bin.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>bin</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>README*</include>
+ <include>LICENSE*</include>
+ <include>NOTICE*</include>
+ <include>RELEASE-NOTES.txt</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>commons-net-${project.version}.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/site/apidocs</directory>
+ <outputDirectory>apidocs</outputDirectory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </fileSet>
+ <!-- Include sources jar for IDEs -->
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>commons-net-${project.version}-sources.jar</include>
+ </includes>
+ </fileSet>
+ <!-- Include examples as binary jar -->
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>commons-net-examples-${project.version}.jar</include>
+ </includes>
+ </fileSet>
+ <!-- Include example sources for developers -->
+ <fileSet>
+ <directory>src/main/java/examples</directory>
+ <outputDirectory>examples</outputDirectory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/assembly/src.xml
----------------------------------------------------------------------
diff --git a/api/src/main/assembly/src.xml b/api/src/main/assembly/src.xml
new file mode 100644
index 0000000..a5f8da1
--- /dev/null
+++ b/api/src/main/assembly/src.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>src</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>zip</format>
+ </formats>
+ <baseDirectory>${artifactId}-${version}-src</baseDirectory>
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>README*</include>
+ <include>LICENSE*</include>
+ <include>NOTICE*</include>
+ <include>RELEASE-NOTES.txt</include>
+ <include>pom.xml</include>
+ <include>findbugs-exclude-filter.xml</include>
+ <include>checkstyle*.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src</directory>
+ </fileSet>
+ </fileSets>
+</assembly>
+
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNode.java b/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNode.java
new file mode 100644
index 0000000..9952fce
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNode.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+/**
+ * A Blank Node represents a resource,
+ * but does not indicate a URI for the resource. Blank nodes act like
+ * existentially qualified variables in first order logic.
+ *
+ * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node" >RDF-1.1
+ * Blank Node</a>, as defined by <a href=
+ * "http://www.w3.org/TR/rdf11-concepts/#section-blank-nodes" >RDF-1.1 Concepts
+ * and Abstract Syntax</a>, a W3C Recommendation published on 25 February 2014.<br>
+ *
+ * Note that: Blank nodes are disjoint from IRIs and literals. Otherwise,
+ * the set of possible blank nodes is arbitrary. RDF makes no reference to any
+ * internal structure of blank nodes.
+ *
+ *
+ * @see <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-blank-node">RDF-1.1
+ * Blank Node</a>
+ */
+public class BlankNode implements BlankNodeOrIRI {
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNodeOrIRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNodeOrIRI.java b/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNodeOrIRI.java
new file mode 100644
index 0000000..8d80b4b
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNodeOrIRI.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+/**
+ * Represents a <code>Resource</code> that is not a <code>Literal</code>.
+ * This is a marker interface implemented by <code>UriRef</code>
+ * and <code>BNode</code>.
+ *
+ * @author reto
+ */
+public interface BlankNodeOrIRI extends RDFTerm {
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/Graph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/Graph.java b/api/src/main/java/org/apache/clerezza/commons/rdf/Graph.java
new file mode 100644
index 0000000..6904722
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Graph.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.clerezza.commons.rdf.event.FilterTriple;
+import org.apache.clerezza.commons.rdf.event.GraphListener;
+
+
+/**
+ * A set of triples (as it doesn't allow duplicates), it does however
+ * not extend {@link java.util.Set} as it doesn't inherit its
+ * specification for <code>hashCode()</code> and <code>equals</code>.
+ * It is possible to add <code>GraphListener</code> to listen for modifications
+ * in the triples.
+ *
+ * @author reto
+ */
+public interface Graph extends Collection<Triple> {
+
+ /**
+ * Filters triples given a pattern.
+ * filter(null, null, null) returns the same as iterator()
+ *
+ * @param subject
+ * @param predicate
+ * @param object
+ * @return <code>Iterator</code>
+ */
+ public Iterator<Triple> filter(BlankNodeOrIRI subject, IRI predicate,
+ RDFTerm object);
+
+ /**
+ * Returns true if <code>other</code> describes the same graph and will
+ * always describe the same graph as this instance, false otherwise.
+ * It returns true if this == other or if it
+ * is otherwise guaranteed that changes to one of the instances are
+ * immediately reflected in the other or if both graphs are immutable.
+ *
+ * @param other
+ * @return true if other == this
+ */
+ @Override
+ public boolean equals(Object other);
+
+ /**
+ * Returns an ImutableGraph describing the graph at the current point in
+ * time. if <code>this</code> is an instance of ImmutableGraph this can
+ * safely return <code>this</code>.
+ *
+ * @return the current time slice of the possibly mutable graph represented by the instance.
+ */
+ public ImmutableGraph getImmutableGraph();
+
+ /**
+ * The lock provided by this methods allows to create read- and write-locks
+ * that span multiple method calls. Having a read locks prevents other
+ * threads from writing to this Graph, having a write-lock prevents other
+ * threads from reading and writing. Implementations would typically
+ * return a <code>java.util.concurrent.locks.ReentrantReadWriteLock</code>.
+ * Immutable instances (such as instances of <code>ImmutableGraph</code>)
+ * or instances used in transaction where concurrent acces of the same
+ * instance is not an issue may return a no-op ReadWriteLock (i.e. one
+ * which returned ReadLock and WriteLock instances of which the methods do
+ * not do anything)
+ *
+ * @return the lock of this Graph
+ */
+ ReadWriteLock getLock();
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/IRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/IRI.java b/api/src/main/java/org/apache/clerezza/commons/rdf/IRI.java
new file mode 100644
index 0000000..be9b3a8
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/IRI.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+import java.io.Serializable;
+
+/**
+ * Represents an RDF URI Reference
+ *
+ * RDF URI References are defined in section 6.4 RDF URI References of
+ * http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#section-Graph-URIref
+ *
+ * Note that an RDF URI Reference is not the same as defined by RFC3986,
+ * RDF URI References support most unicode characters
+ *
+ * @author reto
+ */
+public class IRI implements BlankNodeOrIRI, Serializable {
+
+ private String unicodeString;
+
+ public IRI(String unicodeString) {
+ this.unicodeString = unicodeString;
+ }
+
+ /**
+ * @return the unicode string that produces the URI
+ */
+ public String getUnicodeString() {
+ return unicodeString;
+ }
+
+ /**
+ * Returns true iff <code>obj</code> == <code>UriRef</code>
+ *
+ * @param obj
+ * @return true if obj is an instanceof UriRef with
+ * the same unicode-string, false otherwise
+ */
+ @Override
+ public boolean equals(Object obj) {
+
+ if (!(obj instanceof IRI)) {
+ return false;
+ }
+
+ return unicodeString.equals(((IRI) obj).getUnicodeString());
+ }
+
+ /**
+ * @return 5 + the hashcode of the string
+ */
+ @Override
+ public int hashCode() {
+ int hash = 5 + unicodeString.hashCode();
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append('<');
+ buffer.append(unicodeString);
+ buffer.append('>');
+ return buffer.toString();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/ImmutableGraph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/ImmutableGraph.java b/api/src/main/java/org/apache/clerezza/commons/rdf/ImmutableGraph.java
new file mode 100644
index 0000000..bd94671
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/ImmutableGraph.java
@@ -0,0 +1,55 @@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+/**
+ * A graph, modeled as a set of triples.
+ * This interface does not extend java.util.Set because of the different
+ * identity constraints, i.e. two <code>Graph</code>s may be equal (isomorphic)
+ * even if the set of triples are not.
+ *
+ * Implementations MUST be immutable and throw respective exceptions, when
+ * add/remove-methods are called.
+ *
+ * @see org.apache.clerezza.rdf.core.impl.AbstractGraph
+ * @author reto
+ *
+ */
+public interface ImmutableGraph extends Graph {
+
+ /**
+ * Returns true if two graphs are isomorphic
+ *
+ * @return true if two graphs are isomorphic
+ */
+ @Override
+ public boolean equals(Object obj);
+
+ /**
+ * Return the sum of the blank-nodes independent hashes of the triples.
+ * More precisely the hash of the triple is calculated as follows:
+ * (hash(subject) >> 1) ^ hash(hashCode) ^ (hash(hashCode) << 1)
+ * Where the hash-fucntion return the hashCode of the argument
+ * for grounded arguments and 0 otherwise.
+ *
+ * @return hash code
+ */
+ @Override
+ public int hashCode();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/Language.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/Language.java b/api/src/main/java/org/apache/clerezza/commons/rdf/Language.java
new file mode 100644
index 0000000..62a921e
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Language.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+/**
+ * Represents a language as expressed by the RDF 4646 language tag
+ *
+ * @author reto
+ */
+public class Language {
+
+ private String id;
+
+ /**
+ * Constructs the language tag defined by RDF 4646, normalized to lowercase.
+ *
+ * @param the id as defined by RDF 4646, normalized to lowercase.
+ */
+ public Language(String id) {
+ if ((id == null) || (id.equals(""))) {
+ throw new IllegalArgumentException("A language id may not be null or empty");
+ }
+ this.id = id.toLowerCase();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (other instanceof Language) {
+ return id.equals(((Language) other).id);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/Literal.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/Literal.java b/api/src/main/java/org/apache/clerezza/commons/rdf/Literal.java
new file mode 100644
index 0000000..0f96256
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Literal.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+
+/**
+ * Represents a literal value that can be a node in an RDF Graph.
+ * Literals are used to identify values such as numbers and dates by
+ * means of a lexical representation. There are two types of literals
+ * represented by the subinterfaces {@link PlainLiteral}
+ * and {@link TypedLiteral}
+ *
+ * @author reto
+ */
+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 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 null.
+ *
+ * @return The language tag of the literal or null if no language tag is defined
+ * @see <a
+ * href="http://www.w3.org/TR/rdf11-concepts/#dfn-language-tag">RDF-1.1
+ * Literal language tag</a>
+ */
+ public Language getLanguage();
+
+ /**
+ * Returns true if <code>obj</code> is an instance of
+ * <code>literal</code> that is term-equal with this, false otherwise
+ *
+ * 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.
+ *
+ * @return true if obj equals this, false otherwise.
+ */
+ public boolean equals(Object obj);
+
+ /**
+ * Returns the hash code of the lexical form plus the hash code of the
+ * datatype plus if the literal has a language the hash code of the
+ * language.
+ *
+ * @return hash code
+ */
+ public int hashCode();
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/RDFTerm.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/RDFTerm.java b/api/src/main/java/org/apache/clerezza/commons/rdf/RDFTerm.java
new file mode 100644
index 0000000..197a182
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/RDFTerm.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+/**
+ * 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 {
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/Triple.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/Triple.java b/api/src/main/java/org/apache/clerezza/commons/rdf/Triple.java
new file mode 100644
index 0000000..67cdef0
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Triple.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+/**
+ * A structure containing a subject, a predicate, and an object.
+ * Also known as a statement.
+ *
+ * @author reto
+ */
+public interface Triple {
+
+ BlankNodeOrIRI getSubject();
+
+ IRI getPredicate();
+
+ RDFTerm getObject();
+
+ /**
+ *
+ * @param obj
+ * @return true iff subject, predicate, and object of both triples are equal
+ */
+ @Override
+ boolean equals(Object obj);
+
+ /**
+ * The hash code is computed as follow
+ * (subject.hashCode() >> 1) ^ predicate.hashCode() ^ object.hashCode() << 1)
+ *
+ * Note that the hash returned is computed including the hash of BNodes, so
+ * it is not blank-node blind as in Graph.
+ *
+ * This would have to change if triple should extend Graph
+ *
+ * @return hash code
+ */
+ @Override
+ int hashCode();
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/WatchableGraph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/WatchableGraph.java b/api/src/main/java/org/apache/clerezza/commons/rdf/WatchableGraph.java
new file mode 100644
index 0000000..4ed2cd4
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/WatchableGraph.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.clerezza.commons.rdf.event.FilterTriple;
+import org.apache.clerezza.commons.rdf.event.GraphListener;
+
+
+/**
+ * An extension to the Graph interface that allows to add throws events
+ * on modifications.
+ *
+ * @author reto
+ */
+public interface WatchableGraph extends Graph {
+
+
+ /**
+ * Adds the specified <code>GraphListener</code> to the graph. This listener
+ * will be notified, when the graph is modified and the <code>Triple</code>
+ * that was part of the modifiaction matched the specified
+ * <code>FilterTriple</code>. The notification will be passed to the
+ * listener after the specified delay time (in milli-seconds) has passed.
+ * If more matching events occur during the delay period, then they are
+ * passed all together at the end of the delay period. If the the listener
+ * unregisters or the platform is stopped within the period then the already
+ * occurred events may not be delivered.
+ *
+ * All implementations support this method, immutable implementations will
+ * typically provide an empty implementation, they shall not throw an
+ * exception.
+ *
+ * Implementation of which the triples change over time without add- and
+ * remove-methods being called (e.g. implementation dynamically generating
+ * their triples on invocation of the filer-method) may choose not to, or
+ * only partially propagate their changes to the listener. They should
+ * describe the behavior in the documentation of the class.
+ *
+ * Implementations should keep weak references the listeners, so that the
+ * listener can be garbage collected if its no longer referenced by another
+ * object.
+ *
+ * If delay is 0 notification will happen synchroneously.
+ *
+ * @param listener The listener that will be notified
+ * @param filter The triple filter with which triples are tested,
+ * that were part of the modification.
+ * @param delay The time period afer which the listener will be notified in milliseconds.
+ */
+ public void addGraphListener(GraphListener listener, FilterTriple filter,
+ long delay);
+
+ /**
+ * Adds the specified <code>GraphListener</code> to the graph. This listener
+ * will be notified, when the graph is modified and the <code>Triple</code>
+ * that was part of the modifiaction matched the specified
+ * <code>FilterTriple</code>. The notification will be passed without delay.
+ *
+ * Same as <code>addGraphListener(listener, filter, 0).
+ *
+ * @param listener The listener that will be notified
+ * @param filter The triple filter with which triples are tested,
+ * that were part of the modification.
+ */
+ public void addGraphListener(GraphListener listener, FilterTriple filter);
+
+ /**
+ * Removes the specified <code>GraphListener</code> from the graph. This
+ * listener will no longer be notified, when the graph is modified.
+ *
+ * @param listener The listener to be removed.
+ */
+ public void removeGraphListener(GraphListener listener);
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/event/AddEvent.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/event/AddEvent.java b/api/src/main/java/org/apache/clerezza/commons/rdf/event/AddEvent.java
new file mode 100644
index 0000000..c2716d6
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/event/AddEvent.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf.event;
+
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Graph;
+
+/**
+ * This class represent a addition event that occured on a
+ * <code>TripleCollection</code>.
+ *
+ * @author rbn
+ */
+public class AddEvent extends GraphEvent {
+
+
+ public AddEvent(Graph graph, Triple triple) {
+ super(graph, triple);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/event/FilterTriple.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/event/FilterTriple.java b/api/src/main/java/org/apache/clerezza/commons/rdf/event/FilterTriple.java
new file mode 100644
index 0000000..4e22df7
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/event/FilterTriple.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf.event;
+
+import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
+import org.apache.clerezza.commons.rdf.RDFTerm;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.IRI;
+
+/**
+ * The <code>FilterTriple</code> class provides a match()-method that tests
+ * if a <code>Triple</code> match a certain triple pattern.
+ *
+ * @author mir
+ */
+public class FilterTriple {
+
+ private BlankNodeOrIRI subject;
+ private IRI predicate;
+ private RDFTerm object;
+
+ /**
+ * Creates a new <code>FilterTriple</code>. The specified subject,
+ * predicate and object are used to test a given <code>Triple</code>. Any
+ * of these values can be null, which acts as wildcard in the test.
+ *
+ * @param subject the subject.
+ * @param predicate the predicate.
+ * @param object the object.
+ */
+ public FilterTriple (BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+ this.subject = subject;
+ this.predicate = predicate;
+ this.object = object;
+ }
+
+ /**
+ * Returns true if the subject, predicate and object of the specified
+ * <code>Triple</code> match the subject, predicate and object of this
+ * <code>FilterTriple</code>. Null values in the <code>FilterTriple</code>
+ * act as wildcards.
+ * @param triple
+ * @return
+ */
+ public boolean match(Triple triple) {
+ boolean subjectMatch, predicateMatch, objectMatch;
+ if (this.subject == null) {
+ subjectMatch = true;
+ } else {
+ subjectMatch = this.subject.equals(triple.getSubject());
+ }
+ if (this.predicate == null) {
+ predicateMatch = true;
+ } else {
+ predicateMatch = this.predicate.equals(triple.getPredicate());
+ }
+ if (this.object == null) {
+ objectMatch = true;
+ } else {
+ objectMatch = this.object.equals(triple.getObject());
+ }
+ return subjectMatch && predicateMatch && objectMatch;
+ }
+
+ @Override
+ public String toString() {
+ return "FilterTriples: "+subject+" "+predicate+" "+object;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/event/GraphEvent.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/event/GraphEvent.java b/api/src/main/java/org/apache/clerezza/commons/rdf/event/GraphEvent.java
new file mode 100644
index 0000000..b9e6ec0
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/event/GraphEvent.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf.event;
+
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Graph;
+
+/**
+ * This class represent a modification event that occured on a
+ * <code>TripleCollection</code>. A <code>GraphEvent</code> object keeps
+ * information about this event. These information are: The <code>Triple</code>
+ * that was part of the modification, the type of modification (addition or
+ * removal) and the <code>TripleCollection</code> that was modified.
+ *
+ * @author mir
+ */
+public class GraphEvent {
+
+ private Graph graph;
+ private Triple triple;
+
+ protected GraphEvent(Graph graph, Triple triple) {
+ this.graph = graph;
+ this.triple = triple;
+ }
+
+ /**
+ * Returns the <code>TripleCollection</code> that was modified in the event.
+ * @return the graph
+ */
+ public Graph getGraph() {
+ return graph;
+ }
+
+
+ /**
+ * Return the <code>Triple</code> that was part of the modification.
+ * @return the triple
+ */
+ public Triple getTriple() {
+ return triple;
+ }
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/event/GraphListener.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/event/GraphListener.java b/api/src/main/java/org/apache/clerezza/commons/rdf/event/GraphListener.java
new file mode 100644
index 0000000..9041546
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/event/GraphListener.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf.event;
+
+import java.util.List;
+
+/**
+ * A class that is interested in graph events implements this interface and
+ * is then added as listener to a <code>ListenableTripleCollection</code> or
+ * one of its subclasses. When the <code>ListenableTripleCollection</code> is
+ * modified, then the <code>GraphListener</code> is notified.
+ *
+ * @author mir
+ */
+public interface GraphListener {
+
+ /**
+ * This method is called when a <code>ListenableTripleCollection</code> was
+ * modified, to which this <code>GraphListener</code> was added. A
+ * <code>List</code> containing <code>GraphEvent</code>s are passed as
+ * argument. The list contains all events in which a triple was part of
+ * the modification that matched the <code>FilterTriple</code> which was passed
+ * as argument when the listener was added.
+ * @param events
+ */
+ public void graphChanged(List<GraphEvent> events);
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/event/RemoveEvent.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/event/RemoveEvent.java b/api/src/main/java/org/apache/clerezza/commons/rdf/event/RemoveEvent.java
new file mode 100644
index 0000000..103febc
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/event/RemoveEvent.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.commons.rdf.event;
+
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Graph;
+
+/**
+ * This class represent a removal event that occured on a
+ * <code>TripleCollection</code>.
+ *
+ * @author rbn
+ */
+public class RemoveEvent extends GraphEvent {
+
+
+ public RemoveEvent(Graph graph, Triple triple) {
+ super(graph, triple);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/api/src/main/java/org/apache/clerezza/commons/rdf/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/clerezza/commons/rdf/package-info.java b/api/src/main/java/org/apache/clerezza/commons/rdf/package-info.java
new file mode 100644
index 0000000..62354fe
--- /dev/null
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/package-info.java
@@ -0,0 +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.
+ */
+
+/**
+ * Common RDF API
+ */
+package org.apache.clerezza.commons.rdf;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/doap_rdf.rdf
----------------------------------------------------------------------
diff --git a/doap_rdf.rdf b/doap_rdf.rdf
new file mode 100644
index 0000000..a7a5e17
--- /dev/null
+++ b/doap_rdf.rdf
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<rdf:RDF xmlns="http://usefulinc.com/ns/doap#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:asfext="http://projects.apache.org/ns/asfext#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:doap="http://usefulinc.com/ns/doap#" xml:lang="en">
+ <Project rdf:about="http://commons.apache.org/rdf/">
+ <name>Apache Commons RDF</name>
+ <homepage rdf:resource="http://commons.apache.org/rdf/"/>
+ <programming-language>Java</programming-language>
+ <category rdf:resource="http://projects.apache.org/category/library"/>
+ <license rdf:resource="http://usefulinc.com/doap/licenses/asl20"/>
+ <bug-database rdf:resource="https://issues.apache.org/jira/browse/RDF"/>
+ <download-page rdf:resource="http://commons.apache.org/rdf/download_net.cgi"/>
+ <asfext:pmc rdf:resource="http://commons.apache.org/"/>
+ <shortdesc xml:lang="en">Apache Commons Rdf</shortdesc>
+ <description xml:lang="en"/>
+ <repository>
+ <SVNRepository>
+ <browse rdf:resource="http://svn.apache.org/repos/asf/commons/proper/rdf/trunk"/>
+ <location rdf:resource="http://svn.apache.org/repos/asf/commons/proper/rdf"/>
+ </SVNRepository>
+ </repository>
+ <release>
+ </release>
+ <mailing-list rdf:resource="http://commons.apache.org/mail-lists.html"/>
+ </Project>
+</rdf:RDF>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/impl.sparql/pom.xml
----------------------------------------------------------------------
diff --git a/impl.sparql/pom.xml b/impl.sparql/pom.xml
new file mode 100644
index 0000000..dcf81fc
--- /dev/null
+++ b/impl.sparql/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+
+<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>org.apache.clerezza</groupId>
+ <artifactId>clerezza</artifactId>
+ <version>7</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.apache.clerezza.commons-rdf</groupId>
+ <artifactId>commons-rdf-impl-sparql</artifactId>
+ <version>0.3-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <name>Clerezza Commons RDF SPARQL backed implementation.</name>
+ <description>An implementation of the rdf commons API backed by a sparql
+ endpoint. STATUS: Current code only supports reading
+ graphs.</description>
+
+ <url>http://clerezza.apache.org/commons-rdf/</url>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>http://issues.apache.org/jira/browse/CLEREZZA</url>
+ </issueManagement>
+
+ <inceptionYear>2015</inceptionYear>
+ <scm>
+ <connection>scm:git:https://git-wip-us.apache.org/repos/asf/clerezza-rdf-core.git</connection>
+ <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/clerezza-rdf-core.git</developerConnection>
+ <url>https://git-wip-us.apache.org/repos/asf/clerezza-rdf-core.git</url>
+ <tag>HEAD</tag>
+ </scm>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <commons.encoding>UTF-8</commons.encoding>
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>1.7</maven.compiler.target>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.clerezza.commons.rdf.impl.sparql</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza.commons-rdf</groupId>
+ <artifactId>commons-rdf-api</artifactId>
+ <version>0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza.commons-rdf</groupId>
+ <artifactId>commons-rdf-impl-utils</artifactId>
+ <version>0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jena</groupId>
+ <artifactId>jena-fuseki</artifactId>
+ <version>1.1.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.core</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.jena.parser</artifactId>
+ <version>1.1.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.jena.serializer</artifactId>
+ <version>1.1.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlBNode.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlBNode.java b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlBNode.java
new file mode 100644
index 0000000..9035b0a
--- /dev/null
+++ b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlBNode.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2015 The Apache Software Foundation.
+ *
+ * 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.clerezza.commons.rdf.impl.sparql;
+
+import java.util.Collection;
+import java.util.Objects;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
+import org.apache.clerezza.commons.rdf.ImmutableGraph;
+import org.apache.clerezza.commons.rdf.IRI;
+import org.apache.clerezza.commons.rdf.RDFTerm;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph;
+
+/**
+ *
+ * @author developer
+ */
+class SparqlBNode extends BlankNode {
+
+ final static IRI internalBNodeId = new IRI("urn:x-internalid:fdmpoihdfw");
+
+ final ImmutableGraph context;
+ private final int isoDistinguisher;
+
+ SparqlBNode(BlankNode node, Collection<Triple> context, int isoDistinguisher) {
+ this.isoDistinguisher = isoDistinguisher;
+ final SimpleGraph contextBuider = new SimpleGraph();
+ for (Triple triple : context) {
+ BlankNodeOrIRI subject = triple.getSubject();
+ RDFTerm object = triple.getObject();
+ contextBuider.add(new TripleImpl(subject.equals(node) ? internalBNodeId : subject,
+ triple.getPredicate(),
+ object.equals(node) ? internalBNodeId : object));
+ }
+ this.context = contextBuider.getImmutableGraph();
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7+isoDistinguisher;
+ hash = 61 * hash + Objects.hashCode(this.context);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final SparqlBNode other = (SparqlBNode) obj;
+ if (isoDistinguisher != other.isoDistinguisher) {
+ return false;
+ }
+ return Objects.equals(this.context, other.context);
+ }
+}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/2109cae5/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlClient.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlClient.java b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlClient.java
new file mode 100644
index 0000000..63b0086
--- /dev/null
+++ b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlClient.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2015 The Apache Software Foundation.
+ *
+ * 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.clerezza.commons.rdf.impl.sparql;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.apache.clerezza.commons.rdf.RDFTerm;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+
+/**
+ *
+ * @author developer
+ */
+public class SparqlClient {
+
+ final String endpoint;
+
+ public SparqlClient(final String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public List<Map<String, RDFTerm>> queryResultSet(final String query) throws IOException {
+ return (List<Map<String, RDFTerm>>) queryResult(query);
+ }
+
+ public Object queryResult(final String query) throws IOException {
+ CloseableHttpClient httpclient = HttpClients.createDefault();
+ HttpPost httpPost = new HttpPost(endpoint);
+ List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+ nvps.add(new BasicNameValuePair("query", query));
+ httpPost.setEntity(new UrlEncodedFormEntity(nvps));
+ CloseableHttpResponse response2 = httpclient.execute(httpPost);
+ HttpEntity entity2 = response2.getEntity();
+ try {
+ InputStream in = entity2.getContent();
+ final String mediaType = entity2.getContentType().getValue();
+ if (mediaType.startsWith("application/sparql-results+xml")) {
+ return SparqlResultParser.parse(in);
+ } else {
+ //assuming RDF response
+ //FIXME clerezza-core-rdf to clerezza dependency
+ Parser parser = Parser.getInstance();
+ return parser.parse(in, mediaType);
+ }
+ } finally {
+ EntityUtils.consume(entity2);
+ response2.close();
+ }
+
+ }
+
+
+
+}