[1113] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
| 2 | // |
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
| 4 | // you may not use this file except in compliance with the License. |
---|
| 5 | // You may obtain a copy of the License at |
---|
| 6 | // |
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 8 | // |
---|
| 9 | // Unless required by applicable law or agreed to in writing, software |
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 12 | // See the License for the specific language governing permissions and |
---|
| 13 | // limitations under the License. |
---|
| 14 | |
---|
[1146] | 15 | package de.ugoe.cs.autoquest.tasktrees.taskequality; |
---|
[439] | 16 | |
---|
| 17 | /** |
---|
[557] | 18 | * <p> |
---|
[1146] | 19 | * A task equality denotes, how equal two tasks are. There are different equality levels |
---|
[557] | 20 | * which are similar to the usual design levels of GUI design. These levels are |
---|
| 21 | * <ul> |
---|
| 22 | * <li>conceptual design: defines the concepts to be edited using a GUI</li> |
---|
| 23 | * <li>semantical design: defines the possible functions for editing the concepts</li> |
---|
| 24 | * <li>syntactical design: defines, which steps are needed to execute the functions</li> |
---|
| 25 | * <li>lexical design: defines on the key stroke level, how the steps for executing a function |
---|
| 26 | * can be performed</li> |
---|
| 27 | * </ul> |
---|
[1146] | 28 | * It is not possible to compare two tasks conceptually. But the other design levels can be |
---|
[557] | 29 | * identified and compared. |
---|
| 30 | * </p> |
---|
| 31 | * <p> |
---|
[1146] | 32 | * Tasks can be identical. This is the case if in the java virtual machine, their comparison |
---|
[557] | 33 | * using the <code>==</code> operator or the equals method return true. |
---|
| 34 | * </p> |
---|
| 35 | * <p> |
---|
[1146] | 36 | * Tasks are lexically equal, if they represent the same events on a key stroke level to be |
---|
| 37 | * carried out to execute the task. Identical tasks are also syntactically equal. |
---|
[557] | 38 | * </p> |
---|
| 39 | * <p> |
---|
| 40 | * Nodes are syntactically equal, if they differ in their events on key stroke level, but the |
---|
| 41 | * syntactical result is the same. For example, entering the text "hello" into a text field can |
---|
| 42 | * be done by entering the letters in their correct order, but also by copying the text into the |
---|
[1146] | 43 | * text field. The syntactical result is the same: The text "hello" was entered. But the tasks |
---|
[557] | 44 | * lexically differ because the events on key stroke level are different. On the other hand, |
---|
[1146] | 45 | * lexically equal tasks are also syntactically equal. |
---|
[557] | 46 | * </p> |
---|
| 47 | * <p> |
---|
[1146] | 48 | * Tasks are semantically equal, if they execute the same function for editing the concepts. An |
---|
| 49 | * example are a click on a button and a short cut, both executing the same function. These tasks |
---|
| 50 | * are syntactically and, therefore, also lexically different, but semantically equal. |
---|
| 51 | * Syntactically equal tasks are always also semantically equal. |
---|
[557] | 52 | * </p> |
---|
[439] | 53 | * |
---|
| 54 | * @version $Revision: $ $Date: 19.02.2012$ |
---|
| 55 | * @author 2012, last modified by $Author: patrick$ |
---|
| 56 | */ |
---|
[1146] | 57 | public enum TaskEquality { |
---|
[557] | 58 | IDENTICAL, |
---|
| 59 | LEXICALLY_EQUAL, |
---|
| 60 | SYNTACTICALLY_EQUAL, |
---|
| 61 | SEMANTICALLY_EQUAL, |
---|
| 62 | UNEQUAL; |
---|
[439] | 63 | |
---|
[557] | 64 | /** |
---|
| 65 | * <p> |
---|
[1146] | 66 | * Checks for the current task equality, if it is at least identical to the |
---|
| 67 | * provided one or even more concrete. As an example, the task equality identical also |
---|
| 68 | * indicates, that the tasks are e.g. lexically, syntactically and semantically equal. |
---|
[557] | 69 | * Therefore, the method called on <code>IDENTICAL</code> with <code>SEMANTICALLY_EQUAL</code> |
---|
| 70 | * as parameter will return true. If this method is called on <code>SYNTACTICALLY_EQUAL</code> |
---|
| 71 | * with the parameter <code>IDENTICAL</code> instead, it returns false; |
---|
| 72 | * </p> |
---|
| 73 | * |
---|
[1146] | 74 | * @param taskEquality the task equality to compare with. |
---|
[557] | 75 | * |
---|
| 76 | * @return as described |
---|
| 77 | */ |
---|
[1146] | 78 | public boolean isAtLeast(TaskEquality taskEquality) |
---|
[557] | 79 | { |
---|
[1146] | 80 | switch (taskEquality) { |
---|
[557] | 81 | case IDENTICAL: |
---|
| 82 | return |
---|
| 83 | (this == IDENTICAL); |
---|
| 84 | case LEXICALLY_EQUAL: |
---|
| 85 | return |
---|
| 86 | (this == IDENTICAL) || |
---|
| 87 | (this == LEXICALLY_EQUAL); |
---|
| 88 | case SYNTACTICALLY_EQUAL: |
---|
| 89 | return |
---|
| 90 | (this == IDENTICAL) || |
---|
| 91 | (this == LEXICALLY_EQUAL) || |
---|
| 92 | (this == SYNTACTICALLY_EQUAL); |
---|
| 93 | case SEMANTICALLY_EQUAL: |
---|
| 94 | return |
---|
| 95 | (this == IDENTICAL) || |
---|
| 96 | (this == LEXICALLY_EQUAL) || |
---|
| 97 | (this == SYNTACTICALLY_EQUAL) || |
---|
| 98 | (this == SEMANTICALLY_EQUAL); |
---|
| 99 | case UNEQUAL: |
---|
| 100 | return |
---|
| 101 | (this == UNEQUAL); |
---|
| 102 | default : |
---|
| 103 | return false; |
---|
| 104 | } |
---|
| 105 | } |
---|
[807] | 106 | |
---|
| 107 | /** |
---|
| 108 | * <p> |
---|
[1146] | 109 | * returns the common denominator of this task equality and the provided one. I.e. if one |
---|
[807] | 110 | * equality is e.g. syntactical and the other one only semantical, then semantical is returned. |
---|
| 111 | * </p> |
---|
| 112 | * |
---|
[1156] | 113 | * @param otherEquality the equality, to compare this with |
---|
[1146] | 114 | * |
---|
| 115 | * @return as described |
---|
[807] | 116 | */ |
---|
[1146] | 117 | public TaskEquality getCommonDenominator(TaskEquality otherEquality) { |
---|
[807] | 118 | if (this.isAtLeast(otherEquality)) { |
---|
| 119 | return otherEquality; |
---|
| 120 | } |
---|
| 121 | else if (otherEquality.isAtLeast(this)) { |
---|
| 122 | return this; |
---|
| 123 | } |
---|
| 124 | else { |
---|
[1146] | 125 | return TaskEquality.UNEQUAL; |
---|
[807] | 126 | } |
---|
| 127 | } |
---|
[439] | 128 | } |
---|