Index: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEqualityRuleManager.java
===================================================================
--- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEqualityRuleManager.java	(revision 1190)
+++ trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEqualityRuleManager.java	(revision 1294)
@@ -19,15 +19,15 @@
 
 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
 
 /**
  * <p>
- * The task equality rule manager is capable of comparing tasks based on its internal list
- * of comparison rules. These rules are asked for comparing the two provided tasks. If a rule
- * returns a task equality other than null, this equality is returned. Otherwise the next rule
- * is asked.
+ * The task equality rule manager is capable of comparing tasks and task instances based on its
+ * internal list of comparison rules. These rules are asked for comparing the two provided tasks or
+ * task instance. If a rule returns a task equality other than null, this equality is returned.
+ * Otherwise the next rule is asked.
  * </p>
  * 
- * @version $Revision: $ $Date: 19.02.2012$
- * @author 2012, last modified by $Author: patrick$
+ * @author Patrick Harms
  */
 public class TaskEqualityRuleManager {
@@ -269,3 +269,207 @@
     }
 
+    /**
+     * <p>
+     * this method performs a comparison of the two provided task instances. It iterates its
+     * internal comparison rules. If the first rule returns a task instance equality other than
+     * null, this equality is returned. Otherwise the next rule is tried. If no rule returns an
+     * equality <code>TaskEquality.UNEQUAL</code> is returned.
+     * </p>
+     * 
+     * @param instance1 the first task instance to be compared
+     * @param instance2 the second task instance to be compared
+     * 
+     * @return as described
+     * 
+     * @throws IllegalStateException in the case, the {@link #init()} method was not called on the
+     *                               manager before a call to this method.
+     */
+    public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2)
+        throws IllegalStateException
+    {
+        if (mRuleIndex == null) {
+            throw new IllegalStateException("not initialized");
+        }
+        
+        // LOG.info("checking for equality of " + instance1 + " and " + instance2);
+        TaskEquality instanceEquality = null;
+
+        for (TaskComparisonRule rule : mRuleIndex) {
+            if (rule.isApplicable(instance1, instance2)) {
+                instanceEquality = rule.compare(instance1, instance2);
+                if (instanceEquality != null) {
+                    // LOG.warning("used rule " + rule + " for equality check");
+                    return instanceEquality;
+                }
+            }
+        }
+
+        // LOG.warning("no rule could be applied --> handling tasks as unequal");
+
+        return TaskEquality.UNEQUAL;
+    }
+
+    /**
+     * <p>
+     * this method compares two task instances with respect to the given equality level and returns
+     * true, if this level is given.
+     * </p>
+     * 
+     * @param instance1     the first task instance to be compared
+     * @param instance2     the second task instance to be compared
+     * @param equalityLevel the level of equality to be checked for
+     * 
+     * @return as described
+     * 
+     * @throws IllegalStateException in the case, the {@link #init()} method was not called on the
+     *                               manager before a call to this method.
+     */
+    public boolean areAtLeastEqual(ITaskInstance        instance1,
+                                   ITaskInstance        instance2,
+                                   TaskEquality equalityLevel)
+    {
+        if (equalityLevel == null) {
+            throw new IllegalArgumentException("required equality level must not be null");
+        }
+        
+        switch (equalityLevel) {
+            case IDENTICAL:
+                return areIdentical(instance1, instance2);
+            case LEXICALLY_EQUAL:
+                return areLexicallyEqual(instance1, instance2);
+            case SYNTACTICALLY_EQUAL:
+                return areSyntacticallyEqual(instance1, instance2);
+            case SEMANTICALLY_EQUAL:
+                return areSemanticallyEqual(instance1, instance2);
+            case UNEQUAL:
+                return !areSemanticallyEqual(instance1, instance2);
+            default:
+                throw new IllegalArgumentException("unknown required equality: " + equalityLevel);
+        }
+    }
+
+    /**
+     * <p>
+     * this method checks if the two given task instances are identical. For this, it iterates its
+     * internal comparison rules. If the first rule returns true, than this method returns true
+     * as well. If no rule returns true, this method returns false.
+     * </p>
+     * 
+     * @param instance1 the first task instance to be compared
+     * @param instance2 the second task instance to be compared
+     * 
+     * @return as described
+     * 
+     * @throws IllegalStateException in the case, the {@link #init()} method was not called on the
+     *                               manager before a call to this method.
+     */
+    public boolean areIdentical(ITaskInstance instance1, ITaskInstance instance2) {
+        if (mRuleIndex == null) {
+            throw new IllegalStateException("not initialized");
+        }
+        
+        for (TaskComparisonRule rule : mRuleIndex) {
+            if (rule.isApplicable(instance1, instance2) &&
+                rule.areLexicallyEqual(instance1, instance2))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * <p>
+     * this method checks if the two given task instances are lexically equal. For this, it
+     * iterates its internal comparison rules. If the first rule returns true, than this method
+     * returns true, as well. If no rule returns true, this method returns false.
+     * </p>
+     * 
+     * @param instance1 the first task instance to be compared
+     * @param instance2 the second task instance to be compared
+     * 
+     * @return as described
+     * 
+     * @throws IllegalStateException in the case, the {@link #init()} method was not called on the
+     *                               manager before a call to this method.
+     */
+    public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) {
+        if (mRuleIndex == null) {
+            throw new IllegalStateException("not initialized");
+        }
+        
+        for (TaskComparisonRule rule : mRuleIndex) {
+            if (rule.isApplicable(instance1, instance2) &&
+                rule.areLexicallyEqual(instance1, instance2))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * <p>
+     * this method checks if the two given task instances are syntactically equal. For this, it
+     * iterates its internal comparison rules. If the first rule returns true, than this method
+     * returns true, as well. If no rule returns true, this method returns false.
+     * </p>
+     * 
+     * @param instance1 the first task instance to be compared
+     * @param instance2 the second task instance to be compared
+     * 
+     * @return as described
+     * 
+     * @throws IllegalStateException in the case, the {@link #init()} method was not called on the
+     *                               manager before a call to this method.
+     */
+    public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) {
+        if (mRuleIndex == null) {
+            throw new IllegalStateException("not initialized");
+        }
+        
+        for (TaskComparisonRule rule : mRuleIndex) {
+            if (rule.isApplicable(instance1, instance2) &&
+                rule.areSyntacticallyEqual(instance1, instance2))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * <p>
+     * this method checks if the two given task instances are semantically equal. For this, it
+     * iterates its internal comparison rules. If the first rule returns true, than this method
+     * returns true, as well. If no rule returns true, this method returns false.
+     * </p>
+     * 
+     * @param instance1 the first task instance to be compared
+     * @param instance2 the second task instance to be compared
+     * 
+     * @return as described
+     * 
+     * @throws IllegalStateException in the case, the {@link #init()} method was not called on the
+     *                               manager before a call to this method.
+     */
+    public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) {
+        if (mRuleIndex == null) {
+            throw new IllegalStateException("not initialized");
+        }
+        
+        for (TaskComparisonRule rule : mRuleIndex) {
+            if (rule.isApplicable(instance1, instance2) &&
+                rule.areSemanticallyEqual(instance1, instance2))
+            {
+                 return true;
+            }
+        }
+
+        return false;
+    }
+
 }
