You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by ha...@apache.org on 2019/02/13 20:21:41 UTC

[clerezza] branch reunited updated: CLEREZZA-1038: Move scala.utils from rdf module into api.utils module

This is an automated email from the ASF dual-hosted git repository.

hasan pushed a commit to branch reunited
in repository https://gitbox.apache.org/repos/asf/clerezza.git


The following commit(s) were added to refs/heads/reunited by this push:
     new 799b2d1  CLEREZZA-1038: Move scala.utils from rdf module into api.utils module
799b2d1 is described below

commit 799b2d15ce7c960533bef69d12be11df2eb46169
Author: Hasan <ha...@apache.org>
AuthorDate: Wed Feb 13 21:21:03 2019 +0100

    CLEREZZA-1038: Move scala.utils from rdf module into api.utils module
---
 api.utils/pom.xml                                  |  72 +++++-
 .../org/apache/clerezza/api/utils/GraphNode.java   |  32 +--
 .../org/apache/clerezza/api/utils/GraphUtils.java  |  15 +-
 .../org/apache/clerezza/api/utils/IRIUtil.java     |   8 +-
 .../org/apache/clerezza/api/utils/RdfList.java     |  37 ++--
 .../apache/clerezza/api/utils/SeeAlsoExpander.java |  12 +-
 .../org/apache/clerezza/api/utils/Smusher.java     |  11 +-
 .../org/apache/clerezza/api/utils/UnionGraph.java  |   8 +-
 .../clerezza/api/utils/UnionWatchableGraph.java    |  15 +-
 .../clerezza/api/utils/UriMutatingGraph.java       |  22 +-
 .../utils/graphnodeprovider/GraphNodeProvider.java |   4 +-
 .../clerezza/api/utils/smushing/BaseSmusher.java   |  30 ++-
 .../clerezza/api/utils/smushing/IfpSmusher.java    |  17 +-
 .../clerezza/api/utils/smushing/SameAsSmusher.java |  64 +++---
 .../clerezza/api/scala/utils/CollectedIter.scala   | 132 +++++++++++
 .../clerezza/api/scala/utils/EzLiteral.scala       |  74 +++++++
 .../apache/clerezza/api/scala/utils/EzMGraph.scala |  79 +++++++
 .../clerezza/api/scala/utils/NameSpace.scala       |  36 +++
 .../apache/clerezza/api/scala/utils/Preamble.scala | 117 ++++++++++
 .../clerezza/api/scala/utils/RichGraphNode.scala   | 242 +++++++++++++++++++++
 .../apache/clerezza/api/utils/GraphUtilsTest.java  |  13 +-
 .../apache/clerezza/api/utils/IfpSmushTest.java    |  15 +-
 .../org/apache/clerezza/api/utils/RdfListTest.java |  23 +-
 .../apache/clerezza/api/utils/SameAsSmushTest.java |  13 +-
 .../apache/clerezza/api/utils/TestGraphNode.java   |  43 ++--
 .../apache/clerezza/api/utils/UnionGraphTest.java  |   4 +-
 .../api/utils/smushing/SameAsSmushTest.java        |  17 +-
 .../clerezza/api/scala/utils/EzMGraphTest.scala    | 159 ++++++++++++++
 .../api/scala/utils/RichGraphNodeTest.scala        | 169 ++++++++++++++
 .../api/scala/utils/TypeConversionTest.scala       |  70 ++++++
 30 files changed, 1337 insertions(+), 216 deletions(-)

diff --git a/api.utils/pom.xml b/api.utils/pom.xml
index e67e3be..1b31090 100644
--- a/api.utils/pom.xml
+++ b/api.utils/pom.xml
@@ -16,7 +16,6 @@
   either  express  or implied.  See  the License  for  the  specific
   language governing permissions and limitations under  the License.
 -->
-
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -33,6 +32,7 @@
     <version>8-SNAPSHOT</version>
     <name>Clerezza - API Utilities</name>
     <description>Utility classes to work with Clerezza API</description>
+
     <dependencies>
         <dependency>
             <groupId>junit</groupId>
@@ -70,6 +70,74 @@
             <version>8-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.scala-lang</groupId>
+            <artifactId>scala-library</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
     </dependencies>
 
-</project>
\ No newline at end of file
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>net.alchim31.maven</groupId>
+                    <artifactId>scala-maven-plugin</artifactId>
+                    <version>3.4.6</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+        <plugins>
+            <plugin>
+                <groupId>net.alchim31.maven</groupId>
+                <artifactId>scala-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>scala-compile-first</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                            <goal>compile</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>scala-test-compile</id>
+                        <phase>process-test-resources</phase>
+                        <goals>
+                            <goal>testCompile</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>${project.groupId}.${project.artifactId}.*</Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/GraphNode.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/GraphNode.java
index bedf30d..2a80559 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/GraphNode.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/GraphNode.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.*;
@@ -32,8 +31,8 @@ import java.util.concurrent.locks.Lock;
  * modifying the graph will throw an {@link UnsupportedOperationException}
  * it the underlying Graph in immutable (i.e. is a {@link ImmutableGraph}.
  *
- * @since 0.2
  * @author reto, mir
+ * @since 0.2
  */
 public class GraphNode {
 
@@ -44,7 +43,7 @@ public class GraphNode {
      * Create a GraphNode representing resource within graph.
      *
      * @param resource the resource this GraphNode represents
-     * @param graph the Graph that describes the resource
+     * @param graph    the Graph that describes the resource
      */
     public GraphNode(RDFTerm resource, Graph graph) {
         if (resource == null) {
@@ -77,6 +76,7 @@ public class GraphNode {
 
     /**
      * Deletes the context of a node
+     *
      * @see getNodeContext()
      */
     public void deleteNodeContext() {
@@ -89,7 +89,7 @@ public class GraphNode {
      * The context of a node are the triples containing a node
      * as subject or object and recursively the context of the b-nodes in any
      * of these statements.
-     *
+     * <p>
      * The triples in the ImmutableGraph returned by this method contain the same bnode
      * instances as in the original graph.
      *
@@ -112,7 +112,7 @@ public class GraphNode {
     }
 
     private Graph getContextOf(IRI node, final Set<RDFTerm> dontExpand) {
-        final String uriPrefix = node.getUnicodeString()+'#';
+        final String uriPrefix = node.getUnicodeString() + '#';
         return getContextOf(node, dontExpand, new Acceptor() {
 
             @Override
@@ -121,7 +121,7 @@ public class GraphNode {
                     return true;
                 }
                 if (resource instanceof IRI) {
-                    return ((IRI)resource).getUnicodeString().startsWith(uriPrefix);
+                    return ((IRI) resource).getUnicodeString().startsWith(uriPrefix);
                 }
                 return false;
             }
@@ -133,7 +133,7 @@ public class GraphNode {
      *
      * @param node
      * @param dontExpand a list of bnodes at which to stop expansion, if node
-     * is a BlankNode it should be contained (potentially faster)
+     *                   is a BlankNode it should be contained (potentially faster)
      * @return the context of a node
      */
     private Graph getContextOf(RDFTerm node, final Set<RDFTerm> dontExpand) {
@@ -152,6 +152,7 @@ public class GraphNode {
     private interface Acceptor {
         boolean expand(RDFTerm resource);
     }
+
     private Graph getContextOf(RDFTerm node, final Set<RDFTerm> dontExpand, Acceptor acceptor) {
         Graph result = new SimpleGraph();
         if (node instanceof BlankNodeOrIRI) {
@@ -255,7 +256,7 @@ public class GraphNode {
      *
      * @param property the property to be examined
      * @return the number of triples in the underlying triple-collection
-     *        which meet the specified condition
+     * which meet the specified condition
      */
     public int countObjects(IRI property) {
         return countTriples(graph.filter((BlankNodeOrIRI) resource, property, null));
@@ -331,7 +332,7 @@ public class GraphNode {
      * @param property
      * @param object
      * @return true if the node represented by this object is the subject of a
-     *         statement with the given prediate and object, false otherwise
+     * statement with the given prediate and object, false otherwise
      */
     public boolean hasProperty(IRI property, RDFTerm object) {
         Lock l = readLock();
@@ -358,7 +359,7 @@ public class GraphNode {
      *
      * @param property the property to be examined
      * @return the number of triples in the underlying triple-collection
-     *        which meet the specified condition
+     * which meet the specified condition
      */
     public int countSubjects(IRI property) {
         Lock l = readLock();
@@ -448,7 +449,6 @@ public class GraphNode {
     }
 
     /**
-     *
      * @param triples
      * @returnan {@link Iterator}<{@link IRI}> containing the predicates from
      * an {@link Iterator}<{@link Triple}>
@@ -481,7 +481,7 @@ public class GraphNode {
      * specified property
      *
      * @param property the predicate of the triple to be created
-     * @param value the value of the typed literal object
+     * @param value    the value of the typed literal object
      */
     public void addPropertyValue(IRI property, Object value) {
         addProperty(property,
@@ -558,6 +558,7 @@ public class GraphNode {
     /**
      * Replaces the graph node resouce with the specified <code>BlankNodeOrIRI</code>.
      * The resource is only replaced where it is either subject or object.
+     *
      * @param replacement
      * @return a GraphNode representing the replecement node
      */
@@ -569,6 +570,7 @@ public class GraphNode {
      * Replaces the graph node resouce with the specified <code>BlankNodeOrIRI</code>.
      * Over the boolean <code>checkPredicate</code> it can be specified if the
      * resource should also be replaced where it is used as predicate.
+     *
      * @param replacement
      * @param checkPredicates
      * @return a GraphNode representing the replecement node
@@ -679,7 +681,6 @@ public class GraphNode {
     }
 
     /**
-     *
      * @param obj
      * @return true if obj is an instance of the same class represening the same
      * node in the same graph, subclasses may have different identity criteria.
@@ -704,17 +705,16 @@ public class GraphNode {
      */
     public Lock readLock() {
 
-            return getGraph().getLock().readLock();
+        return getGraph().getLock().readLock();
 
     }
 
     /**
-     *
      * @return
      */
     public Lock writeLock() {
 
-            return (getGraph()).getLock().writeLock();
+        return (getGraph()).getLock().writeLock();
 
     }
 }
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/GraphUtils.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/GraphUtils.java
index 51e25b1..a8b3a3f 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/GraphUtils.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/GraphUtils.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.*;
@@ -61,7 +60,8 @@ public class GraphUtils {
         }
 
         //we first remove the context of bnodes we find in object position
-        OBJ_BNODE_LOOP: while (true) {
+        OBJ_BNODE_LOOP:
+        while (true) {
             final Triple triple = getTripleWithBlankNodeObject(unGroundedTriples);
             if (triple == null) {
                 break;
@@ -73,7 +73,7 @@ public class GraphUtils {
             while (potentialIter.hasNext()) {
                 try {
                     final Triple potentialTriple = potentialIter.next();
-                    BlankNode potentialMatch = (BlankNode)potentialTriple.getObject();
+                    BlankNode potentialMatch = (BlankNode) potentialTriple.getObject();
                     final ImmutableGraph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext();
                     if (potentialContext.equals(context)) {
                         removingTriples.addAll(potentialContext);
@@ -86,7 +86,8 @@ public class GraphUtils {
             }
             throw new NoSuchSubGraphException();
         }
-        SUBJ_BNODE_LOOP: while (true) {
+        SUBJ_BNODE_LOOP:
+        while (true) {
             final Triple triple = getTripleWithBlankNodeSubject(unGroundedTriples);
             if (triple == null) {
                 break;
@@ -101,7 +102,7 @@ public class GraphUtils {
             while (potentialIter.hasNext()) {
                 try {
                     final Triple potentialTriple = potentialIter.next();
-                    BlankNode potentialMatch = (BlankNode)potentialTriple.getSubject();
+                    BlankNode potentialMatch = (BlankNode) potentialTriple.getSubject();
                     final ImmutableGraph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext();
                     if (potentialContext.equals(context)) {
                         removingTriples.addAll(potentialContext);
@@ -127,7 +128,8 @@ public class GraphUtils {
         return true;
     }
 
-    /** retrun triples with a bnode only at object position
+    /**
+     * retrun triples with a bnode only at object position
      *
      * @param triples
      * @return
@@ -143,6 +145,7 @@ public class GraphUtils {
         }
         return null;
     }
+
     private static Triple getTripleWithBlankNodeSubject(Graph triples) {
         for (Triple triple : triples) {
             if (triple.getSubject() instanceof BlankNode) {
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/IRIUtil.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/IRIUtil.java
index e233052..64b45dd 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/IRIUtil.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/IRIUtil.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 /**
@@ -27,13 +26,12 @@ public class IRIUtil {
 
     /**
      * Strips #x00 - #x1F and #x7F-#x9F from a Unicode string
-     * @see <a href="http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference">
-     * http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference</a> and
-     * replaces all US-ASCII space character with a "+".
      *
      * @param inputChars
      * @return the stripped string
-     * 
+     * @see <a href="http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference">
+     * http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference</a> and
+     * replaces all US-ASCII space character with a "+".
      */
     public static String stripNonIRIChars(CharSequence inputChars) {
 
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/RdfList.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/RdfList.java
index e3bdc34..01b3d48 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/RdfList.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/RdfList.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.*;
@@ -63,7 +62,7 @@ public class RdfList extends AbstractList<RDFTerm> {
 
     /**
      * Get a list for the specified resource.
-     *
+     * <p>
      * If the list is modified using the created instance
      * <code>listRDFTerm</code> will always be the first list.
      *
@@ -73,7 +72,6 @@ public class RdfList extends AbstractList<RDFTerm> {
     public RdfList(BlankNodeOrIRI listRDFTerm, Graph tc) {
         firstList = listRDFTerm;
         this.tc = tc;
-
     }
 
     /**
@@ -82,7 +80,7 @@ public class RdfList extends AbstractList<RDFTerm> {
      * @param listNode
      */
     public RdfList(GraphNode listNode) {
-        this((BlankNodeOrIRI)listNode.getNode(), listNode.getGraph());
+        this((BlankNodeOrIRI) listNode.getNode(), listNode.getGraph());
     }
 
     /**
@@ -91,9 +89,8 @@ public class RdfList extends AbstractList<RDFTerm> {
      *
      * @param listRDFTerm
      * @param tc
-     * @return    an empty rdf:List.
-     * @throws IllegalArgumentException
-     *        if the provided {@code  listRDFTerm} is a non-empty rdf:List.
+     * @return an empty rdf:List.
+     * @throws IllegalArgumentException if the provided {@code  listRDFTerm} is a non-empty rdf:List.
      */
     public static RdfList createEmptyList(BlankNodeOrIRI listRDFTerm, Graph tc)
             throws IllegalArgumentException {
@@ -113,7 +110,7 @@ public class RdfList extends AbstractList<RDFTerm> {
         }
         BlankNodeOrIRI currentList;
         if (listList.size() > 0) {
-            currentList = listList.get(listList.size()-1);
+            currentList = listList.get(listList.size() - 1);
         } else {
             currentList = firstList;
             if (!tc.filter(currentList, RDF.first, null).hasNext()) {
@@ -125,7 +122,7 @@ public class RdfList extends AbstractList<RDFTerm> {
         if (listList.size() >= pos) {
             return;
         }
-        while (true) {                
+        while (true) {
             currentList = getRest(currentList);
             if (currentList.equals(RDF_NIL)) {
                 totallyExpanded = true;
@@ -140,7 +137,6 @@ public class RdfList extends AbstractList<RDFTerm> {
     }
 
 
-
     @Override
     public RDFTerm get(int index) {
         expandTill(index + 1);
@@ -149,7 +145,7 @@ public class RdfList extends AbstractList<RDFTerm> {
 
     @Override
     public int size() {
-        expandTill(Integer.MAX_VALUE);        
+        expandTill(Integer.MAX_VALUE);
         return valueList.size();
     }
 
@@ -173,14 +169,13 @@ public class RdfList extends AbstractList<RDFTerm> {
         }
         valueList.add(index, element);
     }
-    
+
     /**
-     *
-     * @param index is > 0
+     * @param index   is > 0
      * @param element
      */
     private void addInRdfList(int index, RDFTerm element) {
-        expandTill(index+1);
+        expandTill(index + 1);
         BlankNodeOrIRI newList = new BlankNode() {
         };
         tc.add(new TripleImpl(newList, RDF.first, element));
@@ -201,7 +196,7 @@ public class RdfList extends AbstractList<RDFTerm> {
         //keeping the first list resource
         tc.remove(new TripleImpl(listList.get(index), RDF.first, valueList.get(index)));
         if (index == (listList.size() - 1)) {
-            tc.remove(new TripleImpl(listList.get(index), RDF.rest, RDF_NIL));    
+            tc.remove(new TripleImpl(listList.get(index), RDF.rest, RDF_NIL));
             if (index > 0) {
                 tc.remove(new TripleImpl(listList.get(index - 1), RDF.rest, listList.get(index)));
                 tc.add(new TripleImpl(listList.get(index - 1), RDF.rest, RDF_NIL));
@@ -210,7 +205,7 @@ public class RdfList extends AbstractList<RDFTerm> {
             }
             listList.remove(index);
         } else {
-            tc.add(new TripleImpl(listList.get(index), RDF.first, valueList.get(index+1)));
+            tc.add(new TripleImpl(listList.get(index), RDF.first, valueList.get(index + 1)));
             tc.remove(new TripleImpl(listList.get(index), RDF.rest, listList.get(index + 1)));
             tc.remove(new TripleImpl(listList.get(index + 1), RDF.first, valueList.get(index + 1)));
             if (index == (listList.size() - 2)) {
@@ -220,7 +215,7 @@ public class RdfList extends AbstractList<RDFTerm> {
                 tc.remove(new TripleImpl(listList.get(index + 1), RDF.rest, listList.get(index + 2)));
                 tc.add(new TripleImpl(listList.get(index), RDF.rest, listList.get(index + 2)));
             }
-            listList.remove(index+1);
+            listList.remove(index + 1);
         }
         return valueList.remove(index);
     }
@@ -235,7 +230,7 @@ public class RdfList extends AbstractList<RDFTerm> {
         } catch (final NullPointerException e) {
             RuntimeException runtimeEx = AccessController.doPrivileged(new PrivilegedAction<RuntimeException>() {
                 @Override
-                public RuntimeException run(){
+                public RuntimeException run() {
                     try {
                         final FileOutputStream fileOutputStream = new FileOutputStream("/tmp/broken-list.nt");
                         final GraphNode graphNode = new GraphNode(listRDFTerm, tc);
@@ -301,7 +296,7 @@ public class RdfList extends AbstractList<RDFTerm> {
         }
 
         Set<RdfList> rdfLists = new HashSet<RdfList>();
-        for (Iterator<GraphNode> it = listNodes.iterator(); it.hasNext();) {
+        for (Iterator<GraphNode> it = listNodes.iterator(); it.hasNext(); ) {
             GraphNode listNode = it.next();
             rdfLists.add(new RdfList(listNode));
         }
@@ -328,7 +323,7 @@ public class RdfList extends AbstractList<RDFTerm> {
         }
         return listNodes;
     }
-    
+
     private static Set<GraphNode> findAllListNodes(GraphNode listPart) {
         Iterator<GraphNode> invRestNodesIter;
         Set<GraphNode> listNodes = new HashSet<GraphNode>();
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/SeeAlsoExpander.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/SeeAlsoExpander.java
index 2cf73cd..0bc9026 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/SeeAlsoExpander.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/SeeAlsoExpander.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.Graph;
@@ -40,9 +39,9 @@ public class SeeAlsoExpander {
      * using TcManger instead of TcProvider as this ensures LockableGraphs
      */
     private final TcManager tcManager;
+
     public SeeAlsoExpander(TcManager tcManager) {
         this.tcManager = tcManager;
-
     }
 
     /**
@@ -51,7 +50,7 @@ public class SeeAlsoExpander {
      * also associate rdfs:seeAlso properties to node this are expanded till
      * the maximum recursion depth specified.
      *
-     * @param node the node to be expanded
+     * @param node      the node to be expanded
      * @param recursion the maximum recursion depth
      * @return a new GraphNode over the union of the original and all expansion graphs
      */
@@ -68,8 +67,7 @@ public class SeeAlsoExpander {
         }
         return new GraphNode(node.getNode(),
                 new UnionGraph(resultTripleCollections.toArray(
-                new Graph[resultTripleCollections.size()])));
-
+                        new Graph[resultTripleCollections.size()])));
     }
 
     private Set<IRI> getSeeAlsoObjectUris(GraphNode node) {
@@ -81,7 +79,7 @@ public class SeeAlsoExpander {
             while (objects.hasNext()) {
                 RDFTerm next = objects.next();
                 if (next instanceof IRI) {
-                    result.add((IRI)next);
+                    result.add((IRI) next);
                 }
             }
         } finally {
@@ -101,7 +99,7 @@ public class SeeAlsoExpander {
             for (IRI target : rdfSeeAlsoTargets) {
                 try {
                     result.addAll(expand(new GraphNode(node.getNode(),
-                        tcManager.getGraph(target)), alreadyVisited, recursion));
+                            tcManager.getGraph(target)), alreadyVisited, recursion));
                 } catch (NoSuchEntityException e) {
                     //ignore
                 }
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/Smusher.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/Smusher.java
index 1dbb8f2..64700ab 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/Smusher.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/Smusher.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.Graph;
@@ -25,9 +24,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * A utility to smush equivalent resources. For greater flexibility use the 
+ * A utility to smush equivalent resources. For greater flexibility use the
  * classes in the smushing package.
- * 
+ *
  * @author reto
  */
 public class Smusher {
@@ -49,13 +48,11 @@ public class Smusher {
 
     /**
      * Smushes the specified graph adding owl:sameAs statements pointing to the new canonical IRI
-     * 
+     *
      * @param mGraph
-     * @param owlSameStatements 
+     * @param owlSameStatements
      */
     public static void sameAsSmush(Graph mGraph, Graph owlSameStatements) {
         new SameAsSmusher().smush(mGraph, owlSameStatements, true);
     }
-
-
 }
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/UnionGraph.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/UnionGraph.java
index 3f939ce..c632765 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/UnionGraph.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/UnionGraph.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.*;
@@ -28,7 +27,6 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 
 /**
- *
  * This class represents the union of multiple triple collections. A UnionGraph
  * appears like a merge of the different graphs (see.
  * http://www.w3.org/TR/rdf-mt/#graphdefs).
@@ -64,7 +62,7 @@ public class UnionGraph extends AbstractGraph {
 
     @Override
     public Iterator<Triple> performFilter(final BlankNodeOrIRI subject,
-            final IRI predicate, final RDFTerm object) {
+                                          final IRI predicate, final RDFTerm object) {
         if (baseTripleCollections.length == 0) {
             return new HashSet<Triple>(0).iterator();
         }
@@ -152,6 +150,7 @@ public class UnionGraph extends AbstractGraph {
     public ReadWriteLock getLock() {
         return readWriteLock;
     }
+
     private ReadWriteLock readWriteLock = new ReadWriteLock() {
 
         @Override
@@ -185,9 +184,6 @@ public class UnionGraph extends AbstractGraph {
 
     }
 
-    ;
-
-
     private static class UnionLock implements Lock {
 
         Lock[] locks;
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/UnionWatchableGraph.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/UnionWatchableGraph.java
index 81b2dbf..12e660a 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/UnionWatchableGraph.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/UnionWatchableGraph.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.Graph;
@@ -24,34 +23,32 @@ import org.apache.clerezza.api.event.FilterTriple;
 import org.apache.clerezza.api.event.GraphListener;
 
 /**
- *
  * @author developer
  */
 public class UnionWatchableGraph extends UnionGraph implements WatchableGraph {
-    
+
     public UnionWatchableGraph(WatchableGraph... baseTripleCollections) {
         super(baseTripleCollections);
     }
-        @Override
+
+    @Override
     public void addGraphListener(GraphListener listener, FilterTriple filter) {
         for (Graph graph : baseTripleCollections) {
-            ((WatchableGraph)graph).addGraphListener(listener, filter);
+            ((WatchableGraph) graph).addGraphListener(listener, filter);
         }
     }
 
     @Override
     public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
         for (Graph graph : baseTripleCollections) {
-            ((WatchableGraph)graph).addGraphListener(listener, filter, delay);
+            ((WatchableGraph) graph).addGraphListener(listener, filter, delay);
         }
     }
 
     @Override
     public void removeGraphListener(GraphListener listener) {
         for (Graph graph : baseTripleCollections) {
-            ((WatchableGraph)graph).removeGraphListener(listener);
+            ((WatchableGraph) graph).removeGraphListener(listener);
         }
     }
-
-    
 }
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/UriMutatingGraph.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/UriMutatingGraph.java
index 0c6871c..4233ea7 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/UriMutatingGraph.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/UriMutatingGraph.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.*;
@@ -29,7 +28,7 @@ import java.util.concurrent.locks.ReadWriteLock;
 /**
  * This wrapps a Triplecollection changing a prefix for the IRIs contained
  * in subject or object position.
- *
+ * <p>
  * Currently it only supports read opearations.
  *
  * @author reto
@@ -43,12 +42,12 @@ public class UriMutatingGraph implements Graph {
     private final int targetPrefixLength;
 
     public UriMutatingGraph(Graph base, String sourcePrefix,
-            String targetPrefix) {
+                            String targetPrefix) {
         this.base = base;
         this.sourcePrefix = sourcePrefix;
-        sourcePrefixLength= sourcePrefix.length();
+        sourcePrefixLength = sourcePrefix.length();
         this.targetPrefix = targetPrefix;
-        targetPrefixLength= targetPrefix.length();
+        targetPrefixLength = targetPrefix.length();
     }
 
     private <R extends RDFTerm> R toTargetRDFTerm(final R sourceRDFTerm) {
@@ -57,10 +56,10 @@ public class UriMutatingGraph implements Graph {
             if (sourceIRI.getUnicodeString().startsWith(sourcePrefix)) {
                 final String uriRest = sourceIRI.getUnicodeString()
                         .substring(sourcePrefixLength);
-                return (R) new IRI(targetPrefix+uriRest);
+                return (R) new IRI(targetPrefix + uriRest);
             }
         }
-        return sourceRDFTerm;            
+        return sourceRDFTerm;
     }
 
     private Triple toTargetTriple(Triple triple) {
@@ -77,7 +76,7 @@ public class UriMutatingGraph implements Graph {
             if (sourceIRI.getUnicodeString().startsWith(targetPrefix)) {
                 final String uriRest = sourceIRI.getUnicodeString()
                         .substring(targetPrefixLength);
-                return (R) new IRI(sourcePrefix+uriRest);
+                return (R) new IRI(sourcePrefix + uriRest);
             }
         }
         return targetRDFTerm;
@@ -96,11 +95,8 @@ public class UriMutatingGraph implements Graph {
         final Iterator<Triple> baseIter = base.filter(toSourceRDFTerm(subject),
                 predicate, toSourceRDFTerm(object));
         return new WrappedIteraror(baseIter);
-
-
     }
 
-
     @Override
     public int size() {
         return base.size();
@@ -113,7 +109,7 @@ public class UriMutatingGraph implements Graph {
 
     @Override
     public boolean contains(Object o) {
-        return base.contains(toSourceTriple((Triple)o));
+        return base.contains(toSourceTriple((Triple) o));
     }
 
     @Override
@@ -191,7 +187,7 @@ public class UriMutatingGraph implements Graph {
         return base.getLock();
     }
 
-    class WrappedIteraror implements Iterator<Triple>{
+    class WrappedIteraror implements Iterator<Triple> {
         private final Iterator<Triple> baseIter;
 
         private WrappedIteraror(Iterator<Triple> baseIter) {
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/graphnodeprovider/GraphNodeProvider.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/graphnodeprovider/GraphNodeProvider.java
index f72106d..3bd8f54 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/graphnodeprovider/GraphNodeProvider.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/graphnodeprovider/GraphNodeProvider.java
@@ -39,8 +39,8 @@ public interface GraphNodeProvider {
     /**
      * Get a GraphNode for the specified resource, The resource is assumed to be
      * local, i.e. the method behaves like get(IRI) for a Uri with an
- authority section contained in the Set retuned by
- <code>org.apache.clerezza.platform.config.PlatformConfig#getBaseUris()</code>
+     * authority section contained in the Set retuned by
+     * <code>org.apache.clerezza.platform.config.PlatformConfig#getBaseUris()</code>
      */
     GraphNode getLocal(IRI uriRef);
 
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/BaseSmusher.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/BaseSmusher.java
index 569e638..6785ae1 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/BaseSmusher.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/BaseSmusher.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils.smushing;
 
 import org.apache.clerezza.api.*;
@@ -27,7 +26,6 @@ import java.util.*;
 import java.util.concurrent.locks.Lock;
 
 /**
- *
  * @author Reto
  */
 public class BaseSmusher {
@@ -35,14 +33,14 @@ public class BaseSmusher {
     /**
      * Smushes the resources in mGraph that belong to the same set in equivalenceSets,
      * i.e. it adds all properties to one of the resources in the equivalence set.
-     * 
-     * Optionally owl:sameAs statement are added that point from the IRIs that 
+     * <p>
+     * Optionally owl:sameAs statement are added that point from the IRIs that
      * no longer have properties to the one with properties. If addOwlSameAs
      * is false the IRIs will just disappear from the graph.
-     * 
-     * @param mGraph the graph to smush
+     *
+     * @param mGraph          the graph to smush
      * @param equivalenceSets sets of equivalent resources
-     * @param addOwlSameAs whether owl:sameAs statements should be added
+     * @param addOwlSameAs    whether owl:sameAs statements should be added
      */
     public void smush(Graph mGraph, Set<Set<BlankNodeOrIRI>> equivalenceSets, boolean addOwlSameAs) {
         Map<BlankNodeOrIRI, BlankNodeOrIRI> current2ReplacementMap = new HashMap<BlankNodeOrIRI, BlankNodeOrIRI>();
@@ -59,7 +57,7 @@ public class BaseSmusher {
         Lock l = mGraph.getLock().writeLock();
         l.lock();
         try {
-            for (Iterator<Triple> it = mGraph.iterator(); it.hasNext();) {
+            for (Iterator<Triple> it = mGraph.iterator(); it.hasNext(); ) {
                 final Triple triple = it.next();
                 final BlankNodeOrIRI subject = triple.getSubject();
                 BlankNodeOrIRI subjectReplacement = current2ReplacementMap.get(subject);
@@ -85,9 +83,9 @@ public class BaseSmusher {
             l.unlock();
         }
     }
-    
-    private BlankNodeOrIRI getReplacementFor(Set<BlankNodeOrIRI> equivalenceSet, 
-            Graph owlSameAsGraph) {
+
+    private BlankNodeOrIRI getReplacementFor(Set<BlankNodeOrIRI> equivalenceSet,
+                                             Graph owlSameAsGraph) {
         final Set<IRI> uriRefs = new HashSet<IRI>();
         for (BlankNodeOrIRI nonLiteral : equivalenceSet) {
             if (nonLiteral instanceof IRI) {
@@ -111,14 +109,14 @@ public class BaseSmusher {
         return preferedIRI;
     }
 
-    
+
     /**
      * Returns a prefered IRI for the IRIs in a set. Typically and in the
-     * default implementation the IRI will be one of the set. Note however that 
+     * default implementation the IRI will be one of the set. Note however that
      * subclass implementations may also return another IRI to be used.
-     * 
+     *
      * @param uriRefs
-     * @return 
+     * @return
      */
     protected IRI getPreferedIRI(Set<IRI> uriRefs) {
         final Iterator<IRI> uriRefIter = uriRefs.iterator();
@@ -126,5 +124,5 @@ public class BaseSmusher {
         //or look at their frequency in mGraph
         return uriRefIter.next();
     }
-    
+
 }
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/IfpSmusher.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/IfpSmusher.java
index 4c57af5..a1464bd 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/IfpSmusher.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/IfpSmusher.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils.smushing;
 
 import org.apache.clerezza.api.*;
@@ -27,13 +26,13 @@ import org.slf4j.LoggerFactory;
 import java.util.*;
 
 /**
- * A utility to equate duplicate nodes in an Mgarph, currently only nodes with 
+ * A utility to equate duplicate nodes in an Mgarph, currently only nodes with
  * a shared ifp are equated.
  *
  * @author reto
  */
 public class IfpSmusher extends BaseSmusher {
-    
+
     static final Logger log = LoggerFactory.getLogger(IfpSmusher.class);
 
     /**
@@ -49,7 +48,7 @@ public class IfpSmusher extends BaseSmusher {
     public void smush(Graph mGraph, Graph tBox) {
         final Set<IRI> ifps = getIfps(tBox);
         final Map<PredicateObject, Set<BlankNodeOrIRI>> ifp2nodesMap = new HashMap<PredicateObject, Set<BlankNodeOrIRI>>();
-        for (Iterator<Triple> it = mGraph.iterator(); it.hasNext();) {
+        for (Iterator<Triple> it = mGraph.iterator(); it.hasNext(); ) {
             final Triple triple = it.next();
             final IRI predicate = triple.getPredicate();
             if (!ifps.contains(predicate)) {
@@ -66,7 +65,6 @@ public class IfpSmusher extends BaseSmusher {
         Set<Set<BlankNodeOrIRI>> unitedEquivalenceSets = uniteSetsWithCommonElement(ifp2nodesMap.values());
         smush(mGraph, unitedEquivalenceSets, true);
     }
-    
 
     private Set<IRI> getIfps(Graph tBox) {
         final Iterator<Triple> ifpDefinitions = tBox.filter(null, RDF.type,
@@ -102,7 +100,7 @@ public class IfpSmusher extends BaseSmusher {
 
     private <T> Set<T> getMatchinSet(Set<T> set, Set<Set<T>> setOfSet) {
         for (Set<T> current : setOfSet) {
-            if (shareElements(set,current)) {
+            if (shareElements(set, current)) {
                 return current;
             }
         }
@@ -117,7 +115,6 @@ public class IfpSmusher extends BaseSmusher {
         }
         return false;
     }
-    
 
     class PredicateObject {
 
@@ -157,9 +154,7 @@ public class IfpSmusher extends BaseSmusher {
 
         @Override
         public String toString() {
-            return "("+predicate+", "+object+")";
+            return "(" + predicate + ", " + object + ")";
         }
-
-
-    };
+    }
 }
diff --git a/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/SameAsSmusher.java b/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/SameAsSmusher.java
index 3571ae6..b9f4de2 100644
--- a/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/SameAsSmusher.java
+++ b/api.utils/src/main/java/org/apache/clerezza/api/utils/smushing/SameAsSmusher.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils.smushing;
 
 import org.apache.clerezza.api.BlankNodeOrIRI;
@@ -35,43 +34,44 @@ import java.util.*;
  * @author reto
  */
 public class SameAsSmusher extends BaseSmusher {
-    
+
     static final Logger log = LoggerFactory.getLogger(SameAsSmusher.class);
-    
+
     /**
      * This will ensure that all properties of sameAs resources are associated
      * to the preferedIRI as returned by {@code getPreferedIRI}
+     *
      * @param mGraph
-     * @param owlSameStatements 
+     * @param owlSameStatements
      * @param addCanonicalSameAsStatements if true owl:sameAsStatements with the preferedIRI as object will be added
      */
-    public void smush(Graph mGraph, 
-            Graph owlSameStatements,
-            boolean addCanonicalSameAsStatements) {
-    	
-    	log.info("Starting smushing");
-        
-    	// This hashmap contains a uri (key) and the set of equivalent uris (value)
-    	final Map<BlankNodeOrIRI, Set<BlankNodeOrIRI>> node2EquivalenceSet = new HashMap<BlankNodeOrIRI, Set<BlankNodeOrIRI>>();
-    	
-    	log.info("Creating the sets of equivalent uris of each subject or object in the owl:sameAs statements");
-    	// Determines for each subject and object in all the owl:sameAs statements the set of ewquivalent uris 
-    	for (Iterator<Triple> it = owlSameStatements.iterator(); it.hasNext();) {            
-    		final Triple triple = it.next();
+    public void smush(Graph mGraph,
+                      Graph owlSameStatements,
+                      boolean addCanonicalSameAsStatements) {
+
+        log.info("Starting smushing");
+
+        // This hashmap contains a uri (key) and the set of equivalent uris (value)
+        final Map<BlankNodeOrIRI, Set<BlankNodeOrIRI>> node2EquivalenceSet = new HashMap<BlankNodeOrIRI, Set<BlankNodeOrIRI>>();
+
+        log.info("Creating the sets of equivalent uris of each subject or object in the owl:sameAs statements");
+        // Determines for each subject and object in all the owl:sameAs statements the set of ewquivalent uris
+        for (Iterator<Triple> it = owlSameStatements.iterator(); it.hasNext(); ) {
+            final Triple triple = it.next();
             final IRI predicate = triple.getPredicate();
             if (!predicate.equals(OWL.sameAs)) {
                 throw new RuntimeException("Statements must use only <http://www.w3.org/2002/07/owl#sameAs> predicate.");
             }
             final BlankNodeOrIRI subject = triple.getSubject();
             //literals not yet supported
-            final BlankNodeOrIRI object = (BlankNodeOrIRI)triple.getObject();
-            
+            final BlankNodeOrIRI object = (BlankNodeOrIRI) triple.getObject();
+
             Set<BlankNodeOrIRI> equivalentNodes = node2EquivalenceSet.get(subject);
-            
+
             // if there is not a set of equivalent uris then create a new set
             if (equivalentNodes == null) {
-            	equivalentNodes = node2EquivalenceSet.get(object);
-            	if (equivalentNodes == null) {
+                equivalentNodes = node2EquivalenceSet.get(object);
+                if (equivalentNodes == null) {
                     equivalentNodes = new HashSet<BlankNodeOrIRI>();
                 }
             } else {
@@ -82,28 +82,26 @@ public class SameAsSmusher extends BaseSmusher {
                         node2EquivalenceSet.remove(res);
                     }
                     for (BlankNodeOrIRI res : objectSet) {
-                        node2EquivalenceSet.put(res,equivalentNodes);
+                        node2EquivalenceSet.put(res, equivalentNodes);
                     }
                     equivalentNodes.addAll(objectSet);
                 }
             }
-            
+
             // add both subject and object of the owl:sameAs statement to the set of equivalent uris
             equivalentNodes.add(subject);
             equivalentNodes.add(object);
-            
+
             // use both uris in the owl:sameAs statement as keys for the set of equivalent uris
             node2EquivalenceSet.put(subject, equivalentNodes);
             node2EquivalenceSet.put(object, equivalentNodes);
-            
+
             log.info("Sets of equivalent uris created.");
-        
-    	}
-    	
-    	// This set contains the sets of equivalent uris
-    	Set<Set<BlankNodeOrIRI>> unitedEquivalenceSets = new HashSet<Set<BlankNodeOrIRI>>(node2EquivalenceSet.values());
+
+        }
+
+        // This set contains the sets of equivalent uris
+        Set<Set<BlankNodeOrIRI>> unitedEquivalenceSets = new HashSet<Set<BlankNodeOrIRI>>(node2EquivalenceSet.values());
         smush(mGraph, unitedEquivalenceSets, addCanonicalSameAsStatements);
     }
-
-    
 }
diff --git a/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/CollectedIter.scala b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/CollectedIter.scala
new file mode 100644
index 0000000..6ad12fe
--- /dev/null
+++ b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/CollectedIter.scala
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor  license  agreements.  See the NOTICE file distributed
+ * with this work  for  additional  information  regarding  copyright
+ * ownership.  The ASF  licenses  this file to you under  the  Apache
+ * License, Version 2.0 (the "License"); you may not  use  this  file
+ * except in compliance with the License.  You may obtain  a copy  of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless  required  by  applicable law  or  agreed  to  in  writing,
+ * software  distributed  under  the  License  is  distributed  on an
+ * "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR  CONDITIONS  OF ANY KIND,
+ * either  express  or implied.  See  the License  for  the  specific
+ * language governing permissions and limitations under  the License.
+ */
+package org.apache.clerezza.api.scala.utils
+
+import java.util.concurrent.locks.Lock
+import java.util.{ConcurrentModificationException, Iterator}
+
+import _root_.scala.collection.JavaConversions._
+import scala.collection.immutable
+import scala.collection.mutable._
+
+/**
+  *
+  * A Collection that groups the elements of an iterator, giving a view over it as over a
+  * sequence.
+  *
+  * The collection takes a function returning an iterator, in order to allow for cases where the
+  * iterator needs to be called from the beginning again. i.e. when a ConcurrentModificationException
+  * occurs and the iteration is repeated in a section used using the provided readLock.
+  */
+class CollectedIter[T](iterCreator: () => Iterator[T], readLock: Lock) extends immutable.Seq[T] {
+
+    def this(jList: java.util.List[T], readLock: Lock) = this(() => jList.iterator(), readLock)
+
+    def this() = this(() => java.util.Collections.emptyList[T].iterator(), null)
+
+    var iter = iterCreator()
+    var firstIter = true
+
+    private val collectedElems = new ArrayBuffer[T]()
+
+    /**
+      * This method allows the position to be expressed between parenthesis
+      */
+    def apply(pos: Int) = {
+        ensureReadTill(pos)
+        collectedElems(pos)
+    }
+
+
+    /**
+      * returns a new fully expanded and sorted CollectediterCreator
+      */
+    def sort(lt: (T, T) => Boolean) = {
+        val sortedElems = iterator.toList.sortWith(lt)
+        //TODO this re-expands everything, return sorted-list directly
+        new CollectedIter[T](sortedElems, readLock)
+
+    }
+
+    /**
+      * Operator style syntax to access a position.
+      */
+    def %(pos: Int) = apply(pos)
+
+    private def ensureReadTill(pos: Int) {
+        try {
+
+            while (iter.hasNext && (collectedElems.length - 1 <= pos)) {
+                val next = iter.next()
+                if (firstIter || !collectedElems.contains(next)) {
+                    collectedElems += next
+                }
+            }
+        } catch {
+            case e: ConcurrentModificationException => {
+                readLock.lock()
+                try {
+                    iter = iterCreator()
+                    firstIter = false
+                    //going beyond pos, do reduce chance we have to aquire another lock
+                    val biggerPos = if (pos < (Integer.MAX_VALUE - 100)) {
+                        pos + 100
+                    } else {
+                        Integer.MAX_VALUE
+                    }
+                    while (iter.hasNext && (collectedElems.length - 1 <= biggerPos)) {
+                        val next = iter.next()
+                        if (!collectedElems.contains(next)) {
+                            collectedElems += next
+                        }
+                    }
+                } finally {
+                    readLock.unlock()
+                }
+            }
+            case e: Exception => throw e
+        }
+    }
+
+    override def length: Int = {
+        length(Integer.MAX_VALUE)
+    }
+
+    /**
+      * The value returned is same or less than the length of the collection,
+      * the underlying Iterator isn't expanded till more than <code>max</code>. If
+      * the result is smaller than max it is the length of the collection.
+      */
+    def length(max: Int): Int = {
+        ensureReadTill(max)
+        collectedElems.length
+    }
+
+    override def toString() = {
+        if (length(1) > 0) {
+            apply(0).toString
+        } else {
+            "empty"
+        }
+    }
+
+    override def iterator = {
+        ensureReadTill(Integer.MAX_VALUE)
+        collectedElems.iterator
+    }
+}
diff --git a/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/EzLiteral.scala b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/EzLiteral.scala
new file mode 100644
index 0000000..de303e1
--- /dev/null
+++ b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/EzLiteral.scala
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor  license  agreements.  See the NOTICE file distributed
+ * with this work  for  additional  information  regarding  copyright
+ * ownership.  The ASF  licenses  this file to you under  the  Apache
+ * License, Version 2.0 (the "License"); you may not  use  this  file
+ * except in compliance with the License.  You may obtain  a copy  of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless  required  by  applicable law  or  agreed  to  in  writing,
+ * software  distributed  under  the  License  is  distributed  on an
+ * "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR  CONDITIONS  OF ANY KIND,
+ * either  express  or implied.  See  the License  for  the  specific
+ * language governing permissions and limitations under  the License.
+ */
+package org.apache.clerezza.api.scala.utils
+
+import org.apache.clerezza.api._
+import org.apache.clerezza.api.impl.literal._
+import org.apache.clerezza.ontologies.XSD
+
+object EzLiteral extends EzLiteralImplicits
+
+trait EzLiteralImplicits {
+
+    implicit def string2lit(str: String) = new EzLiteral(str)
+
+}
+
+/**
+  * An EzLiteral is a typed string literal - ie, just a String literal - that comes with N3/turtle like methods
+  * to map to other types of literals.
+  *
+  * This makes it useful when combined with the EzLiteralImplicit for writing out literals
+  *
+  * <code>
+  * "ABCDEFGHIJKLMN"                   -- a plain string converted to a EzLiteral
+  * "some text in english".lang(en)    -- an english literal
+  * "1234"^^XSD.int                    -- a number
+  * </code>
+  *
+  * @author bblfish
+  */
+class EzLiteral(string: String) extends TypedLiteralImpl(string, XSD.string) {
+
+    /**
+      * @return a plain literal with language specified by lang
+      */
+    def lang(lng: String): Literal = lang(new Language(lng))
+
+    /**
+      * @return a plain literal with language specified by lang
+      */
+    def lang(lng: Language): Literal = new PlainLiteralImpl(string, lng)
+
+    /**
+      * Map to a Typed Literal of given type
+      */
+    def ^^(typ: IRI): Literal = new TypedLiteralImpl(string, typ)
+
+    /**
+      * alias for iri
+      */
+    @deprecated(message = "use  `iri`", since = "1.0.0")
+    def uri = iri
+
+    /**
+      * Map to an IRI of given lexical form
+      */
+    def iri = new IRI(string)
+
+}
diff --git a/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/EzMGraph.scala b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/EzMGraph.scala
new file mode 100644
index 0000000..c5ab112
--- /dev/null
+++ b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/EzMGraph.scala
@@ -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.clerezza.api.scala.utils
+
+import org.apache.clerezza.api._
+import org.apache.clerezza.api.impl.graph._
+
+import _root_.scala.collection.mutable.HashMap
+
+
+/**
+  * EzGraph enhances graph writing, it can make writing rdf graphs in code a lot more
+  * readable, as it avoids a lot of repetition.
+  *
+  * @param graph : a Triple collection
+  * @author hjs, reto
+  */
+class EzGraph(val baseTc: Graph) extends AbstractGraph with TcDependentConversions {
+
+
+    def this() = this(new SimpleGraph())
+
+    def performFilter(subject: BlankNodeOrIRI, predicate: IRI,
+                      obj: RDFTerm): java.util.Iterator[Triple] = baseTc.filter(subject, predicate, obj)
+
+    override def performSize = baseTc.size
+
+    override def add(t: Triple) = baseTc.add(t)
+
+    /**
+      * Add all triples into the other graph to this one
+      */
+    def +=(other: Graph) = {
+        if (baseTc ne other) baseTc.addAll(other)
+    }
+
+    /**
+      * create a new bnode
+      */
+    def bnode = blankNode
+
+    def blankNode: BlankNode = {
+        new BlankNode
+    }
+
+    private val namedBnodes = new HashMap[String, BlankNode]
+
+    /**
+      * create a new named bnode based EzGraphNode with the preferred writing style
+      */
+    def b_(name: String): BlankNode = {
+        namedBnodes.get(name) match {
+            case Some(bnode) => bnode
+            case None => {
+                val bn = new BlankNode
+                namedBnodes.put(name, bn);
+                bn
+            }
+        }
+    }
+
+}
+
+
diff --git a/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/NameSpace.scala b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/NameSpace.scala
new file mode 100644
index 0000000..1231fcc
--- /dev/null
+++ b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/NameSpace.scala
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor  license  agreements.  See the NOTICE file distributed
+ * with this work  for  additional  information  regarding  copyright
+ * ownership.  The ASF  licenses  this file to you under  the  Apache
+ * License, Version 2.0 (the "License"); you may not  use  this  file
+ * except in compliance with the License.  You may obtain  a copy  of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless  required  by  applicable law  or  agreed  to  in  writing,
+ * software  distributed  under  the  License  is  distributed  on an
+ * "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR  CONDITIONS  OF ANY KIND,
+ * either  express  or implied.  See  the License  for  the  specific
+ * language governing permissions and limitations under  the License.
+ */
+package org.apache.clerezza.api.scala.utils
+
+import org.apache.clerezza.api.IRI
+
+/**
+  * A IRI-namespace prefix
+  */
+class NameSpace(prefix: String) {
+
+    /**
+      * returns a IRI applying this namespace prefix to the given symbol
+      */
+    def +(s: Symbol) = new IRI(prefix + s.name)
+
+    /**
+      * returns a IRI applying this prefix to the given string
+      */
+    def +(s: String) = new IRI(prefix + s)
+}
diff --git a/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/Preamble.scala b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/Preamble.scala
new file mode 100644
index 0000000..635f2f3
--- /dev/null
+++ b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/Preamble.scala
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor  license  agreements.  See the NOTICE file distributed
+ * with this work  for  additional  information  regarding  copyright
+ * ownership.  The ASF  licenses  this file to you under  the  Apache
+ * License, Version 2.0 (the "License"); you may not  use  this  file
+ * except in compliance with the License.  You may obtain  a copy  of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless  required  by  applicable law  or  agreed  to  in  writing,
+ * software  distributed  under  the  License  is  distributed  on an
+ * "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR  CONDITIONS  OF ANY KIND,
+ * either  express  or implied.  See  the License  for  the  specific
+ * language governing permissions and limitations under  the License.
+ */
+package org.apache.clerezza.api.scala.utils
+
+import java.math.BigInteger
+import java.net.{URI, URL}
+import java.util.Date
+
+import org.apache.clerezza.api._
+import org.apache.clerezza.api.impl.graph._
+import org.apache.clerezza.api.impl.literal._
+import org.apache.clerezza.api.utils.GraphNode
+
+/**
+  * This object provides the implicit conversions. Typically this is used by
+  * adding
+  * {{{
+  * import org.apache.clerezza.rdf.scala.utils.Preamble._
+  * }}} near the top of the
+  * file using SCB Utilities for Scala
+  *
+  * @author bblfish, reto
+  */
+object Preamble extends TcIndependentConversions {
+
+}
+
+/**
+  * This class provides the implicit conversions of its companion Object and
+  * additional conversions that require an evaluation graph, i.e. the conversion
+  * from a resource to a RichGraphNode.
+  *
+  * Typically this is used by
+  * adding
+  * {{{
+  * val preamble = new org.apache.clerezza.rdf.scala.utils.Preamble(myGraph)
+  * import preamble._
+  * }}}
+  * before the
+  * code section using the conversions
+  *
+  * @author bblfish, reto
+  */
+class Preamble(val baseTc: Graph) extends TcDependentConversions {
+
+}
+
+protected trait TcDependentConversions extends TcIndependentConversions {
+
+    def baseTc: Graph
+
+    implicit def toRichGraphNode(resource: RDFTerm) = {
+        new RichGraphNode(new GraphNode(resource, baseTc))
+    }
+}
+
+protected trait TcIndependentConversions extends EzLiteralImplicits {
+    implicit def toRichGraphNode(node: GraphNode) = {
+        new RichGraphNode(node)
+    }
+
+    implicit def toFirstElement(c: CollectedIter[RichGraphNode]) = {
+        if (c.length(1) > 0) {
+            c(0)
+        } else {
+            TcIndependentConversions.emptyLiteral
+        }
+    }
+
+    private val litFactory = LiteralFactory.getInstance
+
+
+    implicit def lit2String(lit: Literal) = lit.getLexicalForm
+
+    implicit def date2lit(date: Date) = litFactory.createTypedLiteral(date)
+
+    implicit def int2lit(int: Int) = litFactory.createTypedLiteral(int)
+
+    implicit def bigint2lit(bint: BigInt) = litFactory.createTypedLiteral(bint.underlying())
+
+    implicit def bigint2lit(bigInt: BigInteger) = litFactory.createTypedLiteral(bigInt)
+
+    implicit def bool2lit(boolean: Boolean) = litFactory.createTypedLiteral(boolean)
+
+    implicit def long2lit(long: Long) = litFactory.createTypedLiteral(long)
+
+    implicit def double2lit(double: Double) = litFactory.createTypedLiteral(double)
+
+    implicit def uriRef2Prefix(uriRef: IRI) = new NameSpace(uriRef.getUnicodeString)
+
+    implicit def URItoIRI(uri: URI) = new IRI(uri.toString)
+
+    implicit def URLtoIRI(url: URL) = new IRI(url.toExternalForm)
+
+}
+
+protected object TcIndependentConversions {
+    val emptyGraph = new SimpleImmutableGraph(new SimpleGraph)
+    val emptyLiteral = new RichGraphNode(new GraphNode(new PlainLiteralImpl(""), emptyGraph))
+
+}
+
diff --git a/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/RichGraphNode.scala b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/RichGraphNode.scala
new file mode 100644
index 0000000..e4327a2
--- /dev/null
+++ b/api.utils/src/main/scala/org/apache/clerezza/api/scala/utils/RichGraphNode.scala
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor  license  agreements.  See the NOTICE file distributed
+ * with this work  for  additional  information  regarding  copyright
+ * ownership.  The ASF  licenses  this file to you under  the  Apache
+ * License, Version 2.0 (the "License"); you may not  use  this  file
+ * except in compliance with the License.  You may obtain  a copy  of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless  required  by  applicable law  or  agreed  to  in  writing,
+ * software  distributed  under  the  License  is  distributed  on an
+ * "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR  CONDITIONS  OF ANY KIND,
+ * either  express  or implied.  See  the License  for  the  specific
+ * language governing permissions and limitations under  the License.
+ */
+package org.apache.clerezza.api.scala.utils
+
+import java.util.Iterator
+
+import org.apache.clerezza.api._
+import org.apache.clerezza.api.impl.graph.SimpleGraph
+import org.apache.clerezza.api.impl.literal.LiteralFactory
+import org.apache.clerezza.api.utils.{GraphNode, UnionGraph}
+import org.apache.clerezza.ontologies.RDF
+
+import _root_.scala.collection.JavaConversions._
+import _root_.scala.reflect.Manifest
+
+/**
+  * A RichGraphNode decorates A GraphNode with additional method to be part on a DSL-style scala library.
+  *
+  * The default constructor is same a the GraphNode constructor, i.e. it takes the node and its context
+  * Triple-collection
+  *
+  * @param resource the node represented by this RichGraphNode
+  * @param graph    the Graph that describes the resource
+  */
+class RichGraphNode(resource: RDFTerm, graph: Graph) extends GraphNode(resource, graph) {
+
+    /**
+      * Construct a RichGraphNode given an existing [[GraphNde]]
+      *
+      * @param node The GraphNode to be wrapped
+      */
+    def this(node: GraphNode) = this(node.getNode, node.getGraph)
+
+    /**
+      * Operator syntax shortcut to get all objects as <code>RichGraphNode</code>
+      *
+      * @return all objects of the specified property of the node wrapped by this object
+      */
+    def /(property: IRI): CollectedIter[RichGraphNode] = {
+        new CollectedIter[RichGraphNode](() => new GraphNodeIter(getObjects(property)), readLock)
+    }
+
+    /**
+      * Operator syntax shortcut to get all subjects as <code>RichGraphNode</code>ref
+      *
+      * @param property the property for which the subjects pointing to this node by that property are requested
+      * @return the matching resources
+      */
+    def /-(property: IRI): CollectedIter[RichGraphNode] = {
+        new CollectedIter[RichGraphNode](() => new GraphNodeIter(getSubjects(property)), readLock)
+    }
+
+    /**
+      * Get the elements of the rdf:List represented by this node
+      *
+      * @return a List with the elements of the rdf:List represented by this node
+      */
+    def !! = (for (listElem <- asList) yield {
+        new RichGraphNode(new GraphNode(listElem, getGraph))
+    }).toList
+
+    /**
+      * get a specified of the rdf:List represented by this node
+      *
+      * @return the specified index value
+      */
+    def %!!(index: Int) = new RichGraphNode(new GraphNode(asList.get(index),
+        getGraph))
+
+    /**
+      * produces a default String representation for the node, this is the lexical form of literals,
+      * the unicode-string for IRI and for BlankNodes the value returned by toString
+      *
+      * @return the default string representation of the node
+      */
+    def * : String = {
+        getNode() match {
+            case lit: Literal => lit.getLexicalForm
+            case uri: IRI => uri.getUnicodeString
+            case wrappedNode => wrappedNode.toString
+        }
+    }
+
+    private def asClass[T](clazz: Class[T]): T = {
+        val typedLiteral = getNode().asInstanceOf[Literal]
+        clazz match {
+            case c if (c == classOf[Boolean]) => LiteralFactory.getInstance().createObject(
+                classOf[java.lang.Boolean], typedLiteral).booleanValue.asInstanceOf[T]
+            case _ => LiteralFactory.getInstance().createObject(clazz, typedLiteral)
+        }
+    }
+
+    /**
+      * Creates an instance of specified Class-Type representing the value of the literal wrapped by this
+      * <code>GraphNode</code>
+      *
+      * @return the literal represented by this node as instance of the specified type
+      */
+    def as[T](implicit m: Manifest[T]): T = {
+        asClass(m.runtimeClass.asInstanceOf[Class[T]])
+    }
+
+    /**
+      * Operator syntax shortcut to get the <code>RDFTerm</code> wrapped by this
+      * <code>GraphNode</code>
+      *
+      * @return the node represented by this GraphNode as RDFTerm, same as <code>getNode</code>
+      */
+    def ! = {
+        getNode()
+    }
+
+    private class GraphNodeIter[T <: RDFTerm](base: Iterator[T]) extends Iterator[RichGraphNode] {
+        override def hasNext() = {
+            base.hasNext();
+        }
+
+        override def next(): RichGraphNode = {
+            new RichGraphNode(new GraphNode(base.next(), getGraph));
+        }
+
+        override def remove() {
+            base.remove()
+        }
+    }
+
+    /**
+      * Sets the RDF:type of the subject */
+    def a(rdfclass: IRI): RichGraphNode = {
+        addProperty(RDF.`type`, rdfclass)
+        return this
+    }
+
+    /*
+     * create an RichGraphNode from this one where the backing graph is protected from writes by a new
+     * SimpleGraph.
+     */
+    def protect(): RichGraphNode = new RichGraphNode(getNode, new UnionGraph(new SimpleGraph(), graph))
+
+
+    /**
+      * relate the subject via the given relation to....
+      */
+    def --(rel: RDFTerm): DashTuple = new DashTuple(rel)
+
+    def --(rel: RichGraphNode): DashTuple = new DashTuple(rel.getNode)
+
+
+    /**
+      * relate the subject via the inverse of the given relation to....
+      */
+    def <--(tuple: RichGraphNode#DashTuple): RichGraphNode = {
+        val inversePropertyRes = tuple.first.getNode
+        val inverseProperty: IRI = inversePropertyRes match {
+            case p: IRI => p
+            case _ => throw new RuntimeException("DashTuple must be a IRI")
+        }
+        RichGraphNode.this.addInverseProperty(inverseProperty, tuple.second)
+        RichGraphNode.this
+    }
+
+
+    /** class for Inverse relations with the current RichGraphNode.ref as object */
+    //TODO add support for adding many for symmetry reasons
+    //  class InverseDashTuple(rel: DashTuple) {
+    //
+    //    /**
+    //     * ...to the following non literal
+    //     */
+    //    def --(subj: BlankNodeOrIRI): RichGraphNode = {
+    //      RichGraphNode.this.addInverseProperty(rel, subj)
+    //      RichGraphNode.this
+    //    }
+    //
+    //    /**
+    //     * ...to the following resource (given as a string)
+    //     */
+    //    def --(subj: String): RichGraphNode = --(new IRI(subj))
+    //
+    //    /**
+    //     * ...to the following EzGraphNode
+    //     * (useful for opening a new parenthesis and specifying other things in more detail
+    //     */
+    //    def --(subj: GraphNode): RichGraphNode = {
+    //      --(subj.getNode.asInstanceOf[BlankNodeOrIRI])
+    //    }
+    //    // since we can only have inverses from non literals (howto deal with bndoes?)
+    //  }
+
+    /**
+      * class for relations with the current RichGraphNode.ref as subject
+      */
+    class DashTuple(val second: RDFTerm) {
+
+        val first = RichGraphNode.this
+
+        /**
+          * ...to the following non resource
+          */
+        def -->(obj: RDFTerm): RichGraphNode = {
+            val property = second match {
+                case u: IRI => u;
+                case _ => throw new RuntimeException("Property must be a IRI")
+            }
+            RichGraphNode.this.addProperty(property, obj)
+            RichGraphNode.this
+        }
+
+
+        /**
+          * ...to the EzGraphNode, which is useful for opening a parenthesis.
+          */
+        def -->(sub: GraphNode): RichGraphNode = {
+            //RichGraphNode.this + sub
+            -->(sub.getNode)
+        }
+
+        /**
+          * Add one relation for each member of the iterable collection
+          */
+        def -->>[T <: RDFTerm](uris: Iterable[T]): RichGraphNode = {
+            for (u <- uris) -->(u)
+            RichGraphNode.this
+        }
+    }
+
+}
diff --git a/api.utils/src/test/java/org/apache/clerezza/api/utils/GraphUtilsTest.java b/api.utils/src/test/java/org/apache/clerezza/api/utils/GraphUtilsTest.java
index f5df426..a4e5c1e 100644
--- a/api.utils/src/test/java/org/apache/clerezza/api/utils/GraphUtilsTest.java
+++ b/api.utils/src/test/java/org/apache/clerezza/api/utils/GraphUtilsTest.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.BlankNode;
@@ -28,7 +27,6 @@ import org.junit.Assert;
 import org.junit.Test;
 
 /**
- *
  * @author reto
  */
 public class GraphUtilsTest {
@@ -65,12 +63,13 @@ public class GraphUtilsTest {
         }
         return baseGraph;
     }
-    
-    /** It is required that the subgraph comprises the whole context of the Bnodes it ioncludes
-     * 
+
+    /**
+     * It is required that the subgraph comprises the whole context of the Bnodes it ioncludes
+     *
      * @throws org.apache.clerezza.utils.GraphUtils.NoSuchSubGraphException
      */
-    @Test(expected=NoSuchSubGraphException.class)
+    @Test(expected = NoSuchSubGraphException.class)
     public void removeIncompleteSubGraph() throws NoSuchSubGraphException {
         Graph baseGraph = createBaseGraph();
 
@@ -84,7 +83,7 @@ public class GraphUtilsTest {
         GraphUtils.removeSubGraph(baseGraph, subGraph);
     }
 
-    @Test(expected=NoSuchSubGraphException.class)
+    @Test(expected = NoSuchSubGraphException.class)
     public void removeInvalidSubGraph() throws NoSuchSubGraphException {
         Graph baseGraph = createBaseGraph();
 
diff --git a/api.utils/src/test/java/org/apache/clerezza/api/utils/IfpSmushTest.java b/api.utils/src/test/java/org/apache/clerezza/api/utils/IfpSmushTest.java
index 18d3f9d..dd19217 100644
--- a/api.utils/src/test/java/org/apache/clerezza/api/utils/IfpSmushTest.java
+++ b/api.utils/src/test/java/org/apache/clerezza/api/utils/IfpSmushTest.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.BlankNode;
@@ -32,34 +31,34 @@ import org.junit.Assert;
 import org.junit.Test;
 
 /**
- *
  * @author reto
  */
 public class IfpSmushTest {
 
     private Graph ontology = new SimpleGraph();
+
     {
         ontology.add(new TripleImpl(FOAF.mbox, RDF.type, OWL.InverseFunctionalProperty));
     }
 
     @Test
-    public void simpleBlankNode()  {
+    public void simpleBlankNode() {
         Graph mGraph = new SimpleGraph();
         IRI mbox1 = new IRI("mailto:foo@example.org");
         final BlankNode bNode1 = new BlankNode();
         mGraph.add(new TripleImpl(bNode1, FOAF.mbox, mbox1));
-        mGraph.add(new TripleImpl(bNode1, RDFS.comment, 
+        mGraph.add(new TripleImpl(bNode1, RDFS.comment,
                 new PlainLiteralImpl("a comment")));
         final BlankNode bNode2 = new BlankNode();
         mGraph.add(new TripleImpl(bNode2, FOAF.mbox, mbox1));
-        mGraph.add(new TripleImpl(bNode2, RDFS.comment, 
+        mGraph.add(new TripleImpl(bNode2, RDFS.comment,
                 new PlainLiteralImpl("another comment")));
         Smusher.smush(mGraph, ontology);
         Assert.assertEquals(3, mGraph.size());
     }
 
     @Test
-    public void overlappingEquivalenceClasses()  {
+    public void overlappingEquivalenceClasses() {
         Graph mGraph = new SimpleGraph();
         IRI mbox1 = new IRI("mailto:foo@example.org");
         final BlankNode bNode1 = new BlankNode();
@@ -81,7 +80,7 @@ public class IfpSmushTest {
     }
 
     @Test
-    public void oneIRI()  {
+    public void oneIRI() {
         Graph mGraph = new SimpleGraph();
         IRI mbox1 = new IRI("mailto:foo@example.org");
         final IRI resource = new IRI("http://example.org/");
@@ -97,7 +96,7 @@ public class IfpSmushTest {
     }
 
     @Test
-    public void twoIRIs()  {
+    public void twoIRIs() {
         Graph mGraph = new SimpleGraph();
         IRI mbox1 = new IRI("mailto:foo@example.org");
         final IRI resource1 = new IRI("http://example.org/");
diff --git a/api.utils/src/test/java/org/apache/clerezza/api/utils/RdfListTest.java b/api.utils/src/test/java/org/apache/clerezza/api/utils/RdfListTest.java
index ea19303..0ef67c7 100644
--- a/api.utils/src/test/java/org/apache/clerezza/api/utils/RdfListTest.java
+++ b/api.utils/src/test/java/org/apache/clerezza/api/utils/RdfListTest.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import junit.framework.Assert;
@@ -33,7 +32,6 @@ import java.util.Set;
 import static org.junit.Assert.assertEquals;
 
 /**
- *
  * @author rbn
  */
 public class RdfListTest {
@@ -88,11 +86,11 @@ public class RdfListTest {
         Graph tc = new SimpleGraph();
         List<RDFTerm> list = new RdfList(new IRI("http://example.org/mytest"), tc);
         assertEquals(0, list.size());
-        list.add(0,new PlainLiteralImpl("world"));
+        list.add(0, new PlainLiteralImpl("world"));
         list = new RdfList(new IRI("http://example.org/mytest"), tc);
-        list.add(0,new PlainLiteralImpl("beautifuly"));
+        list.add(0, new PlainLiteralImpl("beautifuly"));
         list = new RdfList(new IRI("http://example.org/mytest"), tc);
-        list.add(0,new PlainLiteralImpl("hello"));
+        list.add(0, new PlainLiteralImpl("hello"));
         assertEquals(new PlainLiteralImpl("hello"), list.get(0));
         assertEquals(new PlainLiteralImpl("beautifuly"), list.get(1));
         assertEquals(new PlainLiteralImpl("world"), list.get(2));
@@ -103,12 +101,15 @@ public class RdfListTest {
         Graph tc = new SimpleGraph();
         List<RDFTerm> list = new RdfList(new IRI("http://example.org/mytest"), tc);
         assertEquals(0, list.size());
-        BlankNode node0 = new BlankNode() {};
-        BlankNode node1 = new BlankNode() {};
-        BlankNode node2 = new BlankNode() {};
-        list.add(0,node2);
-        list.add(0,node1);
-        list.add(0,node0);
+        BlankNode node0 = new BlankNode() {
+        };
+        BlankNode node1 = new BlankNode() {
+        };
+        BlankNode node2 = new BlankNode() {
+        };
+        list.add(0, node2);
+        list.add(0, node1);
+        list.add(0, node0);
         assertEquals(node0, list.get(0));
         assertEquals(node1, list.get(1));
         assertEquals(node2, list.get(2));
diff --git a/api.utils/src/test/java/org/apache/clerezza/api/utils/SameAsSmushTest.java b/api.utils/src/test/java/org/apache/clerezza/api/utils/SameAsSmushTest.java
index c03e3c8..5622711 100644
--- a/api.utils/src/test/java/org/apache/clerezza/api/utils/SameAsSmushTest.java
+++ b/api.utils/src/test/java/org/apache/clerezza/api/utils/SameAsSmushTest.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.Graph;
@@ -34,21 +33,22 @@ import org.junit.Test;
 import java.util.Iterator;
 
 /**
- *
  * @author reto
  */
 public class SameAsSmushTest {
-    
+
     private final IRI uriA = new IRI("http://example.org/A");
     private final IRI uriB = new IRI("http://example.org/B");
     private final Literal lit = new PlainLiteralImpl("That's me (and you)");
 
     private Graph sameAsStatements = new SimpleGraph();
+
     {
         sameAsStatements.add(new TripleImpl(uriA, OWL.sameAs, uriB));
     }
-    
-    private Graph  dataGraph = new SimpleGraph();
+
+    private Graph dataGraph = new SimpleGraph();
+
     {
         dataGraph.add(new TripleImpl(uriA, FOAF.knows, uriB));
         dataGraph.add(new TripleImpl(uriB, RDFS.label, lit));
@@ -56,7 +56,7 @@ public class SameAsSmushTest {
     }
 
     @Test
-    public void simple()  {
+    public void simple() {
         Assert.assertEquals(3, dataGraph.size());
         Smusher.sameAsSmush(dataGraph, sameAsStatements);
         Assert.assertEquals(3, dataGraph.size());
@@ -73,5 +73,4 @@ public class SameAsSmushTest {
         Assert.assertEquals(litStmt.getSubject(), knowStmt.getObject());
         Assert.assertEquals(litStmt.getSubject(), dataGraph.filter(null, OWL.sameAs, null).next().getObject());
     }
-
 }
diff --git a/api.utils/src/test/java/org/apache/clerezza/api/utils/TestGraphNode.java b/api.utils/src/test/java/org/apache/clerezza/api/utils/TestGraphNode.java
index 3d0f8e3..2a39556 100644
--- a/api.utils/src/test/java/org/apache/clerezza/api/utils/TestGraphNode.java
+++ b/api.utils/src/test/java/org/apache/clerezza/api/utils/TestGraphNode.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import junit.framework.Assert;
@@ -32,7 +31,6 @@ import java.util.Iterator;
 import java.util.Set;
 
 /**
- *
  * @author reto, mir
  */
 public class TestGraphNode {
@@ -40,8 +38,10 @@ public class TestGraphNode {
     @Test
     public void nodeContext() {
         Graph g = new SimpleGraph();
-        BlankNode bNode1 = new BlankNode() {};
-        BlankNode bNode2 = new BlankNode() {};
+        BlankNode bNode1 = new BlankNode() {
+        };
+        BlankNode bNode2 = new BlankNode() {
+        };
         IRI property1 = new IRI("http://example.org/property1");
         IRI property2 = new IRI("http://example.org/property2");
         g.add(new TripleImpl(bNode1, property1, new PlainLiteralImpl("literal")));
@@ -59,8 +59,10 @@ public class TestGraphNode {
     @Test
     public void addNode() {
         Graph g = new SimpleGraph();
-        BlankNode bNode1 = new BlankNode() {};
-        BlankNode bNode2 = new BlankNode() {};
+        BlankNode bNode1 = new BlankNode() {
+        };
+        BlankNode bNode2 = new BlankNode() {
+        };
         IRI property1 = new IRI("http://example.org/property1");
         GraphNode n = new GraphNode(bNode1, g);
         n.addProperty(property1, bNode2);
@@ -102,10 +104,12 @@ public class TestGraphNode {
     }
 
     @Test
-    public void getAvailableProperties(){
+    public void getAvailableProperties() {
         Graph g = new SimpleGraph();
-        BlankNode bNode1 = new BlankNode() {};
-        BlankNode bNode2 = new BlankNode() {};
+        BlankNode bNode1 = new BlankNode() {
+        };
+        BlankNode bNode2 = new BlankNode() {
+        };
         IRI property1 = new IRI("http://example.org/property1");
         IRI property2 = new IRI("http://example.org/property2");
         IRI property3 = new IRI("http://example.org/property3");
@@ -122,7 +126,7 @@ public class TestGraphNode {
         n.addProperty(property4, bNode2);
         Iterator<IRI> properties = n.getProperties();
         int i = 0;
-        while(properties.hasNext()){
+        while (properties.hasNext()) {
             i++;
             IRI prop = properties.next();
             Assert.assertTrue(props.contains(prop));
@@ -136,8 +140,10 @@ public class TestGraphNode {
     @Test
     public void deleteAll() {
         Graph g = new SimpleGraph();
-        BlankNode bNode1 = new BlankNode() {};
-        BlankNode bNode2 = new BlankNode() {};
+        BlankNode bNode1 = new BlankNode() {
+        };
+        BlankNode bNode2 = new BlankNode() {
+        };
         IRI property1 = new IRI("http://example.org/property1");
         IRI property2 = new IRI("http://example.org/property2");
         //the two properties two be deleted
@@ -155,8 +161,10 @@ public class TestGraphNode {
     @Test
     public void deleteSingleProperty() {
         Graph g = new SimpleGraph();
-        BlankNode bNode1 = new BlankNode() {};
-        BlankNode bNode2 = new BlankNode() {};
+        BlankNode bNode1 = new BlankNode() {
+        };
+        BlankNode bNode2 = new BlankNode() {
+        };
         IRI property1 = new IRI("http://example.org/property1");
         IRI property2 = new IRI("http://example.org/property2");
         //the properties two be deleted
@@ -243,8 +251,10 @@ public class TestGraphNode {
     @Test
     public void equality() {
         Graph g = new SimpleGraph();
-        BlankNode bNode1 = new BlankNode() {};
-        BlankNode bNode2 = new BlankNode() {};
+        BlankNode bNode1 = new BlankNode() {
+        };
+        BlankNode bNode2 = new BlankNode() {
+        };
         IRI property1 = new IRI("http://example.org/property1");
         GraphNode n = new GraphNode(bNode1, g);
         n.addProperty(property1, bNode2);
@@ -262,5 +272,4 @@ public class TestGraphNode {
         }
         return set;
     }
-
 }
diff --git a/api.utils/src/test/java/org/apache/clerezza/api/utils/UnionGraphTest.java b/api.utils/src/test/java/org/apache/clerezza/api/utils/UnionGraphTest.java
index e1f8e33..d45f945 100644
--- a/api.utils/src/test/java/org/apache/clerezza/api/utils/UnionGraphTest.java
+++ b/api.utils/src/test/java/org/apache/clerezza/api/utils/UnionGraphTest.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils;
 
 import org.apache.clerezza.api.BlankNode;
@@ -30,7 +29,6 @@ import org.junit.Test;
 import java.util.Iterator;
 
 /**
- *
  * @author hasan
  */
 public class UnionGraphTest {
@@ -61,7 +59,7 @@ public class UnionGraphTest {
         Assert.assertFalse(unionTriples.hasNext());
         Assert.assertEquals(2, unionGraph.size());
     }
-    
+
     @Test
     public void writeAccess() {
         Graph graph = new SimpleGraph();
diff --git a/api.utils/src/test/java/org/apache/clerezza/api/utils/smushing/SameAsSmushTest.java b/api.utils/src/test/java/org/apache/clerezza/api/utils/smushing/SameAsSmushTest.java
index 10ae1f0..0116014 100644
--- a/api.utils/src/test/java/org/apache/clerezza/api/utils/smushing/SameAsSmushTest.java
+++ b/api.utils/src/test/java/org/apache/clerezza/api/utils/smushing/SameAsSmushTest.java
@@ -15,7 +15,6 @@
  * either  express  or implied.  See  the License  for  the  specific
  * language governing permissions and limitations under  the License.
  */
-
 package org.apache.clerezza.api.utils.smushing;
 
 import org.apache.clerezza.api.Graph;
@@ -35,23 +34,24 @@ import java.util.Iterator;
 import java.util.Set;
 
 /**
- *
  * @author reto
  */
 public class SameAsSmushTest {
-    
+
     private final IRI uriA = new IRI("http://example.org/A");
     private final IRI uriB = new IRI("http://example.org/B");
     private final IRI uriC = new IRI("http://example.org/C");
-    
+
     private final Literal lit = new PlainLiteralImpl("That's me (and you)");
 
     private Graph sameAsStatements = new SimpleGraph();
+
     {
         sameAsStatements.add(new TripleImpl(uriA, OWL.sameAs, uriB));
     }
-    
-    private Graph  dataGraph = new SimpleGraph();
+
+    private Graph dataGraph = new SimpleGraph();
+
     {
         dataGraph.add(new TripleImpl(uriA, FOAF.knows, uriB));
         dataGraph.add(new TripleImpl(uriB, RDFS.label, lit));
@@ -59,7 +59,7 @@ public class SameAsSmushTest {
     }
 
     @Test
-    public void simple()  {
+    public void simple() {
         SameAsSmusher smusher = new SameAsSmusher() {
 
             @Override
@@ -68,7 +68,7 @@ public class SameAsSmushTest {
                 if (!uriRefs.contains(uriB)) throw new RuntimeException("not the set we excpect");
                 return uriC;
             }
-            
+
         };
         Assert.assertEquals(3, dataGraph.size());
         smusher.smush(dataGraph, sameAsStatements, true);
@@ -87,5 +87,4 @@ public class SameAsSmushTest {
         Assert.assertEquals(litStmt.getSubject(), dataGraph.filter(null, OWL.sameAs, null).next().getObject());
         Assert.assertEquals(knowStmt.getSubject(), uriC);
     }
-
 }
diff --git a/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/EzMGraphTest.scala b/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/EzMGraphTest.scala
new file mode 100644
index 0000000..3b51dfc
--- /dev/null
+++ b/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/EzMGraphTest.scala
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor  license  agreements.  See the NOTICE file distributed
+ * with this work  for  additional  information  regarding  copyright
+ * ownership.  The ASF  licenses  this file to you under  the  Apache
+ * License, Version 2.0 (the "License"); you may not  use  this  file
+ * except in compliance with the License.  You may obtain  a copy  of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless  required  by  applicable law  or  agreed  to  in  writing,
+ * software  distributed  under  the  License  is  distributed  on an
+ * "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR  CONDITIONS  OF ANY KIND,
+ * either  express  or implied.  See  the License  for  the  specific
+ * language governing permissions and limitations under  the License.
+ */
+package org.apache.clerezza.api.scala.utils
+
+import org.apache.clerezza.api._
+import org.apache.clerezza.api.impl._
+import org.apache.clerezza.api.impl.graph.SimpleGraph
+import org.apache.clerezza.api.impl.literal._
+import org.apache.clerezza.api.scala.utils.Preamble._
+import org.apache.clerezza.ontologies._
+import org.junit._
+
+/**
+  * @author bblfish, reto
+  */
+class EzGraphTest {
+
+    val bblfishModulus =
+        """
+    9D ☮ 79 ☮ BF ☮ E2 ☮ F4 ☮ 98 ☮ BC ☮ 79 ☮ 6D ☮ AB ☮ 73 ☮ E2 ☮ 8B ☮ 39 ☮ 4D ☮ B5 26 ✜ 68 ✜ 49 ✜ EE ✜ 71 ✜ 87 ✜
+    06 ✜ 32 ✜ C9 ✜ 9F ✜ 3F ✜ 94 ✜ E5 ✜ CB ✜ 4D ✜ B5 12 ☮ 35 ☮ 13 ☮ 69 ☮ 60 ☮ 81 ☮ 58 ☮ 79 ☮ 66 ☮ F3 ☮ 79 ☮ 20 ☮
+    91 ☮ 6A ☮ 3F ☮ 42 5A ✜ F6 ✜ 54 ✜ 42 ✜ 88 ✜ B2 ✜ E9 ✜ 19 ✜ 4A ✜ 79 ✜ 87 ✜ 2E ✜ 62 ✜ 44 ✜ 2D ✜ 7C 06 ☽ 78 ☽ F8
+    ☽ FD ☽ 52 ☽ 92 ☽ 6D ☽ CD ☽ D6 ☽ F3 ☽ 28 ☽ 6B ☽ 1F ☽ DB ☽ CB ☽ D3 F2 ☮ 08 ☮ 34 ☮ 72 ☮ A2 ☮ 12 ☮ 75 ☮ AE ☮ D1
+    ☮ 09 ☮ 17 ☮ D0 ☮ 88 ☮ 4C ☮ 04 ☮ 8E 04 ☾ E5 ☾ BF ☾ D1 ☾ 41 ☾ 64 ☾ D1 ☾ F7 ☾ 89 ☾ 6D ☾ 8B ☾ B2 ☾ F2 ☾ 46 ☾ C0
+    ☾ 56 87 ☮ 8D ☮ B8 ☮ 7C ☮ C6 ☮ FE ☮ E9 ☮ 61 ☮ 88 ☮ 08 ☮ 61 ☮ DD ☮ E3 ☮ B8 ☮ B5 ☮ 47 ♥
+    """
+
+    /** import some references in order to reduce dependencies */
+
+    final val hex: IRI = new IRI("http://www.w3.org/ns/auth/cert#hex")
+    final val identity: IRI = new IRI("http://www.w3.org/ns/auth/cert#identity")
+    final val RSAPublicKey: IRI = new IRI("http://www.w3.org/ns/auth/rsa#RSAPublicKey")
+    final val modulus: IRI = new IRI("http://www.w3.org/ns/auth/rsa#modulus")
+    final val public_exponent: IRI = new IRI("http://www.w3.org/ns/auth/rsa#public_exponent")
+
+    val henryUri: String = "http://bblfish.net/#hjs"
+    val retoUri: String = "http://farewellutopia.com/reto/#me"
+    val danbriUri: String = "http://danbri.org/foaf.rdf#danbri"
+
+
+    private val tinyGraph: ImmutableGraph = {
+        val gr = new SimpleGraph()
+        val reto = new BlankNode()
+        val danny = new BlankNode()
+        val henry = new IRI(henryUri)
+
+        gr.add(new TripleImpl(reto, RDF.`type`, FOAF.Person))
+        gr.add(new TripleImpl(reto, FOAF.name, new PlainLiteralImpl("Reto Bachman-Gmür", new Language("rm"))))
+        //it is difficult to remember that one needs to put a string literal if one does not want to specify a language
+        gr.add(new TripleImpl(reto, FOAF.title, new TypedLiteralImpl("Mr", XSD.string)))
+        gr.add(new TripleImpl(reto, FOAF.currentProject, new IRI("http://clerezza.org/")))
+        gr.add(new TripleImpl(reto, FOAF.knows, henry))
+        gr.add(new TripleImpl(reto, FOAF.knows, danny))
+
+        gr.add(new TripleImpl(danny, FOAF.name, new PlainLiteralImpl("Danny Ayers", new Language("en"))))
+        gr.add(new TripleImpl(danny, RDF.`type`, FOAF.Person))
+        gr.add(new TripleImpl(danny, FOAF.knows, henry))
+        gr.add(new TripleImpl(danny, FOAF.knows, reto))
+
+        gr.add(new TripleImpl(henry, FOAF.name, new TypedLiteralImpl("Henry Story", XSD.string))) //It is tricky to remember that one needs this for pure strings
+        gr.add(new TripleImpl(henry, FOAF.currentProject, new IRI("http://webid.info/")))
+        gr.add(new TripleImpl(henry, RDF.`type`, FOAF.Person))
+        gr.add(new TripleImpl(henry, FOAF.knows, danny))
+        gr.add(new TripleImpl(henry, FOAF.knows, reto))
+
+        val pk = new BlankNode()
+        gr.add(new TripleImpl(pk, RDF.`type`, RSAPublicKey))
+        gr.add(new TripleImpl(pk, identity, henry))
+        gr.add(new TripleImpl(pk, modulus, LiteralFactory.getInstance().createTypedLiteral(65537)))
+        gr.add(new TripleImpl(pk, public_exponent, new TypedLiteralImpl(bblfishModulus, hex)))
+        gr.getImmutableGraph
+    }
+
+
+    @Test
+    def singleTriple {
+        val expected = {
+            val s = new SimpleGraph
+            s.add(new TripleImpl(henryUri.iri, FOAF.knows, retoUri.iri))
+            s.getImmutableGraph
+        }
+        val ez = new EzGraph() {
+            henryUri.iri -- FOAF.knows --> retoUri.iri
+        }
+        Assert.assertEquals("The two graphs should be equals", expected, ez.getImmutableGraph)
+    }
+
+    @Test
+    def inverseTriple {
+        val expected = {
+            val s = new SimpleGraph
+            s.add(new TripleImpl(retoUri.iri, FOAF.knows, henryUri.iri))
+            s.getImmutableGraph
+        }
+        val ez = new EzGraph() {
+            henryUri.iri <-- FOAF.knows -- retoUri.iri
+        }
+        Assert.assertEquals("The two graphs should be equals", expected, ez.getImmutableGraph)
+    }
+
+    @Test
+    def usingAsciiArrows {
+        val ez = new EzGraph() {
+            (
+                    b_("reto").a(FOAF.Person) -- FOAF.name --> "Reto Bachman-Gmür".lang("rm")
+                            -- FOAF.title --> "Mr"
+                            -- FOAF.currentProject --> "http://clerezza.org/".iri
+                            -- FOAF.knows --> (
+                            "http://bblfish.net/#hjs".iri.a(FOAF.Person)
+                                    -- FOAF.name --> "Henry Story"
+                                    -- FOAF.currentProject --> "http://webid.info/".iri
+                                    -- FOAF.knows -->> List(b_("reto"), b_("danny"))
+                                    //one need to list properties before inverse properties, or use brackets
+                                    <-- identity -- (
+                                    bnode.a(RSAPublicKey) //. notation because of precedence of operators
+                                            -- modulus --> 65537
+                                            -- public_exponent --> (bblfishModulus ^^ hex) // brackets needed due to precedence
+                                    )
+                            )
+                            -- FOAF.knows --> (
+                            b_("danny").a(FOAF.Person)
+                                    -- FOAF.name --> "Danny Ayers".lang("en")
+                                    -- FOAF.knows --> "http://bblfish.net/#hjs".iri //knows
+                                    -- FOAF.knows --> b_("reto")
+                            )
+                    )
+        }
+        Assert.assertEquals("the two graphs should be of same size", tinyGraph.size, ez.size)
+        Assert.assertEquals("Both graphs should contain exactly the same triples", tinyGraph, ez.getImmutableGraph)
+        //We can add triples by creating a new anonymous instance
+        new EzGraph(ez) {
+            (
+                    "http://bblfish.net/#hjs".iri -- FOAF.name --> "William"
+                            -- FOAF.name --> "Bill"
+                    )
+        }
+        Assert.assertEquals("the triple colletion has grown by one", tinyGraph.size() + 2, ez.size)
+        //or by just importing it
+        import ez._
+        ez.b_("danny") -- FOAF.name --> "George"
+        Assert.assertEquals("the triple colletion has grown by one", tinyGraph.size() + 3, ez.size)
+    }
+
+}
diff --git a/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/RichGraphNodeTest.scala b/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/RichGraphNodeTest.scala
new file mode 100644
index 0000000..ab723b1
--- /dev/null
+++ b/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/RichGraphNodeTest.scala
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor  license  agreements.  See the NOTICE file distributed
+ * with this work  for  additional  information  regarding  copyright
+ * ownership.  The ASF  licenses  this file to you under  the  Apache
+ * License, Version 2.0 (the "License"); you may not  use  this  file
+ * except in compliance with the License.  You may obtain  a copy  of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless  required  by  applicable law  or  agreed  to  in  writing,
+ * software  distributed  under  the  License  is  distributed  on an
+ * "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR  CONDITIONS  OF ANY KIND,
+ * either  express  or implied.  See  the License  for  the  specific
+ * language governing permissions and limitations under  the License.
+ */
+package org.apache.clerezza.api.scala.utils
+
+import org.apache.clerezza.api._
+import org.apache.clerezza.api.impl._
+import org.apache.clerezza.api.impl.graph._
+import org.apache.clerezza.api.impl.literal._
+import org.apache.clerezza.api.scala.utils.Preamble._
+import org.apache.clerezza.api.utils._
+import org.apache.clerezza.ontologies._
+import org.junit._
+
+class RichGraphNodeTest {
+
+    private val johnUri = new IRI("http://example.org/john")
+    private val susanneUri = new IRI("http://example.org/susanne")
+    private val listUri = new IRI("http://example.org/list")
+    private val greetingsUri = new IRI("http://example.org/greetings")
+    private val billBlankNode = new BlankNode()
+    private var node: RichGraphNode = null;
+    private var mGraph = new SimpleGraph()
+
+    @Before
+    def prepare() = {
+        mGraph.add(new TripleImpl(johnUri, FOAF.name, new PlainLiteralImpl("John")));
+        mGraph.add(new TripleImpl(johnUri, FOAF.nick, new PlainLiteralImpl("johny")));
+        mGraph.add(new TripleImpl(johnUri, FOAF.name, new PlainLiteralImpl("Johnathan Guller")));
+        mGraph.add(new TripleImpl(johnUri, FOAF.knows, billBlankNode))
+        mGraph.add(new TripleImpl(johnUri, RDF.`type`, FOAF.Person));
+        mGraph.add(new TripleImpl(billBlankNode, FOAF.nick, new PlainLiteralImpl("Bill")));
+        mGraph.add(new TripleImpl(billBlankNode, FOAF.name, new PlainLiteralImpl("William")));
+        mGraph.add(new TripleImpl(billBlankNode, RDF.`type`, FOAF.Person));
+        mGraph.add(new TripleImpl(susanneUri, FOAF.knows, johnUri));
+        mGraph.add(new TripleImpl(susanneUri, FOAF.name, new PlainLiteralImpl("Susanne")));
+        mGraph.add(new TripleImpl(susanneUri, RDF.`type`, FOAF.Person));
+        val rdfList = new RdfList(listUri, mGraph);
+        rdfList.add(johnUri)
+        rdfList.add(new PlainLiteralImpl("foo"))
+        rdfList.add(new PlainLiteralImpl("bar"))
+        mGraph.add(new TripleImpl(johnUri, SKOS04.related, listUri))
+        val litEn = new PlainLiteralImpl("hello",
+            new Language("en"))
+        val litFr = new PlainLiteralImpl("satul",
+            new Language("fr"))
+        mGraph.add(new TripleImpl(greetingsUri, RDF.value, litEn))
+        mGraph.add(new TripleImpl(greetingsUri, RDF.value, litFr))
+        node = new GraphNode(johnUri, mGraph)
+    }
+
+    @Test
+    def testBaseGraph {
+        val preamble = new Preamble(mGraph)
+        import preamble._
+        def asGn(gn: GraphNode) = gn
+
+        val johnUriNode = asGn(johnUri)
+        Assert.assertEquals(johnUriNode, node)
+    }
+
+    @Test
+    def testSlash = {
+        val rNode = new RichGraphNode(node)
+        Assert.assertEquals(new PlainLiteralImpl("johny"), (rNode / FOAF.nick) (0).getNode)
+        Assert.assertEquals(2, (rNode / FOAF.name).length(20))
+        val stringNames = (for (name <- (rNode / FOAF.name).iterator) yield {
+            name.toString
+        }).toList
+        Assert.assertTrue(stringNames.contains("\"Johnathan Guller\""))
+        Assert.assertTrue(stringNames.contains("\"John\""))
+    }
+
+    @Test
+    def testIterate = {
+        val simple: Graph = new SimpleGraph();
+        val node = new GraphNode(new BlankNode(), simple);
+        node.addProperty(DCTERMS.provenance, new IRI("http://example.org/foo"));
+        node.addProperty(DCTERMS.language, new IRI("http://www.bluewin.ch/"));
+        simple.add(new TripleImpl(new IRI("http://www.bluewin.ch/"), RDF.`type`, RDFS.Container));
+        node.addProperty(RDF.`type`, PLATFORM.HeadedPage);
+        node.addProperty(RDF.`type`, RDFS.Class);
+        val test: CollectedIter[RichGraphNode] = node / DCTERMS.language / RDF.`type`;
+        Assert.assertEquals(1, test.length)
+        var counter = 0;
+        for (k <- test) {
+            counter = counter + 1
+        }
+        Assert.assertEquals(1, counter)
+    }
+
+    @Test
+    def testInverse = {
+        val rNode = new RichGraphNode(node)
+        Assert.assertEquals(1, (rNode /- FOAF.knows).length)
+    }
+
+    @Test
+    def testMissingProperty = {
+        val rNode = new RichGraphNode(node)
+        Assert.assertEquals(0, (rNode / FOAF.thumbnail).length)
+        Assert.assertEquals("", rNode / FOAF.thumbnail *)
+
+    }
+
+    @Test
+    def testInverseImplicit = {
+        Assert.assertEquals(1, (node /- FOAF.knows).length)
+    }
+
+    @Test
+    def testPath = {
+        Assert.assertEquals(1, (node /- FOAF.knows).length)
+        Assert.assertEquals(new PlainLiteralImpl("Susanne"), node /- FOAF.knows % 0 / FOAF.name % 0 !)
+        Assert.assertEquals(new PlainLiteralImpl("Susanne"), ((node /- FOAF.knows) (0) / FOAF.name) (0) !)
+        Assert.assertEquals(new PlainLiteralImpl("Susanne"), node /- FOAF.knows / FOAF.name !)
+        Assert.assertEquals(new PlainLiteralImpl("Bill"), node / FOAF.knows / FOAF.nick !)
+        Assert.assertEquals("Bill", (node / FOAF.knows / FOAF.nick) (0) *)
+        Assert.assertEquals("Bill", node / FOAF.knows / FOAF.nick *)
+    }
+
+    @Test
+    def testLists = {
+        Assert.assertEquals(new PlainLiteralImpl("foo"), (node / SKOS04.related).asList().get(1))
+        Assert.assertEquals(new PlainLiteralImpl("foo"), (node / SKOS04.related % 0 !!) (1) !)
+        Assert.assertEquals(new PlainLiteralImpl("foo"),
+            (for (value <- node / SKOS04.related % 0 !!) yield value !).toList(1))
+        Assert.assertEquals(new PlainLiteralImpl("bar"),
+            (for (value <- node / SKOS04.related % 0 !!) yield value !).toList(2))
+        Assert.assertEquals(new PlainLiteralImpl("foo"), node / SKOS04.related % 0 %!! 1 !)
+    }
+
+    @Test
+    def sortProperties = {
+        Assert.assertEquals(new PlainLiteralImpl("bar"), (node / SKOS04.related % 0 !!).sortWith((a, b) => ((a *) < (b *)))(0) !)
+        Assert.assertEquals(johnUri, (node / SKOS04.related % 0 !!).sortWith((a, b) => ((a *) > (b *)))(0) !)
+    }
+
+    @Test
+    def literalAsObject = {
+        val dateLiteral = new TypedLiteralImpl("2009-01-01T01:33:58Z",
+            new IRI("http://www.w3.org/2001/XMLSchema#dateTime"))
+        val node = new GraphNode(dateLiteral, new SimpleGraph())
+        Assert.assertNotNull(node.as[java.util.Date])
+    }
+
+    @Test
+    def literalLanguage = {
+        node = new GraphNode(greetingsUri, mGraph)
+        val lang = new Language("en")
+        val enValue = (node / RDF.value).find(l => (l !).asInstanceOf[Literal].getLanguage == lang).get
+        Assert.assertEquals("hello", enValue *)
+    }
+
+}
diff --git a/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/TypeConversionTest.scala b/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/TypeConversionTest.scala
new file mode 100644
index 0000000..2770926
--- /dev/null
+++ b/api.utils/src/test/scala/org/apache/clerezza/api/scala/utils/TypeConversionTest.scala
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor  license  agreements.  See the NOTICE file distributed
+ * with this work  for  additional  information  regarding  copyright
+ * ownership.  The ASF  licenses  this file to you under  the  Apache
+ * License, Version 2.0 (the "License"); you may not  use  this  file
+ * except in compliance with the License.  You may obtain  a copy  of
+ * the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless  required  by  applicable law  or  agreed  to  in  writing,
+ * software  distributed  under  the  License  is  distributed  on an
+ * "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR  CONDITIONS  OF ANY KIND,
+ * either  express  or implied.  See  the License  for  the  specific
+ * language governing permissions and limitations under  the License.
+ */
+package org.apache.clerezza.api.scala.utils
+
+import org.apache.clerezza.api._
+import org.apache.clerezza.api.impl._
+import org.apache.clerezza.api.impl.literal._
+import org.junit._
+
+class TypeConversionTest {
+
+    private val literalFactory = LiteralFactory.getInstance()
+
+    import Preamble._
+
+    @Test
+    def useStringAsObject {
+        val t = new TripleImpl(new IRI(("http://example.org/subject")), new IRI(("http://example.org/predicate")), "a value")
+        Assert.assertEquals(literalFactory.createTypedLiteral("a value"), t.getObject)
+    }
+
+    /*@Test
+    def useStringWithLanguageTag {
+      val t = new TripleImpl(new IRI(("http://example.org/subject")), new IRI(("http://example.org/predicate")), "a value"("en"))
+      Assert.assertEquals(new PlainLiteralImpl("a value", new Language("en")), t.getObject)
+    }*/
+
+    @Test
+    def useStringWithLanguageTag {
+        val lit = new PlainLiteralImpl("a value", new Language("en"))
+        val t = new TripleImpl(new IRI(("http://example.org/subject")), new IRI(("http://example.org/predicate")), "a value" lang "en")
+        Assert.assertEquals(lit, t.getObject)
+    }
+
+    @Test
+    def useStringWithType {
+        val typeUri = new IRI("http://example.org/dt")
+        val t = new TripleImpl(new IRI(("http://example.org/subject")), new IRI(("http://example.org/predicate")), "a value" ^^ typeUri)
+        Assert.assertEquals(new TypedLiteralImpl("a value", typeUri), t.getObject)
+    }
+
+    @Test
+    def literaToString {
+        val lit = literalFactory.createTypedLiteral("a value")
+        val s: String = lit
+        Assert.assertEquals("a value", s)
+    }
+
+    @Test
+    def dotUri {
+        val t = new TripleImpl(new IRI(("http://example.org/subject")), new IRI(("http://example.org/predicate")), "http://example.org".iri)
+        Assert.assertEquals(new IRI("http://example.org"), t.getObject)
+    }
+
+}