source: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEquality.java @ 1156

Last change on this file since 1156 was 1156, checked in by pharms, 11 years ago
  • improved java doc
  • Property svn:executable set to *
File size: 5.1 KB
Line 
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
15package de.ugoe.cs.autoquest.tasktrees.taskequality;
16
17/**
18 * <p>
19 * A task equality denotes, how equal two tasks are. There are different equality levels
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>
28 * It is not possible to compare two tasks conceptually. But the other design levels can be
29 * identified and compared.
30 * </p>
31 * <p>
32 * Tasks can be identical. This is the case if in the java virtual machine, their comparison
33 * using the <code>==</code> operator or the equals method return true.
34 * </p>
35 * <p>
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.
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
43 * text field. The syntactical result is the same: The text "hello" was entered. But the tasks
44 * lexically differ because the events on key stroke level are different. On the other hand,
45 * lexically equal tasks are also syntactically equal. 
46 * </p>
47 * <p>
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.
52 * </p>
53 *
54 * @version $Revision: $ $Date: 19.02.2012$
55 * @author 2012, last modified by $Author: patrick$
56 */
57public enum TaskEquality {
58    IDENTICAL,
59    LEXICALLY_EQUAL,
60    SYNTACTICALLY_EQUAL,
61    SEMANTICALLY_EQUAL,
62    UNEQUAL;
63
64    /**
65     * <p>
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.
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     *
74     * @param taskEquality the task equality to compare with.
75     *
76     * @return as described
77     */
78    public boolean isAtLeast(TaskEquality taskEquality)
79    {
80        switch (taskEquality) {
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    }
106
107    /**
108     * <p>
109     * returns the common denominator of this task equality and the provided one. I.e. if one
110     * equality is e.g. syntactical and the other one only semantical, then semantical is returned.
111     * </p>
112     *
113     * @param otherEquality the equality, to compare this with
114     *
115     * @return as described
116     */
117    public TaskEquality getCommonDenominator(TaskEquality otherEquality) {
118        if (this.isAtLeast(otherEquality)) {
119            return otherEquality;
120        }
121        else if (otherEquality.isAtLeast(this)) {
122            return this;
123        }
124        else {
125            return TaskEquality.UNEQUAL;
126        }
127    }
128}
Note: See TracBrowser for help on using the repository browser.