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 2015/04/09 14:34:04 UTC

[1/7] clerezza-rdf-core git commit: CLEREZZA-982: moved files for new packages

Repository: clerezza-rdf-core
Updated Branches:
  refs/heads/master 95dc83759 -> 12b3d66e1


http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleGraph.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleGraph.java
deleted file mode 100644
index 9b60a15..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleGraph.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils.simple;
-
-import org.apache.commons.rdf.impl.utils.AbstractGraph;
-import java.lang.ref.SoftReference;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.ConcurrentModificationException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-
-/**
- * For now this is a minimalistic implementation, without any indexes or other
- * optimizations.
- *
- * @author reto
- */
-public class SimpleGraph extends AbstractGraph {
-
-    final Set<Triple> triples;
-
-    private boolean checkConcurrency = false;
-
-    class SimpleIterator implements Iterator<Triple> {
-
-        private Iterator<Triple> listIter;
-        private boolean isValid = true;
-
-        public SimpleIterator(Iterator<Triple> listIter) {
-            this.listIter = listIter;
-        }
-        private Triple currentNext;
-
-        @Override
-        public boolean hasNext() {
-            checkValidity();
-            return listIter.hasNext();
-        }
-
-        @Override
-        public Triple next() {
-            checkValidity();
-            currentNext = listIter.next();
-            return currentNext;
-        }        
-
-        @Override
-        public void remove() {
-            checkValidity();
-            listIter.remove();
-            triples.remove(currentNext);            
-            invalidateIterators(this);            
-        }
-
-        private void checkValidity() throws ConcurrentModificationException {
-            if (checkConcurrency && !isValid) {
-                throw new ConcurrentModificationException();
-            }
-        }
-
-        private void invalidate() {
-            isValid = false;
-        }
-    }    
-    
-    private final Set<SoftReference<SimpleIterator>> iterators =
-            Collections.synchronizedSet(new HashSet<SoftReference<SimpleIterator>>());
-    
-    /**
-     * Creates an empty SimpleGraph
-     */
-    public SimpleGraph() {
-        triples = Collections.synchronizedSet(new HashSet<Triple>());
-    }
-
-    /**
-     * Creates a SimpleGraph using the passed iterator, the iterator 
-     * is consumed before the constructor returns
-     * 
-     * @param iterator
-     */
-    public SimpleGraph(Iterator<Triple> iterator) {
-        triples = new HashSet<Triple>();
-        while (iterator.hasNext()) {
-            Triple triple = iterator.next();
-            triples.add(triple);
-        }
-    }
-
-    /**
-     * Creates a SimpleGraph for the specified set of triples, 
-     * subsequent modification of baseSet do affect the created instance.
-     * 
-     * @param baseSet
-     */
-    public SimpleGraph(Set<Triple> baseSet) {
-        this.triples = baseSet;
-    }
-
-    /**
-     * Creates a SimpleGraph for the specified collection of triples,
-     * subsequent modification of baseSet do not affect the created instance.
-     *
-     * @param baseSet
-     */
-    public SimpleGraph(Collection<Triple> baseCollection) {
-        this.triples = new HashSet<Triple>(baseCollection);
-    }
-
-    @Override
-    public int performSize() {
-        return triples.size();
-    }
-
-    @Override
-    public Iterator<Triple> performFilter(final BlankNodeOrIri subject, final Iri predicate, final RdfTerm object) {
-        final List<Triple> tripleList = new ArrayList<Triple>();
-        synchronized (triples) {
-            Iterator<Triple> baseIter = triples.iterator();
-            while (baseIter.hasNext()) {
-                Triple triple = baseIter.next();
-                if ((subject != null)
-                        && (!triple.getSubject().equals(subject))) {
-                    continue;
-                }
-                if ((predicate != null)
-                        && (!triple.getPredicate().equals(predicate))) {
-                    continue;
-                }
-                if ((object != null)
-                        && (!triple.getObject().equals(object))) {
-                    continue;
-                }
-                tripleList.add(triple);
-            }
-
-            final Iterator<Triple> listIter = tripleList.iterator();
-            SimpleIterator resultIter = new SimpleIterator(listIter);
-            if (checkConcurrency) {
-                iterators.add(new SoftReference<SimpleIterator>(resultIter));
-            }
-            return resultIter;
-        }
-    }
-
-
-    @Override
-    public boolean performAdd(Triple e) {
-        boolean modified = triples.add(e);
-        if (modified) {
-            invalidateIterators(null);
-        }
-        return modified;
-    }
-    
-    private void invalidateIterators(SimpleIterator caller) {
-        if (!checkConcurrency) {
-            return;
-        }
-        Set<SoftReference> oldReferences = new HashSet<SoftReference>();
-        synchronized(iterators) {
-            for (SoftReference<SimpleGraph.SimpleIterator> softReference : iterators) {
-                SimpleIterator simpleIterator = softReference.get();
-                if (simpleIterator == null) {
-                    oldReferences.add(softReference);
-                    continue;
-                }
-                if (simpleIterator != caller) {
-                    simpleIterator.invalidate();
-                }
-            }
-        }
-        iterators.removeAll(oldReferences);
-    }
-
-    /**
-     * Specifies whether or not to throw <code>ConcurrentModificationException</code>s,
-     * if this simple triple collection is modified concurrently. Concurrency
-     * check is set to false by default.
-     *
-     * @param bool Specifies whether or not to check concurrent modifications.
-     */
-    public void setCheckConcurrency(boolean bool) {
-        checkConcurrency = bool;
-    }
-    
-    
-    @Override
-    public ImmutableGraph getImmutableGraph() {
-        return new SimpleImmutableGraph(this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
deleted file mode 100644
index bc50a09..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils.simple;
-
-import org.apache.commons.rdf.impl.utils.AbstractImmutableGraph;
-import java.util.Iterator;
-
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-
-/**
- *
- * @author reto
- */
-public class SimpleImmutableGraph extends AbstractImmutableGraph {
-
-    private Graph graph;
-    
-    /**
-     * Creates a ImmutableGraph with the triples in Graph
-     * 
-     * @param Graph the collection of triples this ImmutableGraph shall consist of
-     */
-    public SimpleImmutableGraph(Graph Graph) {
-        this.graph = new SimpleGraph(Graph.iterator());
-    }
-
-    /**
-     * Creates a ImmutableGraph with the triples in Graph.
-     *
-     * This construction allows to specify if the Graph might change
-     * in future. If GraphWillNeverChange is set to true it will
-     * assume that the collection never changes, in this case the collection
-     * isn't copied making things more efficient.
-     *
-     * @param Graph the collection of triples this ImmutableGraph shall consist of
-     * @param GraphWillNeverChange true if the caller promises Graph will never change
-     */
-    public SimpleImmutableGraph(Graph Graph, boolean GraphWillNeverChange) {
-        if (!GraphWillNeverChange) {
-            this.graph = new SimpleGraph(Graph.iterator());
-        } else {
-            this.graph = Graph;
-        }
-    }
-    
-    public SimpleImmutableGraph(Iterator<Triple> tripleIter) {
-        this.graph = new SimpleGraph(tripleIter);
-    }
-
-    @Override
-    public int performSize() {
-        return graph.size();
-    }
-
-    @Override
-    public Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
-        return graph.filter(subject, predicate, object);
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleMGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleMGraph.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleMGraph.java
deleted file mode 100644
index 8d0a5ce..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/simple/SimpleMGraph.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils.simple;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Triple;
-
-/**
- *
- * @deprecated Use SimpleGraph
- * @author reto
- */
-@Deprecated
-public class SimpleMGraph extends SimpleGraph implements Graph {
-
-    /**
-     * Creates an empty SimpleMGraph
-     */
-    public SimpleMGraph() {
-    }
-
-    public SimpleMGraph(Set<Triple> baseSet) {
-        super(baseSet);
-    }
-
-    public SimpleMGraph(Collection<Triple> baseCollection) {
-        super(baseCollection);
-    }
-
-    public SimpleMGraph(Iterator<Triple> iterator) {
-        super(iterator);
-    }
-
-}
-
-    
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
new file mode 100644
index 0000000..5c43c1b
--- /dev/null
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+import org.apache.commons.rdf.impl.utils.graphmatching.GraphMatcher;
+import java.util.Map;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author reto
+ */
+public class GraphMatcherTest {
+
+    final static Iri u1 = new Iri("http://example.org/u1");
+
+    @Test
+    public void testEmpty() {
+        Graph tc1 = new SimpleMGraph();
+        Graph tc2 = new SimpleMGraph();
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        Assert.assertEquals(0, mapping.size());
+    }
+
+    @Test
+    public void test2() {
+        Graph tc1 = new SimpleMGraph();
+        tc1.add(new TripleImpl(u1, u1, u1));
+        Graph tc2 = new SimpleMGraph();
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNull(mapping);
+    }
+
+    @Test
+    public void test3() {
+        Graph tc1 = new SimpleMGraph();
+        tc1.add(new TripleImpl(u1, u1, u1));
+        Graph tc2 = new SimpleMGraph();
+        tc2.add(new TripleImpl(u1, u1, u1));
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        Assert.assertEquals(0, mapping.size());
+    }
+
+    @Test
+    public void test4() {
+        Graph tc1 = new SimpleMGraph();
+        tc1.add(new TripleImpl(u1, u1, new BlankNode()));
+        Graph tc2 = new SimpleMGraph();
+        tc2.add(new TripleImpl(u1, u1, new BlankNode()));
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        Assert.assertEquals(1, mapping.size());
+    }
+
+    @Test
+    public void test5() {
+        Graph tc1 = new SimpleMGraph();
+        tc1.add(new TripleImpl(new BlankNode(), u1, new BlankNode()));
+        Graph tc2 = new SimpleMGraph();
+        tc2.add(new TripleImpl(new BlankNode(), u1, new BlankNode()));
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        Assert.assertEquals(2, mapping.size());
+    }
+
+    @Test
+    public void test6() {
+        Graph tc1 = new SimpleMGraph();
+        final BlankNode b11 = new BlankNode();
+        tc1.add(new TripleImpl(new BlankNode(), u1,b11));
+        tc1.add(new TripleImpl(new BlankNode(), u1,b11));
+        Graph tc2 = new SimpleMGraph();
+        tc2.add(new TripleImpl(new BlankNode(), u1, new BlankNode()));
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNull(mapping);
+    }
+
+    private Graph generateCircle(int size) {
+        return generateCircle(size, new BlankNode());
+    }
+
+    private Graph generateCircle(int size, final BlankNodeOrIri firstNode) {
+        if (size < 1) {
+            throw new IllegalArgumentException();
+        }
+        Graph result = new SimpleMGraph();
+        BlankNodeOrIri lastNode = firstNode;
+        for (int i = 0; i < (size-1); i++) {
+            final BlankNode newNode = new BlankNode();
+            result.add(new TripleImpl(lastNode, u1, newNode));
+            lastNode = newNode;
+        }
+        result.add(new TripleImpl(lastNode, u1, firstNode));
+        return result;
+    }
+
+    @Test
+    public void test7() {
+        Graph tc1 = generateCircle(2);
+        Graph tc2 = generateCircle(2);
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        Assert.assertEquals(2, mapping.size());
+    }
+
+    @Test
+    public void test8() {
+        Graph tc1 = generateCircle(5);
+        Graph tc2 = generateCircle(5);
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        Assert.assertEquals(5, mapping.size());
+    }
+
+    @Test
+    public void test9() {
+        BlankNodeOrIri crossing = new Iri("http://example.org/");
+        Graph tc1 = generateCircle(2,crossing);
+        tc1.addAll(generateCircle(3,crossing));
+        Graph tc2 = generateCircle(2,crossing);
+        tc2.addAll(generateCircle(3,crossing));
+        Assert.assertEquals(5, tc1.size());
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        //a circle of 2 with 1 bnode and one of 2 bnodes
+        Assert.assertEquals(3, mapping.size());
+    }
+
+    @Test
+    public void test10() {
+        BlankNodeOrIri crossing1 = new BlankNode();
+        Graph tc1 = generateCircle(2,crossing1);
+        tc1.addAll(generateCircle(3,crossing1));
+        BlankNodeOrIri crossing2 = new BlankNode();
+        Graph tc2 = generateCircle(2,crossing2);
+        tc2.addAll(generateCircle(3,crossing2));
+        Assert.assertEquals(5, tc1.size());
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        //a circle of 2 and one of 3 with one common node
+        Assert.assertEquals(4, mapping.size());
+    }
+
+    @Test
+    public void test11() {
+        BlankNodeOrIri crossing1 = new BlankNode();
+        Graph tc1 = generateCircle(2,crossing1);
+        tc1.addAll(generateCircle(4,crossing1));
+        BlankNodeOrIri crossing2 = new BlankNode();
+        Graph tc2 = generateCircle(3,crossing2);
+        tc2.addAll(generateCircle(3,crossing2));
+        Assert.assertEquals(6, tc1.size());
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNull(mapping);
+    }
+
+    @Test
+    public void test12() {
+        BlankNodeOrIri start1 = new BlankNode();
+        Graph tc1 = Utils4Testing.generateLine(4,start1);
+        tc1.addAll(Utils4Testing.generateLine(5,start1));
+        BlankNodeOrIri start2 = new BlankNode();
+        Graph tc2 = Utils4Testing.generateLine(5,start2);
+        tc2.addAll(Utils4Testing.generateLine(4,start2));
+        Assert.assertEquals(9, tc1.size());
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNotNull(mapping);
+        Assert.assertEquals(10, mapping.size());
+    }
+
+    @Test
+    public void test13() {
+        BlankNodeOrIri start1 = new BlankNode();
+        Graph tc1 = Utils4Testing.generateLine(4,start1);
+        tc1.addAll(Utils4Testing.generateLine(5,start1));
+        BlankNodeOrIri start2 = new BlankNode();
+        Graph tc2 = Utils4Testing.generateLine(3,start2);
+        tc2.addAll(Utils4Testing.generateLine(3,start2));
+        Assert.assertEquals(9, tc1.size());
+        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
+        Assert.assertNull(mapping);
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
new file mode 100644
index 0000000..baac5b9
--- /dev/null
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+
+import java.util.Map;
+
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author reto
+ */
+public class HashMatchingTest {
+
+    @Test
+    public void twoLine() throws GraphNotIsomorphicException {
+        BlankNodeOrIri start1 = new BlankNode();
+        Graph tc1 = Utils4Testing.generateLine(4,start1);
+        tc1.addAll(Utils4Testing.generateLine(5,start1));
+        BlankNodeOrIri start2 = new BlankNode();
+        Graph tc2 = Utils4Testing.generateLine(5,start2);
+        tc2.addAll(Utils4Testing.generateLine(4,start2));
+        Assert.assertEquals(9, tc1.size());
+        final Map<BlankNode, BlankNode> mapping = new HashMatching(tc1, tc2).getMatchings();
+        Assert.assertNotNull(mapping);
+        Assert.assertEquals(10, mapping.size());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
new file mode 100644
index 0000000..6616060
--- /dev/null
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+import org.apache.commons.rdf.impl.utils.graphmatching.PermutationIterator;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author reto
+ */
+public class PermutationIteratorTest {
+
+    @Test
+    public void simple() {
+        List<String> list = new ArrayList<String>();
+        PermutationIterator<String> pi = new PermutationIterator<String>(list);
+        Assert.assertFalse(pi.hasNext());
+    }
+
+    @Test
+    public void lessSimple() {
+        List<String> list = new ArrayList<String>();
+        list.add("Hasan");
+        PermutationIterator<String> pi = new PermutationIterator<String>(list);
+        Assert.assertTrue(pi.hasNext());
+    }
+
+    @Test
+    public void regular() {
+        List<String> list = new ArrayList<String>();
+        list.add("Hasan");
+        list.add("Tsuy");
+        PermutationIterator<String> pi = new PermutationIterator<String>(list);
+        Set<List<String>> permutations = new HashSet<List<String>>();
+        while (pi.hasNext()) {
+            permutations.add(pi.next());
+        }
+        Assert.assertEquals(2, permutations.size());
+    }
+
+    @Test
+    public void extended() {
+        List<String> list = new ArrayList<String>();
+        list.add("Hasan");
+        list.add("Tsuy");
+        list.add("Llena");
+        PermutationIterator<String> pi = new PermutationIterator<String>(list);
+        Set<List<String>> permutations = new HashSet<List<String>>();
+        while (pi.hasNext()) {
+            permutations.add(pi.next());
+        }
+        Assert.assertEquals(6, permutations.size());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
new file mode 100644
index 0000000..3246575
--- /dev/null
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+
+/**
+ *
+ * @author reto
+ */
+public class Utils4Testing {
+
+    static Graph generateLine(int size, final BlankNodeOrIri firstNode) {
+        if (size < 1) {
+            throw new IllegalArgumentException();
+        }
+        Graph result = new SimpleMGraph();
+        BlankNodeOrIri lastNode = firstNode;
+        for (int i = 0; i < size; i++) {
+            final BlankNode newNode = new BlankNode();
+            result.add(new TripleImpl(lastNode, u1, newNode));
+            lastNode = newNode;
+        }
+        return result;
+    }
+
+    final static Iri u1 = new Iri("http://example.org/u1");
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
new file mode 100644
index 0000000..2782f45
--- /dev/null
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils.simple;
+
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.junit.Test;
+
+import org.apache.commons.rdf.Language;
+import org.apache.commons.rdf.Literal;
+import org.junit.Assert;
+/**
+ *
+ * @author reto
+ *
+ */
+
+public class PlainLiteralImplTest {
+
+    
+    @Test public void plainLiteralEquality() {
+        String stringValue = "some text";
+        Literal literal1 = new PlainLiteralImpl(stringValue);
+        Literal literal2 = new PlainLiteralImpl(stringValue);        
+        Assert.assertEquals(literal1, literal2);
+        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
+        Literal literal3 = new PlainLiteralImpl("something else");
+        Assert.assertFalse(literal1.equals(literal3));
+    }
+    
+    @Test public void languageLiteralEquality() {
+        String stringValue = "some text";
+        Language lang = new Language("en-ca");
+        Literal literal1 = new PlainLiteralImpl(stringValue, lang);
+        Literal literal2 = new PlainLiteralImpl(stringValue, lang);        
+        Assert.assertEquals(literal1, literal2);
+        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
+        Language lang2 = new Language("de");
+        Literal literal3 = new PlainLiteralImpl(stringValue, lang2);
+        Assert.assertFalse(literal1.equals(literal3));
+        Literal literal4 = new PlainLiteralImpl(stringValue, null);
+        Assert.assertFalse(literal3.equals(literal4));
+        Assert.assertFalse(literal4.equals(literal3));
+    }
+
+    /**
+     * hashCode of the lexical form plus the hashCode of the locale
+     */
+    @Test public void checkHashCode() {
+        String stringValue = "some text";
+        Language language = new Language("en");
+        Literal literal = new PlainLiteralImpl(stringValue, language);
+        Assert.assertEquals(literal.getDataType().hashCode() + stringValue.hashCode() + language.hashCode(), literal.hashCode());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java
new file mode 100644
index 0000000..a1e8d54
--- /dev/null
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils.simple;
+
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
+import org.junit.Assert;
+import org.junit.Test;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+
+/**
+ *
+ * @author mir
+ */
+public class SimpleGraphTest {
+
+    private Iri uriRef1 = new Iri("http://example.org/foo");
+    private Iri uriRef2 = new Iri("http://example.org/bar");
+    private Iri uriRef3 = new Iri("http://example.org/test");
+    private Triple triple1 = new TripleImpl(uriRef1, uriRef2, uriRef3);
+    private Triple triple2 = new TripleImpl(uriRef2, uriRef2, uriRef1);
+    private Triple triple3 = new TripleImpl(uriRef3, uriRef1, uriRef3);
+    private Triple triple4 = new TripleImpl(uriRef1, uriRef3, uriRef2);
+    private Triple triple5 = new TripleImpl(uriRef2, uriRef3, uriRef2);
+        
+    @Test
+    public void iteratorRemove() {
+        SimpleGraph stc = new SimpleGraph();
+        stc.add(triple1);
+        stc.add(triple2);
+        stc.add(triple3);
+        stc.add(triple4);
+        stc.add(triple5);
+        Iterator<Triple> iter = stc.iterator();
+        while (iter.hasNext()) {
+            Triple triple = iter.next();
+            iter.remove();
+        }
+        Assert.assertEquals(0, stc.size());
+    }
+
+    @Test
+    public void removeAll() {
+        SimpleGraph stc = new SimpleGraph();
+        stc.add(triple1);
+        stc.add(triple2);
+        stc.add(triple3);
+        stc.add(triple4);
+        stc.add(triple5);
+        SimpleGraph stc2 = new SimpleGraph();
+        stc2.add(triple1);
+        stc2.add(triple3);
+        stc2.add(triple5);
+        stc.removeAll(stc2);
+        Assert.assertEquals(2, stc.size());
+    }
+    
+    @Test
+    public void filterIteratorRemove() {
+        SimpleGraph stc = new SimpleGraph();
+        stc.add(triple1);
+        stc.add(triple2);
+        stc.add(triple3);
+        stc.add(triple4);
+        stc.add(triple5);        
+        Iterator<Triple> iter = stc.filter(uriRef1, null, null);
+        while (iter.hasNext()) {
+            Triple triple = iter.next();
+            iter.remove();
+        }
+        Assert.assertEquals(3, stc.size());
+    }
+
+    @Test(expected=ConcurrentModificationException.class)
+    public void remove() {
+        SimpleGraph stc = new SimpleGraph();
+        stc.setCheckConcurrency(true);
+        stc.add(triple1);
+        stc.add(triple2);
+        stc.add(triple3);
+        stc.add(triple4);
+        stc.add(triple5);
+        Iterator<Triple> iter = stc.filter(uriRef1, null, null);
+        while (iter.hasNext()) {
+            Triple triple = iter.next();
+            stc.remove(triple);
+        }
+        Assert.assertEquals(3, stc.size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java
new file mode 100644
index 0000000..dd2f967
--- /dev/null
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java
@@ -0,0 +1,57 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.commons.rdf.impl.utils.simple;
+/*
+ *
+ * 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.
+ *
+*/
+
+
+import org.junit.Test;
+import junit.framework.Assert;
+
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+/**
+ *
+ * @author reto
+ *
+ */
+
+public class TripleImplTest {
+    
+    
+    @Test public void tripleEquality() {
+        BlankNodeOrIri subject = new Iri("http://example.org/");
+        Iri predicate = new Iri("http://example.org/property");
+        RdfTerm object = new PlainLiteralImpl("property value");
+        Triple triple1 = new TripleImpl(subject, predicate, object);
+        Triple triple2 = new TripleImpl(subject, predicate, object);
+        Assert.assertEquals(triple1.hashCode(), triple2.hashCode());
+        Assert.assertEquals(triple1, triple2);    
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
new file mode 100644
index 0000000..515cf93
--- /dev/null
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils.simple;
+
+import org.apache.commons.rdf.impl.utils.TypedLiteralImpl;
+import org.junit.Test;
+import junit.framework.Assert;
+
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.Literal;
+/**
+ *
+ * @author reto/**
+ *
+ * @author reto/**
+ *
+ * @author reto/**
+ *
+ * @author reto
+ *
+ */
+
+public class TypedLiteralImplTest {
+    
+    
+    @Test public void typedLiteralEquality() {
+        String stringValue = "some text";
+        Iri uriRef = new Iri("http://example.org/datatypes/magic");
+        Literal literal1 = new TypedLiteralImpl(stringValue, uriRef);
+        Literal literal2 = new TypedLiteralImpl(stringValue, uriRef);        
+        Assert.assertEquals(literal1, literal2);
+        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
+        Literal literal3 = new TypedLiteralImpl("something else", uriRef);
+        Assert.assertFalse(literal1.equals(literal3));
+        Iri uriRef2 = new Iri("http://example.org/datatypes/other");
+        Literal literal4 = new TypedLiteralImpl(stringValue, uriRef2);
+        Assert.assertFalse(literal1.equals(literal4));
+    }
+
+
+    /**
+     * The hascode is equals to the hascode of the lexical form plus the hashcode of the dataTyp
+     */
+    @Test public void checkHashCode() {
+        String stringValue = "some text";
+        Iri uriRef = new Iri("http://example.org/datatypes/magic");
+        Literal literal =  new TypedLiteralImpl(stringValue, uriRef);
+        Assert.assertEquals(stringValue.hashCode() + uriRef.hashCode(), literal.hashCode());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java b/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
deleted file mode 100644
index 5c43c1b..0000000
--- a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-import org.apache.commons.rdf.impl.utils.graphmatching.GraphMatcher;
-import java.util.Map;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- * @author reto
- */
-public class GraphMatcherTest {
-
-    final static Iri u1 = new Iri("http://example.org/u1");
-
-    @Test
-    public void testEmpty() {
-        Graph tc1 = new SimpleMGraph();
-        Graph tc2 = new SimpleMGraph();
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        Assert.assertEquals(0, mapping.size());
-    }
-
-    @Test
-    public void test2() {
-        Graph tc1 = new SimpleMGraph();
-        tc1.add(new TripleImpl(u1, u1, u1));
-        Graph tc2 = new SimpleMGraph();
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNull(mapping);
-    }
-
-    @Test
-    public void test3() {
-        Graph tc1 = new SimpleMGraph();
-        tc1.add(new TripleImpl(u1, u1, u1));
-        Graph tc2 = new SimpleMGraph();
-        tc2.add(new TripleImpl(u1, u1, u1));
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        Assert.assertEquals(0, mapping.size());
-    }
-
-    @Test
-    public void test4() {
-        Graph tc1 = new SimpleMGraph();
-        tc1.add(new TripleImpl(u1, u1, new BlankNode()));
-        Graph tc2 = new SimpleMGraph();
-        tc2.add(new TripleImpl(u1, u1, new BlankNode()));
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        Assert.assertEquals(1, mapping.size());
-    }
-
-    @Test
-    public void test5() {
-        Graph tc1 = new SimpleMGraph();
-        tc1.add(new TripleImpl(new BlankNode(), u1, new BlankNode()));
-        Graph tc2 = new SimpleMGraph();
-        tc2.add(new TripleImpl(new BlankNode(), u1, new BlankNode()));
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        Assert.assertEquals(2, mapping.size());
-    }
-
-    @Test
-    public void test6() {
-        Graph tc1 = new SimpleMGraph();
-        final BlankNode b11 = new BlankNode();
-        tc1.add(new TripleImpl(new BlankNode(), u1,b11));
-        tc1.add(new TripleImpl(new BlankNode(), u1,b11));
-        Graph tc2 = new SimpleMGraph();
-        tc2.add(new TripleImpl(new BlankNode(), u1, new BlankNode()));
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNull(mapping);
-    }
-
-    private Graph generateCircle(int size) {
-        return generateCircle(size, new BlankNode());
-    }
-
-    private Graph generateCircle(int size, final BlankNodeOrIri firstNode) {
-        if (size < 1) {
-            throw new IllegalArgumentException();
-        }
-        Graph result = new SimpleMGraph();
-        BlankNodeOrIri lastNode = firstNode;
-        for (int i = 0; i < (size-1); i++) {
-            final BlankNode newNode = new BlankNode();
-            result.add(new TripleImpl(lastNode, u1, newNode));
-            lastNode = newNode;
-        }
-        result.add(new TripleImpl(lastNode, u1, firstNode));
-        return result;
-    }
-
-    @Test
-    public void test7() {
-        Graph tc1 = generateCircle(2);
-        Graph tc2 = generateCircle(2);
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        Assert.assertEquals(2, mapping.size());
-    }
-
-    @Test
-    public void test8() {
-        Graph tc1 = generateCircle(5);
-        Graph tc2 = generateCircle(5);
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        Assert.assertEquals(5, mapping.size());
-    }
-
-    @Test
-    public void test9() {
-        BlankNodeOrIri crossing = new Iri("http://example.org/");
-        Graph tc1 = generateCircle(2,crossing);
-        tc1.addAll(generateCircle(3,crossing));
-        Graph tc2 = generateCircle(2,crossing);
-        tc2.addAll(generateCircle(3,crossing));
-        Assert.assertEquals(5, tc1.size());
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        //a circle of 2 with 1 bnode and one of 2 bnodes
-        Assert.assertEquals(3, mapping.size());
-    }
-
-    @Test
-    public void test10() {
-        BlankNodeOrIri crossing1 = new BlankNode();
-        Graph tc1 = generateCircle(2,crossing1);
-        tc1.addAll(generateCircle(3,crossing1));
-        BlankNodeOrIri crossing2 = new BlankNode();
-        Graph tc2 = generateCircle(2,crossing2);
-        tc2.addAll(generateCircle(3,crossing2));
-        Assert.assertEquals(5, tc1.size());
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        //a circle of 2 and one of 3 with one common node
-        Assert.assertEquals(4, mapping.size());
-    }
-
-    @Test
-    public void test11() {
-        BlankNodeOrIri crossing1 = new BlankNode();
-        Graph tc1 = generateCircle(2,crossing1);
-        tc1.addAll(generateCircle(4,crossing1));
-        BlankNodeOrIri crossing2 = new BlankNode();
-        Graph tc2 = generateCircle(3,crossing2);
-        tc2.addAll(generateCircle(3,crossing2));
-        Assert.assertEquals(6, tc1.size());
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNull(mapping);
-    }
-
-    @Test
-    public void test12() {
-        BlankNodeOrIri start1 = new BlankNode();
-        Graph tc1 = Utils4Testing.generateLine(4,start1);
-        tc1.addAll(Utils4Testing.generateLine(5,start1));
-        BlankNodeOrIri start2 = new BlankNode();
-        Graph tc2 = Utils4Testing.generateLine(5,start2);
-        tc2.addAll(Utils4Testing.generateLine(4,start2));
-        Assert.assertEquals(9, tc1.size());
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNotNull(mapping);
-        Assert.assertEquals(10, mapping.size());
-    }
-
-    @Test
-    public void test13() {
-        BlankNodeOrIri start1 = new BlankNode();
-        Graph tc1 = Utils4Testing.generateLine(4,start1);
-        tc1.addAll(Utils4Testing.generateLine(5,start1));
-        BlankNodeOrIri start2 = new BlankNode();
-        Graph tc2 = Utils4Testing.generateLine(3,start2);
-        tc2.addAll(Utils4Testing.generateLine(3,start2));
-        Assert.assertEquals(9, tc1.size());
-        final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
-        Assert.assertNull(mapping);
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java b/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
deleted file mode 100644
index baac5b9..0000000
--- a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-
-import java.util.Map;
-
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- * @author reto
- */
-public class HashMatchingTest {
-
-    @Test
-    public void twoLine() throws GraphNotIsomorphicException {
-        BlankNodeOrIri start1 = new BlankNode();
-        Graph tc1 = Utils4Testing.generateLine(4,start1);
-        tc1.addAll(Utils4Testing.generateLine(5,start1));
-        BlankNodeOrIri start2 = new BlankNode();
-        Graph tc2 = Utils4Testing.generateLine(5,start2);
-        tc2.addAll(Utils4Testing.generateLine(4,start2));
-        Assert.assertEquals(9, tc1.size());
-        final Map<BlankNode, BlankNode> mapping = new HashMatching(tc1, tc2).getMatchings();
-        Assert.assertNotNull(mapping);
-        Assert.assertEquals(10, mapping.size());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java b/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
deleted file mode 100644
index 6616060..0000000
--- a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-import org.apache.commons.rdf.impl.utils.graphmatching.PermutationIterator;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- * @author reto
- */
-public class PermutationIteratorTest {
-
-    @Test
-    public void simple() {
-        List<String> list = new ArrayList<String>();
-        PermutationIterator<String> pi = new PermutationIterator<String>(list);
-        Assert.assertFalse(pi.hasNext());
-    }
-
-    @Test
-    public void lessSimple() {
-        List<String> list = new ArrayList<String>();
-        list.add("Hasan");
-        PermutationIterator<String> pi = new PermutationIterator<String>(list);
-        Assert.assertTrue(pi.hasNext());
-    }
-
-    @Test
-    public void regular() {
-        List<String> list = new ArrayList<String>();
-        list.add("Hasan");
-        list.add("Tsuy");
-        PermutationIterator<String> pi = new PermutationIterator<String>(list);
-        Set<List<String>> permutations = new HashSet<List<String>>();
-        while (pi.hasNext()) {
-            permutations.add(pi.next());
-        }
-        Assert.assertEquals(2, permutations.size());
-    }
-
-    @Test
-    public void extended() {
-        List<String> list = new ArrayList<String>();
-        list.add("Hasan");
-        list.add("Tsuy");
-        list.add("Llena");
-        PermutationIterator<String> pi = new PermutationIterator<String>(list);
-        Set<List<String>> permutations = new HashSet<List<String>>();
-        while (pi.hasNext()) {
-            permutations.add(pi.next());
-        }
-        Assert.assertEquals(6, permutations.size());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/Utils4Testing.java b/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
deleted file mode 100644
index 3246575..0000000
--- a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-
-/**
- *
- * @author reto
- */
-public class Utils4Testing {
-
-    static Graph generateLine(int size, final BlankNodeOrIri firstNode) {
-        if (size < 1) {
-            throw new IllegalArgumentException();
-        }
-        Graph result = new SimpleMGraph();
-        BlankNodeOrIri lastNode = firstNode;
-        for (int i = 0; i < size; i++) {
-            final BlankNode newNode = new BlankNode();
-            result.add(new TripleImpl(lastNode, u1, newNode));
-            lastNode = newNode;
-        }
-        return result;
-    }
-
-    final static Iri u1 = new Iri("http://example.org/u1");
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java b/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
deleted file mode 100644
index 2782f45..0000000
--- a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils.simple;
-
-import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
-import org.junit.Test;
-
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
-import org.junit.Assert;
-/**
- *
- * @author reto
- *
- */
-
-public class PlainLiteralImplTest {
-
-    
-    @Test public void plainLiteralEquality() {
-        String stringValue = "some text";
-        Literal literal1 = new PlainLiteralImpl(stringValue);
-        Literal literal2 = new PlainLiteralImpl(stringValue);        
-        Assert.assertEquals(literal1, literal2);
-        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
-        Literal literal3 = new PlainLiteralImpl("something else");
-        Assert.assertFalse(literal1.equals(literal3));
-    }
-    
-    @Test public void languageLiteralEquality() {
-        String stringValue = "some text";
-        Language lang = new Language("en-ca");
-        Literal literal1 = new PlainLiteralImpl(stringValue, lang);
-        Literal literal2 = new PlainLiteralImpl(stringValue, lang);        
-        Assert.assertEquals(literal1, literal2);
-        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
-        Language lang2 = new Language("de");
-        Literal literal3 = new PlainLiteralImpl(stringValue, lang2);
-        Assert.assertFalse(literal1.equals(literal3));
-        Literal literal4 = new PlainLiteralImpl(stringValue, null);
-        Assert.assertFalse(literal3.equals(literal4));
-        Assert.assertFalse(literal4.equals(literal3));
-    }
-
-    /**
-     * hashCode of the lexical form plus the hashCode of the locale
-     */
-    @Test public void checkHashCode() {
-        String stringValue = "some text";
-        Language language = new Language("en");
-        Literal literal = new PlainLiteralImpl(stringValue, language);
-        Assert.assertEquals(literal.getDataType().hashCode() + stringValue.hashCode() + language.hashCode(), literal.hashCode());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/SimpleGraphTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/SimpleGraphTest.java b/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/SimpleGraphTest.java
deleted file mode 100644
index a1e8d54..0000000
--- a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/SimpleGraphTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils.simple;
-
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
-
-/**
- *
- * @author mir
- */
-public class SimpleGraphTest {
-
-    private Iri uriRef1 = new Iri("http://example.org/foo");
-    private Iri uriRef2 = new Iri("http://example.org/bar");
-    private Iri uriRef3 = new Iri("http://example.org/test");
-    private Triple triple1 = new TripleImpl(uriRef1, uriRef2, uriRef3);
-    private Triple triple2 = new TripleImpl(uriRef2, uriRef2, uriRef1);
-    private Triple triple3 = new TripleImpl(uriRef3, uriRef1, uriRef3);
-    private Triple triple4 = new TripleImpl(uriRef1, uriRef3, uriRef2);
-    private Triple triple5 = new TripleImpl(uriRef2, uriRef3, uriRef2);
-        
-    @Test
-    public void iteratorRemove() {
-        SimpleGraph stc = new SimpleGraph();
-        stc.add(triple1);
-        stc.add(triple2);
-        stc.add(triple3);
-        stc.add(triple4);
-        stc.add(triple5);
-        Iterator<Triple> iter = stc.iterator();
-        while (iter.hasNext()) {
-            Triple triple = iter.next();
-            iter.remove();
-        }
-        Assert.assertEquals(0, stc.size());
-    }
-
-    @Test
-    public void removeAll() {
-        SimpleGraph stc = new SimpleGraph();
-        stc.add(triple1);
-        stc.add(triple2);
-        stc.add(triple3);
-        stc.add(triple4);
-        stc.add(triple5);
-        SimpleGraph stc2 = new SimpleGraph();
-        stc2.add(triple1);
-        stc2.add(triple3);
-        stc2.add(triple5);
-        stc.removeAll(stc2);
-        Assert.assertEquals(2, stc.size());
-    }
-    
-    @Test
-    public void filterIteratorRemove() {
-        SimpleGraph stc = new SimpleGraph();
-        stc.add(triple1);
-        stc.add(triple2);
-        stc.add(triple3);
-        stc.add(triple4);
-        stc.add(triple5);        
-        Iterator<Triple> iter = stc.filter(uriRef1, null, null);
-        while (iter.hasNext()) {
-            Triple triple = iter.next();
-            iter.remove();
-        }
-        Assert.assertEquals(3, stc.size());
-    }
-
-    @Test(expected=ConcurrentModificationException.class)
-    public void remove() {
-        SimpleGraph stc = new SimpleGraph();
-        stc.setCheckConcurrency(true);
-        stc.add(triple1);
-        stc.add(triple2);
-        stc.add(triple3);
-        stc.add(triple4);
-        stc.add(triple5);
-        Iterator<Triple> iter = stc.filter(uriRef1, null, null);
-        while (iter.hasNext()) {
-            Triple triple = iter.next();
-            stc.remove(triple);
-        }
-        Assert.assertEquals(3, stc.size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/TripleImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/TripleImplTest.java b/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/TripleImplTest.java
deleted file mode 100644
index dd2f967..0000000
--- a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/TripleImplTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.apache.commons.rdf.impl.utils.simple;
-/*
- *
- * 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.
- *
-*/
-
-
-import org.junit.Test;
-import junit.framework.Assert;
-
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-/**
- *
- * @author reto
- *
- */
-
-public class TripleImplTest {
-    
-    
-    @Test public void tripleEquality() {
-        BlankNodeOrIri subject = new Iri("http://example.org/");
-        Iri predicate = new Iri("http://example.org/property");
-        RdfTerm object = new PlainLiteralImpl("property value");
-        Triple triple1 = new TripleImpl(subject, predicate, object);
-        Triple triple2 = new TripleImpl(subject, predicate, object);
-        Assert.assertEquals(triple1.hashCode(), triple2.hashCode());
-        Assert.assertEquals(triple1, triple2);    
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java b/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
deleted file mode 100644
index 515cf93..0000000
--- a/impl.utils/src/test/java/org/apache/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils.simple;
-
-import org.apache.commons.rdf.impl.utils.TypedLiteralImpl;
-import org.junit.Test;
-import junit.framework.Assert;
-
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Literal;
-/**
- *
- * @author reto/**
- *
- * @author reto/**
- *
- * @author reto/**
- *
- * @author reto
- *
- */
-
-public class TypedLiteralImplTest {
-    
-    
-    @Test public void typedLiteralEquality() {
-        String stringValue = "some text";
-        Iri uriRef = new Iri("http://example.org/datatypes/magic");
-        Literal literal1 = new TypedLiteralImpl(stringValue, uriRef);
-        Literal literal2 = new TypedLiteralImpl(stringValue, uriRef);        
-        Assert.assertEquals(literal1, literal2);
-        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
-        Literal literal3 = new TypedLiteralImpl("something else", uriRef);
-        Assert.assertFalse(literal1.equals(literal3));
-        Iri uriRef2 = new Iri("http://example.org/datatypes/other");
-        Literal literal4 = new TypedLiteralImpl(stringValue, uriRef2);
-        Assert.assertFalse(literal1.equals(literal4));
-    }
-
-
-    /**
-     * The hascode is equals to the hascode of the lexical form plus the hashcode of the dataTyp
-     */
-    @Test public void checkHashCode() {
-        String stringValue = "some text";
-        Iri uriRef = new Iri("http://example.org/datatypes/magic");
-        Literal literal =  new TypedLiteralImpl(stringValue, uriRef);
-        Assert.assertEquals(stringValue.hashCode() + uriRef.hashCode(), literal.hashCode());
-    }
-
-}


[7/7] clerezza-rdf-core git commit: CLEREZZA-982: renamed packages

Posted by re...@apache.org.
CLEREZZA-982: renamed packages


Project: http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/commit/12b3d66e
Tree: http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/tree/12b3d66e
Diff: http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/diff/12b3d66e

Branch: refs/heads/master
Commit: 12b3d66e13c0b57690c331b145af18be8c1166f9
Parents: 816dc11
Author: Reto Gmuer <re...@apache.org>
Authored: Thu Apr 9 12:31:42 2015 +0000
Committer: Reto Gmuer <re...@apache.org>
Committed: Thu Apr 9 12:31:42 2015 +0000

----------------------------------------------------------------------
 .../apache/clerezza/commons/rdf/BlankNode.java  |  2 +-
 .../clerezza/commons/rdf/BlankNodeOrIri.java    |  2 +-
 .../org/apache/clerezza/commons/rdf/Graph.java  |  6 ++--
 .../clerezza/commons/rdf/ImmutableGraph.java    |  2 +-
 .../org/apache/clerezza/commons/rdf/Iri.java    |  2 +-
 .../apache/clerezza/commons/rdf/Language.java   |  2 +-
 .../apache/clerezza/commons/rdf/Literal.java    |  2 +-
 .../apache/clerezza/commons/rdf/RdfTerm.java    |  2 +-
 .../org/apache/clerezza/commons/rdf/Triple.java |  2 +-
 .../clerezza/commons/rdf/WatchableGraph.java    |  6 ++--
 .../clerezza/commons/rdf/event/AddEvent.java    |  6 ++--
 .../commons/rdf/event/FilterTriple.java         | 10 +++----
 .../clerezza/commons/rdf/event/GraphEvent.java  |  6 ++--
 .../commons/rdf/event/GraphListener.java        |  2 +-
 .../clerezza/commons/rdf/event/RemoveEvent.java |  6 ++--
 .../clerezza/commons/rdf/package-info.java      |  2 +-
 .../commons/rdf/impl/sparql/SparqlBNode.java    | 18 ++++++------
 .../commons/rdf/impl/sparql/SparqlClient.java   | 12 ++++----
 .../commons/rdf/impl/sparql/SparqlGraph.java    | 24 ++++++++--------
 .../rdf/impl/sparql/BNodeCircleTest.java        | 14 ++++-----
 .../commons/rdf/impl/sparql/BNodeTest.java      | 14 ++++-----
 .../commons/rdf/impl/sparql/SimilarBNodes.java  | 12 ++++----
 .../rdf/impl/sparql/SparqlGraphTest.java        | 16 +++++------
 .../commons/rdf/impl/utils/AbstractGraph.java   | 30 ++++++++++----------
 .../rdf/impl/utils/AbstractImmutableGraph.java  | 12 ++++----
 .../commons/rdf/impl/utils/AbstractLiteral.java |  4 +--
 .../rdf/impl/utils/DelayedNotificator.java      |  6 ++--
 .../commons/rdf/impl/utils/LiteralImpl.java     |  6 ++--
 .../commons/rdf/impl/utils/LockingIterator.java |  4 +--
 .../rdf/impl/utils/PlainLiteralImpl.java        |  8 +++---
 .../commons/rdf/impl/utils/TripleImpl.java      | 10 +++----
 .../rdf/impl/utils/TypedLiteralImpl.java        |  8 +++---
 .../rdf/impl/utils/WatchableGraphWrapper.java   | 26 ++++++++---------
 .../rdf/impl/utils/debug/ReadLockDebug.java     |  2 +-
 .../debug/ReentrantReadWriteLockTracker.java    |  2 +-
 .../rdf/impl/utils/debug/WriteLockDebug.java    |  2 +-
 .../impl/utils/graphmatching/GraphMatcher.java  | 16 +++++------
 .../GraphNotIsomorphicException.java            |  2 +-
 .../graphmatching/GroupMappingIterator.java     |  2 +-
 .../impl/utils/graphmatching/HashMatching.java  | 22 +++++++-------
 .../utils/graphmatching/MappingIterator.java    |  2 +-
 .../graphmatching/PermutationIterator.java      |  2 +-
 .../rdf/impl/utils/graphmatching/Utils.java     |  6 ++--
 .../graphmatching/collections/IntHashMap.java   |  2 +-
 .../graphmatching/collections/IntHashSet.java   |  2 +-
 .../graphmatching/collections/IntIterator.java  |  2 +-
 .../utils/graphmatching/collections/IntSet.java |  2 +-
 .../commons/rdf/impl/utils/package-info.java    |  2 +-
 .../rdf/impl/utils/simple/SimpleGraph.java      | 14 ++++-----
 .../impl/utils/simple/SimpleImmutableGraph.java | 14 ++++-----
 .../rdf/impl/utils/simple/SimpleMGraph.java     |  8 +++---
 .../utils/graphmatching/GraphMatcherTest.java   | 22 +++++++-------
 .../utils/graphmatching/HashMatchingTest.java   |  8 +++---
 .../graphmatching/PermutationIteratorTest.java  |  4 +--
 .../impl/utils/graphmatching/Utils4Testing.java | 14 ++++-----
 .../impl/utils/simple/PlainLiteralImplTest.java |  8 +++---
 .../rdf/impl/utils/simple/SimpleGraphTest.java  | 10 +++----
 .../rdf/impl/utils/simple/TripleImplTest.java   | 14 ++++-----
 .../impl/utils/simple/TypedLiteralImplTest.java |  8 +++---
 59 files changed, 238 insertions(+), 238 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 2fcf23b..f58956e 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNode.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNode.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 /**
  * A Blank Node represents a resource, 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 0a292d8..680456a 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNodeOrIri.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/BlankNodeOrIri.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 /**
  * Represents a <code>Resource</code> that is not a <code>Literal</code>. 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 5a188ff..af2604a 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/Graph.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Graph.java
@@ -16,13 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphListener;
+import org.apache.clerezza.commons.rdf.event.FilterTriple;
+import org.apache.clerezza.commons.rdf.event.GraphListener;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index a3b0211..bd94671 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/ImmutableGraph.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/ImmutableGraph.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 /**
  * A graph, modeled as a set of triples.

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index e1ef0f7..cbcb310 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/Iri.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Iri.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 import java.io.Serializable;
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index e76e16d..62a921e 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/Language.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Language.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 /**
  * Represents a language as expressed by the RDF 4646 language tag

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index cf5e1ee..d43070c 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/Literal.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Literal.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 8f0fb40..d51e01a 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/RdfTerm.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/RdfTerm.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 /**
  * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-term" >RDF-1.1

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 2a1569e..c1c24a7 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/Triple.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/Triple.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 /**
  * A structure containing a subject, a predicate, and an object. 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 6367333..4ed2cd4 100644
--- a/api/src/main/java/org/apache/clerezza/commons/rdf/WatchableGraph.java
+++ b/api/src/main/java/org/apache/clerezza/commons/rdf/WatchableGraph.java
@@ -16,13 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf;
+package org.apache.clerezza.commons.rdf;
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphListener;
+import org.apache.clerezza.commons.rdf.event.FilterTriple;
+import org.apache.clerezza.commons.rdf.event.GraphListener;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 1d4a835..c2716d6 100644
--- 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
@@ -16,10 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.event;
+package org.apache.clerezza.commons.rdf.event;
 
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Graph;
 
 /**
  * This class represent a addition event that occured on a

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 3480c13..b83682b 100644
--- 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
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.event;
+package org.apache.clerezza.commons.rdf.event;
 
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
+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

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index d055088..b9e6ec0 100644
--- 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
@@ -16,10 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.event;
+package org.apache.clerezza.commons.rdf.event;
 
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Graph;
 
 /**
  * This class represent a modification event that occured on a

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 8d0b257..9041546 100644
--- 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
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.event;
+package org.apache.clerezza.commons.rdf.event;
 
 import java.util.List;
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index 60150d6..103febc 100644
--- 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
@@ -16,10 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.event;
+package org.apache.clerezza.commons.rdf.event;
 
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Graph;
 
 /**
  * This class represent a removal event that occured on a

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index da34f2d..62354fe 100644
--- 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
@@ -18,4 +18,4 @@
 /**
  * Common RDF API
  */
-package org.apache.commons.rdf;
\ No newline at end of file
+package org.apache.clerezza.commons.rdf;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index f55f7af..a8002a9 100644
--- 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
@@ -13,18 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.sparql;
+package org.apache.clerezza.commons.rdf.impl.sparql;
 
 import java.util.Collection;
 import java.util.Objects;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+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;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/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
index e522924..0104677 100644
--- 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
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.sparql;
+package org.apache.clerezza.commons.rdf.impl.sparql;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -31,11 +31,11 @@ import org.apache.http.impl.client.HttpClients;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.util.EntityUtils;
 import javax.xml.parsers.*;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.impl.utils.AbstractLiteral;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.Language;
+import org.apache.clerezza.commons.rdf.RdfTerm;
+import org.apache.clerezza.commons.rdf.impl.utils.AbstractLiteral;
 import org.xml.sax.*;
 import org.xml.sax.helpers.*;
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java
index 594a264..5b011c0 100644
--- a/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java
+++ b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.sparql;
+package org.apache.clerezza.commons.rdf.impl.sparql;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -27,17 +27,17 @@ import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.logging.Logger;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Literal;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.AbstractGraph;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.ImmutableGraph;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.Literal;
+import org.apache.clerezza.commons.rdf.RdfTerm;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.impl.utils.AbstractGraph;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java
index 9329c9b..af2c81a 100644
--- a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java
+++ b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.sparql;
+package org.apache.clerezza.commons.rdf.impl.sparql;
 
 import com.hp.hpl.jena.query.DatasetAccessor;
 import com.hp.hpl.jena.query.DatasetAccessorFactory;
@@ -24,12 +24,12 @@ import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
 import java.io.InputStream;
 import java.util.Iterator;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.RdfTerm;
+import org.apache.clerezza.commons.rdf.Triple;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java
index f0a4aff..757c42d 100644
--- a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java
+++ b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.sparql;
+package org.apache.clerezza.commons.rdf.impl.sparql;
 
 import com.hp.hpl.jena.query.DatasetAccessor;
 import com.hp.hpl.jena.query.DatasetAccessorFactory;
@@ -24,12 +24,12 @@ import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
 import java.io.InputStream;
 import java.util.Iterator;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.RdfTerm;
+import org.apache.clerezza.commons.rdf.Triple;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java
index 6300281..baf72c9 100644
--- a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java
+++ b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.sparql;
+package org.apache.clerezza.commons.rdf.impl.sparql;
 
 import com.hp.hpl.jena.query.DatasetAccessor;
 import com.hp.hpl.jena.query.DatasetAccessorFactory;
@@ -24,11 +24,11 @@ import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.rdf.model.ModelFactory;
 import java.io.InputStream;
 import java.util.Iterator;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.Triple;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java
index 0c39e9d..b0291d5 100644
--- a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java
+++ b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.sparql;
+package org.apache.clerezza.commons.rdf.impl.sparql;
 
 import com.hp.hpl.jena.query.DatasetAccessor;
 import com.hp.hpl.jena.query.DatasetAccessorFactory;
@@ -26,13 +26,13 @@ import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.Language;
+import org.apache.clerezza.commons.rdf.Literal;
+import org.apache.clerezza.commons.rdf.RdfTerm;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java
index 2c99679..d87c3e9 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
 import java.lang.ref.WeakReference;
 import java.util.AbstractCollection;
@@ -29,20 +29,20 @@ import java.util.Set;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.WatchableGraph;
-import org.apache.commons.rdf.event.AddEvent;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphEvent;
-import org.apache.commons.rdf.event.GraphListener;
-import org.apache.commons.rdf.event.RemoveEvent;
-import org.apache.commons.rdf.impl.utils.debug.ReentrantReadWriteLockTracker;
-import org.apache.commons.rdf.impl.utils.simple.SimpleImmutableGraph;
+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.Graph;
+import org.apache.clerezza.commons.rdf.ImmutableGraph;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.WatchableGraph;
+import org.apache.clerezza.commons.rdf.event.AddEvent;
+import org.apache.clerezza.commons.rdf.event.FilterTriple;
+import org.apache.clerezza.commons.rdf.event.GraphEvent;
+import org.apache.clerezza.commons.rdf.event.GraphListener;
+import org.apache.clerezza.commons.rdf.event.RemoveEvent;
+import org.apache.clerezza.commons.rdf.impl.utils.debug.ReentrantReadWriteLockTracker;
+import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleImmutableGraph;
 
 /**
  * An abstract implementation of <code>Graph</code> implementing

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java
index 912a5ff..983860a 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java
@@ -16,16 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
 import java.util.Collection;
 import java.util.Iterator;
 
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.graphmatching.GraphMatcher;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.ImmutableGraph;
+import org.apache.clerezza.commons.rdf.RdfTerm;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.impl.utils.graphmatching.GraphMatcher;
 
 /**
  * <code>AbstractGraph</code> is an abstract implementation of <code>ImmutableGraph</code> 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java
index e1fac11..a236f06 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java
@@ -13,9 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
-import org.apache.commons.rdf.Literal;
+import org.apache.clerezza.commons.rdf.Literal;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java
index 8b3bc87..1cf3321 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java
@@ -16,15 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
 import java.lang.ref.WeakReference;
 import java.util.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.commons.rdf.event.GraphEvent;
-import org.apache.commons.rdf.event.GraphListener;
+import org.apache.clerezza.commons.rdf.event.GraphEvent;
+import org.apache.clerezza.commons.rdf.event.GraphListener;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java
index 0de3b84..ed39ca0 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
 import java.io.Serializable;
 
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.Language;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java
index 8f6945e..79747c2 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
 import java.util.Iterator;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Triple;
 
 /**
  * Wrapps an iterator<Triple> reading entering a read-lock on every invocation

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java
index dec30db..0b8aabc 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java
@@ -16,13 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
 import java.io.Serializable;
-import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.Iri;
 
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
+import org.apache.clerezza.commons.rdf.Language;
+import org.apache.clerezza.commons.rdf.Literal;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java
index ece7d55..55c4a84 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
+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;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java
index 4d3ff9d..ca8b5b5 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java
@@ -16,13 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
 import java.io.Serializable;
 
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.Language;
+import org.apache.clerezza.commons.rdf.Literal;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java
index 76b9283..a168e82 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.commons.rdf.impl.utils;
+package org.apache.clerezza.commons.rdf.impl.utils;
 
 import java.lang.ref.WeakReference;
 import java.util.Collection;
@@ -22,18 +22,18 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.WatchableGraph;
-import org.apache.commons.rdf.event.AddEvent;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphEvent;
-import org.apache.commons.rdf.event.GraphListener;
-import org.apache.commons.rdf.event.RemoveEvent;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.Graph;
+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.WatchableGraph;
+import org.apache.clerezza.commons.rdf.event.AddEvent;
+import org.apache.clerezza.commons.rdf.event.FilterTriple;
+import org.apache.clerezza.commons.rdf.event.GraphEvent;
+import org.apache.clerezza.commons.rdf.event.GraphListener;
+import org.apache.clerezza.commons.rdf.event.RemoveEvent;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java
index f2b93b8..1f47fe9 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.debug;
+package org.apache.clerezza.commons.rdf.impl.utils.debug;
 
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
index 65abf32..8f382aa 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils.debug;
+package org.apache.clerezza.commons.rdf.impl.utils.debug;
 
 import java.util.Collection;
 import java.util.Collections;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java
index 0231331..a4261e3 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.debug;
+package org.apache.clerezza.commons.rdf.impl.utils.debug;
 
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
index b7e2500..15c4cf9 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
 
 
@@ -26,13 +26,13 @@ import java.util.Map;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.Graph;
+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.SimpleMGraph;
 
 /**
  * @author reto

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
index 42de52e..5b5600f 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
index f79bd2a..4c7a0ae 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
@@ -15,7 +15,7 @@
  *  under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
 import java.util.ArrayList;
 import java.util.HashMap;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java
index ae419f6..a9cf92f 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java
@@ -17,24 +17,24 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
 
-import org.apache.commons.rdf.impl.utils.graphmatching.collections.IntHashMap;
+import org.apache.clerezza.commons.rdf.impl.utils.graphmatching.collections.IntHashMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.commons.rdf.impl.utils.graphmatching.collections.IntIterator;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.Graph;
+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.Graph;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.graphmatching.collections.IntIterator;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java
index dea95b5..016b590 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java
@@ -1,4 +1,4 @@
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
index 6b6fa07..6f01828 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
 
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java
index 25a7a4b..68e178b 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java
@@ -1,4 +1,4 @@
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -26,8 +26,8 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.Triple;
 
 public class Utils {
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
index 922ae47..776a6af 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
@@ -19,7 +19,7 @@
  * but rereleased by the original author under the ASF license (above).
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching.collections;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching.collections;
 
 
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
index 4dd92b1..70091b8 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching.collections;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching.collections;
 
 import java.util.HashSet;
 import java.util.Iterator;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
index 050cf82..d298066 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching.collections;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching.collections;
 
 import java.util.Iterator;
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
index 5c3e465..b1d6c32 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching.collections;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching.collections;
 
 import java.util.Set;
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/package-info.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/package-info.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/package-info.java
index a1fa1c5..a353062 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/package-info.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/package-info.java
@@ -18,4 +18,4 @@
 /**
  * Common RDF API Implementation utilities.
  */
-package org.apache.commons.rdf.impl.utils;
\ No newline at end of file
+package org.apache.clerezza.commons.rdf.impl.utils;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java
index 9b60a15..cfced01 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java
@@ -16,9 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils.simple;
+package org.apache.clerezza.commons.rdf.impl.utils.simple;
 
-import org.apache.commons.rdf.impl.utils.AbstractGraph;
+import org.apache.clerezza.commons.rdf.impl.utils.AbstractGraph;
 import java.lang.ref.SoftReference;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -29,11 +29,11 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.ImmutableGraph;
+import org.apache.clerezza.commons.rdf.RdfTerm;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Iri;
 
 /**
  * For now this is a minimalistic implementation, without any indexes or other

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
index bc50a09..5c1aecc 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
@@ -16,16 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils.simple;
+package org.apache.clerezza.commons.rdf.impl.utils.simple;
 
-import org.apache.commons.rdf.impl.utils.AbstractImmutableGraph;
+import org.apache.clerezza.commons.rdf.impl.utils.AbstractImmutableGraph;
 import java.util.Iterator;
 
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
+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.Graph;
+import org.apache.clerezza.commons.rdf.Iri;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.java
index 8d0a5ce..1c00cdd 100644
--- a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.java
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.java
@@ -16,15 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils.simple;
+package org.apache.clerezza.commons.rdf.impl.utils.simple;
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.ImmutableGraph;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Triple;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
index 5c43c1b..2270f49 100644
--- a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcherTest.java
@@ -16,19 +16,19 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
-import org.apache.commons.rdf.impl.utils.graphmatching.GraphMatcher;
+import org.apache.clerezza.commons.rdf.impl.utils.graphmatching.GraphMatcher;
 import java.util.Map;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.Graph;
+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.Graph;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleMGraph;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
 import org.junit.Assert;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
index baac5b9..88f8a96 100644
--- a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatchingTest.java
@@ -17,14 +17,14 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
 
 import java.util.Map;
 
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
 import org.junit.Assert;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
index 6616060..3f61508 100644
--- a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIteratorTest.java
@@ -17,9 +17,9 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
-import org.apache.commons.rdf.impl.utils.graphmatching.PermutationIterator;
+import org.apache.clerezza.commons.rdf.impl.utils.graphmatching.PermutationIterator;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
index 3246575..04d7c80 100644
--- a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils4Testing.java
@@ -17,14 +17,14 @@
  * under the License.
  */
 
-package org.apache.commons.rdf.impl.utils.graphmatching;
+package org.apache.clerezza.commons.rdf.impl.utils.graphmatching;
 
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIri;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleMGraph;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
index 2782f45..538a16d 100644
--- a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/PlainLiteralImplTest.java
@@ -16,13 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils.simple;
+package org.apache.clerezza.commons.rdf.impl.utils.simple;
 
-import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
 import org.junit.Test;
 
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
+import org.apache.clerezza.commons.rdf.Language;
+import org.apache.clerezza.commons.rdf.Literal;
 import org.junit.Assert;
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java
index a1e8d54..4875fcf 100644
--- a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraphTest.java
@@ -16,16 +16,16 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils.simple;
+package org.apache.clerezza.commons.rdf.impl.utils.simple;
 
-import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
 import java.util.ConcurrentModificationException;
 import java.util.Iterator;
 import org.junit.Assert;
 import org.junit.Test;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java
index dd2f967..8161768 100644
--- a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TripleImplTest.java
@@ -3,7 +3,7 @@
  * and open the template in the editor.
  */
 
-package org.apache.commons.rdf.impl.utils.simple;
+package org.apache.clerezza.commons.rdf.impl.utils.simple;
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -29,12 +29,12 @@ package org.apache.commons.rdf.impl.utils.simple;
 import org.junit.Test;
 import junit.framework.Assert;
 
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
+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;
+import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl;
 /**
  *
  * @author reto

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/12b3d66e/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
index 515cf93..fd74f4b 100644
--- a/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
+++ b/impl.utils/src/test/java/org/apache/clerezza/commons/rdf/impl/utils/simple/TypedLiteralImplTest.java
@@ -16,14 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.rdf.impl.utils.simple;
+package org.apache.clerezza.commons.rdf.impl.utils.simple;
 
-import org.apache.commons.rdf.impl.utils.TypedLiteralImpl;
+import org.apache.clerezza.commons.rdf.impl.utils.TypedLiteralImpl;
 import org.junit.Test;
 import junit.framework.Assert;
 
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Literal;
+import org.apache.clerezza.commons.rdf.Iri;
+import org.apache.clerezza.commons.rdf.Literal;
 /**
  *
  * @author reto/**


[5/7] clerezza-rdf-core git commit: CLEREZZA-982: moved files for new packages

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/package-info.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/package-info.java b/api/src/main/java/org/apache/commons/rdf/package-info.java
deleted file mode 100644
index da34f2d..0000000
--- a/api/src/main/java/org/apache/commons/rdf/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Common RDF API
- */
-package org.apache.commons.rdf;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/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..f55f7af
--- /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.commons.rdf.impl.sparql;
+
+import java.util.Collection;
+import java.util.Objects;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.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-rdf-core/blob/816dc11f/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..e522924
--- /dev/null
+++ b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlClient.java
@@ -0,0 +1,224 @@
+/*
+ * 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.commons.rdf.impl.sparql;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+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 javax.xml.parsers.*;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.Language;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.impl.utils.AbstractLiteral;
+import org.xml.sax.*;
+import org.xml.sax.helpers.*;
+
+/**
+ *
+ * @author developer
+ */
+public class SparqlClient {
+
+    final String endpoint;
+
+    public SparqlClient(final String endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    List<Map<String, RdfTerm>> queryResultSet(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);
+
+        try {
+            HttpEntity entity2 = response2.getEntity();
+            InputStream in = entity2.getContent();
+            SAXParserFactory spf = SAXParserFactory.newInstance();
+            spf.setNamespaceAware(true);
+            SAXParser saxParser = spf.newSAXParser();
+            XMLReader xmlReader = saxParser.getXMLReader();
+            final SparqlsResultsHandler sparqlsResultsHandler = new SparqlsResultsHandler();
+            xmlReader.setContentHandler(sparqlsResultsHandler);
+            xmlReader.parse(new InputSource(in));
+            /*
+             for (int ch = in.read(); ch != -1; ch = in.read()) {
+             System.out.print((char)ch);
+             }
+             */
+            // do something useful with the response body
+            // and ensure it is fully consumed
+            EntityUtils.consume(entity2);
+            return sparqlsResultsHandler.getResults();
+        } catch (ParserConfigurationException ex) {
+            throw new RuntimeException(ex);
+        } catch (SAXException ex) {
+            throw new RuntimeException(ex);
+        } finally {
+            response2.close();
+        }
+
+    }
+
+    final public static class SparqlsResultsHandler extends DefaultHandler {
+
+        private String currentBindingName;
+        private Map<String, RdfTerm> currentResult = null;
+        private final List<Map<String, RdfTerm>> results = new ArrayList<>();
+        private boolean readingValue;
+        private String lang; //the xml:lang attribute of a literal
+        private String value;
+        private Map<String, BlankNode> bNodeMap = new HashMap<>();
+        private static final Iri XSD_STRING = new Iri("http://www.w3.org/2001/XMLSchema#string");
+
+        private RdfTerm getBNode(String value) {
+            if (!bNodeMap.containsKey(value)) {
+                bNodeMap.put(value, new BlankNode());
+            }
+            return bNodeMap.get(value);
+        }
+
+        private List<Map<String, RdfTerm>> getResults() {
+            return results;
+        }
+
+        enum BindingType {
+
+            uri, bnode, literal;
+        }
+
+        @Override
+        public void startDocument() throws SAXException {
+
+        }
+
+        @Override
+        public void startElement(String namespaceURI,
+                String localName,
+                String qName,
+                Attributes atts)
+                throws SAXException {
+            if ("http://www.w3.org/2005/sparql-results#".equals(namespaceURI)) {
+                if ("result".equals(localName)) {
+                    if (currentResult != null) {
+                        throw new SAXException("unexpected tag <result>");
+                    }
+                    currentResult = new HashMap<>();
+                } else if ("binding".equals(localName)) {
+                    if (currentResult == null) {
+                        throw new SAXException("unexpected tag <binding>");
+                    }
+                    currentBindingName = atts.getValue("name");
+                } else if ("uri".equals(localName) || "bnode".equals(localName) || "literal".equals(localName)) {
+                    if (readingValue) {
+                        throw new SAXException("unexpected tag <" + localName + ">");
+                    }
+                    lang = atts.getValue("http://www.w3.org/XML/1998/namespace", "lang");
+                    readingValue = true;
+                }
+            }
+
+            //System.out.println(namespaceURI);
+            //System.out.println(qName);
+        }
+
+        @Override
+        public void characters(char[] chars, int start, int length) throws SAXException {
+            if (readingValue) {
+                value = new String(chars, start, length);
+                //System.err.println(value + start + ", " + length);
+            }
+        }
+
+        @Override
+        public void endElement(String namespaceURI,
+                String localName,
+                String qName)
+                throws SAXException {
+            if ("http://www.w3.org/2005/sparql-results#".equals(namespaceURI)) {
+                if ("result".equals(localName)) {
+                    results.add(currentResult);
+                    currentResult = null;
+                } else if ("binding".equals(localName)) {
+                    if (currentBindingName == null) {
+                        throw new SAXException("unexpected tag </binding>");
+                    }
+                    currentBindingName = null;
+                } else {
+                    try {
+                        BindingType b = BindingType.valueOf(localName);
+                        RdfTerm rdfTerm = null;
+                        final Language language = lang == null? null : new Language(lang);;
+                        switch (b) {
+                            case uri:
+                                rdfTerm = new Iri(value);
+                                break;
+                            case bnode:
+                                rdfTerm = getBNode(value);
+                                break;
+                            case literal:
+                                final String lf = value;
+                                rdfTerm = new AbstractLiteral() {
+
+                                    @Override
+                                    public String getLexicalForm() {
+                                        return lf;
+                                    }
+
+                                    @Override
+                                    public Iri getDataType() {
+                                        //TODO implement
+                                        return XSD_STRING;
+                                    }
+
+                                    @Override
+                                    public Language getLanguage() {
+                                        return language;
+                                    }
+                                };
+                                break;
+                        }
+                        currentResult.put(currentBindingName, rdfTerm);
+                        readingValue = false;
+                    } catch (IllegalArgumentException e) {
+                            //not uri|bnode|literal
+                    }
+                }
+            }
+        }
+
+        public void endDocument() throws SAXException {
+            //System.out.println("results: " + results.size());
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java
new file mode 100644
index 0000000..594a264
--- /dev/null
+++ b/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraph.java
@@ -0,0 +1,505 @@
+/*
+ * 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.commons.rdf.impl.sparql;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.logging.Logger;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.Literal;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.impl.utils.AbstractGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+
+/**
+ *
+ * @author reto
+ */
+public class SparqlGraph extends AbstractGraph {
+
+    private static final int MAX_ISOMORPHIC_BNODES = 1000;
+    private static final Logger log = Logger.getLogger(SparqlGraph.class.getName());
+
+    final SparqlClient sparqlClient;
+
+    /**
+     * Constructs a Graph representing the default graph at the specified
+     * endpoint
+     */
+    public SparqlGraph(final String endpoint) {
+        sparqlClient = new SparqlClient(endpoint);
+    }
+
+    @Override
+    protected Iterator<Triple> performFilter(final BlankNodeOrIri filterSubject,
+            final Iri filterPredicate, final RdfTerm filterObject) {
+        try {
+            String query = createQuery(filterSubject, filterPredicate, filterObject);
+            final List<Map<String, RdfTerm>> sparqlResults = sparqlClient.queryResultSet(query);
+            //first to triples without bnode-conversion
+            //rawTriples contains the triples with the BNodes from the result set
+            final Collection<Triple> rawTriples = new ArrayList<>();
+            for (Map<String, RdfTerm> result : sparqlResults) {
+                rawTriples.add(new TripleImpl(filterSubject != null ? filterSubject : (BlankNodeOrIri) result.get("s"),
+                        filterPredicate != null ? filterPredicate : (Iri) result.get("p"),
+                        filterObject != null ? filterObject : result.get("o")));
+
+            }
+            //then bnode conversion
+            final Iterator<Triple> rawTriplesIter = rawTriples.iterator();
+            //this is basically just wokring around the lack of (named) nested functions
+            return (new Callable<Iterator<Triple>>() {
+
+                final Map<BlankNode, SparqlBNode> nodeMap = new HashMap<>();
+                final Set<ImmutableGraph> usedContext = new HashSet<>();
+
+                private RdfTerm useSparqlNode(RdfTerm node) throws IOException {
+                    if (node instanceof BlankNodeOrIri) {
+                        return useSparqlNode((BlankNodeOrIri) node);
+                    }
+                    return node;
+                }
+
+                private BlankNodeOrIri useSparqlNode(BlankNodeOrIri node) throws IOException {
+                    if (node instanceof BlankNode) {
+                        if (!nodeMap.containsKey(node)) {
+                            createBlankNodesForcontext((BlankNode) node);
+                        }
+                        if (!nodeMap.containsKey(node)) {
+                            throw new RuntimeException("no Bnode created");
+                        }
+                        return nodeMap.get(node);
+                    } else {
+                        return node;
+                    }
+                }
+
+                private void createBlankNodesForcontext(final BlankNode node) throws IOException {
+                    final Collection<Triple> context = getContext(node);
+                    final Set<BlankNode> rawNodes = new HashSet<>();
+                    for (Triple triple : context) {
+                        {
+                            final BlankNodeOrIri subject = triple.getSubject();
+                            if (subject instanceof BlankNode) {
+                                rawNodes.add((BlankNode) subject);
+                            }
+                        }
+                        {
+                            final RdfTerm object = triple.getObject();
+                            if (object instanceof BlankNode) {
+                                rawNodes.add((BlankNode) object);
+                            }
+                        }
+                    }
+                    final Set<SparqlBNode> createdSparqlNodes = new HashSet<>();
+                    //final Map<BlankNode, SparqlBNode> preliminaryNodes = new HashMap<>();
+                    for (BlankNode rawNode : rawNodes) {
+                        for (int i = 0; i < MAX_ISOMORPHIC_BNODES; i++) {
+                            SparqlBNode sparqlBNode = new SparqlBNode(rawNode, context, i);
+                            if (!createdSparqlNodes.contains(sparqlBNode)) {
+                                nodeMap.put(rawNode, sparqlBNode);
+                                createdSparqlNodes.add(sparqlBNode);
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                private ImmutableGraph getContext(final BlankNode node) throws IOException {
+                    //we need to get the cntext of the BNode
+                    //if the filter was for (null, null, null) we have the whole
+                    //bnode context in the reuslt set, otherwise we need to get 
+                    //more triples from the endpoint,
+                    //let's first handle the easy case
+                    if ((filterSubject == null) && (filterPredicate == null)
+                            && (filterObject == null)) {
+                        return getContextInRaw(node);
+                    } else {
+                        final ImmutableGraph startContext = getContextInRaw(node);
+                        final Set<ImmutableGraph> expandedContexts = expandContext(startContext);
+                        //expand bnode context
+                        //note that there might be different contexts for 
+                        //a bnode as present in the current result set
+                        //in this case we just haveto make sure we don't 
+                        //pick the same context for different bnodes in the resultset
+                        ImmutableGraph result = null;
+                        for (ImmutableGraph expandedContext : expandedContexts) {
+                            if (!usedContext.contains(expandedContext)) {
+                                result = expandedContext;
+                                break;
+                            }
+                        }
+                        if (result == null) {
+                            log.warning("he underlying sparql graph seems to contain redundant triples, this might cause unexpected results");
+                            result = expandedContexts.iterator().next();
+                        } else {
+                            usedContext.add(result);
+                        }
+                        return result;
+                    }
+
+                }
+
+                private ImmutableGraph getContextInRaw(BlankNode node) {
+                    final Graph contextBuilder = new SimpleGraph();
+                    for (Triple rawTriple : rawTriples) {
+                        BlankNodeOrIri rawSubject = rawTriple.getSubject();
+                        RdfTerm rawObject = rawTriple.getObject();
+                        if (rawSubject.equals(node) || rawObject.equals(node)) {
+                            contextBuilder.add(rawTriple);
+                        }
+                    }
+                    return contextBuilder.getImmutableGraph();
+                }
+
+                @Override
+                public Iterator<Triple> call() throws Exception {
+                    return new Iterator<Triple>() {
+
+                        @Override
+                        public boolean hasNext() {
+                            return rawTriplesIter.hasNext();
+                        }
+
+                        @Override
+                        public Triple next() {
+                            try {
+                                Triple rawTriple = rawTriplesIter.next();
+                                return new TripleImpl(useSparqlNode(rawTriple.getSubject()),
+                                        rawTriple.getPredicate(),
+                                        useSparqlNode(rawTriple.getObject()));
+                            } catch (IOException ex) {
+                                throw new RuntimeException(ex);
+                            }
+                        }
+                    };
+                }
+
+                /**
+                 * returns all MSGs that are supergraphs of startContext
+                 *
+                 * @param startContext
+                 * @return
+                 */
+                private Set<ImmutableGraph> expandContext(Collection<Triple> startContext) throws IOException {
+
+                    final StringBuilder queryBuilder = new StringBuilder();
+                    queryBuilder.append("SELECT * WHERE {\n ");
+                    Map<BlankNode, String> bNodeVarNameMap = writeTriplePattern(queryBuilder, startContext);
+                    Set<BlankNode> bNodesInContext = bNodeVarNameMap.keySet();
+                    for (BlankNode bNode : bNodesInContext) {
+                        final String bNodeVarLabel = bNodeVarNameMap.get(bNode);
+                        //looking for outgoing properties of the bnode
+                        queryBuilder.append("OPTIONAL { ");
+                        queryBuilder.append('?');
+                        queryBuilder.append(bNodeVarLabel);
+                        queryBuilder.append(' ');
+                        queryBuilder.append("?po");
+                        queryBuilder.append(bNodeVarLabel);
+                        queryBuilder.append(" ?o");
+                        queryBuilder.append(bNodeVarLabel);
+                        queryBuilder.append(" } .\n");
+                        //looking for incoming properties of the bnode
+                        queryBuilder.append("OPTIONAL { ");
+                        queryBuilder.append("?s");
+                        queryBuilder.append(bNodeVarLabel);
+                        queryBuilder.append(' ');
+                        queryBuilder.append("?pi");
+                        queryBuilder.append(bNodeVarLabel);
+                        queryBuilder.append(" ?");
+                        queryBuilder.append(bNodeVarLabel);
+                        queryBuilder.append(" } .\n");
+                    }
+                    queryBuilder.append(" }");
+                    final List<Map<String, RdfTerm>> expansionQueryResults = sparqlClient.queryResultSet(queryBuilder.toString());
+                    Set<ImmutableGraph> expandedContexts = new HashSet<>();
+                    //the query results may or may be from disjoint supergraphs
+                    //we expand them all as if they are different which may lead
+                    //us to the same MSG multiple times
+                    RESULTS:
+                    for (Map<String, RdfTerm> expansionQueryResult : expansionQueryResults) {
+                        Collection<Triple> expandedContext = new HashSet<>();
+                        Map<BlankNode, BlankNode> newBNodesToOldBNodes = new HashMap<>();
+                        for (BlankNode oldBNode : bNodesInContext) {
+                            final String bNodeVarLabel = bNodeVarNameMap.get(oldBNode);
+                            final RdfTerm newNode = expansionQueryResult.get(bNodeVarLabel);
+                            if (!(newNode instanceof BlankNode)) {
+                                //this subgraph is't a match
+                                continue RESULTS;
+                            }
+                            newBNodesToOldBNodes.put((BlankNode) newNode, oldBNode);
+                        }
+                        expandedContext.addAll(startContext);
+                        boolean newBNodeIntroduced = false;
+                        boolean newTripleAdded = false;
+                        for (BlankNode oldBNode : bNodesInContext) {
+                            final String bNodeVarLabel = bNodeVarNameMap.get(oldBNode);
+                            {
+                                final Iri newPredicate = (Iri) expansionQueryResult.get("po" + bNodeVarLabel);
+                                if (newPredicate != null) {
+                                    RdfTerm newObject = expansionQueryResult.get("o" + bNodeVarLabel);
+                                    if (newObject instanceof BlankNode) {
+                                        if (newBNodesToOldBNodes.containsKey(newObject)) {
+                                            //point back to BNode in startContext
+                                            newObject = newBNodesToOldBNodes.get(newObject);
+                                        } else {
+                                            newBNodeIntroduced = true;
+                                        }
+                                    }
+                                    if (expandedContext.add(new TripleImpl(oldBNode, newPredicate, newObject))) {
+                                        newTripleAdded = true;
+                                    }
+                                }
+                            }
+                            {
+                                final Iri newPredicate = (Iri) expansionQueryResult.get("pi" + bNodeVarLabel);
+                                if (newPredicate != null) {
+                                    RdfTerm newSubject = expansionQueryResult.get("s" + bNodeVarLabel);
+                                    if (newSubject instanceof BlankNode) {
+                                        if (newBNodesToOldBNodes.containsKey(newSubject)) {
+                                            //point back to BNode in startContext
+                                            newSubject = newBNodesToOldBNodes.get(newSubject);
+                                        } else {
+                                            newBNodeIntroduced = true;
+                                        }
+                                    }
+                                    if (expandedContext.add(new TripleImpl((BlankNodeOrIri) newSubject, newPredicate, oldBNode))) {
+                                        newTripleAdded = true;
+                                    }
+                                }
+                            }
+                        }
+                        if (newBNodeIntroduced) {
+                            //we could be more efficient than this ans just expand the newly introduced bnodes
+                            expandedContexts.addAll(expandContext(expandedContext));
+                        } else {
+                            if (newTripleAdded) {
+                                //look for more results
+                                expandedContexts.addAll(expandContext(expandedContext));
+                                //expandedContexts.add(expandedContext);
+                            }
+                        }
+
+                    }
+                    if (expandedContexts.isEmpty()) {
+                        expandedContexts.add(new SimpleGraph(startContext).getImmutableGraph());
+                    }
+                    return expandedContexts;
+                }
+
+            }).call();
+        } catch (AlienBNodeException e) {
+            return new Iterator<Triple>() {
+
+                @Override
+                public boolean hasNext() {
+                    return false;
+                }
+
+                @Override
+                public Triple next() {
+                    throw new NoSuchElementException();
+                }
+            };
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    private String createQuery(final BlankNodeOrIri filterSubject, final Iri filterPredicate, final RdfTerm filterObject) {
+        final StringBuilder selectBuilder = new StringBuilder();
+        selectBuilder.append("SELECT ");
+        final StringBuilder whereBuilder = new StringBuilder();
+        whereBuilder.append("WHERE { ");
+        if (filterSubject == null) {
+            whereBuilder.append("?s");
+            selectBuilder.append("?s ");
+        } else {
+            if (filterSubject instanceof SparqlBNode) {
+                whereBuilder.append("?sn");
+            } else {
+                whereBuilder.append(asSparqlTerm(filterSubject));
+            }
+        }
+        whereBuilder.append(' ');
+        if (filterPredicate == null) {
+            whereBuilder.append("?p");
+            selectBuilder.append("?p ");
+        } else {
+            whereBuilder.append(asSparqlTerm(filterPredicate));
+        }
+        whereBuilder.append(' ');
+        if (filterObject == null) {
+            whereBuilder.append("?o");
+            selectBuilder.append("?o ");
+        } else {
+            if (filterObject instanceof SparqlBNode) {
+                whereBuilder.append("?on");
+            } else {
+                whereBuilder.append(asSparqlTerm(filterObject));
+            }
+        }
+        whereBuilder.append(" .\n");
+        if (filterSubject instanceof SparqlBNode) {
+            //expand bnode context
+            writeTriplePattern(whereBuilder, ((SparqlBNode) filterSubject).context, "sn");
+        }
+        
+        if (filterObject instanceof SparqlBNode) {
+            //expand bnode context
+            writeTriplePattern(whereBuilder, ((SparqlBNode) filterObject).context, "on");
+        }
+
+        whereBuilder.append(" }");
+        return selectBuilder.append(whereBuilder).toString();
+    }
+
+    @Override
+    protected int performSize() {
+        try {
+            return sparqlClient.queryResultSet("SELECT * WHERE { ?s ?p ?o}").size();
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    private String asSparqlTerm(Iri iri) {
+        return "<" + iri.getUnicodeString() + ">";
+    }
+
+    private String asSparqlTerm(Literal literal) {
+        //TODO langauge and datatype
+        return "\"" + literal.getLexicalForm() + "\"";
+    }
+
+    private String asSparqlTerm(BlankNode bnode) {
+        if (!(bnode instanceof SparqlBNode)) {
+            throw new AlienBNodeException();
+        }
+        //this requires adding additional clauses to the graph pattern
+        throw new RuntimeException("SparqlBNodes should have been handled earlier");
+    }
+
+    private String asSparqlTerm(BlankNodeOrIri term) {
+        if (term instanceof Iri) {
+            return asSparqlTerm((Iri) term);
+        } else {
+            return asSparqlTerm((BlankNode) term);
+        }
+    }
+
+    private String asSparqlTerm(RdfTerm term) {
+        if (term instanceof BlankNodeOrIri) {
+            return asSparqlTerm((BlankNodeOrIri) term);
+        } else {
+            return asSparqlTerm((Literal) term);
+        }
+    }
+
+
+    private Map<BlankNode, String> writeTriplePattern(StringBuilder queryBuilder, Collection<Triple> triples) {
+        return writeTriplePattern(queryBuilder, triples, null);
+    }
+        
+    private Map<BlankNode, String> writeTriplePattern(StringBuilder queryBuilder, Collection<Triple> triples, String varLabelForInternalBNodeId) {
+        final Collection<String> triplePatterns = new ArrayList<>();
+        int varCounter = 0;
+        final Map<BlankNode, String> bNodeVarNameMap = new HashMap<>();
+        for (Triple t : triples) {
+            final StringBuilder builder = new StringBuilder();
+            {
+                final BlankNodeOrIri s = t.getSubject();
+                String varName;
+                if (s instanceof BlankNode) {
+                    if (bNodeVarNameMap.containsKey(s)) {
+                        varName = bNodeVarNameMap.get(s);
+                    } else {
+                        varName = "v" + (varCounter++);
+                        bNodeVarNameMap.put((BlankNode) s, varName);
+                    }
+                    builder.append('?');
+                    builder.append(varName);
+                } else {
+                    if (s.equals(SparqlBNode.internalBNodeId)) {
+                        builder.append('?');
+                        builder.append(varLabelForInternalBNodeId);
+                    } else {
+                        builder.append(asSparqlTerm(s));
+                    }
+                    
+                }
+            }
+            builder.append(' ');
+            builder.append(asSparqlTerm(t.getPredicate()));
+            builder.append(' ');
+            {
+                final RdfTerm o = t.getObject();
+                String varName;
+                if (o instanceof BlankNode) {
+                    if (bNodeVarNameMap.containsKey(o)) {
+                        varName = bNodeVarNameMap.get(o);
+                    } else {
+                        varName = "v" + (varCounter++);
+                        bNodeVarNameMap.put((BlankNode) o, varName);
+                    }
+                    builder.append('?');
+                    builder.append(varName);
+                } else {
+                    if (o.equals(SparqlBNode.internalBNodeId)) {
+                        builder.append('?');
+                        builder.append(varLabelForInternalBNodeId);
+                    } else {
+                        builder.append(asSparqlTerm(o));
+                    }
+                }
+            }
+            builder.append('.');
+            triplePatterns.add(builder.toString());
+
+        }
+        for (String triplePattern : triplePatterns) {
+
+            queryBuilder.append(triplePattern);
+            queryBuilder.append('\n');
+        }
+        return bNodeVarNameMap;
+
+    }
+
+    private static class AlienBNodeException extends RuntimeException {
+
+        public AlienBNodeException() {
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlBNode.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlBNode.java b/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlBNode.java
deleted file mode 100644
index f55f7af..0000000
--- a/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlBNode.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.commons.rdf.impl.sparql;
-
-import java.util.Collection;
-import java.util.Objects;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.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-rdf-core/blob/816dc11f/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlClient.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlClient.java b/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlClient.java
deleted file mode 100644
index e522924..0000000
--- a/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlClient.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * 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.commons.rdf.impl.sparql;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-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 javax.xml.parsers.*;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.impl.utils.AbstractLiteral;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
-
-/**
- *
- * @author developer
- */
-public class SparqlClient {
-
-    final String endpoint;
-
-    public SparqlClient(final String endpoint) {
-        this.endpoint = endpoint;
-    }
-
-    List<Map<String, RdfTerm>> queryResultSet(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);
-
-        try {
-            HttpEntity entity2 = response2.getEntity();
-            InputStream in = entity2.getContent();
-            SAXParserFactory spf = SAXParserFactory.newInstance();
-            spf.setNamespaceAware(true);
-            SAXParser saxParser = spf.newSAXParser();
-            XMLReader xmlReader = saxParser.getXMLReader();
-            final SparqlsResultsHandler sparqlsResultsHandler = new SparqlsResultsHandler();
-            xmlReader.setContentHandler(sparqlsResultsHandler);
-            xmlReader.parse(new InputSource(in));
-            /*
-             for (int ch = in.read(); ch != -1; ch = in.read()) {
-             System.out.print((char)ch);
-             }
-             */
-            // do something useful with the response body
-            // and ensure it is fully consumed
-            EntityUtils.consume(entity2);
-            return sparqlsResultsHandler.getResults();
-        } catch (ParserConfigurationException ex) {
-            throw new RuntimeException(ex);
-        } catch (SAXException ex) {
-            throw new RuntimeException(ex);
-        } finally {
-            response2.close();
-        }
-
-    }
-
-    final public static class SparqlsResultsHandler extends DefaultHandler {
-
-        private String currentBindingName;
-        private Map<String, RdfTerm> currentResult = null;
-        private final List<Map<String, RdfTerm>> results = new ArrayList<>();
-        private boolean readingValue;
-        private String lang; //the xml:lang attribute of a literal
-        private String value;
-        private Map<String, BlankNode> bNodeMap = new HashMap<>();
-        private static final Iri XSD_STRING = new Iri("http://www.w3.org/2001/XMLSchema#string");
-
-        private RdfTerm getBNode(String value) {
-            if (!bNodeMap.containsKey(value)) {
-                bNodeMap.put(value, new BlankNode());
-            }
-            return bNodeMap.get(value);
-        }
-
-        private List<Map<String, RdfTerm>> getResults() {
-            return results;
-        }
-
-        enum BindingType {
-
-            uri, bnode, literal;
-        }
-
-        @Override
-        public void startDocument() throws SAXException {
-
-        }
-
-        @Override
-        public void startElement(String namespaceURI,
-                String localName,
-                String qName,
-                Attributes atts)
-                throws SAXException {
-            if ("http://www.w3.org/2005/sparql-results#".equals(namespaceURI)) {
-                if ("result".equals(localName)) {
-                    if (currentResult != null) {
-                        throw new SAXException("unexpected tag <result>");
-                    }
-                    currentResult = new HashMap<>();
-                } else if ("binding".equals(localName)) {
-                    if (currentResult == null) {
-                        throw new SAXException("unexpected tag <binding>");
-                    }
-                    currentBindingName = atts.getValue("name");
-                } else if ("uri".equals(localName) || "bnode".equals(localName) || "literal".equals(localName)) {
-                    if (readingValue) {
-                        throw new SAXException("unexpected tag <" + localName + ">");
-                    }
-                    lang = atts.getValue("http://www.w3.org/XML/1998/namespace", "lang");
-                    readingValue = true;
-                }
-            }
-
-            //System.out.println(namespaceURI);
-            //System.out.println(qName);
-        }
-
-        @Override
-        public void characters(char[] chars, int start, int length) throws SAXException {
-            if (readingValue) {
-                value = new String(chars, start, length);
-                //System.err.println(value + start + ", " + length);
-            }
-        }
-
-        @Override
-        public void endElement(String namespaceURI,
-                String localName,
-                String qName)
-                throws SAXException {
-            if ("http://www.w3.org/2005/sparql-results#".equals(namespaceURI)) {
-                if ("result".equals(localName)) {
-                    results.add(currentResult);
-                    currentResult = null;
-                } else if ("binding".equals(localName)) {
-                    if (currentBindingName == null) {
-                        throw new SAXException("unexpected tag </binding>");
-                    }
-                    currentBindingName = null;
-                } else {
-                    try {
-                        BindingType b = BindingType.valueOf(localName);
-                        RdfTerm rdfTerm = null;
-                        final Language language = lang == null? null : new Language(lang);;
-                        switch (b) {
-                            case uri:
-                                rdfTerm = new Iri(value);
-                                break;
-                            case bnode:
-                                rdfTerm = getBNode(value);
-                                break;
-                            case literal:
-                                final String lf = value;
-                                rdfTerm = new AbstractLiteral() {
-
-                                    @Override
-                                    public String getLexicalForm() {
-                                        return lf;
-                                    }
-
-                                    @Override
-                                    public Iri getDataType() {
-                                        //TODO implement
-                                        return XSD_STRING;
-                                    }
-
-                                    @Override
-                                    public Language getLanguage() {
-                                        return language;
-                                    }
-                                };
-                                break;
-                        }
-                        currentResult.put(currentBindingName, rdfTerm);
-                        readingValue = false;
-                    } catch (IllegalArgumentException e) {
-                            //not uri|bnode|literal
-                    }
-                }
-            }
-        }
-
-        public void endDocument() throws SAXException {
-            //System.out.println("results: " + results.size());
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlGraph.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlGraph.java b/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlGraph.java
deleted file mode 100644
index 594a264..0000000
--- a/impl.sparql/src/main/java/org/apache/commons/rdf/impl/sparql/SparqlGraph.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * 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.commons.rdf.impl.sparql;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.logging.Logger;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Literal;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.AbstractGraph;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
-
-/**
- *
- * @author reto
- */
-public class SparqlGraph extends AbstractGraph {
-
-    private static final int MAX_ISOMORPHIC_BNODES = 1000;
-    private static final Logger log = Logger.getLogger(SparqlGraph.class.getName());
-
-    final SparqlClient sparqlClient;
-
-    /**
-     * Constructs a Graph representing the default graph at the specified
-     * endpoint
-     */
-    public SparqlGraph(final String endpoint) {
-        sparqlClient = new SparqlClient(endpoint);
-    }
-
-    @Override
-    protected Iterator<Triple> performFilter(final BlankNodeOrIri filterSubject,
-            final Iri filterPredicate, final RdfTerm filterObject) {
-        try {
-            String query = createQuery(filterSubject, filterPredicate, filterObject);
-            final List<Map<String, RdfTerm>> sparqlResults = sparqlClient.queryResultSet(query);
-            //first to triples without bnode-conversion
-            //rawTriples contains the triples with the BNodes from the result set
-            final Collection<Triple> rawTriples = new ArrayList<>();
-            for (Map<String, RdfTerm> result : sparqlResults) {
-                rawTriples.add(new TripleImpl(filterSubject != null ? filterSubject : (BlankNodeOrIri) result.get("s"),
-                        filterPredicate != null ? filterPredicate : (Iri) result.get("p"),
-                        filterObject != null ? filterObject : result.get("o")));
-
-            }
-            //then bnode conversion
-            final Iterator<Triple> rawTriplesIter = rawTriples.iterator();
-            //this is basically just wokring around the lack of (named) nested functions
-            return (new Callable<Iterator<Triple>>() {
-
-                final Map<BlankNode, SparqlBNode> nodeMap = new HashMap<>();
-                final Set<ImmutableGraph> usedContext = new HashSet<>();
-
-                private RdfTerm useSparqlNode(RdfTerm node) throws IOException {
-                    if (node instanceof BlankNodeOrIri) {
-                        return useSparqlNode((BlankNodeOrIri) node);
-                    }
-                    return node;
-                }
-
-                private BlankNodeOrIri useSparqlNode(BlankNodeOrIri node) throws IOException {
-                    if (node instanceof BlankNode) {
-                        if (!nodeMap.containsKey(node)) {
-                            createBlankNodesForcontext((BlankNode) node);
-                        }
-                        if (!nodeMap.containsKey(node)) {
-                            throw new RuntimeException("no Bnode created");
-                        }
-                        return nodeMap.get(node);
-                    } else {
-                        return node;
-                    }
-                }
-
-                private void createBlankNodesForcontext(final BlankNode node) throws IOException {
-                    final Collection<Triple> context = getContext(node);
-                    final Set<BlankNode> rawNodes = new HashSet<>();
-                    for (Triple triple : context) {
-                        {
-                            final BlankNodeOrIri subject = triple.getSubject();
-                            if (subject instanceof BlankNode) {
-                                rawNodes.add((BlankNode) subject);
-                            }
-                        }
-                        {
-                            final RdfTerm object = triple.getObject();
-                            if (object instanceof BlankNode) {
-                                rawNodes.add((BlankNode) object);
-                            }
-                        }
-                    }
-                    final Set<SparqlBNode> createdSparqlNodes = new HashSet<>();
-                    //final Map<BlankNode, SparqlBNode> preliminaryNodes = new HashMap<>();
-                    for (BlankNode rawNode : rawNodes) {
-                        for (int i = 0; i < MAX_ISOMORPHIC_BNODES; i++) {
-                            SparqlBNode sparqlBNode = new SparqlBNode(rawNode, context, i);
-                            if (!createdSparqlNodes.contains(sparqlBNode)) {
-                                nodeMap.put(rawNode, sparqlBNode);
-                                createdSparqlNodes.add(sparqlBNode);
-                                break;
-                            }
-                        }
-                    }
-                }
-
-                private ImmutableGraph getContext(final BlankNode node) throws IOException {
-                    //we need to get the cntext of the BNode
-                    //if the filter was for (null, null, null) we have the whole
-                    //bnode context in the reuslt set, otherwise we need to get 
-                    //more triples from the endpoint,
-                    //let's first handle the easy case
-                    if ((filterSubject == null) && (filterPredicate == null)
-                            && (filterObject == null)) {
-                        return getContextInRaw(node);
-                    } else {
-                        final ImmutableGraph startContext = getContextInRaw(node);
-                        final Set<ImmutableGraph> expandedContexts = expandContext(startContext);
-                        //expand bnode context
-                        //note that there might be different contexts for 
-                        //a bnode as present in the current result set
-                        //in this case we just haveto make sure we don't 
-                        //pick the same context for different bnodes in the resultset
-                        ImmutableGraph result = null;
-                        for (ImmutableGraph expandedContext : expandedContexts) {
-                            if (!usedContext.contains(expandedContext)) {
-                                result = expandedContext;
-                                break;
-                            }
-                        }
-                        if (result == null) {
-                            log.warning("he underlying sparql graph seems to contain redundant triples, this might cause unexpected results");
-                            result = expandedContexts.iterator().next();
-                        } else {
-                            usedContext.add(result);
-                        }
-                        return result;
-                    }
-
-                }
-
-                private ImmutableGraph getContextInRaw(BlankNode node) {
-                    final Graph contextBuilder = new SimpleGraph();
-                    for (Triple rawTriple : rawTriples) {
-                        BlankNodeOrIri rawSubject = rawTriple.getSubject();
-                        RdfTerm rawObject = rawTriple.getObject();
-                        if (rawSubject.equals(node) || rawObject.equals(node)) {
-                            contextBuilder.add(rawTriple);
-                        }
-                    }
-                    return contextBuilder.getImmutableGraph();
-                }
-
-                @Override
-                public Iterator<Triple> call() throws Exception {
-                    return new Iterator<Triple>() {
-
-                        @Override
-                        public boolean hasNext() {
-                            return rawTriplesIter.hasNext();
-                        }
-
-                        @Override
-                        public Triple next() {
-                            try {
-                                Triple rawTriple = rawTriplesIter.next();
-                                return new TripleImpl(useSparqlNode(rawTriple.getSubject()),
-                                        rawTriple.getPredicate(),
-                                        useSparqlNode(rawTriple.getObject()));
-                            } catch (IOException ex) {
-                                throw new RuntimeException(ex);
-                            }
-                        }
-                    };
-                }
-
-                /**
-                 * returns all MSGs that are supergraphs of startContext
-                 *
-                 * @param startContext
-                 * @return
-                 */
-                private Set<ImmutableGraph> expandContext(Collection<Triple> startContext) throws IOException {
-
-                    final StringBuilder queryBuilder = new StringBuilder();
-                    queryBuilder.append("SELECT * WHERE {\n ");
-                    Map<BlankNode, String> bNodeVarNameMap = writeTriplePattern(queryBuilder, startContext);
-                    Set<BlankNode> bNodesInContext = bNodeVarNameMap.keySet();
-                    for (BlankNode bNode : bNodesInContext) {
-                        final String bNodeVarLabel = bNodeVarNameMap.get(bNode);
-                        //looking for outgoing properties of the bnode
-                        queryBuilder.append("OPTIONAL { ");
-                        queryBuilder.append('?');
-                        queryBuilder.append(bNodeVarLabel);
-                        queryBuilder.append(' ');
-                        queryBuilder.append("?po");
-                        queryBuilder.append(bNodeVarLabel);
-                        queryBuilder.append(" ?o");
-                        queryBuilder.append(bNodeVarLabel);
-                        queryBuilder.append(" } .\n");
-                        //looking for incoming properties of the bnode
-                        queryBuilder.append("OPTIONAL { ");
-                        queryBuilder.append("?s");
-                        queryBuilder.append(bNodeVarLabel);
-                        queryBuilder.append(' ');
-                        queryBuilder.append("?pi");
-                        queryBuilder.append(bNodeVarLabel);
-                        queryBuilder.append(" ?");
-                        queryBuilder.append(bNodeVarLabel);
-                        queryBuilder.append(" } .\n");
-                    }
-                    queryBuilder.append(" }");
-                    final List<Map<String, RdfTerm>> expansionQueryResults = sparqlClient.queryResultSet(queryBuilder.toString());
-                    Set<ImmutableGraph> expandedContexts = new HashSet<>();
-                    //the query results may or may be from disjoint supergraphs
-                    //we expand them all as if they are different which may lead
-                    //us to the same MSG multiple times
-                    RESULTS:
-                    for (Map<String, RdfTerm> expansionQueryResult : expansionQueryResults) {
-                        Collection<Triple> expandedContext = new HashSet<>();
-                        Map<BlankNode, BlankNode> newBNodesToOldBNodes = new HashMap<>();
-                        for (BlankNode oldBNode : bNodesInContext) {
-                            final String bNodeVarLabel = bNodeVarNameMap.get(oldBNode);
-                            final RdfTerm newNode = expansionQueryResult.get(bNodeVarLabel);
-                            if (!(newNode instanceof BlankNode)) {
-                                //this subgraph is't a match
-                                continue RESULTS;
-                            }
-                            newBNodesToOldBNodes.put((BlankNode) newNode, oldBNode);
-                        }
-                        expandedContext.addAll(startContext);
-                        boolean newBNodeIntroduced = false;
-                        boolean newTripleAdded = false;
-                        for (BlankNode oldBNode : bNodesInContext) {
-                            final String bNodeVarLabel = bNodeVarNameMap.get(oldBNode);
-                            {
-                                final Iri newPredicate = (Iri) expansionQueryResult.get("po" + bNodeVarLabel);
-                                if (newPredicate != null) {
-                                    RdfTerm newObject = expansionQueryResult.get("o" + bNodeVarLabel);
-                                    if (newObject instanceof BlankNode) {
-                                        if (newBNodesToOldBNodes.containsKey(newObject)) {
-                                            //point back to BNode in startContext
-                                            newObject = newBNodesToOldBNodes.get(newObject);
-                                        } else {
-                                            newBNodeIntroduced = true;
-                                        }
-                                    }
-                                    if (expandedContext.add(new TripleImpl(oldBNode, newPredicate, newObject))) {
-                                        newTripleAdded = true;
-                                    }
-                                }
-                            }
-                            {
-                                final Iri newPredicate = (Iri) expansionQueryResult.get("pi" + bNodeVarLabel);
-                                if (newPredicate != null) {
-                                    RdfTerm newSubject = expansionQueryResult.get("s" + bNodeVarLabel);
-                                    if (newSubject instanceof BlankNode) {
-                                        if (newBNodesToOldBNodes.containsKey(newSubject)) {
-                                            //point back to BNode in startContext
-                                            newSubject = newBNodesToOldBNodes.get(newSubject);
-                                        } else {
-                                            newBNodeIntroduced = true;
-                                        }
-                                    }
-                                    if (expandedContext.add(new TripleImpl((BlankNodeOrIri) newSubject, newPredicate, oldBNode))) {
-                                        newTripleAdded = true;
-                                    }
-                                }
-                            }
-                        }
-                        if (newBNodeIntroduced) {
-                            //we could be more efficient than this ans just expand the newly introduced bnodes
-                            expandedContexts.addAll(expandContext(expandedContext));
-                        } else {
-                            if (newTripleAdded) {
-                                //look for more results
-                                expandedContexts.addAll(expandContext(expandedContext));
-                                //expandedContexts.add(expandedContext);
-                            }
-                        }
-
-                    }
-                    if (expandedContexts.isEmpty()) {
-                        expandedContexts.add(new SimpleGraph(startContext).getImmutableGraph());
-                    }
-                    return expandedContexts;
-                }
-
-            }).call();
-        } catch (AlienBNodeException e) {
-            return new Iterator<Triple>() {
-
-                @Override
-                public boolean hasNext() {
-                    return false;
-                }
-
-                @Override
-                public Triple next() {
-                    throw new NoSuchElementException();
-                }
-            };
-        } catch (IOException ex) {
-            throw new RuntimeException(ex);
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    private String createQuery(final BlankNodeOrIri filterSubject, final Iri filterPredicate, final RdfTerm filterObject) {
-        final StringBuilder selectBuilder = new StringBuilder();
-        selectBuilder.append("SELECT ");
-        final StringBuilder whereBuilder = new StringBuilder();
-        whereBuilder.append("WHERE { ");
-        if (filterSubject == null) {
-            whereBuilder.append("?s");
-            selectBuilder.append("?s ");
-        } else {
-            if (filterSubject instanceof SparqlBNode) {
-                whereBuilder.append("?sn");
-            } else {
-                whereBuilder.append(asSparqlTerm(filterSubject));
-            }
-        }
-        whereBuilder.append(' ');
-        if (filterPredicate == null) {
-            whereBuilder.append("?p");
-            selectBuilder.append("?p ");
-        } else {
-            whereBuilder.append(asSparqlTerm(filterPredicate));
-        }
-        whereBuilder.append(' ');
-        if (filterObject == null) {
-            whereBuilder.append("?o");
-            selectBuilder.append("?o ");
-        } else {
-            if (filterObject instanceof SparqlBNode) {
-                whereBuilder.append("?on");
-            } else {
-                whereBuilder.append(asSparqlTerm(filterObject));
-            }
-        }
-        whereBuilder.append(" .\n");
-        if (filterSubject instanceof SparqlBNode) {
-            //expand bnode context
-            writeTriplePattern(whereBuilder, ((SparqlBNode) filterSubject).context, "sn");
-        }
-        
-        if (filterObject instanceof SparqlBNode) {
-            //expand bnode context
-            writeTriplePattern(whereBuilder, ((SparqlBNode) filterObject).context, "on");
-        }
-
-        whereBuilder.append(" }");
-        return selectBuilder.append(whereBuilder).toString();
-    }
-
-    @Override
-    protected int performSize() {
-        try {
-            return sparqlClient.queryResultSet("SELECT * WHERE { ?s ?p ?o}").size();
-        } catch (IOException ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    private String asSparqlTerm(Iri iri) {
-        return "<" + iri.getUnicodeString() + ">";
-    }
-
-    private String asSparqlTerm(Literal literal) {
-        //TODO langauge and datatype
-        return "\"" + literal.getLexicalForm() + "\"";
-    }
-
-    private String asSparqlTerm(BlankNode bnode) {
-        if (!(bnode instanceof SparqlBNode)) {
-            throw new AlienBNodeException();
-        }
-        //this requires adding additional clauses to the graph pattern
-        throw new RuntimeException("SparqlBNodes should have been handled earlier");
-    }
-
-    private String asSparqlTerm(BlankNodeOrIri term) {
-        if (term instanceof Iri) {
-            return asSparqlTerm((Iri) term);
-        } else {
-            return asSparqlTerm((BlankNode) term);
-        }
-    }
-
-    private String asSparqlTerm(RdfTerm term) {
-        if (term instanceof BlankNodeOrIri) {
-            return asSparqlTerm((BlankNodeOrIri) term);
-        } else {
-            return asSparqlTerm((Literal) term);
-        }
-    }
-
-
-    private Map<BlankNode, String> writeTriplePattern(StringBuilder queryBuilder, Collection<Triple> triples) {
-        return writeTriplePattern(queryBuilder, triples, null);
-    }
-        
-    private Map<BlankNode, String> writeTriplePattern(StringBuilder queryBuilder, Collection<Triple> triples, String varLabelForInternalBNodeId) {
-        final Collection<String> triplePatterns = new ArrayList<>();
-        int varCounter = 0;
-        final Map<BlankNode, String> bNodeVarNameMap = new HashMap<>();
-        for (Triple t : triples) {
-            final StringBuilder builder = new StringBuilder();
-            {
-                final BlankNodeOrIri s = t.getSubject();
-                String varName;
-                if (s instanceof BlankNode) {
-                    if (bNodeVarNameMap.containsKey(s)) {
-                        varName = bNodeVarNameMap.get(s);
-                    } else {
-                        varName = "v" + (varCounter++);
-                        bNodeVarNameMap.put((BlankNode) s, varName);
-                    }
-                    builder.append('?');
-                    builder.append(varName);
-                } else {
-                    if (s.equals(SparqlBNode.internalBNodeId)) {
-                        builder.append('?');
-                        builder.append(varLabelForInternalBNodeId);
-                    } else {
-                        builder.append(asSparqlTerm(s));
-                    }
-                    
-                }
-            }
-            builder.append(' ');
-            builder.append(asSparqlTerm(t.getPredicate()));
-            builder.append(' ');
-            {
-                final RdfTerm o = t.getObject();
-                String varName;
-                if (o instanceof BlankNode) {
-                    if (bNodeVarNameMap.containsKey(o)) {
-                        varName = bNodeVarNameMap.get(o);
-                    } else {
-                        varName = "v" + (varCounter++);
-                        bNodeVarNameMap.put((BlankNode) o, varName);
-                    }
-                    builder.append('?');
-                    builder.append(varName);
-                } else {
-                    if (o.equals(SparqlBNode.internalBNodeId)) {
-                        builder.append('?');
-                        builder.append(varLabelForInternalBNodeId);
-                    } else {
-                        builder.append(asSparqlTerm(o));
-                    }
-                }
-            }
-            builder.append('.');
-            triplePatterns.add(builder.toString());
-
-        }
-        for (String triplePattern : triplePatterns) {
-
-            queryBuilder.append(triplePattern);
-            queryBuilder.append('\n');
-        }
-        return bNodeVarNameMap;
-
-    }
-
-    private static class AlienBNodeException extends RuntimeException {
-
-        public AlienBNodeException() {
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java
new file mode 100644
index 0000000..9329c9b
--- /dev/null
+++ b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeCircleTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.commons.rdf.impl.sparql;
+
+import com.hp.hpl.jena.query.DatasetAccessor;
+import com.hp.hpl.jena.query.DatasetAccessorFactory;
+import java.io.IOException;
+import java.net.ServerSocket;
+import org.apache.jena.fuseki.EmbeddedFusekiServer;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import java.io.InputStream;
+import java.util.Iterator;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author reto
+ */
+public class BNodeCircleTest {
+
+    final static int serverPort = findFreePort();
+    static EmbeddedFusekiServer server;
+
+    @BeforeClass
+    public static void prepare() throws IOException {
+        final String serviceURI = "http://localhost:" + serverPort + "/ds/data";
+        final DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(serviceURI);
+        final InputStream in = BNodeCircleTest.class.getResourceAsStream("bnode-circle.ttl");
+        final Model m = ModelFactory.createDefaultModel();
+        String base = "http://example.org/";
+        m.read(in, base, "TURTLE");
+        server = EmbeddedFusekiServer.memTDB(serverPort, "/ds");//dataSet.getAbsolutePath());
+        server.start();
+        System.out.println("Started fuseki on port " + serverPort);
+        accessor.putModel(m);
+    }
+
+    @AfterClass
+    public static void cleanup() {
+        server.stop();
+    }
+
+    @Test
+    public void graphSize() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        Assert.assertEquals("Graph not of the exepected size", 2, graph.size());
+    }
+
+    
+    
+    @Test
+    public void nullFilter() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        final Iterator<Triple> iter = graph.filter(null, null, null);
+        Assert.assertTrue(iter.hasNext());
+        final Triple triple1 = iter.next();
+        final BlankNodeOrIri subject = triple1.getSubject();
+        final RdfTerm object = triple1.getObject();
+        Assert.assertTrue(subject instanceof BlankNode);
+        Assert.assertTrue(object instanceof BlankNode);
+        Assert.assertNotEquals(subject, object);
+        Assert.assertTrue(iter.hasNext());
+    }
+    
+    @Test
+    public void foafKnowsFilter() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        
+        final Iri foafKnows = new Iri("http://xmlns.com/foaf/0.1/knows");
+
+        final Iterator<Triple> iter = graph.filter(null, foafKnows, null);
+        Assert.assertTrue(iter.hasNext());
+        final Triple triple1 = iter.next();
+        final BlankNodeOrIri subject = triple1.getSubject();
+        final RdfTerm object = triple1.getObject();
+        Assert.assertTrue(subject instanceof BlankNode);
+        Assert.assertTrue(object instanceof BlankNode);
+        Assert.assertNotEquals(subject, object);
+        Assert.assertTrue(iter.hasNext());
+    }
+    
+
+    
+
+    public static int findFreePort() {
+        int port = 0;
+        try (ServerSocket server = new ServerSocket(0);) {
+            port = server.getLocalPort();
+        } catch (Exception e) {
+            throw new RuntimeException("unable to find a free port");
+        }
+        return port;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java
new file mode 100644
index 0000000..f0a4aff
--- /dev/null
+++ b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/BNodeTest.java
@@ -0,0 +1,139 @@
+/*
+ * 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.commons.rdf.impl.sparql;
+
+import com.hp.hpl.jena.query.DatasetAccessor;
+import com.hp.hpl.jena.query.DatasetAccessorFactory;
+import java.io.IOException;
+import java.net.ServerSocket;
+import org.apache.jena.fuseki.EmbeddedFusekiServer;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import java.io.InputStream;
+import java.util.Iterator;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author reto
+ */
+public class BNodeTest {
+
+    final static int serverPort = findFreePort();
+    static EmbeddedFusekiServer server;
+
+    @BeforeClass
+    public static void prepare() throws IOException {
+        final String serviceURI = "http://localhost:" + serverPort + "/ds/data";
+        final DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(serviceURI);
+        final InputStream in = BNodeTest.class.getResourceAsStream("simple-bnode.ttl");
+        final Model m = ModelFactory.createDefaultModel();
+        String base = "http://example.org/";
+        m.read(in, base, "TURTLE");
+        server = EmbeddedFusekiServer.memTDB(serverPort, "/ds");//dataSet.getAbsolutePath());
+        server.start();
+        System.out.println("Started fuseki on port " + serverPort);
+        accessor.putModel(m);
+    }
+
+    @AfterClass
+    public static void cleanup() {
+        server.stop();
+    }
+
+    @Test
+    public void graphSize() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        Assert.assertEquals("Graph not of the exepected size", 3, graph.size());
+    }
+
+    /* Filtering with a Bode that cannot be in graph
+    */
+    @Test
+    public void filterAlienBNode() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        
+        final BlankNode blankNode = new BlankNode();
+        final Iterator<Triple> iter = graph.filter(blankNode, null, null);
+        Assert.assertFalse(iter.hasNext());
+    }
+    
+    @Test
+    public void bNodeIdentity() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        
+        final Iri foafPerson = new Iri("http://xmlns.com/foaf/0.1/Person");
+        final Iri foafName = new Iri("http://xmlns.com/foaf/0.1/name");
+        final Iri foafKnows = new Iri("http://xmlns.com/foaf/0.1/knows");
+        final Iri rdfType = new Iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
+
+        final Iterator<Triple> iter = graph.filter(null, foafName, null);
+        Assert.assertTrue(iter.hasNext());
+        final BlankNodeOrIri namedThing = iter.next().getSubject();
+        Assert.assertTrue(namedThing instanceof BlankNode);
+        
+        final Iterator<Triple> iter2 = graph.filter(null, rdfType, foafPerson);
+        Assert.assertTrue(iter2.hasNext());
+        final BlankNodeOrIri person = iter2.next().getSubject();
+        Assert.assertTrue(person instanceof BlankNode);
+        Assert.assertEquals(namedThing, person);
+        
+        final Iterator<Triple> iter3 = graph.filter(null, foafKnows, null);
+        Assert.assertTrue(iter3.hasNext());
+        final RdfTerm knownThing = iter3.next().getObject();
+        Assert.assertTrue(knownThing instanceof BlankNode);
+        Assert.assertEquals(knownThing, person);
+        Assert.assertEquals(namedThing, knownThing);
+    }
+    
+    @Test
+    public void filter1() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        
+        final Iri foafPerson = new Iri("http://xmlns.com/foaf/0.1/Person");
+        final Iri foafName = new Iri("http://xmlns.com/foaf/0.1/name");
+        final Iri rdfType = new Iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
+
+        final Iterator<Triple> iter = graph.filter(null, foafName, null);
+        Assert.assertTrue(iter.hasNext());
+        final BlankNodeOrIri person = iter.next().getSubject();
+        Assert.assertTrue(person instanceof BlankNode);
+        
+        final Iterator<Triple> iter2 = graph.filter(person, rdfType, null);
+        Assert.assertTrue(iter2.hasNext());
+    }
+    
+
+    public static int findFreePort() {
+        int port = 0;
+        try (ServerSocket server = new ServerSocket(0);) {
+            port = server.getLocalPort();
+        } catch (Exception e) {
+            throw new RuntimeException("unable to find a free port");
+        }
+        return port;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java
new file mode 100644
index 0000000..6300281
--- /dev/null
+++ b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SimilarBNodes.java
@@ -0,0 +1,104 @@
+/*
+ * 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.commons.rdf.impl.sparql;
+
+import com.hp.hpl.jena.query.DatasetAccessor;
+import com.hp.hpl.jena.query.DatasetAccessorFactory;
+import java.io.IOException;
+import java.net.ServerSocket;
+import org.apache.jena.fuseki.EmbeddedFusekiServer;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import java.io.InputStream;
+import java.util.Iterator;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.Triple;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author reto
+ */
+public class SimilarBNodes {
+
+    final static int serverPort = findFreePort();
+    static EmbeddedFusekiServer server;
+
+    @BeforeClass
+    public static void prepare() throws IOException {
+        final String serviceURI = "http://localhost:" + serverPort + "/ds/data";
+        final DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(serviceURI);
+        final InputStream in = SimilarBNodes.class.getResourceAsStream("similar-bnodes.ttl");
+        final Model m = ModelFactory.createDefaultModel();
+        String base = "http://example.org/";
+        m.read(in, base, "TURTLE");
+        server = EmbeddedFusekiServer.memTDB(serverPort, "/ds");//dataSet.getAbsolutePath());
+        server.start();
+        System.out.println("Started fuseki on port " + serverPort);
+        accessor.putModel(m);
+    }
+
+    @AfterClass
+    public static void cleanup() {
+        server.stop();
+    }
+
+    @Test
+    public void graphSize() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        Assert.assertEquals("Graph not of the exepected size", 2, graph.size());
+    }
+
+    
+    
+    @Test
+    public void foafKnowsFilter() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        
+        final Iri foafKnows = new Iri("http://xmlns.com/foaf/0.1/knows");
+
+        final Iterator<Triple> iter = graph.filter(null, foafKnows, null);
+        Assert.assertTrue(iter.hasNext());
+        final Triple triple1 = iter.next();
+        final BlankNodeOrIri subject1 = triple1.getSubject();
+        Assert.assertTrue(subject1 instanceof BlankNode);
+        Assert.assertTrue(iter.hasNext());
+        final Triple triple2 = iter.next();
+        final BlankNodeOrIri subject2 = triple2.getSubject();
+        Assert.assertTrue(subject2 instanceof BlankNode);
+        Assert.assertNotEquals(subject1, subject2);
+    }
+    
+
+    
+
+    public static int findFreePort() {
+        int port = 0;
+        try (ServerSocket server = new ServerSocket(0);) {
+            port = server.getLocalPort();
+        } catch (Exception e) {
+            throw new RuntimeException("unable to find a free port");
+        }
+        return port;
+    }
+
+}


[2/7] clerezza-rdf-core git commit: CLEREZZA-982: moved files for new packages

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/LockingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/LockingIterator.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/LockingIterator.java
deleted file mode 100644
index 8f6945e..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/LockingIterator.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils;
-
-import java.util.Iterator;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.Triple;
-
-/**
- * Wrapps an iterator<Triple> reading entering a read-lock on every invocation
- * of hasNext and next
- * @author reto
- */
-class LockingIterator implements Iterator<Triple> {
-
-    private Iterator<Triple> base;
-    private Lock readLock;
-    private Lock writeLock;
-
-    public LockingIterator(Iterator<Triple> iterator, ReadWriteLock lock) {
-        base = iterator;
-        readLock = lock.readLock();
-        writeLock = lock.writeLock();
-    }
-
-    @Override
-    public boolean hasNext() {
-        readLock.lock();
-        try {
-            return base.hasNext();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public Triple next() {
-        readLock.lock();
-        try {
-            return base.next();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public void remove() {
-        writeLock.lock();
-        try {
-            base.remove();
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/PlainLiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/PlainLiteralImpl.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/PlainLiteralImpl.java
deleted file mode 100644
index dec30db..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/PlainLiteralImpl.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils;
-
-import java.io.Serializable;
-import org.apache.commons.rdf.Iri;
-
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
-
-/**
- *
- * @author reto
- */
-public class PlainLiteralImpl extends AbstractLiteral implements Literal, Serializable {
-
-    private String lexicalForm;
-    private Language language = null;
-
-    public PlainLiteralImpl(String value) {
-        if (value == null) {
-            throw new IllegalArgumentException("The literal string cannot be null");
-        }
-        this.lexicalForm = value;
-    }
-
-    public PlainLiteralImpl(String value, Language language) {
-        if (value == null) {
-            throw new IllegalArgumentException("The literal string cannot be null");
-        }
-        this.lexicalForm = value;
-        this.language = language;
-    }
-
-    @Override
-    public String getLexicalForm() {
-        return lexicalForm;
-    }
-
-    @Override
-    public Language getLanguage() {
-        return language;
-    }
-
-    @Override
-    public String toString() {
-        StringBuffer result = new StringBuffer();
-        result.append('\"').append(lexicalForm).append('\"');
-        if (language != null) {
-            result.append("@").append(language.toString());
-        }
-        return result.toString();
-    }
-
-    @Override
-    public Iri getDataType() {
-        return XSD_STRING;
-    }
-    private static final Iri XSD_STRING = new Iri("http://www.w3.org/2001/XMLSchema#string");
-    private static final int XSD_STRING_HASH = XSD_STRING.hashCode();
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/TripleImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/TripleImpl.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/TripleImpl.java
deleted file mode 100644
index ece7d55..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/TripleImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils;
-
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-
-/**
- *
- * @author reto
- */
-public class TripleImpl implements Triple {
-
-    private final BlankNodeOrIri subject;
-    private final Iri predicate;
-    private final RdfTerm object;
-
-    /**
-     * Creates a new <code>TripleImpl</code>.
-     *
-     * @param subject  the subject.
-     * @param predicate  the predicate.
-     * @param object  the object.
-     * @throws IllegalArgumentException  if an attribute is <code>null</code>.
-     */
-    public TripleImpl(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
-        if (subject == null) {
-            throw new IllegalArgumentException("Invalid subject: null");
-        } else if (predicate == null) {
-            throw new IllegalArgumentException("Invalid predicate: null");
-        } else if (object == null) {
-            throw new IllegalArgumentException("Invalid object: null");
-        }
-        this.subject = subject;
-        this.predicate = predicate;
-        this.object = object;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == null) {
-            return false;
-        }
-        if (!(obj instanceof Triple)) {
-            return false;
-        }
-        final Triple other = (Triple) obj;
-        if (!this.subject.equals(other.getSubject())) {
-            return false;
-        }
-        if (!this.predicate.equals(other.getPredicate())) {
-            return false;
-        }
-        if (!this.object.equals(other.getObject())) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        return (subject.hashCode() >> 1) ^ predicate.hashCode() ^ (object.hashCode() << 1);
-    }
-
-    @Override
-    public BlankNodeOrIri getSubject() {
-        return subject;
-    }
-
-    public Iri getPredicate() {
-        return predicate;
-    }
-
-    public RdfTerm getObject() {
-        return object;
-    }
-
-    @Override
-    public String toString() {
-        return subject + " " + predicate + " " + object + ".";
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/TypedLiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/TypedLiteralImpl.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/TypedLiteralImpl.java
deleted file mode 100644
index 4d3ff9d..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/TypedLiteralImpl.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils;
-
-import java.io.Serializable;
-
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
-
-/**
- *
- * @author reto
- */
-public class TypedLiteralImpl extends AbstractLiteral implements  Serializable {
-    private String lexicalForm;
-    private Iri dataType;
-    private int hashCode;
-
-    /**
-     * @param lexicalForm 
-     * @param dataType 
-     */
-    public TypedLiteralImpl(String lexicalForm, Iri dataType) {
-        this.lexicalForm = lexicalForm;
-        this.dataType = dataType;
-        this.hashCode = super.hashCode();
-    }
-    
-    public Iri getDataType() {
-        return dataType;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.clerezza.rdf.core.LiteralNode#getLexicalForm()
-     */
-    @Override
-    public String getLexicalForm() {
-        return lexicalForm;
-    }
-
-    @Override
-    public int hashCode() {
-        return hashCode;
-    }
-    
-
-    @Override
-    public String toString() {
-        StringBuffer result = new StringBuffer();
-        result.append('\"');
-        result.append(getLexicalForm());
-        result.append('\"');
-        result.append("^^");
-        result.append(getDataType());
-        return result.toString();
-    }
-
-    @Override
-    public Language getLanguage() {
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/WatchableGraphWrapper.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/WatchableGraphWrapper.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/WatchableGraphWrapper.java
deleted file mode 100644
index 76b9283..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/WatchableGraphWrapper.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * 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.commons.rdf.impl.utils;
-
-import java.lang.ref.WeakReference;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.WatchableGraph;
-import org.apache.commons.rdf.event.AddEvent;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphEvent;
-import org.apache.commons.rdf.event.GraphListener;
-import org.apache.commons.rdf.event.RemoveEvent;
-
-/**
- *
- * @author developer
- */
-public class WatchableGraphWrapper implements WatchableGraph {
-    
-    final Graph wrapped;
-
-    public WatchableGraphWrapper(Graph wrapped) {
-        this.wrapped = wrapped;
-    }
-    
-       
-    //all listeners
-    private final Set<ListenerConfiguration> listenerConfigs = Collections.synchronizedSet(
-            new HashSet<ListenerConfiguration>());
-    private DelayedNotificator delayedNotificator = new DelayedNotificator();
-
-    @Override
-    public Iterator<Triple> iterator() {
-        return filter(null, null, null);
-    }
-
-    @Override
-    public boolean contains(Object o) {
-        if (!(o instanceof Triple)) {
-            return false;
-        }
-        Triple t = (Triple) o;
-        return filter(t.getSubject(), t.getPredicate(), t.getObject()).hasNext();
-    }
-
-    @Override
-    public Iterator<Triple> filter(BlankNodeOrIri subject, Iri predicate,
-            RdfTerm object) {
-        final Iterator<Triple> baseIter = wrapped.filter(subject, predicate, object);
-        return new Iterator<Triple>() {
-
-            Triple currentTriple = null;
-
-            @Override
-            public boolean hasNext() {
-                return baseIter.hasNext();
-            }
-
-            @Override
-            public Triple next() {
-                currentTriple = baseIter.next();
-                return currentTriple;
-            }
-
-            @Override
-            public void remove() {
-                baseIter.remove();
-                dispatchEvent(new RemoveEvent(WatchableGraphWrapper.this, currentTriple));
-            }
-        };
-    }
-
-    @Override
-    public boolean add(Triple triple) {
-        boolean success = performAdd(triple);
-        if (success) {
-            dispatchEvent(new AddEvent(this, triple));
-        }
-        return success;
-    }
-
-    /**
-     * A subclass of <code>AbstractGraph</code> should override 
-     * this method instead of <code>add</code> for Graph event support to be
-     * added.
-     * 
-     * @param e The triple to be added to the triple collection
-     * @return
-     */
-    protected boolean performAdd(Triple e) {
-        return wrapped.add(e);
-    }
-
-    @Override
-    public boolean remove(Object o) {
-        Triple triple = (Triple) o;
-        boolean success = performRemove(triple);
-        if (success) {
-            dispatchEvent(new RemoveEvent(this, triple));
-        }
-        return success;
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c) {
-        boolean modified = false;
-        for (Iterator<? extends Object> it = c.iterator(); it.hasNext();) {
-            Object object = it.next();
-            if (remove(object)) {
-                modified = true;
-            }
-        }
-        return modified;
-    }
-
-    /**
-     * A subclass of <code>AbstractGraph</code> should override 
-     * this method instead of <code>remove</code> for ImmutableGraph event support to be
-     * added.
-     * 
-     * @param o The triple to be removed from the triple collection
-     * @return
-     */
-    protected boolean performRemove(Triple triple) {
-        Iterator<Triple> e = filter(null, null, null);
-        while (e.hasNext()) {
-            if (triple.equals(e.next())) {
-                e.remove();
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Dispatches a <code>GraphEvent</code> to all registered listeners for which
-     * the specified <code>Triple</code> matches the <code>FilterTriple</code>s
-     * of the listeners.
-     * 
-     * @param triple The Triple that was modified
-     * @param type The type of modification
-     */
-    protected void dispatchEvent(GraphEvent event) {
-        synchronized(listenerConfigs) {
-            Iterator<ListenerConfiguration> iter = listenerConfigs.iterator();
-            while (iter.hasNext()) {
-                ListenerConfiguration config = iter.next();
-                GraphListener registeredListener = config.getListener();
-                if (registeredListener == null) {
-                    iter.remove();
-                    continue;
-                }
-                if (config.getFilter().match(event.getTriple())) {
-                    delayedNotificator.sendEventToListener(registeredListener, event);
-                }
-            }
-        }
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter) {
-        addGraphListener(listener, filter, 0);
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter,
-            long delay) {
-        listenerConfigs.add(new ListenerConfiguration(listener, filter));
-        if (delay > 0) {
-            delayedNotificator.addDelayedListener(listener, delay);
-        }
-    }
-
-    @Override
-    public void removeGraphListener(GraphListener listener) {
-        synchronized(listenerConfigs) {
-            Iterator<ListenerConfiguration> iter = listenerConfigs.iterator();
-            while (iter.hasNext()) {
-                ListenerConfiguration listenerConfig = iter.next();
-                GraphListener registeredListener = listenerConfig.getListener();
-                if ((registeredListener == null) || (registeredListener.equals(listener))) {
-                    iter.remove();
-                }
-            }
-        }
-        delayedNotificator.removeDelayedListener(listener);
-    }
-
-    @Override
-    public ImmutableGraph getImmutableGraph() {
-        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-    }
-
-    @Override
-    public ReadWriteLock getLock() {
-        return wrapped.getLock();
-    }
-
-    @Override
-    public int size() {
-        return wrapped.size();
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return wrapped.isEmpty();
-    }
-
-    @Override
-    public Object[] toArray() {
-        return wrapped.toArray();
-    }
-
-    @Override
-    public <T> T[] toArray(T[] a) {
-        return wrapped.toArray(a);
-    }
-
-    @Override
-    public boolean containsAll(Collection<?> c) {
-        return wrapped.containsAll(c);
-    }
-
-    @Override
-    public boolean addAll(Collection<? extends Triple> c) {
-        return wrapped.addAll(c);
-    }
-
-    @Override
-    public boolean retainAll(Collection<?> c) {
-        return wrapped.retainAll(c);
-    }
-
-    @Override
-    public void clear() {
-        wrapped.clear();
-    }
-
-    private static class ListenerConfiguration {
-
-        private WeakReference<GraphListener> listenerRef;
-        private FilterTriple filter;
-
-        private ListenerConfiguration(GraphListener listener, FilterTriple filter) {
-            this.listenerRef = new WeakReference<GraphListener>(listener);
-            this.filter = filter;
-        }
-
-        /**
-         * @return the listener
-         */
-        GraphListener getListener() {
-            GraphListener listener = listenerRef.get();
-            return listener;
-        }
-
-        /**
-         * @return the filter
-         */
-        FilterTriple getFilter() {
-            return filter;
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/ReadLockDebug.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/ReadLockDebug.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/ReadLockDebug.java
deleted file mode 100644
index f2b93b8..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/ReadLockDebug.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.debug;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
-
-/**
- *
- * @author mir
- */
-public class ReadLockDebug extends ReadLock {
-
-    ReentrantReadWriteLockTracker lock;
-    StackTraceElement[] stackTrace;
-
-    ReadLock readLock;
-    public ReadLockDebug(ReentrantReadWriteLockTracker lock) {
-        super(lock);
-        this.lock = lock;
-        this.readLock = lock.realReadLock();
-    }
-
-    @Override
-    public void lock() {
-        readLock.lock();
-        lock.addLockedReadLock(this);
-        stackTrace = Thread.currentThread().getStackTrace();
-    }
-
-    @Override
-    public void lockInterruptibly() throws InterruptedException {
-        readLock.lockInterruptibly();
-    }
-
-    @Override
-    public Condition newCondition() {
-        return readLock.newCondition();
-    }
-
-    @Override
-    public String toString() {
-        return readLock.toString();
-    }
-
-    @Override
-    public boolean tryLock() {
-        return readLock.tryLock();
-    }
-
-    @Override
-    public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
-        return readLock.tryLock(timeout, unit);
-    }
-
-    @Override
-    public void unlock() {
-        readLock.unlock();
-        lock.removeReadLock(this);
-        stackTrace = null;
-    }
-
-    public StackTraceElement[] getStackTrace() {
-        return stackTrace;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
deleted file mode 100644
index 65abf32..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils.debug;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- *
- * @author mir
- */
-public class ReentrantReadWriteLockTracker extends ReentrantReadWriteLock {
-
-
-    private Set<ReadLockDebug> lockedReadLocks = Collections.synchronizedSet(new HashSet<ReadLockDebug>());
-    private final WriteLockDebug writeLock = new WriteLockDebug(this);
-    @Override
-    protected Thread getOwner() {
-        return super.getOwner();
-    }
-
-    @Override
-    protected Collection<Thread> getQueuedReaderThreads() {
-        return super.getQueuedReaderThreads();
-    }
-
-    @Override
-    protected Collection<Thread> getQueuedThreads() {
-        return super.getQueuedThreads();
-    }
-
-    @Override
-    protected Collection<Thread> getQueuedWriterThreads() {
-        return super.getQueuedWriterThreads();
-    }
-
-    @Override
-    public int getReadHoldCount() {
-        return super.getReadHoldCount();
-    }
-
-    @Override
-    public int getReadLockCount() {
-        return super.getReadLockCount();
-    }
-
-    @Override
-    public int getWaitQueueLength(Condition condition) {
-        return super.getWaitQueueLength(condition);
-    }
-
-    @Override
-    protected Collection<Thread> getWaitingThreads(Condition condition) {
-        return super.getWaitingThreads(condition);
-    }
-
-    @Override
-    public int getWriteHoldCount() {
-        return super.getWriteHoldCount();
-    }
-
-    @Override
-    public boolean hasWaiters(Condition condition) {
-        return super.hasWaiters(condition);
-    }
-
-    @Override
-    public boolean isWriteLocked() {
-        return super.isWriteLocked();
-    }
-
-    @Override
-    public boolean isWriteLockedByCurrentThread() {
-        return super.isWriteLockedByCurrentThread();
-    }
-
-    @Override
-    public ReadLock readLock() {
-        return new ReadLockDebug(this);
-    }
-
-    ReadLock realReadLock() {
-        return super.readLock();
-    }
-
-    WriteLock realWriteLock() {
-        return super.writeLock();
-    }
-
-    @Override
-    public String toString() {
-        return super.toString();
-    }
-
-    @Override
-    public WriteLockDebug writeLock() {
-        return writeLock;
-    }
-
-    void addLockedReadLock(ReadLockDebug lock) {
-        lockedReadLocks.add(lock);
-    }
-
-    void removeReadLock(ReadLockDebug lock) {
-        lockedReadLocks.remove(lock);
-    }
-
-    public Set<ReadLockDebug> getLockedReadLocks() {
-        return lockedReadLocks;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/WriteLockDebug.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/WriteLockDebug.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/WriteLockDebug.java
deleted file mode 100644
index 0231331..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/debug/WriteLockDebug.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.debug;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
-
-/**
- *
- * @author mir
- */
-public class WriteLockDebug extends WriteLock {
-
-    private ReentrantReadWriteLockTracker lock;
-    private WriteLock writeLock;
-    private StackTraceElement[] stackTrace;
-
-    public WriteLockDebug(ReentrantReadWriteLockTracker lock) {
-        super(lock);
-        this.lock = lock;
-        this.writeLock = lock.realWriteLock();
-    }
-
-    @Override
-    public int getHoldCount() {
-        return writeLock.getHoldCount();
-    }
-
-    @Override
-    public boolean isHeldByCurrentThread() {
-        return writeLock.isHeldByCurrentThread();
-    }
-
-    @Override
-    public void lock() {
-        writeLock.lock();
-        stackTrace = Thread.currentThread().getStackTrace();
-    }
-
-    @Override
-    public void lockInterruptibly() throws InterruptedException {
-        writeLock.lockInterruptibly();
-    }
-
-    @Override
-    public Condition newCondition() {
-        return writeLock.newCondition();
-    }
-
-    @Override
-    public boolean tryLock() {
-        return writeLock.tryLock();
-    }
-
-    @Override
-    public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
-        return writeLock.tryLock(timeout, unit);
-    }
-
-    @Override
-    public void unlock() {
-        writeLock.unlock();
-        stackTrace = null;
-    }
-
-    public StackTraceElement[] getStackTrace() {
-        return stackTrace;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphMatcher.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
deleted file mode 100644
index b7e2500..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
-
-/**
- * @author reto
- * 
- */
-public class GraphMatcher {
-
-
-    private final static Logger log = Logger.getLogger(GraphMatcher.class.getName());
-
-    /**
-     * get a mapping from g1 to g2 or null if the graphs are not isomorphic. The
-     * returned map maps each <code>BNode</code>s from g1 to one
-     * of g2. If the graphs are ground graphs the method return an empty map if
-     * the ImmutableGraph are equals and null otherwise.
-     * <p/>
-     * NOTE: This method does not returned mapping from blank nodes to grounded
-     * nodes, a bnode in g1 is not a vraiable that may match any node, but must
-     * match a bnode in g2.
-     * <p/>
-     *
-     * On the algorithm:<br/>
-     * - In a first step it checked if every grounded triple in g1 matches one
-     * in g2<br/>
-     * - [optional] blank node blind matching</br>
-     * - in a map mbng1 bnode of g1 is mapped to a set of of its
-     * properties and inverse properties, this is the predicate and the object
-     * or subject respectively, analoguosly in mbgn2 every bnode of g2<br/>
-     * - based on the incoming and outgoing properties a hash is calculated for
-     * each bnode, in the first step when calculating the hash  aconstant value
-     * is taken for the bnodes that might be subject or object in the (inverse properties)
-     * - hash-classes:
-     * 
-     * @param g1
-     * @param g2
-     * @return a Set of NodePairs
-     */
-    public static Map<BlankNode, BlankNode> getValidMapping(Graph og1, Graph og2) {
-        Graph g1 = new SimpleMGraph(og1);
-        Graph g2 = new SimpleMGraph(og2);
-        if (!Utils.removeGrounded(g1,g2)) {
-            return null;
-        }
-        final HashMatching hashMatching;
-        try {
-            hashMatching = new HashMatching(g1, g2);
-        } catch (GraphNotIsomorphicException ex) {
-            return null;
-        }
-        Map<BlankNode, BlankNode> matchings = hashMatching.getMatchings();
-        if (g1.size() > 0) {
-            //start trial an error matching
-            //TODO (CLEREZZA-81) at least in the situation where one matching
-            //group is big (approx > 5) we should switch back to hash-based matching
-            //after a first guessed matching, rather than try all permutations
-            Map<BlankNode, BlankNode> remainingMappings = trialAndErrorMatching(g1, g2, hashMatching.getMatchingGroups());
-            if (remainingMappings == null) {
-                return null;
-            } else {
-                matchings.putAll(remainingMappings);
-            }
-        }
-        return matchings;
-    }
-
-    private static Map<BlankNode, BlankNode> trialAndErrorMatching(Graph g1, Graph g2,
-            Map<Set<BlankNode>, Set<BlankNode>> matchingGroups) {
-        if (log.isLoggable(Level.FINE)) {
-            Set<BlankNode> bn1  = Utils.getBNodes(g1);
-            log.log(Level.FINE,"doing trial and error matching for {0}"+" bnodes, "+"in graphs of size: {1}.", new Object[]{bn1.size(), g1.size()});
-        }
-        Iterator<Map<BlankNode, BlankNode>> mappingIter
-                = GroupMappingIterator.create(matchingGroups);
-        while (mappingIter.hasNext()) {
-            Map<BlankNode, BlankNode> map = mappingIter.next();
-            if (checkMapping(g1, g2, map)) {
-                return map;
-            }
-        }
-        return null;
-    }
-
-    private static boolean checkMapping(Graph g1, Graph g2, Map<BlankNode, BlankNode> map) {
-        for (Triple triple : g1) {
-            if (!g2.contains(map(triple, map))) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    private static Triple map(Triple triple, Map<BlankNode, BlankNode> map) {
-        final BlankNodeOrIri oSubject = triple.getSubject();
-
-        BlankNodeOrIri subject = oSubject instanceof BlankNode ?
-            map.get((BlankNode)oSubject) : oSubject;
-
-        RdfTerm oObject = triple.getObject();
-        RdfTerm object = oObject instanceof BlankNode ?
-            map.get((BlankNode)oObject) : oObject;
-        return new TripleImpl(subject, triple.getPredicate(), object);
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
deleted file mode 100644
index 42de52e..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-/**
- *
- * @author reto
- */
-class GraphNotIsomorphicException extends Exception {
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
deleted file mode 100644
index f79bd2a..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- *  Copyright 2010 reto.
- * 
- *  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.
- *  under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * Iterates over all mappings from each element of every Set<T> to each
- * elemenent of their corresponding Set<U>.
- *
- * @author reto
- */
-class GroupMappingIterator<T,U> implements Iterator<Map<T, U>> {
-
-    private Iterator<Map<T, U>> firstPartIter;
-    private Map<T, U> currentFirstPart;
-    final private Map<Set<T>, Set<U>> restMap;
-    private Iterator<Map<T, U>> currentRestPartIter;
-
-    static <T,U> Iterator<Map<T, U>> create(Map<Set<T>, Set<U>> matchingGroups) {
-        if (matchingGroups.size() > 1) {
-            return new GroupMappingIterator<T, U>(matchingGroups);
-        } else {
-            if (matchingGroups.size() == 0) {
-                return new ArrayList<Map<T, U>>(0).iterator();
-            }
-            Map.Entry<Set<T>, Set<U>> entry = matchingGroups.entrySet().iterator().next();
-            return new MappingIterator<T,U>(entry.getKey(),
-                        entry.getValue());
-        }
-    }
-
-    private GroupMappingIterator(Map<Set<T>, Set<U>> matchingGroups) {
-        if (matchingGroups.size() == 0) {
-            throw new IllegalArgumentException("matchingGroups must not be empty");
-        }
-        restMap = new HashMap<Set<T>, Set<U>>();
-        boolean first = true;
-        for (Map.Entry<Set<T>, Set<U>> entry : matchingGroups.entrySet()) {
-            if (first) {
-                firstPartIter = new MappingIterator<T,U>(entry.getKey(),
-                        entry.getValue());
-                first = false;
-            } else {
-                restMap.put(entry.getKey(), entry.getValue());
-            }
-        }
-        currentRestPartIter = create(restMap);
-        currentFirstPart = firstPartIter.next();
-    }
-
-    @Override
-    public boolean hasNext() {
-        return firstPartIter.hasNext() || currentRestPartIter.hasNext();
-    }
-
-    @Override
-    public Map<T, U> next() {
-        Map<T, U> restPart;
-        if (currentRestPartIter.hasNext()) {
-            restPart = currentRestPartIter.next();
-        } else {
-            if (firstPartIter.hasNext()) {
-                currentFirstPart = firstPartIter.next();
-                currentRestPartIter = create(restMap);
-                restPart = currentRestPartIter.next();
-            } else {
-                throw new NoSuchElementException();
-            }
-        }
-        Map<T, U> result = new HashMap<T, U>(restPart);
-        result.putAll(currentFirstPart);
-        return result;
-    }
-
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/HashMatching.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/HashMatching.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/HashMatching.java
deleted file mode 100644
index ae419f6..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/HashMatching.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-
-import org.apache.commons.rdf.impl.utils.graphmatching.collections.IntHashMap;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.commons.rdf.impl.utils.graphmatching.collections.IntIterator;
-
-/**
- *
- * @author reto
- */
-public class HashMatching {
-
-    private Map<BlankNode, BlankNode> matchings = new HashMap<BlankNode, BlankNode>();
-    private Map<Set<BlankNode>, Set<BlankNode>> matchingGroups;
-
-    /**
-     * tc1 and tc2 will be modified: the triples containing no unmatched bnode
-     * will be removed
-     *
-     * @param tc1
-     * @param tc2
-     * @throws GraphNotIsomorphicException
-     */
-    HashMatching(Graph tc1, Graph tc2) throws GraphNotIsomorphicException {
-        int foundMatchings = 0;
-        int foundMatchingGroups = 0;
-        Map<BlankNode, Integer> bNodeHashMap = new HashMap<BlankNode, Integer>();
-        while (true) {
-            bNodeHashMap = matchByHashes(tc1, tc2, bNodeHashMap);
-            if (bNodeHashMap == null) {
-                throw new GraphNotIsomorphicException();
-            }
-            if (matchings.size() == foundMatchings) {
-                if (!(matchingGroups.size() > foundMatchingGroups)) {
-                    break;
-                }
-            }
-            foundMatchings = matchings.size();
-            foundMatchingGroups = matchingGroups.size();
-        }
-    }
-
-    /**
-     *
-     * @return a map containing set of which each bnodes mappes one of the other set
-     */
-    public Map<Set<BlankNode>, Set<BlankNode>> getMatchingGroups() {
-        return matchingGroups;
-    }
-
-    public Map<BlankNode, BlankNode> getMatchings() {
-        return matchings;
-    }
-
-    
-    private static IntHashMap<Set<BlankNode>> getHashNodes(Map<BlankNode,
-            Set<Property>> bNodePropMap, Map<BlankNode, Integer> bNodeHashMap) {
-        IntHashMap<Set<BlankNode>> result = new IntHashMap<Set<BlankNode>>();
-        for (Map.Entry<BlankNode, Set<Property>> entry : bNodePropMap.entrySet()) {
-            int hash = computeHash(entry.getValue(), bNodeHashMap);
-            Set<BlankNode> bNodeSet = result.get(hash);
-            if (bNodeSet == null) {
-                bNodeSet = new HashSet<BlankNode>();
-                result.put(hash,bNodeSet);
-            }
-            bNodeSet.add(entry.getKey());
-        }
-        return result;
-    }
-    /*
-     * returns a Map from bnodes to hash that can be used for future
-     * refinements, this could be separate for each ImmutableGraph.
-     *
-     * triples no longer containing an unmatched bnodes ae removed.
-     *
-     * Note that the matched node are not guaranteed to be equals, but only to
-     * be the correct if the graphs are isomorphic.
-     */
-    private Map<BlankNode, Integer> matchByHashes(Graph g1, Graph g2,
-            Map<BlankNode, Integer> bNodeHashMap) {
-        Map<BlankNode, Set<Property>> bNodePropMap1  = getBNodePropMap(g1);
-        Map<BlankNode, Set<Property>> bNodePropMap2  = getBNodePropMap(g2);
-        IntHashMap<Set<BlankNode>> hashNodeMap1 = getHashNodes(bNodePropMap1, bNodeHashMap);
-        IntHashMap<Set<BlankNode>> hashNodeMap2 = getHashNodes(bNodePropMap2, bNodeHashMap);
-        if (!hashNodeMap1.keySet().equals(hashNodeMap2.keySet())) {
-            return null;
-        }
-
-        matchingGroups = new HashMap<Set<BlankNode>, Set<BlankNode>>();
-        IntIterator hashIter = hashNodeMap1.keySet().intIterator();
-        while (hashIter.hasNext()) {
-            int hash = hashIter.next();
-            Set<BlankNode> nodes1 = hashNodeMap1.get(hash);
-            Set<BlankNode> nodes2 = hashNodeMap2.get(hash);
-            if (nodes1.size() != nodes2.size()) {
-                return null;
-            }
-            if (nodes1.size() != 1) {
-                matchingGroups.put(nodes1, nodes2);
-                continue;
-            }
-            final BlankNode bNode1 = nodes1.iterator().next();
-            final BlankNode bNode2 = nodes2.iterator().next();
-            matchings.put(bNode1,bNode2);
-            //in the graphs replace node occurences with grounded node,
-            BlankNodeOrIri mappedNode = new MappedNode(bNode1, bNode2);
-            replaceNode(g1,bNode1, mappedNode);
-            replaceNode(g2, bNode2, mappedNode);
-            //remove grounded triples
-            if (!Utils.removeGrounded(g1,g2)) {
-                return null;
-            }
-        }
-        Map<BlankNode, Integer> result = new HashMap<BlankNode, Integer>();
-        addInverted(result, hashNodeMap1);
-        addInverted(result, hashNodeMap2);
-        return result;
-    }
-    private static int computeHash(Set<Property> propertySet, Map<BlankNode, Integer> bNodeHashMap) {
-        int result = 0;
-        for (Property property : propertySet) {
-            result += property.hashCode(bNodeHashMap);
-        }
-        return result;
-    }
-    private static Map<BlankNode, Set<Property>> getBNodePropMap(Graph g) {
-        Set<BlankNode> bNodes = Utils.getBNodes(g);
-        Map<BlankNode, Set<Property>> result = new HashMap<BlankNode, Set<Property>>();
-        for (BlankNode bNode : bNodes) {
-            result.put(bNode, getProperties(bNode, g));
-        }
-        return result;
-    }
-    private static Set<Property> getProperties(BlankNode bNode, Graph g) {
-        Set<Property> result = new HashSet<Property>();
-        Iterator<Triple> ti = g.filter(bNode, null, null);
-        while (ti.hasNext()) {
-            Triple triple = ti.next();
-            result.add(new ForwardProperty(triple.getPredicate(), triple.getObject()));
-        }
-        ti = g.filter(null, null, bNode);
-        while (ti.hasNext()) {
-            Triple triple = ti.next();
-            result.add(new BackwardProperty(triple.getSubject(), triple.getPredicate()));
-        }
-        return result;
-    }
-    private static int nodeHash(RdfTerm resource, Map<BlankNode, Integer> bNodeHashMap) {
-        if (resource instanceof BlankNode) {
-            Integer mapValue = bNodeHashMap.get((BlankNode)resource);
-            if (mapValue == null) {
-                return 0;
-            } else {
-                return mapValue;
-            }
-        } else {
-            return resource.hashCode();
-        }
-    }
-    private static void replaceNode(Graph graph, BlankNode bNode, BlankNodeOrIri replacementNode) {
-        Set<Triple> triplesToRemove = new HashSet<Triple>();
-        for (Triple triple : graph) {
-            Triple replacementTriple = getReplacement(triple, bNode, replacementNode);
-            if (replacementTriple != null) {
-                triplesToRemove.add(triple);
-                graph.add(replacementTriple);
-            }
-        }
-        graph.removeAll(triplesToRemove);
-    }
-    private static Triple getReplacement(Triple triple, BlankNode bNode, BlankNodeOrIri replacementNode) {
-        if (triple.getSubject().equals(bNode)) {
-            if (triple.getObject().equals(bNode)) {
-                return new TripleImpl(replacementNode, triple.getPredicate(), replacementNode);
-            } else {
-                return new TripleImpl(replacementNode, triple.getPredicate(), triple.getObject());
-            }
-        } else {
-            if (triple.getObject().equals(bNode)) {
-                return new TripleImpl(triple.getSubject(), triple.getPredicate(), replacementNode);
-            } else {
-                return null;
-            }
-        }
-    }
-    private static void addInverted(Map<BlankNode, Integer> result, IntHashMap<Set<BlankNode>> hashNodeMap) {
-        for (int hash : hashNodeMap.keySet()) {
-            Set<BlankNode> bNodes = hashNodeMap.get(hash);
-            for (BlankNode bNode : bNodes) {
-                result.put(bNode, hash);
-            }
-        }
-    }
-    
-    private static class BackwardProperty implements Property {
-        private BlankNodeOrIri subject;
-        private Iri predicate;
-    
-        public BackwardProperty(BlankNodeOrIri subject, Iri predicate) {
-            this.subject = subject;
-            this.predicate = predicate;
-        }
-    
-        @Override
-        public int hashCode(Map<BlankNode, Integer> bNodeHashMap) {
-            return  0xFF ^ predicate.hashCode() ^ nodeHash(subject, bNodeHashMap);
-        }
-    
-    }
-    private static class ForwardProperty implements Property {
-        private Iri predicate;
-        private RdfTerm object;
-    
-        public ForwardProperty(Iri predicate, RdfTerm object) {
-            this.predicate = predicate;
-            this.object = object;
-        }
-    
-        @Override
-        public int hashCode(Map<BlankNode, Integer> bNodeHashMap) {
-            return predicate.hashCode() ^ nodeHash(object, bNodeHashMap);
-        }
-    }
-    private static class MappedNode implements BlankNodeOrIri {
-        private BlankNode bNode1, bNode2;
-    
-        public MappedNode(BlankNode bNode1, BlankNode bNode2) {
-            this.bNode1 = bNode1;
-            this.bNode2 = bNode2;
-        }
-        
-    }
-    private static interface Property {
-        public int hashCode(Map<BlankNode, Integer> bNodeHashMap);
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/MappingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/MappingIterator.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/MappingIterator.java
deleted file mode 100644
index dea95b5..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/MappingIterator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-/*
- * 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.
- */
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * An iterator over all possible mapping beetween the elemnets of two sets of
- * the same size, each mapping maps each element from set1 to a disctinct one of
- * set2.
- *
- *
- *
- * @author reto
- */
-class MappingIterator<T,U> implements Iterator<Map<T, U>> {
-
-    private List<T> list1;
-    private Iterator<List<U>> permutationList2Iterator;
-
-
-    public MappingIterator(Set<T> set1, Set<U> set2) {
-        if (set1.size() != set2.size()) {
-            throw new IllegalArgumentException();
-        }
-        this.list1 = new ArrayList<T>(set1);
-        permutationList2Iterator = new PermutationIterator<U>(
-                new ArrayList<U>(set2));
-    }
-
-    @Override
-    public boolean hasNext() {
-        return permutationList2Iterator.hasNext();
-    }
-
-    @Override
-    public Map<T, U> next() {
-        List<U> list2 = permutationList2Iterator.next();
-        Map<T, U> result = new HashMap<T, U>(list1.size());
-        for (int i = 0; i < list1.size(); i++) {
-            result.put(list1.get(i), list2.get(i));
-        }
-        return result;
-    }
-
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/PermutationIterator.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
deleted file mode 100644
index 6b6fa07..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching;
-
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- *
- * An Iterator over all permuations of a list.
- *
- * @author reto
- */
-class PermutationIterator<T> implements Iterator<List<T>> {
-
-    private Iterator<List<T>> restIterator;
-    private List<T> list;
-    private List<T> next;
-    int posInList = 0; //the position of the last element of next returned list
-    //with list, this is the one excluded from restIterator
-
-    PermutationIterator(List<T> list) {
-        this.list = Collections.unmodifiableList(list);
-        if (list.size() > 1) {
-            createRestList();
-        }
-        prepareNext();
-    }
-
-    @Override
-    public boolean hasNext() {
-        return next != null;
-    }
-
-    @Override
-    public List<T> next() {
-        List<T> result = next;
-        if (result == null) {
-            throw new NoSuchElementException();
-        }
-        prepareNext();
-        return result;
-    }
-
-    @Override
-    public void remove() {
-        throw new UnsupportedOperationException("Not supported");
-    }
-
-    private void createRestList() {
-        List<T> restList = new ArrayList<T>(list);
-        restList.remove(posInList);
-        restIterator = new PermutationIterator<T>(restList);
-    }
-
-    private void prepareNext() {
-        next = getNext();
-        
-    }
-    private List<T> getNext() {
-        if (list.size() == 0) {
-            return null;
-        }
-        if (list.size() == 1) {
-            if (posInList++ == 0) {
-                return new ArrayList<T>(list);
-            } else {
-                return null;
-            }
-        } else {
-            if (!restIterator.hasNext()) {
-                if (posInList < (list.size()-1)) {
-                    posInList++;
-                    createRestList();
-                } else {
-                    return null;
-                }
-            }
-            List<T> result = restIterator.next();
-            result.add(list.get(posInList));
-            return result;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/Utils.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/Utils.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/Utils.java
deleted file mode 100644
index 25a7a4b..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/Utils.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.commons.rdf.impl.utils.graphmatching;
-/*
- *
- * 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.
- *
-*/
-
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Triple;
-
-public class Utils {
-
-    static Set<BlankNode> getBNodes(Collection<Triple> s) {
-        Set<BlankNode> result = new HashSet<BlankNode>();
-        for (Triple triple : s) {
-            if (triple.getSubject() instanceof BlankNode) {
-                result.add((BlankNode) triple.getSubject());
-            }
-            if (triple.getObject() instanceof BlankNode) {
-                result.add((BlankNode) triple.getObject());
-            }
-        }
-        return result;
-    }
-
-    /**
-     * removes the common grounded triples from s1 and s2. returns false if
-     * a grounded triple is not in both sets, true otherwise
-     */
-    static boolean removeGrounded(Collection<Triple> s1, Collection<Triple> s2) {
-        Iterator<Triple> triplesIter = s1.iterator();
-        while (triplesIter.hasNext()) {
-            Triple triple = triplesIter.next();
-            if (!isGrounded(triple)) {
-                continue;
-            }
-            if (!s2.remove(triple)) {
-                return false;
-            }
-            triplesIter.remove();
-        }
-        //for efficiency we might skip this (redefine method)
-        for (Triple triple : s2) {
-            if (isGrounded(triple)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    private static boolean isGrounded(Triple triple) {
-        if (triple.getSubject() instanceof BlankNode) {
-            return false;
-        }
-        if (triple.getObject() instanceof BlankNode) {
-            return false;
-        }
-        return true;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
deleted file mode 100644
index 922ae47..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright 2002-2004 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.
- */
-
-/*
- * Note: originally released under the GNU LGPL v2.1, 
- * but rereleased by the original author under the ASF license (above).
- */
-
-package org.apache.commons.rdf.impl.utils.graphmatching.collections;
-
-
-
-/**
- * <p>A hash map that uses primitive ints for the key rather than objects.</p>
- *
- * <p>Note that this class is for internal optimization purposes only, and may
- * not be supported in future releases of Jakarta Commons Lang.  Utilities of
- * this sort may be included in future releases of Jakarta Commons Collections.</p>
- *
- * @author Justin Couch
- * @author Alex Chaffee (alex@apache.org)
- * @author Stephen Colebourne
- * @since 2.0
- * @version $Revision: 1.2 $
- * @see java.util.HashMap
- */
-public class IntHashMap<T> {
-
-
-    private IntSet keySet = new IntHashSet();
-
-    /**
-     * The hash table data.
-     */
-    private transient Entry<T> table[];
-
-    /**
-     * The total number of entries in the hash table.
-     */
-    private transient int count;
-
-    /**
-     * The table is rehashed when its size exceeds this threshold.  (The
-     * value of this field is (int)(capacity * loadFactor).)
-     *
-     * @serial
-     */
-    private int threshold;
-
-    /**
-     * The load factor for the hashtable.
-     *
-     * @serial
-     */
-    private float loadFactor;
-
-    /**
-     * <p>Innerclass that acts as a datastructure to create a new entry in the
-     * table.</p>
-     */
-    private static class Entry<T> {
-        int hash;
-        int key;
-        T value;
-        Entry<T> next;
-
-        /**
-         * <p>Create a new entry with the given values.</p>
-         *
-         * @param hash The code used to hash the object with
-         * @param key The key used to enter this in the table
-         * @param value The value for this key
-         * @param next A reference to the next entry in the table
-         */
-        protected Entry(int hash, int key, T value, Entry<T> next) {
-            this.hash = hash;
-            this.key = key;
-            this.value = value;
-            this.next = next;
-        }
-    }
-
-    /**
-     * <p>Constructs a new, empty hashtable with a default capacity and load
-     * factor, which is <code>20</code> and <code>0.75</code> respectively.</p>
-     */
-    public IntHashMap() {
-        this(20, 0.75f);
-    }
-
-    /**
-     * <p>Constructs a new, empty hashtable with the specified initial capacity
-     * and default load factor, which is <code>0.75</code>.</p>
-     *
-     * @param  initialCapacity the initial capacity of the hashtable.
-     * @throws IllegalArgumentException if the initial capacity is less
-     *   than zero.
-     */
-    public IntHashMap(int initialCapacity) {
-        this(initialCapacity, 0.75f);
-    }
-
-    /**
-     * <p>Constructs a new, empty hashtable with the specified initial
-     * capacity and the specified load factor.</p>
-     *
-     * @param initialCapacity the initial capacity of the hashtable.
-     * @param loadFactor the load factor of the hashtable.
-     * @throws IllegalArgumentException  if the initial capacity is less
-     *             than zero, or if the load factor is nonpositive.
-     */
-    public IntHashMap(int initialCapacity, float loadFactor) {
-        super();
-        if (initialCapacity < 0) {
-            throw new IllegalArgumentException("Illegal Capacity: " + initialCapacity);
-        }
-        if (loadFactor <= 0) {
-            throw new IllegalArgumentException("Illegal Load: " + loadFactor);
-        }
-        if (initialCapacity == 0) {
-            initialCapacity = 1;
-        }
-
-        this.loadFactor = loadFactor;
-        table = new Entry[initialCapacity];
-        threshold = (int) (initialCapacity * loadFactor);
-    }
-
-    /**
-     * <p>Returns the number of keys in this hashtable.</p>
-     *
-     * @return  the number of keys in this hashtable.
-     */
-    public int size() {
-        return count;
-    }
-
-    /**
-     * <p>Tests if this hashtable maps no keys to values.</p>
-     *
-     * @return  <code>true</code> if this hashtable maps no keys to values;
-     *          <code>false</code> otherwise.
-     */
-    public boolean isEmpty() {
-        return count == 0;
-    }
-
-    /**
-     * <p>Tests if some key maps into the specified value in this hashtable.
-     * This operation is more expensive than the <code>containsKey</code>
-     * method.</p>
-     *
-     * <p>Note that this method is identical in functionality to containsValue,
-     * (which is part of the Map interface in the collections framework).</p>
-     *
-     * @param      value   a value to search for.
-     * @return     <code>true</code> if and only if some key maps to the
-     *             <code>value</code> argument in this hashtable as
-     *             determined by the <tt>equals</tt> method;
-     *             <code>false</code> otherwise.
-     * @throws  NullPointerException  if the value is <code>null</code>.
-     * @see        #containsKey(int)
-     * @see        #containsValue(Object)
-     * @see        java.util.Map
-     */
-    public boolean contains(Object value) {
-        if (value == null) {
-            throw new NullPointerException();
-        }
-
-        Entry tab[] = table;
-        for (int i = tab.length; i-- > 0;) {
-            for (Entry e = tab[i]; e != null; e = e.next) {
-                if (e.value.equals(value)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
-     * <p>Returns <code>true</code> if this HashMap maps one or more keys
-     * to this value.</p>
-     *
-     * <p>Note that this method is identical in functionality to contains
-     * (which predates the Map interface).</p>
-     *
-     * @param value value whose presence in this HashMap is to be tested.
-     * @see    java.util.Map
-     * @since JDK1.2
-     */
-    public boolean containsValue(Object value) {
-        return contains(value);
-    }
-
-    /**
-     * <p>Tests if the specified object is a key in this hashtable.</p>
-     *
-     * @param  key  possible key.
-     * @return <code>true</code> if and only if the specified object is a
-     *    key in this hashtable, as determined by the <tt>equals</tt>
-     *    method; <code>false</code> otherwise.
-     * @see #contains(Object)
-     */
-    public boolean containsKey(int key) {
-        Entry tab[] = table;
-        int hash = key;
-        int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry e = tab[index]; e != null; e = e.next) {
-            if (e.hash == hash) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * <p>Returns the value to which the specified key is mapped in this map.</p>
-     *
-     * @param   key   a key in the hashtable.
-     * @return  the value to which the key is mapped in this hashtable;
-     *          <code>null</code> if the key is not mapped to any value in
-     *          this hashtable.
-     * @see     #put(int, Object)
-     */
-    public T get(int key) {
-        Entry<T> tab[] = table;
-        int hash = key;
-        int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry<T> e = tab[index]; e != null; e = e.next) {
-            if (e.hash == hash) {
-                return e.value;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * <p>Increases the capacity of and internally reorganizes this
-     * hashtable, in order to accommodate and access its entries more
-     * efficiently.</p>
-     *
-     * <p>This method is called automatically when the number of keys
-     * in the hashtable exceeds this hashtable's capacity and load
-     * factor.</p>
-     */
-    protected void rehash() {
-        int oldCapacity = table.length;
-        Entry<T> oldMap[] = table;
-
-        int newCapacity = oldCapacity * 2 + 1;
-        Entry<T> newMap[] = new Entry[newCapacity];
-
-        threshold = (int) (newCapacity * loadFactor);
-        table = newMap;
-
-        for (int i = oldCapacity; i-- > 0;) {
-            for (Entry<T> old = oldMap[i]; old != null;) {
-                Entry<T> e = old;
-                old = old.next;
-
-                int index = (e.hash & 0x7FFFFFFF) % newCapacity;
-                e.next = newMap[index];
-                newMap[index] = e;
-            }
-        }
-    }
-
-    /**
-     * <p>Maps the specified <code>key</code> to the specified
-     * <code>value</code> in this hashtable. The key cannot be
-     * <code>null</code>. </p>
-     *
-     * <p>The value can be retrieved by calling the <code>get</code> method
-     * with a key that is equal to the original key.</p>
-     *
-     * @param key     the hashtable key.
-     * @param value   the value.
-     * @return the previous value of the specified key in this hashtable,
-     *         or <code>null</code> if it did not have one.
-     * @throws  NullPointerException  if the key is <code>null</code>.
-     * @see     #get(int)
-     */
-    public Object put(int key, T value) {
-            keySet.add(key);
-        // Makes sure the key is not already in the hashtable.
-        Entry<T> tab[] = table;
-        int hash = key;
-        int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry<T> e = tab[index]; e != null; e = e.next) {
-            if (e.hash == hash) {
-                T old = e.value;
-                e.value = value;
-                return old;
-            }
-        }
-
-        if (count >= threshold) {
-            // Rehash the table if the threshold is exceeded
-            rehash();
-
-            tab = table;
-            index = (hash & 0x7FFFFFFF) % tab.length;
-        }
-
-        // Creates the new entry.
-        Entry<T> e = new Entry<T>(hash, key, value, tab[index]);
-        tab[index] = e;
-        count++;
-        return null;
-    }
-
-    /**
-     * <p>Removes the key (and its corresponding value) from this
-     * hashtable.</p>
-     *
-     * <p>This method does nothing if the key is not present in the
-     * hashtable.</p>
-     *
-     * @param   key   the key that needs to be removed.
-     * @return  the value to which the key had been mapped in this hashtable,
-     *          or <code>null</code> if the key did not have a mapping.
-     */
-    /*public Object remove(int key) {
-        Entry tab[] = table;
-        int hash = key;
-        int index = (hash & 0x7FFFFFFF) % tab.length;
-        for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) {
-            if (e.hash == hash) {
-                if (prev != null) {
-                    prev.next = e.next;
-                } else {
-                    tab[index] = e.next;
-                }
-                count--;
-                Object oldValue = e.value;
-                e.value = null;
-                return oldValue;
-            }
-        }
-        return null;
-    }*/
-
-    /**
-     * <p>Clears this hashtable so that it contains no keys.</p>
-     */
-    public synchronized void clear() {
-            keySet.clear();
-        Entry tab[] = table;
-        for (int index = tab.length; --index >= 0;) {
-            tab[index] = null;
-        }
-        count = 0;
-    }
-    
-    public IntSet keySet() {
-            return keySet;
-    }
-    
-    
-    
-}
-

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
deleted file mode 100644
index 4dd92b1..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2002-2004 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.commons.rdf.impl.utils.graphmatching.collections;
-
-import java.util.HashSet;
-import java.util.Iterator;
-
-/**
- * This is currently just a placeholder implementation based onm HashSet<Integer>
- * an efficient implementation is to store the primitives directly.
- *
- * @author reto
- */
-public class IntHashSet extends HashSet<Integer> implements IntSet {
-
-    @Override
-    public IntIterator intIterator() {
-        final Iterator<Integer> base = iterator();
-        return new IntIterator() {
-
-            @Override
-            public int nextInt() {
-                return base.next();
-            }
-
-            @Override
-            public boolean hasNext() {
-                return base.hasNext();
-            }
-
-            @Override
-            public Integer next() {
-                return base.next();
-            }
-
-            @Override
-            public void remove() {
-                base.remove();
-            }
-        };
-    }
-
-    @Override
-    public void add(int i) {
-        super.add((Integer)i);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
deleted file mode 100644
index 050cf82..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2002-2004 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.commons.rdf.impl.utils.graphmatching.collections;
-
-import java.util.Iterator;
-
-
-/**
- * An iterator allowing to iterate over ints, Iterator<Integer> is extended for
- * compatibility, however accessing nextInt allows faster implementations.
- *
- * @author reto
- */
-public interface IntIterator extends Iterator<Integer> {
-    public int nextInt();
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntSet.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
deleted file mode 100644
index 5c3e465..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2002-2004 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.commons.rdf.impl.utils.graphmatching.collections;
-
-import java.util.Set;
-
-/**
- * A IntSet allows directly adding primitive ints to a set, Set<Integer> is 
- * extended, but accessingt he respective methods is less efficient.
- *
- * @author reto
- */
-public interface IntSet extends Set<Integer> {
-    /**
-     *
-     * @return an iterator over the primitive int
-     */
-    public IntIterator intIterator();
-    
-    public void add(int i);
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/package-info.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/package-info.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/package-info.java
deleted file mode 100644
index a1fa1c5..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Common RDF API Implementation utilities.
- */
-package org.apache.commons.rdf.impl.utils;
\ No newline at end of file


[6/7] clerezza-rdf-core git commit: CLEREZZA-982: moved files for new packages

Posted by re...@apache.org.
CLEREZZA-982: moved files for new packages


Project: http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/commit/816dc11f
Tree: http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/tree/816dc11f
Diff: http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/diff/816dc11f

Branch: refs/heads/master
Commit: 816dc11f23b3fc769467608035381db401ca0d05
Parents: 95dc837
Author: Reto Gmuer <re...@apache.org>
Authored: Thu Apr 9 12:24:53 2015 +0000
Committer: Reto Gmuer <re...@apache.org>
Committed: Thu Apr 9 12:24:53 2015 +0000

----------------------------------------------------------------------
 .../apache/clerezza/commons/rdf/BlankNode.java  |  41 ++
 .../clerezza/commons/rdf/BlankNodeOrIri.java    |  30 ++
 .../org/apache/clerezza/commons/rdf/Graph.java  |  88 ++++
 .../clerezza/commons/rdf/ImmutableGraph.java    |  55 ++
 .../org/apache/clerezza/commons/rdf/Iri.java    |  83 +++
 .../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 +
 .../java/org/apache/commons/rdf/BlankNode.java  |  41 --
 .../org/apache/commons/rdf/BlankNodeOrIri.java  |  30 --
 .../main/java/org/apache/commons/rdf/Graph.java |  88 ----
 .../org/apache/commons/rdf/ImmutableGraph.java  |  55 --
 .../main/java/org/apache/commons/rdf/Iri.java   |  83 ---
 .../java/org/apache/commons/rdf/Language.java   |  63 ---
 .../java/org/apache/commons/rdf/Literal.java    |  93 ----
 .../java/org/apache/commons/rdf/RdfTerm.java    |  32 --
 .../java/org/apache/commons/rdf/Triple.java     |  57 ---
 .../org/apache/commons/rdf/WatchableGraph.java  |  94 ----
 .../org/apache/commons/rdf/event/AddEvent.java  |  37 --
 .../apache/commons/rdf/event/FilterTriple.java  |  86 ----
 .../apache/commons/rdf/event/GraphEvent.java    |  59 ---
 .../apache/commons/rdf/event/GraphListener.java |  43 --
 .../apache/commons/rdf/event/RemoveEvent.java   |  37 --
 .../org/apache/commons/rdf/package-info.java    |  21 -
 .../commons/rdf/impl/sparql/SparqlBNode.java    |  74 +++
 .../commons/rdf/impl/sparql/SparqlClient.java   | 224 ++++++++
 .../commons/rdf/impl/sparql/SparqlGraph.java    | 505 +++++++++++++++++++
 .../commons/rdf/impl/sparql/SparqlBNode.java    |  74 ---
 .../commons/rdf/impl/sparql/SparqlClient.java   | 224 --------
 .../commons/rdf/impl/sparql/SparqlGraph.java    | 505 -------------------
 .../rdf/impl/sparql/BNodeCircleTest.java        | 118 +++++
 .../commons/rdf/impl/sparql/BNodeTest.java      | 139 +++++
 .../commons/rdf/impl/sparql/SimilarBNodes.java  | 104 ++++
 .../rdf/impl/sparql/SparqlGraphTest.java        | 113 +++++
 .../rdf/impl/sparql/BNodeCircleTest.java        | 118 -----
 .../commons/rdf/impl/sparql/BNodeTest.java      | 139 -----
 .../commons/rdf/impl/sparql/SimilarBNodes.java  | 104 ----
 .../rdf/impl/sparql/SparqlGraphTest.java        | 113 -----
 .../commons/rdf/impl/sparql/bnode-circle.ttl    |   7 +
 .../commons/rdf/impl/sparql/grounded.ttl        |  16 +
 .../commons/rdf/impl/sparql/similar-bnodes.ttl  |   8 +
 .../commons/rdf/impl/sparql/simple-bnode.ttl    |   7 +
 .../commons/rdf/impl/sparql/bnode-circle.ttl    |   7 -
 .../apache/commons/rdf/impl/sparql/grounded.ttl |  16 -
 .../commons/rdf/impl/sparql/similar-bnodes.ttl  |   8 -
 .../commons/rdf/impl/sparql/simple-bnode.ttl    |   7 -
 .../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        |  77 +++
 .../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 +++
 .../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        |  77 ---
 .../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 +++
 .../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 ---
 126 files changed, 6221 insertions(+), 6221 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/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..2fcf23b
--- /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.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-rdf-core/blob/816dc11f/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..0a292d8
--- /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.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-rdf-core/blob/816dc11f/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..5a188ff
--- /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.commons.rdf;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.commons.rdf.event.FilterTriple;
+import org.apache.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-rdf-core/blob/816dc11f/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..a3b0211
--- /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.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-rdf-core/blob/816dc11f/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..e1ef0f7
--- /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.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-rdf-core/blob/816dc11f/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..e76e16d
--- /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.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-rdf-core/blob/816dc11f/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..cf5e1ee
--- /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.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-rdf-core/blob/816dc11f/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..8f0fb40
--- /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.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-rdf-core/blob/816dc11f/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..2a1569e
--- /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.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-rdf-core/blob/816dc11f/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..6367333
--- /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.commons.rdf;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.commons.rdf.event.FilterTriple;
+import org.apache.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-rdf-core/blob/816dc11f/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..1d4a835
--- /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.commons.rdf.event;
+
+import org.apache.commons.rdf.Triple;
+import org.apache.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-rdf-core/blob/816dc11f/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..3480c13
--- /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.commons.rdf.event;
+
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.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-rdf-core/blob/816dc11f/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..d055088
--- /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.commons.rdf.event;
+
+import org.apache.commons.rdf.Triple;
+import org.apache.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-rdf-core/blob/816dc11f/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..8d0b257
--- /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.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-rdf-core/blob/816dc11f/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..60150d6
--- /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.commons.rdf.event;
+
+import org.apache.commons.rdf.Triple;
+import org.apache.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-rdf-core/blob/816dc11f/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..da34f2d
--- /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.commons.rdf;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/BlankNode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/BlankNode.java b/api/src/main/java/org/apache/commons/rdf/BlankNode.java
deleted file mode 100644
index 2fcf23b..0000000
--- a/api/src/main/java/org/apache/commons/rdf/BlankNode.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-/**
- * 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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/BlankNodeOrIri.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/BlankNodeOrIri.java b/api/src/main/java/org/apache/commons/rdf/BlankNodeOrIri.java
deleted file mode 100644
index 0a292d8..0000000
--- a/api/src/main/java/org/apache/commons/rdf/BlankNodeOrIri.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-/**
- * 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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/Graph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/Graph.java b/api/src/main/java/org/apache/commons/rdf/Graph.java
deleted file mode 100644
index 5a188ff..0000000
--- a/api/src/main/java/org/apache/commons/rdf/Graph.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/ImmutableGraph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/ImmutableGraph.java b/api/src/main/java/org/apache/commons/rdf/ImmutableGraph.java
deleted file mode 100644
index a3b0211..0000000
--- a/api/src/main/java/org/apache/commons/rdf/ImmutableGraph.java
+++ /dev/null
@@ -1,55 +0,0 @@
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-/**
- * 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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/Iri.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/Iri.java b/api/src/main/java/org/apache/commons/rdf/Iri.java
deleted file mode 100644
index e1ef0f7..0000000
--- a/api/src/main/java/org/apache/commons/rdf/Iri.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/Language.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/Language.java b/api/src/main/java/org/apache/commons/rdf/Language.java
deleted file mode 100644
index e76e16d..0000000
--- a/api/src/main/java/org/apache/commons/rdf/Language.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-/**
- * 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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/Literal.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/Literal.java b/api/src/main/java/org/apache/commons/rdf/Literal.java
deleted file mode 100644
index cf5e1ee..0000000
--- a/api/src/main/java/org/apache/commons/rdf/Literal.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-
-/**
- * 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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/RdfTerm.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/RdfTerm.java b/api/src/main/java/org/apache/commons/rdf/RdfTerm.java
deleted file mode 100644
index 8f0fb40..0000000
--- a/api/src/main/java/org/apache/commons/rdf/RdfTerm.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-/**
- * 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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/Triple.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/Triple.java b/api/src/main/java/org/apache/commons/rdf/Triple.java
deleted file mode 100644
index 2a1569e..0000000
--- a/api/src/main/java/org/apache/commons/rdf/Triple.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-/**
- * 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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/WatchableGraph.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/WatchableGraph.java b/api/src/main/java/org/apache/commons/rdf/WatchableGraph.java
deleted file mode 100644
index 6367333..0000000
--- a/api/src/main/java/org/apache/commons/rdf/WatchableGraph.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/event/AddEvent.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/event/AddEvent.java b/api/src/main/java/org/apache/commons/rdf/event/AddEvent.java
deleted file mode 100644
index 1d4a835..0000000
--- a/api/src/main/java/org/apache/commons/rdf/event/AddEvent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.event;
-
-import org.apache.commons.rdf.Triple;
-import org.apache.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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/event/FilterTriple.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/event/FilterTriple.java b/api/src/main/java/org/apache/commons/rdf/event/FilterTriple.java
deleted file mode 100644
index 3480c13..0000000
--- a/api/src/main/java/org/apache/commons/rdf/event/FilterTriple.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.event;
-
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/event/GraphEvent.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/event/GraphEvent.java b/api/src/main/java/org/apache/commons/rdf/event/GraphEvent.java
deleted file mode 100644
index d055088..0000000
--- a/api/src/main/java/org/apache/commons/rdf/event/GraphEvent.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.event;
-
-import org.apache.commons.rdf.Triple;
-import org.apache.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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/event/GraphListener.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/event/GraphListener.java b/api/src/main/java/org/apache/commons/rdf/event/GraphListener.java
deleted file mode 100644
index 8d0b257..0000000
--- a/api/src/main/java/org/apache/commons/rdf/event/GraphListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.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-rdf-core/blob/816dc11f/api/src/main/java/org/apache/commons/rdf/event/RemoveEvent.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/event/RemoveEvent.java b/api/src/main/java/org/apache/commons/rdf/event/RemoveEvent.java
deleted file mode 100644
index 60150d6..0000000
--- a/api/src/main/java/org/apache/commons/rdf/event/RemoveEvent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.event;
-
-import org.apache.commons.rdf.Triple;
-import org.apache.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);
-    }
-
-}


[4/7] clerezza-rdf-core git commit: CLEREZZA-982: moved files for new packages

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java
new file mode 100644
index 0000000..0c39e9d
--- /dev/null
+++ b/impl.sparql/src/test/java/org/apache/clerezza/commons/rdf/impl/sparql/SparqlGraphTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.commons.rdf.impl.sparql;
+
+import com.hp.hpl.jena.query.DatasetAccessor;
+import com.hp.hpl.jena.query.DatasetAccessorFactory;
+import java.io.IOException;
+import java.net.ServerSocket;
+import org.apache.jena.fuseki.EmbeddedFusekiServer;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.Language;
+import org.apache.commons.rdf.Literal;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author reto
+ */
+public class SparqlGraphTest {
+
+    final static int serverPort = findFreePort();
+    static EmbeddedFusekiServer server;
+
+    @BeforeClass
+    public static void prepare() throws IOException {
+        final String serviceURI = "http://localhost:" + serverPort + "/ds/data";
+        final DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(serviceURI);
+        final InputStream in = SparqlGraphTest.class.getResourceAsStream("grounded.ttl");
+        final Model m = ModelFactory.createDefaultModel();
+        String base = "http://example.org/";
+        m.read(in, base, "TURTLE");
+        server = EmbeddedFusekiServer.memTDB(serverPort, "/ds");//dataSet.getAbsolutePath());
+        server.start();
+        System.out.println("Started fuseki on port " + serverPort);
+        accessor.putModel(m);
+    }
+
+    @AfterClass
+    public static void cleanup() {
+        server.stop();
+    }
+
+    @Test
+    public void graphSize() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        Assert.assertEquals("Graph not of the exepected size", 8, graph.size());
+    }
+
+    @Test
+    public void filter1() {
+        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
+        final Iri spiderman = new Iri("http://example.org/#spiderman");
+        final Iri greenGoblin = new Iri("http://example.org/#green-goblin");
+        final Iri enemyOf = new Iri("http://www.perceive.net/schemas/relationship/enemyOf");
+        final Iri foafName = new Iri("http://xmlns.com/foaf/0.1/name");
+        {
+            final Iterator<Triple> iter = graph.filter(spiderman, null, greenGoblin);
+            Assert.assertTrue(iter.hasNext());
+            Assert.assertEquals(enemyOf, iter.next().getPredicate());
+            Assert.assertFalse(iter.hasNext());
+        }
+        {
+            final Iterator<Triple> iter = graph.filter(spiderman, foafName, null);
+            Set<Literal> names = new HashSet<>();
+            for (int i = 0; i < 2; i++) {
+                Assert.assertTrue(iter.hasNext());
+                RdfTerm name = iter.next().getObject();
+                Assert.assertTrue(name instanceof Literal);
+                names.add((Literal)name);
+            }
+            Assert.assertFalse(iter.hasNext());
+            Assert.assertTrue(names.contains(new PlainLiteralImpl("Spiderman")));
+            Assert.assertTrue(names.contains(new PlainLiteralImpl("Человек-паук", new Language("ru"))));
+        }
+    }
+
+    public static int findFreePort() {
+        int port = 0;
+        try (ServerSocket server = new ServerSocket(0);) {
+            port = server.getLocalPort();
+        } catch (Exception e) {
+            throw new RuntimeException("unable to find a free port");
+        }
+        return port;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/BNodeCircleTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/BNodeCircleTest.java b/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/BNodeCircleTest.java
deleted file mode 100644
index 9329c9b..0000000
--- a/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/BNodeCircleTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.commons.rdf.impl.sparql;
-
-import com.hp.hpl.jena.query.DatasetAccessor;
-import com.hp.hpl.jena.query.DatasetAccessorFactory;
-import java.io.IOException;
-import java.net.ServerSocket;
-import org.apache.jena.fuseki.EmbeddedFusekiServer;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
-import java.io.InputStream;
-import java.util.Iterator;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author reto
- */
-public class BNodeCircleTest {
-
-    final static int serverPort = findFreePort();
-    static EmbeddedFusekiServer server;
-
-    @BeforeClass
-    public static void prepare() throws IOException {
-        final String serviceURI = "http://localhost:" + serverPort + "/ds/data";
-        final DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(serviceURI);
-        final InputStream in = BNodeCircleTest.class.getResourceAsStream("bnode-circle.ttl");
-        final Model m = ModelFactory.createDefaultModel();
-        String base = "http://example.org/";
-        m.read(in, base, "TURTLE");
-        server = EmbeddedFusekiServer.memTDB(serverPort, "/ds");//dataSet.getAbsolutePath());
-        server.start();
-        System.out.println("Started fuseki on port " + serverPort);
-        accessor.putModel(m);
-    }
-
-    @AfterClass
-    public static void cleanup() {
-        server.stop();
-    }
-
-    @Test
-    public void graphSize() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        Assert.assertEquals("Graph not of the exepected size", 2, graph.size());
-    }
-
-    
-    
-    @Test
-    public void nullFilter() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        final Iterator<Triple> iter = graph.filter(null, null, null);
-        Assert.assertTrue(iter.hasNext());
-        final Triple triple1 = iter.next();
-        final BlankNodeOrIri subject = triple1.getSubject();
-        final RdfTerm object = triple1.getObject();
-        Assert.assertTrue(subject instanceof BlankNode);
-        Assert.assertTrue(object instanceof BlankNode);
-        Assert.assertNotEquals(subject, object);
-        Assert.assertTrue(iter.hasNext());
-    }
-    
-    @Test
-    public void foafKnowsFilter() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        
-        final Iri foafKnows = new Iri("http://xmlns.com/foaf/0.1/knows");
-
-        final Iterator<Triple> iter = graph.filter(null, foafKnows, null);
-        Assert.assertTrue(iter.hasNext());
-        final Triple triple1 = iter.next();
-        final BlankNodeOrIri subject = triple1.getSubject();
-        final RdfTerm object = triple1.getObject();
-        Assert.assertTrue(subject instanceof BlankNode);
-        Assert.assertTrue(object instanceof BlankNode);
-        Assert.assertNotEquals(subject, object);
-        Assert.assertTrue(iter.hasNext());
-    }
-    
-
-    
-
-    public static int findFreePort() {
-        int port = 0;
-        try (ServerSocket server = new ServerSocket(0);) {
-            port = server.getLocalPort();
-        } catch (Exception e) {
-            throw new RuntimeException("unable to find a free port");
-        }
-        return port;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/BNodeTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/BNodeTest.java b/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/BNodeTest.java
deleted file mode 100644
index f0a4aff..0000000
--- a/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/BNodeTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.commons.rdf.impl.sparql;
-
-import com.hp.hpl.jena.query.DatasetAccessor;
-import com.hp.hpl.jena.query.DatasetAccessorFactory;
-import java.io.IOException;
-import java.net.ServerSocket;
-import org.apache.jena.fuseki.EmbeddedFusekiServer;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
-import java.io.InputStream;
-import java.util.Iterator;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author reto
- */
-public class BNodeTest {
-
-    final static int serverPort = findFreePort();
-    static EmbeddedFusekiServer server;
-
-    @BeforeClass
-    public static void prepare() throws IOException {
-        final String serviceURI = "http://localhost:" + serverPort + "/ds/data";
-        final DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(serviceURI);
-        final InputStream in = BNodeTest.class.getResourceAsStream("simple-bnode.ttl");
-        final Model m = ModelFactory.createDefaultModel();
-        String base = "http://example.org/";
-        m.read(in, base, "TURTLE");
-        server = EmbeddedFusekiServer.memTDB(serverPort, "/ds");//dataSet.getAbsolutePath());
-        server.start();
-        System.out.println("Started fuseki on port " + serverPort);
-        accessor.putModel(m);
-    }
-
-    @AfterClass
-    public static void cleanup() {
-        server.stop();
-    }
-
-    @Test
-    public void graphSize() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        Assert.assertEquals("Graph not of the exepected size", 3, graph.size());
-    }
-
-    /* Filtering with a Bode that cannot be in graph
-    */
-    @Test
-    public void filterAlienBNode() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        
-        final BlankNode blankNode = new BlankNode();
-        final Iterator<Triple> iter = graph.filter(blankNode, null, null);
-        Assert.assertFalse(iter.hasNext());
-    }
-    
-    @Test
-    public void bNodeIdentity() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        
-        final Iri foafPerson = new Iri("http://xmlns.com/foaf/0.1/Person");
-        final Iri foafName = new Iri("http://xmlns.com/foaf/0.1/name");
-        final Iri foafKnows = new Iri("http://xmlns.com/foaf/0.1/knows");
-        final Iri rdfType = new Iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
-
-        final Iterator<Triple> iter = graph.filter(null, foafName, null);
-        Assert.assertTrue(iter.hasNext());
-        final BlankNodeOrIri namedThing = iter.next().getSubject();
-        Assert.assertTrue(namedThing instanceof BlankNode);
-        
-        final Iterator<Triple> iter2 = graph.filter(null, rdfType, foafPerson);
-        Assert.assertTrue(iter2.hasNext());
-        final BlankNodeOrIri person = iter2.next().getSubject();
-        Assert.assertTrue(person instanceof BlankNode);
-        Assert.assertEquals(namedThing, person);
-        
-        final Iterator<Triple> iter3 = graph.filter(null, foafKnows, null);
-        Assert.assertTrue(iter3.hasNext());
-        final RdfTerm knownThing = iter3.next().getObject();
-        Assert.assertTrue(knownThing instanceof BlankNode);
-        Assert.assertEquals(knownThing, person);
-        Assert.assertEquals(namedThing, knownThing);
-    }
-    
-    @Test
-    public void filter1() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        
-        final Iri foafPerson = new Iri("http://xmlns.com/foaf/0.1/Person");
-        final Iri foafName = new Iri("http://xmlns.com/foaf/0.1/name");
-        final Iri rdfType = new Iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
-
-        final Iterator<Triple> iter = graph.filter(null, foafName, null);
-        Assert.assertTrue(iter.hasNext());
-        final BlankNodeOrIri person = iter.next().getSubject();
-        Assert.assertTrue(person instanceof BlankNode);
-        
-        final Iterator<Triple> iter2 = graph.filter(person, rdfType, null);
-        Assert.assertTrue(iter2.hasNext());
-    }
-    
-
-    public static int findFreePort() {
-        int port = 0;
-        try (ServerSocket server = new ServerSocket(0);) {
-            port = server.getLocalPort();
-        } catch (Exception e) {
-            throw new RuntimeException("unable to find a free port");
-        }
-        return port;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/SimilarBNodes.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/SimilarBNodes.java b/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/SimilarBNodes.java
deleted file mode 100644
index 6300281..0000000
--- a/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/SimilarBNodes.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.commons.rdf.impl.sparql;
-
-import com.hp.hpl.jena.query.DatasetAccessor;
-import com.hp.hpl.jena.query.DatasetAccessorFactory;
-import java.io.IOException;
-import java.net.ServerSocket;
-import org.apache.jena.fuseki.EmbeddedFusekiServer;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
-import java.io.InputStream;
-import java.util.Iterator;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Triple;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author reto
- */
-public class SimilarBNodes {
-
-    final static int serverPort = findFreePort();
-    static EmbeddedFusekiServer server;
-
-    @BeforeClass
-    public static void prepare() throws IOException {
-        final String serviceURI = "http://localhost:" + serverPort + "/ds/data";
-        final DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(serviceURI);
-        final InputStream in = SimilarBNodes.class.getResourceAsStream("similar-bnodes.ttl");
-        final Model m = ModelFactory.createDefaultModel();
-        String base = "http://example.org/";
-        m.read(in, base, "TURTLE");
-        server = EmbeddedFusekiServer.memTDB(serverPort, "/ds");//dataSet.getAbsolutePath());
-        server.start();
-        System.out.println("Started fuseki on port " + serverPort);
-        accessor.putModel(m);
-    }
-
-    @AfterClass
-    public static void cleanup() {
-        server.stop();
-    }
-
-    @Test
-    public void graphSize() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        Assert.assertEquals("Graph not of the exepected size", 2, graph.size());
-    }
-
-    
-    
-    @Test
-    public void foafKnowsFilter() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        
-        final Iri foafKnows = new Iri("http://xmlns.com/foaf/0.1/knows");
-
-        final Iterator<Triple> iter = graph.filter(null, foafKnows, null);
-        Assert.assertTrue(iter.hasNext());
-        final Triple triple1 = iter.next();
-        final BlankNodeOrIri subject1 = triple1.getSubject();
-        Assert.assertTrue(subject1 instanceof BlankNode);
-        Assert.assertTrue(iter.hasNext());
-        final Triple triple2 = iter.next();
-        final BlankNodeOrIri subject2 = triple2.getSubject();
-        Assert.assertTrue(subject2 instanceof BlankNode);
-        Assert.assertNotEquals(subject1, subject2);
-    }
-    
-
-    
-
-    public static int findFreePort() {
-        int port = 0;
-        try (ServerSocket server = new ServerSocket(0);) {
-            port = server.getLocalPort();
-        } catch (Exception e) {
-            throw new RuntimeException("unable to find a free port");
-        }
-        return port;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/SparqlGraphTest.java
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/SparqlGraphTest.java b/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/SparqlGraphTest.java
deleted file mode 100644
index 0c39e9d..0000000
--- a/impl.sparql/src/test/java/org/apache/commons/rdf/impl/sparql/SparqlGraphTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.commons.rdf.impl.sparql;
-
-import com.hp.hpl.jena.query.DatasetAccessor;
-import com.hp.hpl.jena.query.DatasetAccessorFactory;
-import java.io.IOException;
-import java.net.ServerSocket;
-import org.apache.jena.fuseki.EmbeddedFusekiServer;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.ModelFactory;
-import java.io.InputStream;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author reto
- */
-public class SparqlGraphTest {
-
-    final static int serverPort = findFreePort();
-    static EmbeddedFusekiServer server;
-
-    @BeforeClass
-    public static void prepare() throws IOException {
-        final String serviceURI = "http://localhost:" + serverPort + "/ds/data";
-        final DatasetAccessor accessor = DatasetAccessorFactory.createHTTP(serviceURI);
-        final InputStream in = SparqlGraphTest.class.getResourceAsStream("grounded.ttl");
-        final Model m = ModelFactory.createDefaultModel();
-        String base = "http://example.org/";
-        m.read(in, base, "TURTLE");
-        server = EmbeddedFusekiServer.memTDB(serverPort, "/ds");//dataSet.getAbsolutePath());
-        server.start();
-        System.out.println("Started fuseki on port " + serverPort);
-        accessor.putModel(m);
-    }
-
-    @AfterClass
-    public static void cleanup() {
-        server.stop();
-    }
-
-    @Test
-    public void graphSize() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        Assert.assertEquals("Graph not of the exepected size", 8, graph.size());
-    }
-
-    @Test
-    public void filter1() {
-        final Graph graph = new SparqlGraph("http://localhost:" + serverPort + "/ds/query");
-        final Iri spiderman = new Iri("http://example.org/#spiderman");
-        final Iri greenGoblin = new Iri("http://example.org/#green-goblin");
-        final Iri enemyOf = new Iri("http://www.perceive.net/schemas/relationship/enemyOf");
-        final Iri foafName = new Iri("http://xmlns.com/foaf/0.1/name");
-        {
-            final Iterator<Triple> iter = graph.filter(spiderman, null, greenGoblin);
-            Assert.assertTrue(iter.hasNext());
-            Assert.assertEquals(enemyOf, iter.next().getPredicate());
-            Assert.assertFalse(iter.hasNext());
-        }
-        {
-            final Iterator<Triple> iter = graph.filter(spiderman, foafName, null);
-            Set<Literal> names = new HashSet<>();
-            for (int i = 0; i < 2; i++) {
-                Assert.assertTrue(iter.hasNext());
-                RdfTerm name = iter.next().getObject();
-                Assert.assertTrue(name instanceof Literal);
-                names.add((Literal)name);
-            }
-            Assert.assertFalse(iter.hasNext());
-            Assert.assertTrue(names.contains(new PlainLiteralImpl("Spiderman")));
-            Assert.assertTrue(names.contains(new PlainLiteralImpl("Человек-паук", new Language("ru"))));
-        }
-    }
-
-    public static int findFreePort() {
-        int port = 0;
-        try (ServerSocket server = new ServerSocket(0);) {
-            port = server.getLocalPort();
-        } catch (Exception e) {
-            throw new RuntimeException("unable to find a free port");
-        }
-        return port;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/bnode-circle.ttl
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/bnode-circle.ttl b/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/bnode-circle.ttl
new file mode 100644
index 0000000..f03ab4d
--- /dev/null
+++ b/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/bnode-circle.ttl
@@ -0,0 +1,7 @@
+@base <http://example.org/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+
+_:a foaf:knows _:b .
+_:b foaf:knows _:a .
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/grounded.ttl
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/grounded.ttl b/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/grounded.ttl
new file mode 100644
index 0000000..ccc39c4
--- /dev/null
+++ b/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/grounded.ttl
@@ -0,0 +1,16 @@
+@base <http://example.org/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix rel: <http://www.perceive.net/schemas/relationship/> .
+
+<#green-goblin>
+    rel:enemyOf <#spiderman> ;
+    a foaf:Person ;    # in the context of the Marvel universe
+    foaf:name "Green Goblin" ;
+    foaf:age 128 .
+
+<#spiderman>
+    rel:enemyOf <#green-goblin> ;
+    a foaf:Person ;
+    foaf:name "Spiderman", "Человек-паук"@ru .
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/similar-bnodes.ttl
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/similar-bnodes.ttl b/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/similar-bnodes.ttl
new file mode 100644
index 0000000..16c1ceb
--- /dev/null
+++ b/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/similar-bnodes.ttl
@@ -0,0 +1,8 @@
+@base <http://example.org/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+
+
+[] foaf:knows [ foaf:name "Alice"] .
+[] foaf:knows [ foaf:name "Bob" ] .
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/simple-bnode.ttl
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/simple-bnode.ttl b/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/simple-bnode.ttl
new file mode 100644
index 0000000..6bcf67f
--- /dev/null
+++ b/impl.sparql/src/test/resources/org/apache/clerezza/commons/rdf/impl/sparql/simple-bnode.ttl
@@ -0,0 +1,7 @@
+@base <http://example.org/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+
+<http://example.org/#me> foaf:knows [ a foaf:Person;
+  foaf:name "Alice Barker"].
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/bnode-circle.ttl
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/bnode-circle.ttl b/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/bnode-circle.ttl
deleted file mode 100644
index f03ab4d..0000000
--- a/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/bnode-circle.ttl
+++ /dev/null
@@ -1,7 +0,0 @@
-@base <http://example.org/> .
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix foaf: <http://xmlns.com/foaf/0.1/> .
-
-_:a foaf:knows _:b .
-_:b foaf:knows _:a .
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/grounded.ttl
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/grounded.ttl b/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/grounded.ttl
deleted file mode 100644
index ccc39c4..0000000
--- a/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/grounded.ttl
+++ /dev/null
@@ -1,16 +0,0 @@
-@base <http://example.org/> .
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix foaf: <http://xmlns.com/foaf/0.1/> .
-@prefix rel: <http://www.perceive.net/schemas/relationship/> .
-
-<#green-goblin>
-    rel:enemyOf <#spiderman> ;
-    a foaf:Person ;    # in the context of the Marvel universe
-    foaf:name "Green Goblin" ;
-    foaf:age 128 .
-
-<#spiderman>
-    rel:enemyOf <#green-goblin> ;
-    a foaf:Person ;
-    foaf:name "Spiderman", "Человек-паук"@ru .
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/similar-bnodes.ttl
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/similar-bnodes.ttl b/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/similar-bnodes.ttl
deleted file mode 100644
index 16c1ceb..0000000
--- a/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/similar-bnodes.ttl
+++ /dev/null
@@ -1,8 +0,0 @@
-@base <http://example.org/> .
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix foaf: <http://xmlns.com/foaf/0.1/> .
-
-
-[] foaf:knows [ foaf:name "Alice"] .
-[] foaf:knows [ foaf:name "Bob" ] .
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/simple-bnode.ttl
----------------------------------------------------------------------
diff --git a/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/simple-bnode.ttl b/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/simple-bnode.ttl
deleted file mode 100644
index 6bcf67f..0000000
--- a/impl.sparql/src/test/resources/org/apache/commons/rdf/impl/sparql/simple-bnode.ttl
+++ /dev/null
@@ -1,7 +0,0 @@
-@base <http://example.org/> .
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix foaf: <http://xmlns.com/foaf/0.1/> .
-
-<http://example.org/#me> foaf:knows [ a foaf:Person;
-  foaf:name "Alice Barker"].
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java
new file mode 100644
index 0000000..2c99679
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractGraph.java
@@ -0,0 +1,316 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils;
+
+import java.lang.ref.WeakReference;
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import java.util.Set;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.WatchableGraph;
+import org.apache.commons.rdf.event.AddEvent;
+import org.apache.commons.rdf.event.FilterTriple;
+import org.apache.commons.rdf.event.GraphEvent;
+import org.apache.commons.rdf.event.GraphListener;
+import org.apache.commons.rdf.event.RemoveEvent;
+import org.apache.commons.rdf.impl.utils.debug.ReentrantReadWriteLockTracker;
+import org.apache.commons.rdf.impl.utils.simple.SimpleImmutableGraph;
+
+/**
+ * An abstract implementation of <code>Graph</code> implementing
+ * <code>iterator</code> and <code>contains</code> calling <code>filter</code>.
+ *
+ * @author reto
+ */
+public abstract class AbstractGraph extends AbstractCollection<Triple>
+        implements Graph {
+
+    
+    private static final String DEBUG_MODE = "rdfLocksDebugging";
+    private final ReadWriteLock lock;
+
+    private final Lock readLock;
+    private final Lock writeLock;
+
+    /**
+     * Constructs a LocalbleMGraph for an Graph.
+     *
+     * @param providedMGraph a non-lockable graph
+     */
+    public AbstractGraph() {
+        {
+            String debugMode = System.getProperty(DEBUG_MODE);
+            if (debugMode != null && debugMode.toLowerCase().equals("true")) {
+                lock = new ReentrantReadWriteLockTracker();
+            } else {
+                lock = new ReentrantReadWriteLock();
+            }
+        }
+        readLock = lock.readLock();
+        writeLock = lock.writeLock();
+    }
+    
+    public AbstractGraph(final ReadWriteLock lock) {
+        this.lock = lock;
+        readLock = lock.readLock();
+        writeLock = lock.writeLock();
+    }
+
+    @Override
+    public ReadWriteLock getLock() {
+        return lock;
+    }
+
+    @Override
+    public ImmutableGraph getImmutableGraph() {
+        readLock.lock();
+        try {
+            return performGetImmutableGraph();
+        } finally {
+            readLock.unlock();
+        }
+    }
+    
+    public ImmutableGraph performGetImmutableGraph() {
+        return new SimpleImmutableGraph(this);
+    }
+
+    @Override
+    public Iterator<Triple> filter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
+        readLock.lock();
+        try {
+            return new LockingIterator(performFilter(subject, predicate, object), lock);
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public int size() {
+        readLock.lock();
+        try {
+            return performSize();
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean isEmpty() {
+        readLock.lock();
+        try {
+            return performIsEmpty();
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    @SuppressWarnings("element-type-mismatch")
+    public boolean contains(Object o) {
+        readLock.lock();
+        try {
+            return performContains(o);
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public Iterator<Triple> iterator() {
+        readLock.lock();
+        try {
+            return new LockingIterator(performIterator(), lock);
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public Object[] toArray() {
+        readLock.lock();
+        try {
+            return performToArray();
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public <T> T[] toArray(T[] a) {
+        readLock.lock();
+        try {
+            return performToArray(a);
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean containsAll(Collection<?> c) {
+        readLock.lock();
+        try {
+            return performContainsAll(c);
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean add(Triple e) {
+        writeLock.lock();
+        try {
+            return performAdd(e);
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean remove(Object o) {
+        writeLock.lock();
+        try {
+            return performRemove(o);
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends Triple> c) {
+        writeLock.lock();
+        try {
+            return performAddAll(c);
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean removeAll(Collection<?> c) {
+        writeLock.lock();
+        try {
+            return performRemoveAll(c);
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+    @Override
+    public boolean retainAll(Collection<?> c) {
+        writeLock.lock();
+        try {
+            return performRetainAll(c);
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+    @Override
+    public void clear() {
+        writeLock.lock();
+        try {
+            performClear();
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+    
+    @Override
+    public boolean equals(Object obj) {
+        /*if (obj == null) {
+            return false;
+        }
+        if (obj == this) {
+            return true;
+        }
+        if (obj.getClass() != getClass()) {
+            return false;
+        }*/
+        return this == obj;
+    }
+
+
+    protected abstract Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate, RdfTerm object);
+
+    protected abstract int performSize();
+
+    protected boolean performIsEmpty() {
+        return super.isEmpty();
+    }
+
+    protected Object[] performToArray() {
+        return super.toArray();
+    }
+
+    protected boolean performRemove(Object o) {
+        return super.remove(o);
+    }
+
+    protected boolean performAddAll(Collection<? extends Triple> c) {
+        return super.addAll(c);
+    }
+
+    protected boolean performRemoveAll(Collection<?> c) {
+        return super.removeAll(c);
+    }
+
+    protected boolean performRetainAll(Collection<?> c) {
+        return super.retainAll(c);
+    }
+
+    protected void performClear() {
+        super.clear();
+    }
+
+    protected boolean performContains(Object o) {
+        return super.contains(o);
+    }
+
+    protected Iterator<Triple> performIterator() {
+        return performFilter(null, null, null);
+    }
+
+    protected boolean performContainsAll(Collection<?> c) {
+        return super.containsAll(c);
+    }
+
+    protected <T> T[] performToArray(T[] a) {
+        return super.toArray(a);
+    }
+
+    protected boolean performAdd(Triple e) {
+        return super.add(e);
+    }
+
+ 
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java
new file mode 100644
index 0000000..912a5ff
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractImmutableGraph.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.impl.utils.graphmatching.GraphMatcher;
+
+/**
+ * <code>AbstractGraph</code> is an abstract implementation of <code>ImmutableGraph</code> 
+ * implementing the <code>equals</code> and the <code>hashCode</code> methods.
+ * 
+ * @author reto
+ * 
+ */
+public abstract class AbstractImmutableGraph extends AbstractGraph
+        implements ImmutableGraph {
+
+    public final synchronized int hashCode() {
+        int result = 0;
+        for (Iterator<Triple> iter = iterator(); iter.hasNext();) {
+            result += getBlankNodeBlindHash(iter.next());
+        }
+        return result;
+    }
+
+    /**
+     * @param triple
+     * @return hash without BNode hashes
+     */
+    private int getBlankNodeBlindHash(Triple triple) {
+        int hash = triple.getPredicate().hashCode();
+        RdfTerm subject = triple.getSubject();
+
+        if (!(subject instanceof BlankNode)) {
+            hash ^= subject.hashCode() >> 1;
+        }
+        RdfTerm object = triple.getObject();
+        if (!(object instanceof BlankNode)) {
+            hash ^= object.hashCode() << 1;
+        }
+
+        return hash;
+    }
+
+    @Override
+    public boolean add(Triple e) {
+        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
+
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends Triple> c) {
+        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
+    }
+
+    @Override
+    public boolean remove(Object o) {
+        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
+    }
+
+    @Override
+    public boolean removeAll(Collection<?> c) {
+        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
+    }
+
+    @Override
+    public void clear() {
+        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
+    }
+    
+    
+    @Override
+    public ImmutableGraph getImmutableGraph() {
+        return this;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof ImmutableGraph)) {
+            return false;
+        }
+        if (hashCode() != obj.hashCode()) {
+            return false;
+        }
+        return GraphMatcher.getValidMapping(this, (ImmutableGraph) obj) != null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java
new file mode 100644
index 0000000..e1fac11
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/AbstractLiteral.java
@@ -0,0 +1,61 @@
+/*
+ * 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.commons.rdf.impl.utils;
+
+import org.apache.commons.rdf.Literal;
+
+/**
+ *
+ * @author developer
+ */
+public abstract class AbstractLiteral implements Literal {
+
+    @Override
+    public int hashCode() {
+        int result = 0;
+        if (getLanguage() != null) {
+            result = getLanguage().hashCode();
+        }
+        result += getLexicalForm().hashCode();
+        result += getDataType().hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof Literal) {
+            Literal other = (Literal) obj;
+            
+            if (getLanguage() == null) {
+                if (other.getLanguage() != null) {
+                    return false;
+                }
+            } else {
+                if (!getLanguage().equals(other.getLanguage())) {
+                    return false;
+                }
+            }
+            boolean res = getDataType().equals(other.getDataType()) && getLexicalForm().equals(other.getLexicalForm());
+            return res;
+        } else {
+            return false;
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java
new file mode 100644
index 0000000..8b3bc87
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/DelayedNotificator.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils;
+
+import java.lang.ref.WeakReference;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.rdf.event.GraphEvent;
+import org.apache.commons.rdf.event.GraphListener;
+
+
+/**
+ *
+ * @author reto
+ */
+class DelayedNotificator {
+
+    private static final Logger log = Logger.getLogger(DelayedNotificator.class.getName());
+    private static Timer timer = new Timer("Event delivery timer",true);
+
+    static class ListenerHolder {
+
+        long delay;
+        List<GraphEvent> events = null;
+        WeakReference<GraphListener> listenerRef;
+
+        public ListenerHolder(GraphListener listener, long delay) {
+            this.listenerRef = new WeakReference<GraphListener>(listener);
+            this.delay = delay;
+        }
+
+        private void registerEvent(GraphEvent event) {
+            synchronized (this) {
+                if (events == null) {
+                    events = new ArrayList<GraphEvent>();
+                    events.add(event);
+                    timer.schedule(new TimerTask() {
+
+                        @Override
+                        public void run() {
+                            List<GraphEvent> eventsLocal;
+                            synchronized (ListenerHolder.this) {
+                                eventsLocal = events;
+                                events = null;
+                            }
+                            GraphListener listener = listenerRef.get();
+                            if (listener == null) {
+                                log.fine("Ignoring garbage collected listener");
+                            } else {
+                                try {
+                                    listener.graphChanged(eventsLocal);
+                                } catch (Exception e) {
+                                    log.log(Level.WARNING, "Exception delivering ImmutableGraph event", e);
+                                }
+                            }
+                        }
+                    }, delay);
+                } else {
+                    events.add(event);
+                }
+            }
+        }
+    }
+    
+    private final Map<GraphListener, ListenerHolder> map = Collections.synchronizedMap(
+            new WeakHashMap<GraphListener, ListenerHolder>());
+
+    void addDelayedListener(GraphListener listener, long delay) {
+        map.put(listener, new ListenerHolder(listener, delay));
+    }
+
+    /**
+     * removes a Listener, this doesn't prevent the listenerRef from receiving
+     * events alreay scheduled.
+     *
+     * @param listenerRef
+     */
+    void removeDelayedListener(GraphListener listener) {
+        map.remove(listener);
+    }
+
+    /**
+     * if the listenerRef has not been registered as delayed listenerRef te events is
+     * forwarded synchroneously
+     * @param event
+     */
+    void sendEventToListener(GraphListener listener, GraphEvent event) {
+        ListenerHolder holder = map.get(listener);
+        if (holder == null) {
+            listener.graphChanged(Collections.singletonList(event));
+        } else {
+            holder.registerEvent(event);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java
new file mode 100644
index 0000000..0de3b84
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LiteralImpl.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils;
+
+import java.io.Serializable;
+
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.Language;
+
+/**
+ *
+ * @author reto
+ */
+public class LiteralImpl extends AbstractLiteral implements  Serializable {
+    private String lexicalForm;
+    private Iri dataType;
+    private int hashCode;
+    private Language language;
+
+    /**
+     * @param lexicalForm 
+     * @param dataType 
+     * @param Language the language of this literal
+     */
+    public LiteralImpl(String lexicalForm, Iri dataType, Language language) {
+        this.lexicalForm = lexicalForm;
+        this.dataType = dataType;
+        this.language = language;
+        this.hashCode = super.hashCode();
+    }
+    
+    public Iri getDataType() {
+        return dataType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.clerezza.rdf.core.LiteralNode#getLexicalForm()
+     */
+    @Override
+    public String getLexicalForm() {
+        return lexicalForm;
+    }
+
+    @Override
+    public int hashCode() {
+        return hashCode;
+    }
+    
+
+    @Override
+    public String toString() {
+        StringBuffer result = new StringBuffer();
+        result.append('\"');
+        result.append(getLexicalForm());
+        result.append('\"');
+        result.append("^^");
+        result.append(getDataType());
+        return result.toString();
+    }
+
+    @Override
+    public Language getLanguage() {
+        return language;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java
new file mode 100644
index 0000000..8f6945e
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/LockingIterator.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils;
+
+import java.util.Iterator;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.commons.rdf.Triple;
+
+/**
+ * Wrapps an iterator<Triple> reading entering a read-lock on every invocation
+ * of hasNext and next
+ * @author reto
+ */
+class LockingIterator implements Iterator<Triple> {
+
+    private Iterator<Triple> base;
+    private Lock readLock;
+    private Lock writeLock;
+
+    public LockingIterator(Iterator<Triple> iterator, ReadWriteLock lock) {
+        base = iterator;
+        readLock = lock.readLock();
+        writeLock = lock.writeLock();
+    }
+
+    @Override
+    public boolean hasNext() {
+        readLock.lock();
+        try {
+            return base.hasNext();
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public Triple next() {
+        readLock.lock();
+        try {
+            return base.next();
+        } finally {
+            readLock.unlock();
+        }
+    }
+
+    @Override
+    public void remove() {
+        writeLock.lock();
+        try {
+            base.remove();
+        } finally {
+            writeLock.unlock();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java
new file mode 100644
index 0000000..dec30db
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/PlainLiteralImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils;
+
+import java.io.Serializable;
+import org.apache.commons.rdf.Iri;
+
+import org.apache.commons.rdf.Language;
+import org.apache.commons.rdf.Literal;
+
+/**
+ *
+ * @author reto
+ */
+public class PlainLiteralImpl extends AbstractLiteral implements Literal, Serializable {
+
+    private String lexicalForm;
+    private Language language = null;
+
+    public PlainLiteralImpl(String value) {
+        if (value == null) {
+            throw new IllegalArgumentException("The literal string cannot be null");
+        }
+        this.lexicalForm = value;
+    }
+
+    public PlainLiteralImpl(String value, Language language) {
+        if (value == null) {
+            throw new IllegalArgumentException("The literal string cannot be null");
+        }
+        this.lexicalForm = value;
+        this.language = language;
+    }
+
+    @Override
+    public String getLexicalForm() {
+        return lexicalForm;
+    }
+
+    @Override
+    public Language getLanguage() {
+        return language;
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer result = new StringBuffer();
+        result.append('\"').append(lexicalForm).append('\"');
+        if (language != null) {
+            result.append("@").append(language.toString());
+        }
+        return result.toString();
+    }
+
+    @Override
+    public Iri getDataType() {
+        return XSD_STRING;
+    }
+    private static final Iri XSD_STRING = new Iri("http://www.w3.org/2001/XMLSchema#string");
+    private static final int XSD_STRING_HASH = XSD_STRING.hashCode();
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java
new file mode 100644
index 0000000..ece7d55
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TripleImpl.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils;
+
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+
+/**
+ *
+ * @author reto
+ */
+public class TripleImpl implements Triple {
+
+    private final BlankNodeOrIri subject;
+    private final Iri predicate;
+    private final RdfTerm object;
+
+    /**
+     * Creates a new <code>TripleImpl</code>.
+     *
+     * @param subject  the subject.
+     * @param predicate  the predicate.
+     * @param object  the object.
+     * @throws IllegalArgumentException  if an attribute is <code>null</code>.
+     */
+    public TripleImpl(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
+        if (subject == null) {
+            throw new IllegalArgumentException("Invalid subject: null");
+        } else if (predicate == null) {
+            throw new IllegalArgumentException("Invalid predicate: null");
+        } else if (object == null) {
+            throw new IllegalArgumentException("Invalid object: null");
+        }
+        this.subject = subject;
+        this.predicate = predicate;
+        this.object = object;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (!(obj instanceof Triple)) {
+            return false;
+        }
+        final Triple other = (Triple) obj;
+        if (!this.subject.equals(other.getSubject())) {
+            return false;
+        }
+        if (!this.predicate.equals(other.getPredicate())) {
+            return false;
+        }
+        if (!this.object.equals(other.getObject())) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return (subject.hashCode() >> 1) ^ predicate.hashCode() ^ (object.hashCode() << 1);
+    }
+
+    @Override
+    public BlankNodeOrIri getSubject() {
+        return subject;
+    }
+
+    public Iri getPredicate() {
+        return predicate;
+    }
+
+    public RdfTerm getObject() {
+        return object;
+    }
+
+    @Override
+    public String toString() {
+        return subject + " " + predicate + " " + object + ".";
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java
new file mode 100644
index 0000000..4d3ff9d
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/TypedLiteralImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils;
+
+import java.io.Serializable;
+
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.Language;
+import org.apache.commons.rdf.Literal;
+
+/**
+ *
+ * @author reto
+ */
+public class TypedLiteralImpl extends AbstractLiteral implements  Serializable {
+    private String lexicalForm;
+    private Iri dataType;
+    private int hashCode;
+
+    /**
+     * @param lexicalForm 
+     * @param dataType 
+     */
+    public TypedLiteralImpl(String lexicalForm, Iri dataType) {
+        this.lexicalForm = lexicalForm;
+        this.dataType = dataType;
+        this.hashCode = super.hashCode();
+    }
+    
+    public Iri getDataType() {
+        return dataType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.clerezza.rdf.core.LiteralNode#getLexicalForm()
+     */
+    @Override
+    public String getLexicalForm() {
+        return lexicalForm;
+    }
+
+    @Override
+    public int hashCode() {
+        return hashCode;
+    }
+    
+
+    @Override
+    public String toString() {
+        StringBuffer result = new StringBuffer();
+        result.append('\"');
+        result.append(getLexicalForm());
+        result.append('\"');
+        result.append("^^");
+        result.append(getDataType());
+        return result.toString();
+    }
+
+    @Override
+    public Language getLanguage() {
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java
new file mode 100644
index 0000000..76b9283
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/WatchableGraphWrapper.java
@@ -0,0 +1,289 @@
+/*
+ * 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.commons.rdf.impl.utils;
+
+import java.lang.ref.WeakReference;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.WatchableGraph;
+import org.apache.commons.rdf.event.AddEvent;
+import org.apache.commons.rdf.event.FilterTriple;
+import org.apache.commons.rdf.event.GraphEvent;
+import org.apache.commons.rdf.event.GraphListener;
+import org.apache.commons.rdf.event.RemoveEvent;
+
+/**
+ *
+ * @author developer
+ */
+public class WatchableGraphWrapper implements WatchableGraph {
+    
+    final Graph wrapped;
+
+    public WatchableGraphWrapper(Graph wrapped) {
+        this.wrapped = wrapped;
+    }
+    
+       
+    //all listeners
+    private final Set<ListenerConfiguration> listenerConfigs = Collections.synchronizedSet(
+            new HashSet<ListenerConfiguration>());
+    private DelayedNotificator delayedNotificator = new DelayedNotificator();
+
+    @Override
+    public Iterator<Triple> iterator() {
+        return filter(null, null, null);
+    }
+
+    @Override
+    public boolean contains(Object o) {
+        if (!(o instanceof Triple)) {
+            return false;
+        }
+        Triple t = (Triple) o;
+        return filter(t.getSubject(), t.getPredicate(), t.getObject()).hasNext();
+    }
+
+    @Override
+    public Iterator<Triple> filter(BlankNodeOrIri subject, Iri predicate,
+            RdfTerm object) {
+        final Iterator<Triple> baseIter = wrapped.filter(subject, predicate, object);
+        return new Iterator<Triple>() {
+
+            Triple currentTriple = null;
+
+            @Override
+            public boolean hasNext() {
+                return baseIter.hasNext();
+            }
+
+            @Override
+            public Triple next() {
+                currentTriple = baseIter.next();
+                return currentTriple;
+            }
+
+            @Override
+            public void remove() {
+                baseIter.remove();
+                dispatchEvent(new RemoveEvent(WatchableGraphWrapper.this, currentTriple));
+            }
+        };
+    }
+
+    @Override
+    public boolean add(Triple triple) {
+        boolean success = performAdd(triple);
+        if (success) {
+            dispatchEvent(new AddEvent(this, triple));
+        }
+        return success;
+    }
+
+    /**
+     * A subclass of <code>AbstractGraph</code> should override 
+     * this method instead of <code>add</code> for Graph event support to be
+     * added.
+     * 
+     * @param e The triple to be added to the triple collection
+     * @return
+     */
+    protected boolean performAdd(Triple e) {
+        return wrapped.add(e);
+    }
+
+    @Override
+    public boolean remove(Object o) {
+        Triple triple = (Triple) o;
+        boolean success = performRemove(triple);
+        if (success) {
+            dispatchEvent(new RemoveEvent(this, triple));
+        }
+        return success;
+    }
+
+    @Override
+    public boolean removeAll(Collection<?> c) {
+        boolean modified = false;
+        for (Iterator<? extends Object> it = c.iterator(); it.hasNext();) {
+            Object object = it.next();
+            if (remove(object)) {
+                modified = true;
+            }
+        }
+        return modified;
+    }
+
+    /**
+     * A subclass of <code>AbstractGraph</code> should override 
+     * this method instead of <code>remove</code> for ImmutableGraph event support to be
+     * added.
+     * 
+     * @param o The triple to be removed from the triple collection
+     * @return
+     */
+    protected boolean performRemove(Triple triple) {
+        Iterator<Triple> e = filter(null, null, null);
+        while (e.hasNext()) {
+            if (triple.equals(e.next())) {
+                e.remove();
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Dispatches a <code>GraphEvent</code> to all registered listeners for which
+     * the specified <code>Triple</code> matches the <code>FilterTriple</code>s
+     * of the listeners.
+     * 
+     * @param triple The Triple that was modified
+     * @param type The type of modification
+     */
+    protected void dispatchEvent(GraphEvent event) {
+        synchronized(listenerConfigs) {
+            Iterator<ListenerConfiguration> iter = listenerConfigs.iterator();
+            while (iter.hasNext()) {
+                ListenerConfiguration config = iter.next();
+                GraphListener registeredListener = config.getListener();
+                if (registeredListener == null) {
+                    iter.remove();
+                    continue;
+                }
+                if (config.getFilter().match(event.getTriple())) {
+                    delayedNotificator.sendEventToListener(registeredListener, event);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void addGraphListener(GraphListener listener, FilterTriple filter) {
+        addGraphListener(listener, filter, 0);
+    }
+
+    @Override
+    public void addGraphListener(GraphListener listener, FilterTriple filter,
+            long delay) {
+        listenerConfigs.add(new ListenerConfiguration(listener, filter));
+        if (delay > 0) {
+            delayedNotificator.addDelayedListener(listener, delay);
+        }
+    }
+
+    @Override
+    public void removeGraphListener(GraphListener listener) {
+        synchronized(listenerConfigs) {
+            Iterator<ListenerConfiguration> iter = listenerConfigs.iterator();
+            while (iter.hasNext()) {
+                ListenerConfiguration listenerConfig = iter.next();
+                GraphListener registeredListener = listenerConfig.getListener();
+                if ((registeredListener == null) || (registeredListener.equals(listener))) {
+                    iter.remove();
+                }
+            }
+        }
+        delayedNotificator.removeDelayedListener(listener);
+    }
+
+    @Override
+    public ImmutableGraph getImmutableGraph() {
+        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public ReadWriteLock getLock() {
+        return wrapped.getLock();
+    }
+
+    @Override
+    public int size() {
+        return wrapped.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return wrapped.isEmpty();
+    }
+
+    @Override
+    public Object[] toArray() {
+        return wrapped.toArray();
+    }
+
+    @Override
+    public <T> T[] toArray(T[] a) {
+        return wrapped.toArray(a);
+    }
+
+    @Override
+    public boolean containsAll(Collection<?> c) {
+        return wrapped.containsAll(c);
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends Triple> c) {
+        return wrapped.addAll(c);
+    }
+
+    @Override
+    public boolean retainAll(Collection<?> c) {
+        return wrapped.retainAll(c);
+    }
+
+    @Override
+    public void clear() {
+        wrapped.clear();
+    }
+
+    private static class ListenerConfiguration {
+
+        private WeakReference<GraphListener> listenerRef;
+        private FilterTriple filter;
+
+        private ListenerConfiguration(GraphListener listener, FilterTriple filter) {
+            this.listenerRef = new WeakReference<GraphListener>(listener);
+            this.filter = filter;
+        }
+
+        /**
+         * @return the listener
+         */
+        GraphListener getListener() {
+            GraphListener listener = listenerRef.get();
+            return listener;
+        }
+
+        /**
+         * @return the filter
+         */
+        FilterTriple getFilter() {
+            return filter;
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java
new file mode 100644
index 0000000..f2b93b8
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReadLockDebug.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.debug;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
+
+/**
+ *
+ * @author mir
+ */
+public class ReadLockDebug extends ReadLock {
+
+    ReentrantReadWriteLockTracker lock;
+    StackTraceElement[] stackTrace;
+
+    ReadLock readLock;
+    public ReadLockDebug(ReentrantReadWriteLockTracker lock) {
+        super(lock);
+        this.lock = lock;
+        this.readLock = lock.realReadLock();
+    }
+
+    @Override
+    public void lock() {
+        readLock.lock();
+        lock.addLockedReadLock(this);
+        stackTrace = Thread.currentThread().getStackTrace();
+    }
+
+    @Override
+    public void lockInterruptibly() throws InterruptedException {
+        readLock.lockInterruptibly();
+    }
+
+    @Override
+    public Condition newCondition() {
+        return readLock.newCondition();
+    }
+
+    @Override
+    public String toString() {
+        return readLock.toString();
+    }
+
+    @Override
+    public boolean tryLock() {
+        return readLock.tryLock();
+    }
+
+    @Override
+    public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
+        return readLock.tryLock(timeout, unit);
+    }
+
+    @Override
+    public void unlock() {
+        readLock.unlock();
+        lock.removeReadLock(this);
+        stackTrace = null;
+    }
+
+    public StackTraceElement[] getStackTrace() {
+        return stackTrace;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
new file mode 100644
index 0000000..65abf32
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/ReentrantReadWriteLockTracker.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils.debug;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ *
+ * @author mir
+ */
+public class ReentrantReadWriteLockTracker extends ReentrantReadWriteLock {
+
+
+    private Set<ReadLockDebug> lockedReadLocks = Collections.synchronizedSet(new HashSet<ReadLockDebug>());
+    private final WriteLockDebug writeLock = new WriteLockDebug(this);
+    @Override
+    protected Thread getOwner() {
+        return super.getOwner();
+    }
+
+    @Override
+    protected Collection<Thread> getQueuedReaderThreads() {
+        return super.getQueuedReaderThreads();
+    }
+
+    @Override
+    protected Collection<Thread> getQueuedThreads() {
+        return super.getQueuedThreads();
+    }
+
+    @Override
+    protected Collection<Thread> getQueuedWriterThreads() {
+        return super.getQueuedWriterThreads();
+    }
+
+    @Override
+    public int getReadHoldCount() {
+        return super.getReadHoldCount();
+    }
+
+    @Override
+    public int getReadLockCount() {
+        return super.getReadLockCount();
+    }
+
+    @Override
+    public int getWaitQueueLength(Condition condition) {
+        return super.getWaitQueueLength(condition);
+    }
+
+    @Override
+    protected Collection<Thread> getWaitingThreads(Condition condition) {
+        return super.getWaitingThreads(condition);
+    }
+
+    @Override
+    public int getWriteHoldCount() {
+        return super.getWriteHoldCount();
+    }
+
+    @Override
+    public boolean hasWaiters(Condition condition) {
+        return super.hasWaiters(condition);
+    }
+
+    @Override
+    public boolean isWriteLocked() {
+        return super.isWriteLocked();
+    }
+
+    @Override
+    public boolean isWriteLockedByCurrentThread() {
+        return super.isWriteLockedByCurrentThread();
+    }
+
+    @Override
+    public ReadLock readLock() {
+        return new ReadLockDebug(this);
+    }
+
+    ReadLock realReadLock() {
+        return super.readLock();
+    }
+
+    WriteLock realWriteLock() {
+        return super.writeLock();
+    }
+
+    @Override
+    public String toString() {
+        return super.toString();
+    }
+
+    @Override
+    public WriteLockDebug writeLock() {
+        return writeLock;
+    }
+
+    void addLockedReadLock(ReadLockDebug lock) {
+        lockedReadLocks.add(lock);
+    }
+
+    void removeReadLock(ReadLockDebug lock) {
+        lockedReadLocks.remove(lock);
+    }
+
+    public Set<ReadLockDebug> getLockedReadLocks() {
+        return lockedReadLocks;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java
new file mode 100644
index 0000000..0231331
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/debug/WriteLockDebug.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.debug;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
+
+/**
+ *
+ * @author mir
+ */
+public class WriteLockDebug extends WriteLock {
+
+    private ReentrantReadWriteLockTracker lock;
+    private WriteLock writeLock;
+    private StackTraceElement[] stackTrace;
+
+    public WriteLockDebug(ReentrantReadWriteLockTracker lock) {
+        super(lock);
+        this.lock = lock;
+        this.writeLock = lock.realWriteLock();
+    }
+
+    @Override
+    public int getHoldCount() {
+        return writeLock.getHoldCount();
+    }
+
+    @Override
+    public boolean isHeldByCurrentThread() {
+        return writeLock.isHeldByCurrentThread();
+    }
+
+    @Override
+    public void lock() {
+        writeLock.lock();
+        stackTrace = Thread.currentThread().getStackTrace();
+    }
+
+    @Override
+    public void lockInterruptibly() throws InterruptedException {
+        writeLock.lockInterruptibly();
+    }
+
+    @Override
+    public Condition newCondition() {
+        return writeLock.newCondition();
+    }
+
+    @Override
+    public boolean tryLock() {
+        return writeLock.tryLock();
+    }
+
+    @Override
+    public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException {
+        return writeLock.tryLock(timeout, unit);
+    }
+
+    @Override
+    public void unlock() {
+        writeLock.unlock();
+        stackTrace = null;
+    }
+
+    public StackTraceElement[] getStackTrace() {
+        return stackTrace;
+    }
+
+
+}


[3/7] clerezza-rdf-core git commit: CLEREZZA-982: moved files for new packages

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
new file mode 100644
index 0000000..b7e2500
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphMatcher.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph;
+
+/**
+ * @author reto
+ * 
+ */
+public class GraphMatcher {
+
+
+    private final static Logger log = Logger.getLogger(GraphMatcher.class.getName());
+
+    /**
+     * get a mapping from g1 to g2 or null if the graphs are not isomorphic. The
+     * returned map maps each <code>BNode</code>s from g1 to one
+     * of g2. If the graphs are ground graphs the method return an empty map if
+     * the ImmutableGraph are equals and null otherwise.
+     * <p/>
+     * NOTE: This method does not returned mapping from blank nodes to grounded
+     * nodes, a bnode in g1 is not a vraiable that may match any node, but must
+     * match a bnode in g2.
+     * <p/>
+     *
+     * On the algorithm:<br/>
+     * - In a first step it checked if every grounded triple in g1 matches one
+     * in g2<br/>
+     * - [optional] blank node blind matching</br>
+     * - in a map mbng1 bnode of g1 is mapped to a set of of its
+     * properties and inverse properties, this is the predicate and the object
+     * or subject respectively, analoguosly in mbgn2 every bnode of g2<br/>
+     * - based on the incoming and outgoing properties a hash is calculated for
+     * each bnode, in the first step when calculating the hash  aconstant value
+     * is taken for the bnodes that might be subject or object in the (inverse properties)
+     * - hash-classes:
+     * 
+     * @param g1
+     * @param g2
+     * @return a Set of NodePairs
+     */
+    public static Map<BlankNode, BlankNode> getValidMapping(Graph og1, Graph og2) {
+        Graph g1 = new SimpleMGraph(og1);
+        Graph g2 = new SimpleMGraph(og2);
+        if (!Utils.removeGrounded(g1,g2)) {
+            return null;
+        }
+        final HashMatching hashMatching;
+        try {
+            hashMatching = new HashMatching(g1, g2);
+        } catch (GraphNotIsomorphicException ex) {
+            return null;
+        }
+        Map<BlankNode, BlankNode> matchings = hashMatching.getMatchings();
+        if (g1.size() > 0) {
+            //start trial an error matching
+            //TODO (CLEREZZA-81) at least in the situation where one matching
+            //group is big (approx > 5) we should switch back to hash-based matching
+            //after a first guessed matching, rather than try all permutations
+            Map<BlankNode, BlankNode> remainingMappings = trialAndErrorMatching(g1, g2, hashMatching.getMatchingGroups());
+            if (remainingMappings == null) {
+                return null;
+            } else {
+                matchings.putAll(remainingMappings);
+            }
+        }
+        return matchings;
+    }
+
+    private static Map<BlankNode, BlankNode> trialAndErrorMatching(Graph g1, Graph g2,
+            Map<Set<BlankNode>, Set<BlankNode>> matchingGroups) {
+        if (log.isLoggable(Level.FINE)) {
+            Set<BlankNode> bn1  = Utils.getBNodes(g1);
+            log.log(Level.FINE,"doing trial and error matching for {0}"+" bnodes, "+"in graphs of size: {1}.", new Object[]{bn1.size(), g1.size()});
+        }
+        Iterator<Map<BlankNode, BlankNode>> mappingIter
+                = GroupMappingIterator.create(matchingGroups);
+        while (mappingIter.hasNext()) {
+            Map<BlankNode, BlankNode> map = mappingIter.next();
+            if (checkMapping(g1, g2, map)) {
+                return map;
+            }
+        }
+        return null;
+    }
+
+    private static boolean checkMapping(Graph g1, Graph g2, Map<BlankNode, BlankNode> map) {
+        for (Triple triple : g1) {
+            if (!g2.contains(map(triple, map))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private static Triple map(Triple triple, Map<BlankNode, BlankNode> map) {
+        final BlankNodeOrIri oSubject = triple.getSubject();
+
+        BlankNodeOrIri subject = oSubject instanceof BlankNode ?
+            map.get((BlankNode)oSubject) : oSubject;
+
+        RdfTerm oObject = triple.getObject();
+        RdfTerm object = oObject instanceof BlankNode ?
+            map.get((BlankNode)oObject) : oObject;
+        return new TripleImpl(subject, triple.getPredicate(), object);
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
new file mode 100644
index 0000000..42de52e
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GraphNotIsomorphicException.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+/**
+ *
+ * @author reto
+ */
+class GraphNotIsomorphicException extends Exception {
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
new file mode 100644
index 0000000..f79bd2a
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/GroupMappingIterator.java
@@ -0,0 +1,102 @@
+/*
+ *  Copyright 2010 reto.
+ * 
+ *  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.
+ *  under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * Iterates over all mappings from each element of every Set<T> to each
+ * elemenent of their corresponding Set<U>.
+ *
+ * @author reto
+ */
+class GroupMappingIterator<T,U> implements Iterator<Map<T, U>> {
+
+    private Iterator<Map<T, U>> firstPartIter;
+    private Map<T, U> currentFirstPart;
+    final private Map<Set<T>, Set<U>> restMap;
+    private Iterator<Map<T, U>> currentRestPartIter;
+
+    static <T,U> Iterator<Map<T, U>> create(Map<Set<T>, Set<U>> matchingGroups) {
+        if (matchingGroups.size() > 1) {
+            return new GroupMappingIterator<T, U>(matchingGroups);
+        } else {
+            if (matchingGroups.size() == 0) {
+                return new ArrayList<Map<T, U>>(0).iterator();
+            }
+            Map.Entry<Set<T>, Set<U>> entry = matchingGroups.entrySet().iterator().next();
+            return new MappingIterator<T,U>(entry.getKey(),
+                        entry.getValue());
+        }
+    }
+
+    private GroupMappingIterator(Map<Set<T>, Set<U>> matchingGroups) {
+        if (matchingGroups.size() == 0) {
+            throw new IllegalArgumentException("matchingGroups must not be empty");
+        }
+        restMap = new HashMap<Set<T>, Set<U>>();
+        boolean first = true;
+        for (Map.Entry<Set<T>, Set<U>> entry : matchingGroups.entrySet()) {
+            if (first) {
+                firstPartIter = new MappingIterator<T,U>(entry.getKey(),
+                        entry.getValue());
+                first = false;
+            } else {
+                restMap.put(entry.getKey(), entry.getValue());
+            }
+        }
+        currentRestPartIter = create(restMap);
+        currentFirstPart = firstPartIter.next();
+    }
+
+    @Override
+    public boolean hasNext() {
+        return firstPartIter.hasNext() || currentRestPartIter.hasNext();
+    }
+
+    @Override
+    public Map<T, U> next() {
+        Map<T, U> restPart;
+        if (currentRestPartIter.hasNext()) {
+            restPart = currentRestPartIter.next();
+        } else {
+            if (firstPartIter.hasNext()) {
+                currentFirstPart = firstPartIter.next();
+                currentRestPartIter = create(restMap);
+                restPart = currentRestPartIter.next();
+            } else {
+                throw new NoSuchElementException();
+            }
+        }
+        Map<T, U> result = new HashMap<T, U>(restPart);
+        result.putAll(currentFirstPart);
+        return result;
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java
new file mode 100644
index 0000000..ae419f6
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/HashMatching.java
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+
+import org.apache.commons.rdf.impl.utils.graphmatching.collections.IntHashMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.commons.rdf.impl.utils.graphmatching.collections.IntIterator;
+
+/**
+ *
+ * @author reto
+ */
+public class HashMatching {
+
+    private Map<BlankNode, BlankNode> matchings = new HashMap<BlankNode, BlankNode>();
+    private Map<Set<BlankNode>, Set<BlankNode>> matchingGroups;
+
+    /**
+     * tc1 and tc2 will be modified: the triples containing no unmatched bnode
+     * will be removed
+     *
+     * @param tc1
+     * @param tc2
+     * @throws GraphNotIsomorphicException
+     */
+    HashMatching(Graph tc1, Graph tc2) throws GraphNotIsomorphicException {
+        int foundMatchings = 0;
+        int foundMatchingGroups = 0;
+        Map<BlankNode, Integer> bNodeHashMap = new HashMap<BlankNode, Integer>();
+        while (true) {
+            bNodeHashMap = matchByHashes(tc1, tc2, bNodeHashMap);
+            if (bNodeHashMap == null) {
+                throw new GraphNotIsomorphicException();
+            }
+            if (matchings.size() == foundMatchings) {
+                if (!(matchingGroups.size() > foundMatchingGroups)) {
+                    break;
+                }
+            }
+            foundMatchings = matchings.size();
+            foundMatchingGroups = matchingGroups.size();
+        }
+    }
+
+    /**
+     *
+     * @return a map containing set of which each bnodes mappes one of the other set
+     */
+    public Map<Set<BlankNode>, Set<BlankNode>> getMatchingGroups() {
+        return matchingGroups;
+    }
+
+    public Map<BlankNode, BlankNode> getMatchings() {
+        return matchings;
+    }
+
+    
+    private static IntHashMap<Set<BlankNode>> getHashNodes(Map<BlankNode,
+            Set<Property>> bNodePropMap, Map<BlankNode, Integer> bNodeHashMap) {
+        IntHashMap<Set<BlankNode>> result = new IntHashMap<Set<BlankNode>>();
+        for (Map.Entry<BlankNode, Set<Property>> entry : bNodePropMap.entrySet()) {
+            int hash = computeHash(entry.getValue(), bNodeHashMap);
+            Set<BlankNode> bNodeSet = result.get(hash);
+            if (bNodeSet == null) {
+                bNodeSet = new HashSet<BlankNode>();
+                result.put(hash,bNodeSet);
+            }
+            bNodeSet.add(entry.getKey());
+        }
+        return result;
+    }
+    /*
+     * returns a Map from bnodes to hash that can be used for future
+     * refinements, this could be separate for each ImmutableGraph.
+     *
+     * triples no longer containing an unmatched bnodes ae removed.
+     *
+     * Note that the matched node are not guaranteed to be equals, but only to
+     * be the correct if the graphs are isomorphic.
+     */
+    private Map<BlankNode, Integer> matchByHashes(Graph g1, Graph g2,
+            Map<BlankNode, Integer> bNodeHashMap) {
+        Map<BlankNode, Set<Property>> bNodePropMap1  = getBNodePropMap(g1);
+        Map<BlankNode, Set<Property>> bNodePropMap2  = getBNodePropMap(g2);
+        IntHashMap<Set<BlankNode>> hashNodeMap1 = getHashNodes(bNodePropMap1, bNodeHashMap);
+        IntHashMap<Set<BlankNode>> hashNodeMap2 = getHashNodes(bNodePropMap2, bNodeHashMap);
+        if (!hashNodeMap1.keySet().equals(hashNodeMap2.keySet())) {
+            return null;
+        }
+
+        matchingGroups = new HashMap<Set<BlankNode>, Set<BlankNode>>();
+        IntIterator hashIter = hashNodeMap1.keySet().intIterator();
+        while (hashIter.hasNext()) {
+            int hash = hashIter.next();
+            Set<BlankNode> nodes1 = hashNodeMap1.get(hash);
+            Set<BlankNode> nodes2 = hashNodeMap2.get(hash);
+            if (nodes1.size() != nodes2.size()) {
+                return null;
+            }
+            if (nodes1.size() != 1) {
+                matchingGroups.put(nodes1, nodes2);
+                continue;
+            }
+            final BlankNode bNode1 = nodes1.iterator().next();
+            final BlankNode bNode2 = nodes2.iterator().next();
+            matchings.put(bNode1,bNode2);
+            //in the graphs replace node occurences with grounded node,
+            BlankNodeOrIri mappedNode = new MappedNode(bNode1, bNode2);
+            replaceNode(g1,bNode1, mappedNode);
+            replaceNode(g2, bNode2, mappedNode);
+            //remove grounded triples
+            if (!Utils.removeGrounded(g1,g2)) {
+                return null;
+            }
+        }
+        Map<BlankNode, Integer> result = new HashMap<BlankNode, Integer>();
+        addInverted(result, hashNodeMap1);
+        addInverted(result, hashNodeMap2);
+        return result;
+    }
+    private static int computeHash(Set<Property> propertySet, Map<BlankNode, Integer> bNodeHashMap) {
+        int result = 0;
+        for (Property property : propertySet) {
+            result += property.hashCode(bNodeHashMap);
+        }
+        return result;
+    }
+    private static Map<BlankNode, Set<Property>> getBNodePropMap(Graph g) {
+        Set<BlankNode> bNodes = Utils.getBNodes(g);
+        Map<BlankNode, Set<Property>> result = new HashMap<BlankNode, Set<Property>>();
+        for (BlankNode bNode : bNodes) {
+            result.put(bNode, getProperties(bNode, g));
+        }
+        return result;
+    }
+    private static Set<Property> getProperties(BlankNode bNode, Graph g) {
+        Set<Property> result = new HashSet<Property>();
+        Iterator<Triple> ti = g.filter(bNode, null, null);
+        while (ti.hasNext()) {
+            Triple triple = ti.next();
+            result.add(new ForwardProperty(triple.getPredicate(), triple.getObject()));
+        }
+        ti = g.filter(null, null, bNode);
+        while (ti.hasNext()) {
+            Triple triple = ti.next();
+            result.add(new BackwardProperty(triple.getSubject(), triple.getPredicate()));
+        }
+        return result;
+    }
+    private static int nodeHash(RdfTerm resource, Map<BlankNode, Integer> bNodeHashMap) {
+        if (resource instanceof BlankNode) {
+            Integer mapValue = bNodeHashMap.get((BlankNode)resource);
+            if (mapValue == null) {
+                return 0;
+            } else {
+                return mapValue;
+            }
+        } else {
+            return resource.hashCode();
+        }
+    }
+    private static void replaceNode(Graph graph, BlankNode bNode, BlankNodeOrIri replacementNode) {
+        Set<Triple> triplesToRemove = new HashSet<Triple>();
+        for (Triple triple : graph) {
+            Triple replacementTriple = getReplacement(triple, bNode, replacementNode);
+            if (replacementTriple != null) {
+                triplesToRemove.add(triple);
+                graph.add(replacementTriple);
+            }
+        }
+        graph.removeAll(triplesToRemove);
+    }
+    private static Triple getReplacement(Triple triple, BlankNode bNode, BlankNodeOrIri replacementNode) {
+        if (triple.getSubject().equals(bNode)) {
+            if (triple.getObject().equals(bNode)) {
+                return new TripleImpl(replacementNode, triple.getPredicate(), replacementNode);
+            } else {
+                return new TripleImpl(replacementNode, triple.getPredicate(), triple.getObject());
+            }
+        } else {
+            if (triple.getObject().equals(bNode)) {
+                return new TripleImpl(triple.getSubject(), triple.getPredicate(), replacementNode);
+            } else {
+                return null;
+            }
+        }
+    }
+    private static void addInverted(Map<BlankNode, Integer> result, IntHashMap<Set<BlankNode>> hashNodeMap) {
+        for (int hash : hashNodeMap.keySet()) {
+            Set<BlankNode> bNodes = hashNodeMap.get(hash);
+            for (BlankNode bNode : bNodes) {
+                result.put(bNode, hash);
+            }
+        }
+    }
+    
+    private static class BackwardProperty implements Property {
+        private BlankNodeOrIri subject;
+        private Iri predicate;
+    
+        public BackwardProperty(BlankNodeOrIri subject, Iri predicate) {
+            this.subject = subject;
+            this.predicate = predicate;
+        }
+    
+        @Override
+        public int hashCode(Map<BlankNode, Integer> bNodeHashMap) {
+            return  0xFF ^ predicate.hashCode() ^ nodeHash(subject, bNodeHashMap);
+        }
+    
+    }
+    private static class ForwardProperty implements Property {
+        private Iri predicate;
+        private RdfTerm object;
+    
+        public ForwardProperty(Iri predicate, RdfTerm object) {
+            this.predicate = predicate;
+            this.object = object;
+        }
+    
+        @Override
+        public int hashCode(Map<BlankNode, Integer> bNodeHashMap) {
+            return predicate.hashCode() ^ nodeHash(object, bNodeHashMap);
+        }
+    }
+    private static class MappedNode implements BlankNodeOrIri {
+        private BlankNode bNode1, bNode2;
+    
+        public MappedNode(BlankNode bNode1, BlankNode bNode2) {
+            this.bNode1 = bNode1;
+            this.bNode2 = bNode2;
+        }
+        
+    }
+    private static interface Property {
+        public int hashCode(Map<BlankNode, Integer> bNodeHashMap);
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java
new file mode 100644
index 0000000..dea95b5
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/MappingIterator.java
@@ -0,0 +1,76 @@
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+/*
+ * 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.
+ */
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * An iterator over all possible mapping beetween the elemnets of two sets of
+ * the same size, each mapping maps each element from set1 to a disctinct one of
+ * set2.
+ *
+ *
+ *
+ * @author reto
+ */
+class MappingIterator<T,U> implements Iterator<Map<T, U>> {
+
+    private List<T> list1;
+    private Iterator<List<U>> permutationList2Iterator;
+
+
+    public MappingIterator(Set<T> set1, Set<U> set2) {
+        if (set1.size() != set2.size()) {
+            throw new IllegalArgumentException();
+        }
+        this.list1 = new ArrayList<T>(set1);
+        permutationList2Iterator = new PermutationIterator<U>(
+                new ArrayList<U>(set2));
+    }
+
+    @Override
+    public boolean hasNext() {
+        return permutationList2Iterator.hasNext();
+    }
+
+    @Override
+    public Map<T, U> next() {
+        List<U> list2 = permutationList2Iterator.next();
+        Map<T, U> result = new HashMap<T, U>(list1.size());
+        for (int i = 0; i < list1.size(); i++) {
+            result.put(list1.get(i), list2.get(i));
+        }
+        return result;
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
new file mode 100644
index 0000000..6b6fa07
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/PermutationIterator.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching;
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+/**
+ *
+ * An Iterator over all permuations of a list.
+ *
+ * @author reto
+ */
+class PermutationIterator<T> implements Iterator<List<T>> {
+
+    private Iterator<List<T>> restIterator;
+    private List<T> list;
+    private List<T> next;
+    int posInList = 0; //the position of the last element of next returned list
+    //with list, this is the one excluded from restIterator
+
+    PermutationIterator(List<T> list) {
+        this.list = Collections.unmodifiableList(list);
+        if (list.size() > 1) {
+            createRestList();
+        }
+        prepareNext();
+    }
+
+    @Override
+    public boolean hasNext() {
+        return next != null;
+    }
+
+    @Override
+    public List<T> next() {
+        List<T> result = next;
+        if (result == null) {
+            throw new NoSuchElementException();
+        }
+        prepareNext();
+        return result;
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException("Not supported");
+    }
+
+    private void createRestList() {
+        List<T> restList = new ArrayList<T>(list);
+        restList.remove(posInList);
+        restIterator = new PermutationIterator<T>(restList);
+    }
+
+    private void prepareNext() {
+        next = getNext();
+        
+    }
+    private List<T> getNext() {
+        if (list.size() == 0) {
+            return null;
+        }
+        if (list.size() == 1) {
+            if (posInList++ == 0) {
+                return new ArrayList<T>(list);
+            } else {
+                return null;
+            }
+        } else {
+            if (!restIterator.hasNext()) {
+                if (posInList < (list.size()-1)) {
+                    posInList++;
+                    createRestList();
+                } else {
+                    return null;
+                }
+            }
+            List<T> result = restIterator.next();
+            result.add(list.get(posInList));
+            return result;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java
new file mode 100644
index 0000000..25a7a4b
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/Utils.java
@@ -0,0 +1,82 @@
+package org.apache.commons.rdf.impl.utils.graphmatching;
+/*
+ *
+ * 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.
+ *
+*/
+
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Triple;
+
+public class Utils {
+
+    static Set<BlankNode> getBNodes(Collection<Triple> s) {
+        Set<BlankNode> result = new HashSet<BlankNode>();
+        for (Triple triple : s) {
+            if (triple.getSubject() instanceof BlankNode) {
+                result.add((BlankNode) triple.getSubject());
+            }
+            if (triple.getObject() instanceof BlankNode) {
+                result.add((BlankNode) triple.getObject());
+            }
+        }
+        return result;
+    }
+
+    /**
+     * removes the common grounded triples from s1 and s2. returns false if
+     * a grounded triple is not in both sets, true otherwise
+     */
+    static boolean removeGrounded(Collection<Triple> s1, Collection<Triple> s2) {
+        Iterator<Triple> triplesIter = s1.iterator();
+        while (triplesIter.hasNext()) {
+            Triple triple = triplesIter.next();
+            if (!isGrounded(triple)) {
+                continue;
+            }
+            if (!s2.remove(triple)) {
+                return false;
+            }
+            triplesIter.remove();
+        }
+        //for efficiency we might skip this (redefine method)
+        for (Triple triple : s2) {
+            if (isGrounded(triple)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private static boolean isGrounded(Triple triple) {
+        if (triple.getSubject() instanceof BlankNode) {
+            return false;
+        }
+        if (triple.getObject() instanceof BlankNode) {
+            return false;
+        }
+        return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
new file mode 100644
index 0000000..922ae47
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashMap.java
@@ -0,0 +1,377 @@
+/*
+ * Copyright 2002-2004 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.
+ */
+
+/*
+ * Note: originally released under the GNU LGPL v2.1, 
+ * but rereleased by the original author under the ASF license (above).
+ */
+
+package org.apache.commons.rdf.impl.utils.graphmatching.collections;
+
+
+
+/**
+ * <p>A hash map that uses primitive ints for the key rather than objects.</p>
+ *
+ * <p>Note that this class is for internal optimization purposes only, and may
+ * not be supported in future releases of Jakarta Commons Lang.  Utilities of
+ * this sort may be included in future releases of Jakarta Commons Collections.</p>
+ *
+ * @author Justin Couch
+ * @author Alex Chaffee (alex@apache.org)
+ * @author Stephen Colebourne
+ * @since 2.0
+ * @version $Revision: 1.2 $
+ * @see java.util.HashMap
+ */
+public class IntHashMap<T> {
+
+
+    private IntSet keySet = new IntHashSet();
+
+    /**
+     * The hash table data.
+     */
+    private transient Entry<T> table[];
+
+    /**
+     * The total number of entries in the hash table.
+     */
+    private transient int count;
+
+    /**
+     * The table is rehashed when its size exceeds this threshold.  (The
+     * value of this field is (int)(capacity * loadFactor).)
+     *
+     * @serial
+     */
+    private int threshold;
+
+    /**
+     * The load factor for the hashtable.
+     *
+     * @serial
+     */
+    private float loadFactor;
+
+    /**
+     * <p>Innerclass that acts as a datastructure to create a new entry in the
+     * table.</p>
+     */
+    private static class Entry<T> {
+        int hash;
+        int key;
+        T value;
+        Entry<T> next;
+
+        /**
+         * <p>Create a new entry with the given values.</p>
+         *
+         * @param hash The code used to hash the object with
+         * @param key The key used to enter this in the table
+         * @param value The value for this key
+         * @param next A reference to the next entry in the table
+         */
+        protected Entry(int hash, int key, T value, Entry<T> next) {
+            this.hash = hash;
+            this.key = key;
+            this.value = value;
+            this.next = next;
+        }
+    }
+
+    /**
+     * <p>Constructs a new, empty hashtable with a default capacity and load
+     * factor, which is <code>20</code> and <code>0.75</code> respectively.</p>
+     */
+    public IntHashMap() {
+        this(20, 0.75f);
+    }
+
+    /**
+     * <p>Constructs a new, empty hashtable with the specified initial capacity
+     * and default load factor, which is <code>0.75</code>.</p>
+     *
+     * @param  initialCapacity the initial capacity of the hashtable.
+     * @throws IllegalArgumentException if the initial capacity is less
+     *   than zero.
+     */
+    public IntHashMap(int initialCapacity) {
+        this(initialCapacity, 0.75f);
+    }
+
+    /**
+     * <p>Constructs a new, empty hashtable with the specified initial
+     * capacity and the specified load factor.</p>
+     *
+     * @param initialCapacity the initial capacity of the hashtable.
+     * @param loadFactor the load factor of the hashtable.
+     * @throws IllegalArgumentException  if the initial capacity is less
+     *             than zero, or if the load factor is nonpositive.
+     */
+    public IntHashMap(int initialCapacity, float loadFactor) {
+        super();
+        if (initialCapacity < 0) {
+            throw new IllegalArgumentException("Illegal Capacity: " + initialCapacity);
+        }
+        if (loadFactor <= 0) {
+            throw new IllegalArgumentException("Illegal Load: " + loadFactor);
+        }
+        if (initialCapacity == 0) {
+            initialCapacity = 1;
+        }
+
+        this.loadFactor = loadFactor;
+        table = new Entry[initialCapacity];
+        threshold = (int) (initialCapacity * loadFactor);
+    }
+
+    /**
+     * <p>Returns the number of keys in this hashtable.</p>
+     *
+     * @return  the number of keys in this hashtable.
+     */
+    public int size() {
+        return count;
+    }
+
+    /**
+     * <p>Tests if this hashtable maps no keys to values.</p>
+     *
+     * @return  <code>true</code> if this hashtable maps no keys to values;
+     *          <code>false</code> otherwise.
+     */
+    public boolean isEmpty() {
+        return count == 0;
+    }
+
+    /**
+     * <p>Tests if some key maps into the specified value in this hashtable.
+     * This operation is more expensive than the <code>containsKey</code>
+     * method.</p>
+     *
+     * <p>Note that this method is identical in functionality to containsValue,
+     * (which is part of the Map interface in the collections framework).</p>
+     *
+     * @param      value   a value to search for.
+     * @return     <code>true</code> if and only if some key maps to the
+     *             <code>value</code> argument in this hashtable as
+     *             determined by the <tt>equals</tt> method;
+     *             <code>false</code> otherwise.
+     * @throws  NullPointerException  if the value is <code>null</code>.
+     * @see        #containsKey(int)
+     * @see        #containsValue(Object)
+     * @see        java.util.Map
+     */
+    public boolean contains(Object value) {
+        if (value == null) {
+            throw new NullPointerException();
+        }
+
+        Entry tab[] = table;
+        for (int i = tab.length; i-- > 0;) {
+            for (Entry e = tab[i]; e != null; e = e.next) {
+                if (e.value.equals(value)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * <p>Returns <code>true</code> if this HashMap maps one or more keys
+     * to this value.</p>
+     *
+     * <p>Note that this method is identical in functionality to contains
+     * (which predates the Map interface).</p>
+     *
+     * @param value value whose presence in this HashMap is to be tested.
+     * @see    java.util.Map
+     * @since JDK1.2
+     */
+    public boolean containsValue(Object value) {
+        return contains(value);
+    }
+
+    /**
+     * <p>Tests if the specified object is a key in this hashtable.</p>
+     *
+     * @param  key  possible key.
+     * @return <code>true</code> if and only if the specified object is a
+     *    key in this hashtable, as determined by the <tt>equals</tt>
+     *    method; <code>false</code> otherwise.
+     * @see #contains(Object)
+     */
+    public boolean containsKey(int key) {
+        Entry tab[] = table;
+        int hash = key;
+        int index = (hash & 0x7FFFFFFF) % tab.length;
+        for (Entry e = tab[index]; e != null; e = e.next) {
+            if (e.hash == hash) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * <p>Returns the value to which the specified key is mapped in this map.</p>
+     *
+     * @param   key   a key in the hashtable.
+     * @return  the value to which the key is mapped in this hashtable;
+     *          <code>null</code> if the key is not mapped to any value in
+     *          this hashtable.
+     * @see     #put(int, Object)
+     */
+    public T get(int key) {
+        Entry<T> tab[] = table;
+        int hash = key;
+        int index = (hash & 0x7FFFFFFF) % tab.length;
+        for (Entry<T> e = tab[index]; e != null; e = e.next) {
+            if (e.hash == hash) {
+                return e.value;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * <p>Increases the capacity of and internally reorganizes this
+     * hashtable, in order to accommodate and access its entries more
+     * efficiently.</p>
+     *
+     * <p>This method is called automatically when the number of keys
+     * in the hashtable exceeds this hashtable's capacity and load
+     * factor.</p>
+     */
+    protected void rehash() {
+        int oldCapacity = table.length;
+        Entry<T> oldMap[] = table;
+
+        int newCapacity = oldCapacity * 2 + 1;
+        Entry<T> newMap[] = new Entry[newCapacity];
+
+        threshold = (int) (newCapacity * loadFactor);
+        table = newMap;
+
+        for (int i = oldCapacity; i-- > 0;) {
+            for (Entry<T> old = oldMap[i]; old != null;) {
+                Entry<T> e = old;
+                old = old.next;
+
+                int index = (e.hash & 0x7FFFFFFF) % newCapacity;
+                e.next = newMap[index];
+                newMap[index] = e;
+            }
+        }
+    }
+
+    /**
+     * <p>Maps the specified <code>key</code> to the specified
+     * <code>value</code> in this hashtable. The key cannot be
+     * <code>null</code>. </p>
+     *
+     * <p>The value can be retrieved by calling the <code>get</code> method
+     * with a key that is equal to the original key.</p>
+     *
+     * @param key     the hashtable key.
+     * @param value   the value.
+     * @return the previous value of the specified key in this hashtable,
+     *         or <code>null</code> if it did not have one.
+     * @throws  NullPointerException  if the key is <code>null</code>.
+     * @see     #get(int)
+     */
+    public Object put(int key, T value) {
+            keySet.add(key);
+        // Makes sure the key is not already in the hashtable.
+        Entry<T> tab[] = table;
+        int hash = key;
+        int index = (hash & 0x7FFFFFFF) % tab.length;
+        for (Entry<T> e = tab[index]; e != null; e = e.next) {
+            if (e.hash == hash) {
+                T old = e.value;
+                e.value = value;
+                return old;
+            }
+        }
+
+        if (count >= threshold) {
+            // Rehash the table if the threshold is exceeded
+            rehash();
+
+            tab = table;
+            index = (hash & 0x7FFFFFFF) % tab.length;
+        }
+
+        // Creates the new entry.
+        Entry<T> e = new Entry<T>(hash, key, value, tab[index]);
+        tab[index] = e;
+        count++;
+        return null;
+    }
+
+    /**
+     * <p>Removes the key (and its corresponding value) from this
+     * hashtable.</p>
+     *
+     * <p>This method does nothing if the key is not present in the
+     * hashtable.</p>
+     *
+     * @param   key   the key that needs to be removed.
+     * @return  the value to which the key had been mapped in this hashtable,
+     *          or <code>null</code> if the key did not have a mapping.
+     */
+    /*public Object remove(int key) {
+        Entry tab[] = table;
+        int hash = key;
+        int index = (hash & 0x7FFFFFFF) % tab.length;
+        for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) {
+            if (e.hash == hash) {
+                if (prev != null) {
+                    prev.next = e.next;
+                } else {
+                    tab[index] = e.next;
+                }
+                count--;
+                Object oldValue = e.value;
+                e.value = null;
+                return oldValue;
+            }
+        }
+        return null;
+    }*/
+
+    /**
+     * <p>Clears this hashtable so that it contains no keys.</p>
+     */
+    public synchronized void clear() {
+            keySet.clear();
+        Entry tab[] = table;
+        for (int index = tab.length; --index >= 0;) {
+            tab[index] = null;
+        }
+        count = 0;
+    }
+    
+    public IntSet keySet() {
+            return keySet;
+    }
+    
+    
+    
+}
+

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
new file mode 100644
index 0000000..4dd92b1
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntHashSet.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002-2004 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.commons.rdf.impl.utils.graphmatching.collections;
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * This is currently just a placeholder implementation based onm HashSet<Integer>
+ * an efficient implementation is to store the primitives directly.
+ *
+ * @author reto
+ */
+public class IntHashSet extends HashSet<Integer> implements IntSet {
+
+    @Override
+    public IntIterator intIterator() {
+        final Iterator<Integer> base = iterator();
+        return new IntIterator() {
+
+            @Override
+            public int nextInt() {
+                return base.next();
+            }
+
+            @Override
+            public boolean hasNext() {
+                return base.hasNext();
+            }
+
+            @Override
+            public Integer next() {
+                return base.next();
+            }
+
+            @Override
+            public void remove() {
+                base.remove();
+            }
+        };
+    }
+
+    @Override
+    public void add(int i) {
+        super.add((Integer)i);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
new file mode 100644
index 0000000..050cf82
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntIterator.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2002-2004 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.commons.rdf.impl.utils.graphmatching.collections;
+
+import java.util.Iterator;
+
+
+/**
+ * An iterator allowing to iterate over ints, Iterator<Integer> is extended for
+ * compatibility, however accessing nextInt allows faster implementations.
+ *
+ * @author reto
+ */
+public interface IntIterator extends Iterator<Integer> {
+    public int nextInt();
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
new file mode 100644
index 0000000..5c3e465
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/graphmatching/collections/IntSet.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2002-2004 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.commons.rdf.impl.utils.graphmatching.collections;
+
+import java.util.Set;
+
+/**
+ * A IntSet allows directly adding primitive ints to a set, Set<Integer> is 
+ * extended, but accessingt he respective methods is less efficient.
+ *
+ * @author reto
+ */
+public interface IntSet extends Set<Integer> {
+    /**
+     *
+     * @return an iterator over the primitive int
+     */
+    public IntIterator intIterator();
+    
+    public void add(int i);
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/package-info.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/package-info.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/package-info.java
new file mode 100644
index 0000000..a1fa1c5
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/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 Implementation utilities.
+ */
+package org.apache.commons.rdf.impl.utils;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java
new file mode 100644
index 0000000..9b60a15
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleGraph.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils.simple;
+
+import org.apache.commons.rdf.impl.utils.AbstractGraph;
+import java.lang.ref.SoftReference;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.ConcurrentModificationException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+
+/**
+ * For now this is a minimalistic implementation, without any indexes or other
+ * optimizations.
+ *
+ * @author reto
+ */
+public class SimpleGraph extends AbstractGraph {
+
+    final Set<Triple> triples;
+
+    private boolean checkConcurrency = false;
+
+    class SimpleIterator implements Iterator<Triple> {
+
+        private Iterator<Triple> listIter;
+        private boolean isValid = true;
+
+        public SimpleIterator(Iterator<Triple> listIter) {
+            this.listIter = listIter;
+        }
+        private Triple currentNext;
+
+        @Override
+        public boolean hasNext() {
+            checkValidity();
+            return listIter.hasNext();
+        }
+
+        @Override
+        public Triple next() {
+            checkValidity();
+            currentNext = listIter.next();
+            return currentNext;
+        }        
+
+        @Override
+        public void remove() {
+            checkValidity();
+            listIter.remove();
+            triples.remove(currentNext);            
+            invalidateIterators(this);            
+        }
+
+        private void checkValidity() throws ConcurrentModificationException {
+            if (checkConcurrency && !isValid) {
+                throw new ConcurrentModificationException();
+            }
+        }
+
+        private void invalidate() {
+            isValid = false;
+        }
+    }    
+    
+    private final Set<SoftReference<SimpleIterator>> iterators =
+            Collections.synchronizedSet(new HashSet<SoftReference<SimpleIterator>>());
+    
+    /**
+     * Creates an empty SimpleGraph
+     */
+    public SimpleGraph() {
+        triples = Collections.synchronizedSet(new HashSet<Triple>());
+    }
+
+    /**
+     * Creates a SimpleGraph using the passed iterator, the iterator 
+     * is consumed before the constructor returns
+     * 
+     * @param iterator
+     */
+    public SimpleGraph(Iterator<Triple> iterator) {
+        triples = new HashSet<Triple>();
+        while (iterator.hasNext()) {
+            Triple triple = iterator.next();
+            triples.add(triple);
+        }
+    }
+
+    /**
+     * Creates a SimpleGraph for the specified set of triples, 
+     * subsequent modification of baseSet do affect the created instance.
+     * 
+     * @param baseSet
+     */
+    public SimpleGraph(Set<Triple> baseSet) {
+        this.triples = baseSet;
+    }
+
+    /**
+     * Creates a SimpleGraph for the specified collection of triples,
+     * subsequent modification of baseSet do not affect the created instance.
+     *
+     * @param baseSet
+     */
+    public SimpleGraph(Collection<Triple> baseCollection) {
+        this.triples = new HashSet<Triple>(baseCollection);
+    }
+
+    @Override
+    public int performSize() {
+        return triples.size();
+    }
+
+    @Override
+    public Iterator<Triple> performFilter(final BlankNodeOrIri subject, final Iri predicate, final RdfTerm object) {
+        final List<Triple> tripleList = new ArrayList<Triple>();
+        synchronized (triples) {
+            Iterator<Triple> baseIter = triples.iterator();
+            while (baseIter.hasNext()) {
+                Triple triple = baseIter.next();
+                if ((subject != null)
+                        && (!triple.getSubject().equals(subject))) {
+                    continue;
+                }
+                if ((predicate != null)
+                        && (!triple.getPredicate().equals(predicate))) {
+                    continue;
+                }
+                if ((object != null)
+                        && (!triple.getObject().equals(object))) {
+                    continue;
+                }
+                tripleList.add(triple);
+            }
+
+            final Iterator<Triple> listIter = tripleList.iterator();
+            SimpleIterator resultIter = new SimpleIterator(listIter);
+            if (checkConcurrency) {
+                iterators.add(new SoftReference<SimpleIterator>(resultIter));
+            }
+            return resultIter;
+        }
+    }
+
+
+    @Override
+    public boolean performAdd(Triple e) {
+        boolean modified = triples.add(e);
+        if (modified) {
+            invalidateIterators(null);
+        }
+        return modified;
+    }
+    
+    private void invalidateIterators(SimpleIterator caller) {
+        if (!checkConcurrency) {
+            return;
+        }
+        Set<SoftReference> oldReferences = new HashSet<SoftReference>();
+        synchronized(iterators) {
+            for (SoftReference<SimpleGraph.SimpleIterator> softReference : iterators) {
+                SimpleIterator simpleIterator = softReference.get();
+                if (simpleIterator == null) {
+                    oldReferences.add(softReference);
+                    continue;
+                }
+                if (simpleIterator != caller) {
+                    simpleIterator.invalidate();
+                }
+            }
+        }
+        iterators.removeAll(oldReferences);
+    }
+
+    /**
+     * Specifies whether or not to throw <code>ConcurrentModificationException</code>s,
+     * if this simple triple collection is modified concurrently. Concurrency
+     * check is set to false by default.
+     *
+     * @param bool Specifies whether or not to check concurrent modifications.
+     */
+    public void setCheckConcurrency(boolean bool) {
+        checkConcurrency = bool;
+    }
+    
+    
+    @Override
+    public ImmutableGraph getImmutableGraph() {
+        return new SimpleImmutableGraph(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
new file mode 100644
index 0000000..bc50a09
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleImmutableGraph.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.rdf.impl.utils.simple;
+
+import org.apache.commons.rdf.impl.utils.AbstractImmutableGraph;
+import java.util.Iterator;
+
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+
+/**
+ *
+ * @author reto
+ */
+public class SimpleImmutableGraph extends AbstractImmutableGraph {
+
+    private Graph graph;
+    
+    /**
+     * Creates a ImmutableGraph with the triples in Graph
+     * 
+     * @param Graph the collection of triples this ImmutableGraph shall consist of
+     */
+    public SimpleImmutableGraph(Graph Graph) {
+        this.graph = new SimpleGraph(Graph.iterator());
+    }
+
+    /**
+     * Creates a ImmutableGraph with the triples in Graph.
+     *
+     * This construction allows to specify if the Graph might change
+     * in future. If GraphWillNeverChange is set to true it will
+     * assume that the collection never changes, in this case the collection
+     * isn't copied making things more efficient.
+     *
+     * @param Graph the collection of triples this ImmutableGraph shall consist of
+     * @param GraphWillNeverChange true if the caller promises Graph will never change
+     */
+    public SimpleImmutableGraph(Graph Graph, boolean GraphWillNeverChange) {
+        if (!GraphWillNeverChange) {
+            this.graph = new SimpleGraph(Graph.iterator());
+        } else {
+            this.graph = Graph;
+        }
+    }
+    
+    public SimpleImmutableGraph(Iterator<Triple> tripleIter) {
+        this.graph = new SimpleGraph(tripleIter);
+    }
+
+    @Override
+    public int performSize() {
+        return graph.size();
+    }
+
+    @Override
+    public Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
+        return graph.filter(subject, predicate, object);
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.java b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.java
new file mode 100644
index 0000000..8d0a5ce
--- /dev/null
+++ b/impl.utils/src/main/java/org/apache/clerezza/commons/rdf/impl/utils/simple/SimpleMGraph.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.commons.rdf.impl.utils.simple;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Triple;
+
+/**
+ *
+ * @deprecated Use SimpleGraph
+ * @author reto
+ */
+@Deprecated
+public class SimpleMGraph extends SimpleGraph implements Graph {
+
+    /**
+     * Creates an empty SimpleMGraph
+     */
+    public SimpleMGraph() {
+    }
+
+    public SimpleMGraph(Set<Triple> baseSet) {
+        super(baseSet);
+    }
+
+    public SimpleMGraph(Collection<Triple> baseCollection) {
+        super(baseCollection);
+    }
+
+    public SimpleMGraph(Iterator<Triple> iterator) {
+        super(iterator);
+    }
+
+}
+
+    
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractGraph.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractGraph.java
deleted file mode 100644
index 2c99679..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractGraph.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils;
-
-import java.lang.ref.WeakReference;
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import java.util.Set;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.WatchableGraph;
-import org.apache.commons.rdf.event.AddEvent;
-import org.apache.commons.rdf.event.FilterTriple;
-import org.apache.commons.rdf.event.GraphEvent;
-import org.apache.commons.rdf.event.GraphListener;
-import org.apache.commons.rdf.event.RemoveEvent;
-import org.apache.commons.rdf.impl.utils.debug.ReentrantReadWriteLockTracker;
-import org.apache.commons.rdf.impl.utils.simple.SimpleImmutableGraph;
-
-/**
- * An abstract implementation of <code>Graph</code> implementing
- * <code>iterator</code> and <code>contains</code> calling <code>filter</code>.
- *
- * @author reto
- */
-public abstract class AbstractGraph extends AbstractCollection<Triple>
-        implements Graph {
-
-    
-    private static final String DEBUG_MODE = "rdfLocksDebugging";
-    private final ReadWriteLock lock;
-
-    private final Lock readLock;
-    private final Lock writeLock;
-
-    /**
-     * Constructs a LocalbleMGraph for an Graph.
-     *
-     * @param providedMGraph a non-lockable graph
-     */
-    public AbstractGraph() {
-        {
-            String debugMode = System.getProperty(DEBUG_MODE);
-            if (debugMode != null && debugMode.toLowerCase().equals("true")) {
-                lock = new ReentrantReadWriteLockTracker();
-            } else {
-                lock = new ReentrantReadWriteLock();
-            }
-        }
-        readLock = lock.readLock();
-        writeLock = lock.writeLock();
-    }
-    
-    public AbstractGraph(final ReadWriteLock lock) {
-        this.lock = lock;
-        readLock = lock.readLock();
-        writeLock = lock.writeLock();
-    }
-
-    @Override
-    public ReadWriteLock getLock() {
-        return lock;
-    }
-
-    @Override
-    public ImmutableGraph getImmutableGraph() {
-        readLock.lock();
-        try {
-            return performGetImmutableGraph();
-        } finally {
-            readLock.unlock();
-        }
-    }
-    
-    public ImmutableGraph performGetImmutableGraph() {
-        return new SimpleImmutableGraph(this);
-    }
-
-    @Override
-    public Iterator<Triple> filter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
-        readLock.lock();
-        try {
-            return new LockingIterator(performFilter(subject, predicate, object), lock);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public int size() {
-        readLock.lock();
-        try {
-            return performSize();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean isEmpty() {
-        readLock.lock();
-        try {
-            return performIsEmpty();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    @SuppressWarnings("element-type-mismatch")
-    public boolean contains(Object o) {
-        readLock.lock();
-        try {
-            return performContains(o);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public Iterator<Triple> iterator() {
-        readLock.lock();
-        try {
-            return new LockingIterator(performIterator(), lock);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public Object[] toArray() {
-        readLock.lock();
-        try {
-            return performToArray();
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public <T> T[] toArray(T[] a) {
-        readLock.lock();
-        try {
-            return performToArray(a);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean containsAll(Collection<?> c) {
-        readLock.lock();
-        try {
-            return performContainsAll(c);
-        } finally {
-            readLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean add(Triple e) {
-        writeLock.lock();
-        try {
-            return performAdd(e);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean remove(Object o) {
-        writeLock.lock();
-        try {
-            return performRemove(o);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean addAll(Collection<? extends Triple> c) {
-        writeLock.lock();
-        try {
-            return performAddAll(c);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c) {
-        writeLock.lock();
-        try {
-            return performRemoveAll(c);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public boolean retainAll(Collection<?> c) {
-        writeLock.lock();
-        try {
-            return performRetainAll(c);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    @Override
-    public void clear() {
-        writeLock.lock();
-        try {
-            performClear();
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    
-    @Override
-    public boolean equals(Object obj) {
-        /*if (obj == null) {
-            return false;
-        }
-        if (obj == this) {
-            return true;
-        }
-        if (obj.getClass() != getClass()) {
-            return false;
-        }*/
-        return this == obj;
-    }
-
-
-    protected abstract Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate, RdfTerm object);
-
-    protected abstract int performSize();
-
-    protected boolean performIsEmpty() {
-        return super.isEmpty();
-    }
-
-    protected Object[] performToArray() {
-        return super.toArray();
-    }
-
-    protected boolean performRemove(Object o) {
-        return super.remove(o);
-    }
-
-    protected boolean performAddAll(Collection<? extends Triple> c) {
-        return super.addAll(c);
-    }
-
-    protected boolean performRemoveAll(Collection<?> c) {
-        return super.removeAll(c);
-    }
-
-    protected boolean performRetainAll(Collection<?> c) {
-        return super.retainAll(c);
-    }
-
-    protected void performClear() {
-        super.clear();
-    }
-
-    protected boolean performContains(Object o) {
-        return super.contains(o);
-    }
-
-    protected Iterator<Triple> performIterator() {
-        return performFilter(null, null, null);
-    }
-
-    protected boolean performContainsAll(Collection<?> c) {
-        return super.containsAll(c);
-    }
-
-    protected <T> T[] performToArray(T[] a) {
-        return super.toArray(a);
-    }
-
-    protected boolean performAdd(Triple e) {
-        return super.add(e);
-    }
-
- 
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractImmutableGraph.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractImmutableGraph.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractImmutableGraph.java
deleted file mode 100644
index 912a5ff..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractImmutableGraph.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.impl.utils.graphmatching.GraphMatcher;
-
-/**
- * <code>AbstractGraph</code> is an abstract implementation of <code>ImmutableGraph</code> 
- * implementing the <code>equals</code> and the <code>hashCode</code> methods.
- * 
- * @author reto
- * 
- */
-public abstract class AbstractImmutableGraph extends AbstractGraph
-        implements ImmutableGraph {
-
-    public final synchronized int hashCode() {
-        int result = 0;
-        for (Iterator<Triple> iter = iterator(); iter.hasNext();) {
-            result += getBlankNodeBlindHash(iter.next());
-        }
-        return result;
-    }
-
-    /**
-     * @param triple
-     * @return hash without BNode hashes
-     */
-    private int getBlankNodeBlindHash(Triple triple) {
-        int hash = triple.getPredicate().hashCode();
-        RdfTerm subject = triple.getSubject();
-
-        if (!(subject instanceof BlankNode)) {
-            hash ^= subject.hashCode() >> 1;
-        }
-        RdfTerm object = triple.getObject();
-        if (!(object instanceof BlankNode)) {
-            hash ^= object.hashCode() << 1;
-        }
-
-        return hash;
-    }
-
-    @Override
-    public boolean add(Triple e) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-
-    }
-
-    @Override
-    public boolean addAll(Collection<? extends Triple> c) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-    }
-
-    @Override
-    public boolean remove(Object o) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c) {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-    }
-
-    @Override
-    public void clear() {
-        throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
-    }
-    
-    
-    @Override
-    public ImmutableGraph getImmutableGraph() {
-        return this;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof ImmutableGraph)) {
-            return false;
-        }
-        if (hashCode() != obj.hashCode()) {
-            return false;
-        }
-        return GraphMatcher.getValidMapping(this, (ImmutableGraph) obj) != null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractLiteral.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractLiteral.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractLiteral.java
deleted file mode 100644
index e1fac11..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/AbstractLiteral.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.commons.rdf.impl.utils;
-
-import org.apache.commons.rdf.Literal;
-
-/**
- *
- * @author developer
- */
-public abstract class AbstractLiteral implements Literal {
-
-    @Override
-    public int hashCode() {
-        int result = 0;
-        if (getLanguage() != null) {
-            result = getLanguage().hashCode();
-        }
-        result += getLexicalForm().hashCode();
-        result += getDataType().hashCode();
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof Literal) {
-            Literal other = (Literal) obj;
-            
-            if (getLanguage() == null) {
-                if (other.getLanguage() != null) {
-                    return false;
-                }
-            } else {
-                if (!getLanguage().equals(other.getLanguage())) {
-                    return false;
-                }
-            }
-            boolean res = getDataType().equals(other.getDataType()) && getLexicalForm().equals(other.getLexicalForm());
-            return res;
-        } else {
-            return false;
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/DelayedNotificator.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/DelayedNotificator.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/DelayedNotificator.java
deleted file mode 100644
index 8b3bc87..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/DelayedNotificator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils;
-
-import java.lang.ref.WeakReference;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.commons.rdf.event.GraphEvent;
-import org.apache.commons.rdf.event.GraphListener;
-
-
-/**
- *
- * @author reto
- */
-class DelayedNotificator {
-
-    private static final Logger log = Logger.getLogger(DelayedNotificator.class.getName());
-    private static Timer timer = new Timer("Event delivery timer",true);
-
-    static class ListenerHolder {
-
-        long delay;
-        List<GraphEvent> events = null;
-        WeakReference<GraphListener> listenerRef;
-
-        public ListenerHolder(GraphListener listener, long delay) {
-            this.listenerRef = new WeakReference<GraphListener>(listener);
-            this.delay = delay;
-        }
-
-        private void registerEvent(GraphEvent event) {
-            synchronized (this) {
-                if (events == null) {
-                    events = new ArrayList<GraphEvent>();
-                    events.add(event);
-                    timer.schedule(new TimerTask() {
-
-                        @Override
-                        public void run() {
-                            List<GraphEvent> eventsLocal;
-                            synchronized (ListenerHolder.this) {
-                                eventsLocal = events;
-                                events = null;
-                            }
-                            GraphListener listener = listenerRef.get();
-                            if (listener == null) {
-                                log.fine("Ignoring garbage collected listener");
-                            } else {
-                                try {
-                                    listener.graphChanged(eventsLocal);
-                                } catch (Exception e) {
-                                    log.log(Level.WARNING, "Exception delivering ImmutableGraph event", e);
-                                }
-                            }
-                        }
-                    }, delay);
-                } else {
-                    events.add(event);
-                }
-            }
-        }
-    }
-    
-    private final Map<GraphListener, ListenerHolder> map = Collections.synchronizedMap(
-            new WeakHashMap<GraphListener, ListenerHolder>());
-
-    void addDelayedListener(GraphListener listener, long delay) {
-        map.put(listener, new ListenerHolder(listener, delay));
-    }
-
-    /**
-     * removes a Listener, this doesn't prevent the listenerRef from receiving
-     * events alreay scheduled.
-     *
-     * @param listenerRef
-     */
-    void removeDelayedListener(GraphListener listener) {
-        map.remove(listener);
-    }
-
-    /**
-     * if the listenerRef has not been registered as delayed listenerRef te events is
-     * forwarded synchroneously
-     * @param event
-     */
-    void sendEventToListener(GraphListener listener, GraphEvent event) {
-        ListenerHolder holder = map.get(listener);
-        if (holder == null) {
-            listener.graphChanged(Collections.singletonList(event));
-        } else {
-            holder.registerEvent(event);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza-rdf-core/blob/816dc11f/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/LiteralImpl.java b/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/LiteralImpl.java
deleted file mode 100644
index 0de3b84..0000000
--- a/impl.utils/src/main/java/org/apache/commons/rdf/impl/utils/LiteralImpl.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.commons.rdf.impl.utils;
-
-import java.io.Serializable;
-
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
-
-/**
- *
- * @author reto
- */
-public class LiteralImpl extends AbstractLiteral implements  Serializable {
-    private String lexicalForm;
-    private Iri dataType;
-    private int hashCode;
-    private Language language;
-
-    /**
-     * @param lexicalForm 
-     * @param dataType 
-     * @param Language the language of this literal
-     */
-    public LiteralImpl(String lexicalForm, Iri dataType, Language language) {
-        this.lexicalForm = lexicalForm;
-        this.dataType = dataType;
-        this.language = language;
-        this.hashCode = super.hashCode();
-    }
-    
-    public Iri getDataType() {
-        return dataType;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.clerezza.rdf.core.LiteralNode#getLexicalForm()
-     */
-    @Override
-    public String getLexicalForm() {
-        return lexicalForm;
-    }
-
-    @Override
-    public int hashCode() {
-        return hashCode;
-    }
-    
-
-    @Override
-    public String toString() {
-        StringBuffer result = new StringBuffer();
-        result.append('\"');
-        result.append(getLexicalForm());
-        result.append('\"');
-        result.append("^^");
-        result.append(getDataType());
-        return result.toString();
-    }
-
-    @Override
-    public Language getLanguage() {
-        return language;
-    }
-
-}