Changeset 807 for trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/nodeequality/IterationComparisonRule.java
- Timestamp:
- 09/11/12 16:45:51 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-tasktrees/src/main/java/de/ugoe/cs/quest/tasktrees/nodeequality/IterationComparisonRule.java
r655 r807 41 41 * </tr> 42 42 * <tr> 43 * <td>an iteration with a selection of syntactically equal children</td> 44 * <td>an iteration with a selection of syntactically equal children that are all syntactically 45 * equal to the selection of children of iteration 1</td> 46 * <td><code>NodeEquality.SYNTACTICALLY_EQUAL</code></td> 47 * </tr> 48 * <tr> 43 49 * <td>an iteration with a selection of semantically equal children</td> 44 50 * <td>an iteration with a child that is semantically equal to the children of the child 45 51 * selection of iteration 1</td> 52 * <td><code>NodeEquality.SEMANTICALLY_EQUAL</code></td> 53 * </tr> 54 * <tr> 55 * <td>an iteration with a selection of semantically equal children</td> 56 * <td>an iteration with a selection of semantically equal children that are all semantically 57 * equal to the selection of children of iteration 1</td> 46 58 * <td><code>NodeEquality.SEMANTICALLY_EQUAL</code></td> 47 59 * </tr> … … 80 92 } 81 93 94 if (node1 == node2) { 95 return NodeEquality.IDENTICAL; 96 } 97 82 98 // if both iterations do not have children, they are equal although this doesn't make sense 83 99 if ((node1.getChildren().size() == 0) && (node2.getChildren().size() == 0)) { 84 return NodeEquality.IDENTICAL; 100 return NodeEquality.LEXICALLY_EQUAL; 101 } 102 else if ((node1.getChildren().size() == 0) || (node2.getChildren().size() == 0)) { 103 return NodeEquality.UNEQUAL; 85 104 } 86 105 … … 102 121 103 122 if (nodeEquality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)) { 104 return nodeEquality; 123 // prevent, that identical is returned, because the iterations itself are not identical 124 // although the iterated tasks are 125 if (nodeEquality == NodeEquality.IDENTICAL) { 126 return NodeEquality.LEXICALLY_EQUAL; 127 } 128 else { 129 return nodeEquality; 130 } 105 131 } 106 132 … … 115 141 /** 116 142 * <p> 117 * compares two task tree nodes. One of them must be a selection of at least semantically118 * equal children. The other one can be any task tree node. The method returns a node equality119 * that is not <code>NodeEquality.UNEQUAL</code> if the other node is at least semantically120 * equal to the children of the selection. It returns more concrete equalities, if the121 * equality between the other node and the childrenof the selection is more concrete.143 * compares two task tree nodes. One of them must be a selection, the other one can be any task 144 * tree node. The method returns a node equality that is not <code>NodeEquality.UNEQUAL</code> 145 * if the other node is at least semantically equal to the children of the selection. It 146 * returns more concrete equalities, if the equality between the other node and the children 147 * of the selection is more concrete. 122 148 * </p> 123 149 * … … 144 170 } 145 171 146 NodeEquality lessConcreteEqualityForAllComparisons = NodeEquality.IDENTICAL; 172 // Iterations, where one has a selection and the other one not can at most be syntactically 173 // equal but not identical 174 NodeEquality commonDenominatorForAllComparisons = NodeEquality.SYNTACTICALLY_EQUAL; 147 175 148 176 for (ITaskTreeNode child : selection.getChildren()) { 149 177 NodeEquality nodeEquality = mRuleManager.applyRules(node, child); 150 178 151 if (!nodeEquality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)) { 179 if ((nodeEquality == null) || (nodeEquality == NodeEquality.UNEQUAL)) 180 { 152 181 return NodeEquality.UNEQUAL; 153 182 } 154 else if (!lessConcreteEqualityForAllComparisons.isAtLeast(nodeEquality)) {155 lessConcreteEqualityForAllComparisons = nodeEquality;156 }183 184 commonDenominatorForAllComparisons = 185 commonDenominatorForAllComparisons.getCommonDenominator(nodeEquality); 157 186 } 158 187 159 return lessConcreteEqualityForAllComparisons;188 return commonDenominatorForAllComparisons; 160 189 } 161 190
Note: See TracChangeset
for help on using the changeset viewer.