source: trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/nodeequality/NodeEquality.java @ 557

Last change on this file since 557 was 557, checked in by pharms, 12 years ago
  • adapted task tree creation stuff to more general event handling
  • Property svn:executable set to *
File size: 4.1 KB
Line 
1// Module    : $RCSfile: NodeEquality.java,v $
2// Version   : $Revision: 0.0 $  $Author: patrick $  $Date: 19.02.2012 $
3// Project   : TaskTreeCreator
4// Creation  : 2012 by patrick
5// Copyright : Patrick Harms, 2012
6
7package de.ugoe.cs.quest.tasktrees.nodeequality;
8
9/**
10 * <p>
11 * A node equality denotes, how equal two task tree nodes are. There are different equality levels
12 * which are similar to the usual design levels of GUI design. These levels are
13 * <ul>
14 *   <li>conceptual design: defines the concepts to be edited using a GUI</li>
15 *   <li>semantical design: defines the possible functions for editing the concepts</li>
16 *   <li>syntactical design: defines, which steps are needed to execute the functions</li>
17 *   <li>lexical design: defines on the key stroke level, how the steps for executing a function
18 *       can be performed</li>
19 * </ul>
20 * It is not possible to compare two task nodes conceptually. But the other design levels can be
21 * identified and compared.
22 * </p>
23 * <p>
24 * Nodes can be identical. This is the case if in the java virtual machine, their comparison
25 * using the <code>==</code> operator or the equals method return true.
26 * </p>
27 * <p>
28 * Nodes are lexically equal, if they represent the same events on a key stroke level to be
29 * carried out to execute the task. Identical nodes are also syntactically equal.
30 * </p>
31 * <p>
32 * Nodes are syntactically equal, if they differ in their events on key stroke level, but the
33 * syntactical result is the same. For example, entering the text "hello" into a text field can
34 * be done by entering the letters in their correct order, but also by copying the text into the
35 * text field. The syntactical result is the same: The text hello was entered. But the tasks
36 * lexically differ because the events on key stroke level are different. On the other hand,
37 * lexically equal nodes are also syntactically equal. 
38 * </p>
39 * <p>
40 * Task tree nodes are semantically equal, if they execute the same function for editing the
41 * concepts. An example are a click on a button and a short cut, both executing the same function.
42 * These task tree nodes are syntactically and, therefore, also lexically different, but
43 * semantically equal. Syntactically equal task tree nodes are always also semantically equal.
44 * </p>
45 *
46 * @version $Revision: $ $Date: 19.02.2012$
47 * @author 2012, last modified by $Author: patrick$
48 */
49public enum NodeEquality {
50    IDENTICAL,
51    LEXICALLY_EQUAL,
52    SYNTACTICALLY_EQUAL,
53    SEMANTICALLY_EQUAL,
54    UNEQUAL;
55
56    /**
57     * <p>
58     * Checks for the current node equality, if it is at least identical to the
59     * provided one or even more concrete. As an example, the node equality identical also
60     * indicates, that the nodes are e.g. lexically, syntactically and semantically equal.
61     * Therefore, the method called on <code>IDENTICAL</code> with <code>SEMANTICALLY_EQUAL</code>
62     * as parameter will return true. If this method is called on <code>SYNTACTICALLY_EQUAL</code>
63     * with the parameter <code>IDENTICAL</code> instead, it returns false;
64     * </p>
65     *
66     * @param nodeEquality the node equality to compare with.
67     *
68     * @return as described
69     */
70    public boolean isAtLeast(NodeEquality nodeEquality)
71    {
72        switch (nodeEquality) {
73            case IDENTICAL:
74                return
75                    (this == IDENTICAL);
76            case LEXICALLY_EQUAL:
77                return
78                    (this == IDENTICAL) ||
79                    (this == LEXICALLY_EQUAL);
80            case SYNTACTICALLY_EQUAL:
81                return
82                    (this == IDENTICAL) ||
83                    (this == LEXICALLY_EQUAL) ||
84                    (this == SYNTACTICALLY_EQUAL);
85            case SEMANTICALLY_EQUAL:
86                return
87                    (this == IDENTICAL) ||
88                    (this == LEXICALLY_EQUAL) ||
89                    (this == SYNTACTICALLY_EQUAL) ||
90                    (this == SEMANTICALLY_EQUAL);
91            case UNEQUAL:
92                return
93                    (this == UNEQUAL);
94            default :
95                return false;
96        }
97    }
98}
Note: See TracBrowser for help on using the repository browser.