Ignore:
Timestamp:
03/18/13 11:46:47 (11 years ago)
Author:
pharms
Message:
  • refactoring of task tree node comparison to be able to optimize the comparisons for the different comparison levels lexically, syntactically, semantically
Location:
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/EventTaskComparisonRule.java

    r1113 r1125  
    2828public class EventTaskComparisonRule implements NodeComparisonRule { 
    2929     
    30     /* 
    31      * (non-Javadoc) 
    32      *  
    33      * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 
     30    /* (non-Javadoc) 
     31     * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
    3432     */ 
    3533    @Override 
    36     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    37         if ((!(node1 instanceof IEventTask)) || (!(node2 instanceof IEventTask))) { 
    38             return null; 
    39         } 
     34    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     35        return (node1 instanceof IEventTask) && (node2 instanceof IEventTask); 
     36    } 
    4037 
    41         if (node1 == node2) { 
    42             return NodeEquality.IDENTICAL; 
    43         } 
    44  
     38    /* (non-Javadoc) 
     39     * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     40     */ 
     41    @Override 
     42    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
    4543        IEventTask task1 = (IEventTask) node1; 
    4644        IEventTask task2 = (IEventTask) node2; 
    4745         
    48         if (task1.getEventType().equals(task2.getEventType()) && 
    49             task1.getEventTarget().equals(task2.getEventTarget())) 
    50         { 
     46        return (task1.getEventType().equals(task2.getEventType()) && 
     47                task1.getEventTarget().equals(task2.getEventTarget())); 
     48    } 
     49 
     50    /* (non-Javadoc) 
     51     * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     52     */ 
     53    @Override 
     54    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     55        return areLexicallyEqual(node1, node2); 
     56    } 
     57 
     58    /* (non-Javadoc) 
     59     * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     60     */ 
     61    @Override 
     62    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     63        return areLexicallyEqual(node1, node2); 
     64    } 
     65 
     66    @Override 
     67    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
     68        if (areLexicallyEqual(node1, node2)) { 
    5169            return NodeEquality.LEXICALLY_EQUAL; 
    5270        } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/GUIEventTaskComparisonRule.java

    r1113 r1125  
    1717import de.ugoe.cs.autoquest.eventcore.IEventTarget; 
    1818import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; 
     19import de.ugoe.cs.autoquest.eventcore.gui.KeyInteraction; 
     20import de.ugoe.cs.autoquest.eventcore.gui.KeyPressed; 
     21import de.ugoe.cs.autoquest.eventcore.gui.KeyReleased; 
     22import de.ugoe.cs.autoquest.eventcore.gui.KeyTyped; 
     23import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonDown; 
     24import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonInteraction; 
     25import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonUp; 
    1926import de.ugoe.cs.autoquest.eventcore.gui.MouseClick; 
    2027import de.ugoe.cs.autoquest.eventcore.gui.MouseDoubleClick; 
    2128import de.ugoe.cs.autoquest.eventcore.gui.MouseDragAndDrop; 
     29import de.ugoe.cs.autoquest.eventcore.gui.Scroll; 
    2230import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 
    2331import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection; 
     
    2735import de.ugoe.cs.autoquest.eventcore.guimodel.IImage; 
    2836import de.ugoe.cs.autoquest.eventcore.guimodel.IListBox; 
     37import de.ugoe.cs.autoquest.eventcore.guimodel.IMenu; 
    2938import de.ugoe.cs.autoquest.eventcore.guimodel.IMenuButton; 
    3039import de.ugoe.cs.autoquest.eventcore.guimodel.IRadioButton; 
     
    5160public class GUIEventTaskComparisonRule implements NodeComparisonRule { 
    5261     
    53     /* 
    54      * (non-Javadoc) 
    55      *  
    56      * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 
     62    /* (non-Javadoc) 
     63     * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     64     */ 
     65    @Override 
     66    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     67        return 
     68            ((node1 instanceof IEventTask) && (node2 instanceof IEventTask) && 
     69            (((IEventTask) node1).getEventType() instanceof IInteraction) && 
     70            (((IEventTask) node2).getEventType() instanceof IInteraction)); 
     71    } 
     72 
     73    /* (non-Javadoc) 
     74     * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     75     */ 
     76    @Override 
     77    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     78        NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
     79        return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     80    } 
     81 
     82    /* (non-Javadoc) 
     83     * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     84     */ 
     85    @Override 
     86    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     87        NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
     88        return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     89    } 
     90 
     91    /* (non-Javadoc) 
     92     * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     93     */ 
     94    @Override 
     95    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     96        NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
     97        return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     98    } 
     99 
     100    /* (non-Javadoc) 
     101     * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
    57102     */ 
    58103    @Override 
    59104    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    60         if ((!(node1 instanceof IEventTask)) || (!(node2 instanceof IEventTask))) { 
    61             return null; 
    62         } 
    63          
     105        return getEquality(node1, node2, null); 
     106    } 
     107 
     108    /** 
     109     *  
     110     */ 
     111    private NodeEquality getEquality(ITaskTreeNode node1, 
     112                                     ITaskTreeNode node2, 
     113                                     NodeEquality  requiredEqualityLevel) 
     114    { 
    64115        IEventTask task1 = (IEventTask) node1; 
    65116        IEventTask task2 = (IEventTask) node2; 
    66117         
    67         if ((!(task1.getEventType() instanceof IInteraction)) || 
    68             (!(task2.getEventType() instanceof IInteraction))) 
    69         { 
    70             return null; 
    71         } 
    72  
    73         if (node1 == node2) { 
    74             return NodeEquality.IDENTICAL; 
    75         } 
    76  
    77118        if (!task1.getEventTarget().equals(task2.getEventTarget())) { 
    78119            return NodeEquality.UNEQUAL; 
     
    82123        IInteraction interaction2 = (IInteraction) task2.getEventType(); 
    83124         
    84         return compareInteractions(interaction1, interaction2, task1.getEventTarget()); 
     125        return compareInteractions 
     126            (interaction1, interaction2, task1.getEventTarget(), requiredEqualityLevel); 
    85127    } 
    86128 
     
    105147    private NodeEquality compareInteractions(IInteraction interaction1, 
    106148                                             IInteraction interaction2, 
    107                                              IEventTarget eventTarget) 
    108     { 
     149                                             IEventTarget eventTarget, 
     150                                             NodeEquality equalityLevel) 
     151    { 
     152        NodeEquality level = equalityLevel; 
     153         
     154        if (level == null) { 
     155            level = NodeEquality.LEXICALLY_EQUAL; 
     156        } 
     157         
    109158        if (interaction1 == interaction2) { 
    110159            return NodeEquality.LEXICALLY_EQUAL; 
    111160        } 
     161        else if ((interaction1 instanceof KeyInteraction) && 
     162                 (interaction2 instanceof KeyInteraction)) 
     163        { 
     164            return compareKeyInteractions 
     165                ((KeyInteraction) interaction1, (KeyInteraction) interaction2, level); 
     166        } 
     167        else if ((interaction1 instanceof MouseButtonInteraction) && 
     168                 (interaction2 instanceof MouseButtonInteraction)) 
     169        { 
     170            return compareMouseButtonInteractions 
     171                ((MouseButtonInteraction) interaction1, (MouseButtonInteraction) interaction2, 
     172                 eventTarget, level); 
     173        } 
     174        else if ((interaction1 instanceof Scroll) && (interaction2 instanceof Scroll)) { 
     175            return compareScrolls((Scroll) interaction1, (Scroll) interaction2, level); 
     176        } 
    112177        else if ((interaction1 instanceof TextInput) && (interaction2 instanceof TextInput)) { 
    113             return compareTextInputs((TextInput) interaction1, (TextInput) interaction2); 
     178            return compareTextInputs 
     179                ((TextInput) interaction1, (TextInput) interaction2, level); 
    114180        } 
    115181        else if ((interaction1 instanceof ValueSelection) && 
     
    117183        { 
    118184            return compareValueSelections 
    119                 ((ValueSelection<?>) interaction1, (ValueSelection<?>) interaction2); 
    120         } 
    121         else if ((interaction1 instanceof MouseClick) && 
    122                  (interaction2 instanceof MouseClick)) 
    123         { 
    124             return compareMouseClicks 
    125                 ((MouseClick) interaction1, (MouseClick) interaction2, eventTarget); 
    126         } 
    127         else if ((interaction1 instanceof MouseDoubleClick) && 
    128                  (interaction2 instanceof MouseDoubleClick)) 
    129         { 
    130             return compareMouseDoubleClicks 
    131                 ((MouseDoubleClick) interaction1, (MouseDoubleClick) interaction2, eventTarget); 
    132         } 
    133         else if ((interaction1 instanceof MouseDragAndDrop) && 
    134                  (interaction2 instanceof MouseDragAndDrop)) 
    135         { 
    136             return compareMouseDragAndDrops 
    137                 ((MouseDragAndDrop) interaction1, (MouseDragAndDrop) interaction2); 
     185                ((ValueSelection<?>) interaction1, (ValueSelection<?>) interaction2, level); 
    138186        } 
    139187        else if (interaction1.equals(interaction2)) { 
     
    143191            return NodeEquality.UNEQUAL; 
    144192        } 
     193    } 
     194 
     195    /** 
     196     * <p> 
     197     * TODO: comment 
     198     * </p> 
     199     * 
     200     * @param interaction1 
     201     * @param interaction2 
     202     * @param eventTarget 
     203     * @param level 
     204     * @return 
     205     */ 
     206    private NodeEquality compareKeyInteractions(KeyInteraction interaction1, 
     207                                                KeyInteraction interaction2, 
     208                                                NodeEquality   equalityLevel) 
     209    { 
     210        if (((interaction1 instanceof KeyPressed) && (interaction2 instanceof KeyPressed)) || 
     211            ((interaction1 instanceof KeyReleased) && (interaction2 instanceof KeyReleased)) || 
     212            ((interaction1 instanceof KeyTyped) && (interaction2 instanceof KeyTyped))) 
     213        { 
     214            if ((equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) && 
     215                (interaction1.getKey() == interaction2.getKey())) 
     216            { 
     217                return NodeEquality.LEXICALLY_EQUAL; 
     218            } 
     219            else { 
     220                return NodeEquality.SEMANTICALLY_EQUAL; 
     221            } 
     222        } 
     223         
     224        return NodeEquality.UNEQUAL; 
     225    } 
     226     
     227    /** 
     228     * <p> 
     229     * compares two mouse drag and drops. If both drag and drops have the same start and end 
     230     * coordinates, they are lexically equal. Otherwise, they are semantically equal. 
     231     * </p> 
     232     * 
     233     * @param interaction1 the first mouse drag and drop to compare 
     234     * @param interaction2 the second mouse drag and drop to compare 
     235     *  
     236     * @return as described 
     237     */ 
     238    private NodeEquality compareMouseDragAndDrops(MouseDragAndDrop interaction1, 
     239                                                  MouseDragAndDrop interaction2, 
     240                                                  NodeEquality     equalityLevel) 
     241    { 
     242        if (interaction1.getButton() != interaction2.getButton()) { 
     243            return NodeEquality.UNEQUAL; 
     244        } 
     245         
     246        if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 
     247            int x1 = interaction1.getX(); 
     248            int x1Start = interaction1.getXStart(); 
     249            int x2 = interaction2.getX(); 
     250            int x2Start = interaction2.getXStart(); 
     251            int y1 = interaction1.getY(); 
     252            int y1Start = interaction1.getYStart(); 
     253            int y2 = interaction2.getY(); 
     254            int y2Start = interaction2.getYStart(); 
     255         
     256            if ((x1Start == x2Start) && (x1 == x2) && (y1Start == y2Start) && (y1 == y2)) { 
     257                return NodeEquality.LEXICALLY_EQUAL; 
     258            } 
     259        } 
     260         
     261        return NodeEquality.SEMANTICALLY_EQUAL; 
     262    } 
     263 
     264    /** 
     265     * <p> 
     266     * compares two mouse button interactions such as clicks, mouse button down, or double clicks. 
     267     * If both interactions have the same coordinates, they are lexically equal. Otherwise, they 
     268     * are semantically equal. Mouse clicks for which the coordinates make no lexical difference 
     269     * (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) are treated as 
     270     * lexically equal. 
     271     * </p> 
     272     * 
     273     * @param interaction1 the first mouse button interaction to compare 
     274     * @param interaction2 the second mouse button interaction to compare 
     275     * @param eventTarget  the event target on which the interactions happened (used within 
     276     *                     special comparisons like mouse clicks on buttons, where the coordinates 
     277     *                     can be ignored) 
     278     *  
     279     * @return as described 
     280     */ 
     281    private NodeEquality compareMouseButtonInteractions(MouseButtonInteraction interaction1, 
     282                                                        MouseButtonInteraction interaction2, 
     283                                                        IEventTarget           eventTarget, 
     284                                                        NodeEquality           equalityLevel) 
     285    { 
     286        boolean coordinatesMatch = true; 
     287         
     288        if ((interaction1 instanceof MouseDragAndDrop) && 
     289            (interaction2 instanceof MouseDragAndDrop)) 
     290        { 
     291            return compareMouseDragAndDrops 
     292                ((MouseDragAndDrop) interaction1, (MouseDragAndDrop) interaction2, equalityLevel); 
     293        } 
     294        else if (interaction1.getButton() != interaction2.getButton()) { 
     295            return NodeEquality.UNEQUAL; 
     296        } 
     297        else if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL) && 
     298                 clickCoordinatesMakeLexicalDifference(eventTarget)) 
     299        { 
     300            int x1 = interaction1.getX(); 
     301            int x2 = interaction2.getX(); 
     302            int y1 = interaction1.getY(); 
     303            int y2 = interaction2.getY(); 
     304 
     305            if ((x1 != x2) || (y1 != y2)) { 
     306                coordinatesMatch = false; 
     307            } 
     308        } 
     309         
     310        // up to now, they can be equal. Now check the types. Do it as last action as these 
     311        // checks take the most time and should, therefore, only be done latest 
     312        if (((interaction1 instanceof MouseClick) && (interaction2 instanceof MouseClick)) || 
     313            ((interaction1 instanceof MouseDoubleClick) && 
     314             (interaction2 instanceof MouseDoubleClick)) || 
     315            ((interaction1 instanceof MouseButtonDown) && 
     316             (interaction2 instanceof MouseButtonDown)) || 
     317            ((interaction1 instanceof MouseButtonUp) && 
     318             (interaction2 instanceof MouseButtonUp))) 
     319        { 
     320            if (coordinatesMatch) { 
     321                return NodeEquality.LEXICALLY_EQUAL; 
     322            } 
     323            else { 
     324                return NodeEquality.SEMANTICALLY_EQUAL; 
     325            } 
     326        } 
     327         
     328        return NodeEquality.UNEQUAL; 
     329    } 
     330 
     331    /** 
     332     * <p> 
     333     * compares two mouse button interactions such as clicks, mouse button down, or double clicks. 
     334     * If both interactions have the same coordinates, they are lexically equal. Otherwise, they 
     335     * are semantically equal. Mouse clicks for which the coordinates make no lexical difference 
     336     * (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) are treated as 
     337     * lexically equal. 
     338     * </p> 
     339     * 
     340     * @param interaction1 the first mouse button interaction to compare 
     341     * @param interaction2 the second mouse button interaction to compare 
     342     * @param eventTarget  the event target on which the interactions happened (used within 
     343     *                     special comparisons like mouse clicks on buttons, where the coordinates 
     344     *                     can be ignored) 
     345     *  
     346     * @return as described 
     347     */ 
     348    private NodeEquality compareScrolls(Scroll       interaction1, 
     349                                        Scroll       interaction2, 
     350                                        NodeEquality equalityLevel) 
     351    { 
     352        if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 
     353            int x1 = interaction1.getXPosition(); 
     354            int x2 = interaction2.getXPosition(); 
     355            int y1 = interaction1.getYPosition(); 
     356            int y2 = interaction2.getYPosition(); 
     357         
     358            if ((x1 == x2) && (y1 == y2)) { 
     359                return NodeEquality.LEXICALLY_EQUAL; 
     360            } 
     361        } 
     362         
     363        return NodeEquality.SEMANTICALLY_EQUAL; 
    145364    } 
    146365 
     
    158377     * @return as described 
    159378     */ 
    160     private NodeEquality compareTextInputs(TextInput interaction1, TextInput interaction2) { 
    161         if (interaction1.getEnteredText().equals(interaction2.getEnteredText())) { 
    162             if (interaction1.getTextInputEvents().equals(interaction2.getTextInputEvents())) { 
    163                 return NodeEquality.LEXICALLY_EQUAL; 
    164             } 
    165             else { 
    166                 return NodeEquality.SYNTACTICALLY_EQUAL; 
    167             } 
    168         } 
    169         else { 
    170             return NodeEquality.SEMANTICALLY_EQUAL; 
     379    private NodeEquality compareTextInputs(TextInput    interaction1, 
     380                                           TextInput    interaction2, 
     381                                           NodeEquality equalityLevel) 
     382    { 
     383        switch (equalityLevel) { 
     384            case LEXICALLY_EQUAL: 
     385                if (interaction1.getTextInputEvents().equals(interaction2.getTextInputEvents())) { 
     386                    return NodeEquality.LEXICALLY_EQUAL; 
     387                } 
     388                // fall through 
     389            case SYNTACTICALLY_EQUAL: 
     390                if (interaction1.getEnteredText().equals(interaction2.getEnteredText())) { 
     391                    return NodeEquality.SYNTACTICALLY_EQUAL; 
     392                } 
     393                // fall through 
     394            case SEMANTICALLY_EQUAL: 
     395                return NodeEquality.SEMANTICALLY_EQUAL; 
     396            default: 
     397                return NodeEquality.UNEQUAL; 
    171398        } 
    172399    } 
     
    185412     */ 
    186413    private NodeEquality compareValueSelections(ValueSelection<?> interaction1, 
    187                                                 ValueSelection<?> interaction2) 
    188     { 
    189         Object value1 = interaction1.getSelectedValue(); 
    190         Object value2 = interaction2.getSelectedValue(); 
    191          
    192         if ((value1 == value2) || ((value1 != null) && (value1.equals(value2)))) { 
    193             return NodeEquality.LEXICALLY_EQUAL; 
    194         } 
    195         else { 
    196             return NodeEquality.SEMANTICALLY_EQUAL; 
    197         } 
    198     } 
    199  
    200     /** 
    201      * <p> 
    202      * compares two mouse clicks. If both clicks have the same coordinates, they are lexically 
    203      * equal. Otherwise, they are semantically equal. Mouse clicks for which the coordinates make 
    204      * no lexical difference (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) 
    205      * are treated as lexically equal. 
    206      * </p> 
    207      * 
    208      * @param interaction1 the first mouse click to compare 
    209      * @param interaction2 the second mouse click to compare 
    210      * @param eventTarget  the event target on which the interactions happened (used within 
    211      *                     special comparisons like mouse clicks on buttons, where the coordinates 
    212      *                     can be ignored) 
    213      *  
    214      * @return as described 
    215      */ 
    216     private NodeEquality compareMouseClicks(MouseClick   interaction1, 
    217                                             MouseClick   interaction2, 
    218                                             IEventTarget eventTarget) 
    219     { 
    220         if (interaction1.getButton() != interaction2.getButton()) { 
    221             return NodeEquality.UNEQUAL; 
    222         } 
    223          
    224         if (!clickCoordinatesMakeLexicalDifference(eventTarget)) { 
    225             return NodeEquality.LEXICALLY_EQUAL; 
    226         } 
    227          
    228         int x1 = interaction1.getX(); 
    229         int x2 = interaction2.getX(); 
    230         int y1 = interaction1.getY(); 
    231         int y2 = interaction2.getY(); 
    232          
    233         if ((x1 == x2) && (y1 == y2)) { 
    234             return NodeEquality.LEXICALLY_EQUAL; 
    235         } 
    236         else { 
    237             return NodeEquality.SEMANTICALLY_EQUAL; 
    238         } 
    239     } 
    240  
    241     /** 
    242      * <p> 
    243      * compares two mouse double clicks. If both double clicks have the same coordinates, they are 
    244      * lexically equal. Otherwise, they are semantically equal. Double clicks for which the 
    245      * coordinates make no lexical difference 
    246      * (see {@link #clickCoordinatesMakeLexicalDifference(IEventTarget)}) are treated as lexically 
    247      * equal. 
    248      * </p> 
    249      * 
    250      * @param interaction1 the first mouse double click to compare 
    251      * @param interaction2 the second mouse double click to compare 
    252      * @param eventTarget  the event target on which the interactions happened (used within 
    253      *                     special comparisons like mouse clicks on buttons, where the coordinates 
    254      *                     can be ignored) 
    255      *  
    256      * @return as described 
    257      */ 
    258     private NodeEquality compareMouseDoubleClicks(MouseDoubleClick interaction1, 
    259                                                   MouseDoubleClick interaction2, 
    260                                                   IEventTarget     eventTarget) 
    261     { 
    262         if (interaction1.getButton() != interaction2.getButton()) { 
    263             return NodeEquality.UNEQUAL; 
    264         } 
    265          
    266         if (!clickCoordinatesMakeLexicalDifference(eventTarget)) { 
    267             return NodeEquality.LEXICALLY_EQUAL; 
    268         } 
    269          
    270         int x1 = interaction1.getX(); 
    271         int x2 = interaction2.getX(); 
    272         int y1 = interaction1.getY(); 
    273         int y2 = interaction2.getY(); 
    274          
    275         if ((x1 == x2) && (y1 == y2)) { 
    276             return NodeEquality.LEXICALLY_EQUAL; 
    277         } 
    278         else { 
    279             return NodeEquality.SEMANTICALLY_EQUAL; 
    280         } 
    281     } 
    282  
    283     /** 
    284      * <p> 
    285      * compares two mouse drag and drops. If both drag and drops have the same start and end 
    286      * coordinates, they are lexically equal. Otherwise, they are semantically equal. 
    287      * </p> 
    288      * 
    289      * @param interaction1 the first mouse drag and drop to compare 
    290      * @param interaction2 the second mouse drag and drop to compare 
    291      *  
    292      * @return as described 
    293      */ 
    294     private NodeEquality compareMouseDragAndDrops(MouseDragAndDrop interaction1, 
    295                                                   MouseDragAndDrop interaction2) 
    296     { 
    297         if (interaction1.getButton() != interaction2.getButton()) { 
    298             return NodeEquality.UNEQUAL; 
    299         } 
    300          
    301         int x1 = interaction1.getX(); 
    302         int x1Start = interaction1.getXStart(); 
    303         int x2 = interaction2.getX(); 
    304         int x2Start = interaction2.getXStart(); 
    305         int y1 = interaction1.getY(); 
    306         int y1Start = interaction1.getYStart(); 
    307         int y2 = interaction2.getY(); 
    308         int y2Start = interaction2.getYStart(); 
    309          
    310         if ((x1Start == x2Start) && (x1 == x2) && (y1Start == y2Start) && (y1 == y2)) { 
    311             return NodeEquality.LEXICALLY_EQUAL; 
    312         } 
    313         else { 
    314             return NodeEquality.SEMANTICALLY_EQUAL; 
    315         } 
     414                                                ValueSelection<?> interaction2, 
     415                                                NodeEquality      equalityLevel) 
     416    { 
     417        if (equalityLevel.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)) { 
     418            Object value1 = interaction1.getSelectedValue(); 
     419            Object value2 = interaction2.getSelectedValue(); 
     420         
     421            if ((value1 == value2) || ((value1 != null) && (value1.equals(value2)))) { 
     422                return NodeEquality.LEXICALLY_EQUAL; 
     423            } 
     424        } 
     425         
     426        return NodeEquality.SEMANTICALLY_EQUAL; 
    316427    } 
    317428 
     
    336447            (eventTarget instanceof IImage) || 
    337448            (eventTarget instanceof IListBox) || 
     449            (eventTarget instanceof IMenu) || 
    338450            (eventTarget instanceof IMenuButton) || 
    339451            (eventTarget instanceof IRadioButton) || 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/IterationComparisonRule.java

    r1113 r1125  
    1515package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
    1616 
     17import java.util.List; 
     18 
     19import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    1720import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
    1821import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
     22import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
    1923import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    2024 
     
    9599    } 
    96100 
    97     /* 
    98      * (non-Javadoc) 
    99      *  
    100      * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 
     101    /* (non-Javadoc) 
     102     * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     103     */ 
     104    @Override 
     105    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     106        return (node1 instanceof IIteration) && (node2 instanceof IIteration); 
     107    } 
     108 
     109    /* (non-Javadoc) 
     110     * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     111     */ 
     112    @Override 
     113    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     114        List<ITaskTreeNode> children1 = node1.getChildren(); 
     115        List<ITaskTreeNode> children2 = node2.getChildren(); 
     116         
     117        if (children1.size() == children2.size()) { 
     118            if (children1.size() == 0) { 
     119                return true; 
     120            } 
     121            else { 
     122                ITaskTreeNode child1 = children1.get(0); 
     123                ITaskTreeNode child2 = children2.get(0); 
     124                 
     125                // iterations may have 3 different structures. 
     126                // 1. they have one child, which is the iterated one 
     127                // 2. they have a sequence of children, which is iterated 
     128                // 3. they have a selection of different iterated variants (usually the variants 
     129                //    are semantically equal) 
     130                // check if the type of children match. If not, return false. If they match, 
     131                // use the equality manager to perform further comparisons 
     132                 
     133                if (((child1 instanceof ISelection) && (child2 instanceof ISelection)) || 
     134                    ((child1 instanceof ISequence) && (child2 instanceof ISequence)) || 
     135                    ((child1 instanceof IEventTask) && (child2 instanceof IEventTask))) 
     136                { 
     137                    return getNodeEquality 
     138                        (child1, child2).isAtLeast(NodeEquality.LEXICALLY_EQUAL); 
     139                } 
     140            } 
     141        } 
     142         
     143        return false; 
     144    } 
     145 
     146    /* (non-Javadoc) 
     147     * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     148     */ 
     149    @Override 
     150    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     151        List<ITaskTreeNode> children1 = node1.getChildren(); 
     152        List<ITaskTreeNode> children2 = node2.getChildren(); 
     153         
     154        if (children1.size() == children2.size()) { 
     155            if (children1.size() == 0) { 
     156                return true; 
     157            } 
     158            else { 
     159                ITaskTreeNode child1 = children1.get(0); 
     160                ITaskTreeNode child2 = children2.get(0); 
     161                 
     162                // iterations may have 3 different structures. 
     163                // 1. they have one child, which is the iterated one 
     164                // 2. they have a sequence of children, which is iterated 
     165                // 3. they have a selection of different iterated variants (usually the variants 
     166                //    are semantically equal) 
     167                // ignore the type of the children but check them for equality. 
     168                 
     169                return getNodeEquality(child1, child2).isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL); 
     170            } 
     171        } 
     172         
     173        return false; 
     174    } 
     175 
     176    /* (non-Javadoc) 
     177     * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     178     */ 
     179    @Override 
     180    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     181        return compare(node1, node2).isAtLeast(NodeEquality.SEMANTICALLY_EQUAL); 
     182    } 
     183 
     184    /* (non-Javadoc) 
     185     * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
    101186     */ 
    102187    @Override 
    103188    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    104         if ((!(node1 instanceof IIteration)) || (!(node2 instanceof IIteration))) { 
    105             return null; 
    106         } 
    107  
    108         if (node1 == node2) { 
    109             return NodeEquality.IDENTICAL; 
    110         } 
     189        List<ITaskTreeNode> children1 = node1.getChildren(); 
     190        List<ITaskTreeNode> children2 = node2.getChildren(); 
    111191 
    112192        // if both iterations do not have children, they are equal although this doesn't make sense 
    113         if ((node1.getChildren().size() == 0) && (node2.getChildren().size() == 0)) { 
     193        if ((children1.size() == 0) && (children2.size() == 0)) { 
    114194            return NodeEquality.LEXICALLY_EQUAL; 
    115195        } 
    116         else if ((node1.getChildren().size() == 0) || (node2.getChildren().size() == 0)) { 
     196        else if ((children1.size() == 0) || (children2.size() == 0)) { 
    117197            return NodeEquality.UNEQUAL; 
    118198        } 
    119199 
    120         ITaskTreeNode child1 = node1.getChildren().get(0); 
    121         ITaskTreeNode child2 = node2.getChildren().get(0); 
     200        ITaskTreeNode child1 = children1.get(0); 
     201        ITaskTreeNode child2 = children2.get(0); 
    122202 
    123203        // iterations may have 3 different structures. 
     
    132212        // This condition matches, if both iterations are the same variants of iteration. I.e. three 
    133213        // combinations of the permutation are handled herewith. 
    134         NodeEquality nodeEquality = mRuleManager.applyRules(child1, child2); 
     214        NodeEquality nodeEquality = getNodeEquality(child1, child2); 
     215         
     216        if (nodeEquality != null) { 
     217            return nodeEquality; 
     218        } 
     219 
     220        // compare one iteration with a single node as a child and another one with a selection of 
     221        // semantically equal nodes 
     222        return selectionChildrenSemanticallyEqualNode(child1, child2); 
     223         
     224        // all other combinations (i.e. sequence with single child and sequence with selection) 
     225        // can not match 
     226    } 
     227 
     228    /** 
     229     * TODO update comment 
     230     */ 
     231    private NodeEquality getNodeEquality(ITaskTreeNode child1, ITaskTreeNode child2) { 
     232        NodeEquality nodeEquality = callRuleManager(child1, child2, null); 
    135233 
    136234        if (nodeEquality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)) { 
     
    144242            } 
    145243        } 
    146  
    147         // compare one iteration with a single node as a child and another one with a selection of 
    148         // semantically equal nodes 
    149         return selectionChildrenSemanticallyEqualNode(child1, child2); 
    150          
    151         // all other combinations (i.e. sequence with single child and sequence with selection) 
    152         // can not match 
     244         
     245        return NodeEquality.UNEQUAL; 
    153246    } 
    154247 
     
    189282 
    190283        for (ITaskTreeNode child : selection.getChildren()) { 
    191             NodeEquality nodeEquality = mRuleManager.applyRules(node, child); 
     284            NodeEquality nodeEquality = 
     285                  callRuleManager(node, child, commonDenominatorForAllComparisons); 
    192286 
    193287            if ((nodeEquality == null) || (nodeEquality == NodeEquality.UNEQUAL)) 
     
    203297    } 
    204298 
     299    /** 
     300     * <p> 
     301     * TODO: comment 
     302     * </p> 
     303     * 
     304     * @param child1 
     305     * @param child2 
     306     * @param requiredEqualityLevel 
     307     * @return 
     308     */ 
     309    private NodeEquality callRuleManager(ITaskTreeNode child1, 
     310                                         ITaskTreeNode child2, 
     311                                         NodeEquality  requiredEqualityLevel) 
     312    { 
     313        if (requiredEqualityLevel == null) { 
     314            return mRuleManager.compare(child1, child2); 
     315        } 
     316        else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 
     317            return requiredEqualityLevel; 
     318        } 
     319        else { 
     320            return NodeEquality.UNEQUAL; 
     321        } 
     322    } 
    205323} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeAndIterationComparisonRule.java

    r1113 r1125  
    1414 
    1515package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     16 
     17import java.util.List; 
    1618 
    1719import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
     
    4850    } 
    4951 
    50     /* 
    51      * (non-Javadoc) 
    52      *  
    53      * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 
     52    /* (non-Javadoc) 
     53     * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     54     */ 
     55    @Override 
     56    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     57        return ((node1 instanceof IIteration) && (!(node2 instanceof IIteration))) || 
     58               ((node2 instanceof IIteration) && (!(node1 instanceof IIteration))); 
     59    } 
     60 
     61    /* (non-Javadoc) 
     62     * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     63     */ 
     64    @Override 
     65    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     66        NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
     67        return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     68    } 
     69 
     70    /* (non-Javadoc) 
     71     * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     72     */ 
     73    @Override 
     74    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     75        NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
     76        return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     77    } 
     78 
     79    /* (non-Javadoc) 
     80     * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     81     */ 
     82    @Override 
     83    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     84        NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
     85        return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     86    } 
     87 
     88    /* (non-Javadoc) 
     89     * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
    5490     */ 
    5591    @Override 
    5692    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
     93        return getEquality(node1, node2, null); 
     94    } 
     95 
     96    /** 
     97     *  
     98     */ 
     99    private NodeEquality getEquality(ITaskTreeNode node1, 
     100                                     ITaskTreeNode node2, 
     101                                     NodeEquality  requiredEqualityLevel) 
     102    { 
    57103        IIteration iteration = null; 
    58104        ITaskTreeNode node = null; 
     
    80126        } 
    81127 
     128        List<ITaskTreeNode> children = iteration.getChildren(); 
     129         
    82130        // now, that we found the iteration and the node, lets compare the child of the iteration 
    83131        // with the node. 
    84         if (iteration.getChildren().size() < 1) { 
     132        if (children.size() < 1) { 
    85133            return null; 
    86134        } 
    87135 
    88         NodeEquality nodeEquality = mRuleManager.applyRules(iteration.getChildren().get(0), node); 
     136        NodeEquality nodeEquality = callRuleManager(children.get(0), node, requiredEqualityLevel); 
    89137 
    90138        // although the subtask may be identical to the node, we can not return identical, as 
     
    98146 
    99147    } 
     148     
     149    /** 
     150     * <p> 
     151     * TODO: comment 
     152     * </p> 
     153     * 
     154     * @param child1 
     155     * @param child2 
     156     * @param requiredEqualityLevel 
     157     * @return 
     158     */ 
     159    private NodeEquality callRuleManager(ITaskTreeNode child1, 
     160                                         ITaskTreeNode child2, 
     161                                         NodeEquality  requiredEqualityLevel) 
     162    { 
     163        if (requiredEqualityLevel == null) { 
     164            return mRuleManager.compare(child1, child2); 
     165        } 
     166        else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 
     167            return requiredEqualityLevel; 
     168        } 
     169        else { 
     170            return NodeEquality.UNEQUAL; 
     171        } 
     172    } 
    100173} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeAndSelectionComparisonRule.java

    r1113 r1125  
    1414 
    1515package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     16 
     17import java.util.List; 
    1618 
    1719import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
     
    3335    /** the rule manager for internally comparing task tree nodes */ 
    3436    private NodeEqualityRuleManager mRuleManager; 
    35  
     37     
    3638    /** 
    3739     * <p> 
     
    4749    } 
    4850 
    49     /* 
    50      * (non-Javadoc) 
    51      *  
    52      * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 
     51    /* (non-Javadoc) 
     52     * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     53     */ 
     54    @Override 
     55    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     56        return ((node1 instanceof ISelection) && (!(node2 instanceof ISelection))) || 
     57               ((node2 instanceof ISelection) && (!(node1 instanceof ISelection))); 
     58    } 
     59 
     60    /* (non-Javadoc) 
     61     * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     62     */ 
     63    @Override 
     64    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     65        NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
     66        return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     67    } 
     68 
     69    /* (non-Javadoc) 
     70     * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     71     */ 
     72    @Override 
     73    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     74        NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
     75        return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     76    } 
     77 
     78    /* (non-Javadoc) 
     79     * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     80     */ 
     81    @Override 
     82    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     83        NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
     84        return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     85    } 
     86 
     87    /* (non-Javadoc) 
     88     * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
    5389     */ 
    5490    @Override 
    5591    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
     92        return getEquality(node1, node2, null); 
     93    } 
     94     
     95    /** 
     96     *  
     97     */ 
     98    private NodeEquality getEquality(ITaskTreeNode node1, 
     99                                     ITaskTreeNode node2, 
     100                                     NodeEquality  requiredEqualityLevel) 
     101    { 
    56102        ISelection selection = null; 
    57103        ITaskTreeNode node = null; 
     
    59105        if (node1 instanceof ISelection) { 
    60106            if (node2 instanceof ISelection) { 
    61                 // the rule is not responsible for two iterations 
     107                // the rule is not responsible for two selections 
    62108                return null; 
    63109            } 
     
    68114        else if (node2 instanceof ISelection) { 
    69115            if (node1 instanceof ISelection) { 
    70                 // the rule is not responsible for two iterations 
     116                // the rule is not responsible for two selections 
    71117                return null; 
    72118            } 
     
    79125        } 
    80126 
    81         // now, that we found the iteration and the node, lets compare the child of the iteration 
     127        // now, that we found the selection and the node, lets compare the children of the selection 
    82128        // with the node. 
    83         if (selection.getChildren().size() < 1) { 
     129        List<ITaskTreeNode> children = selection.getChildren(); 
     130         
     131        if (children.size() < 1) { 
    84132            return null; 
    85133        } 
     
    87135        NodeEquality mostConcreteNodeEquality = null; 
    88136         
    89         for (ITaskTreeNode child : selection.getChildren()) { 
    90             NodeEquality nodeEquality = mRuleManager.applyRules(child, node); 
     137        for (ITaskTreeNode child : children) { 
     138            NodeEquality nodeEquality = callRuleManager(child, node, requiredEqualityLevel); 
    91139             
    92140            if (nodeEquality != NodeEquality.UNEQUAL) { 
     
    94142                    mostConcreteNodeEquality = nodeEquality; 
    95143                } 
    96                 else { 
    97                     mostConcreteNodeEquality = 
    98                         mostConcreteNodeEquality.getCommonDenominator(nodeEquality); 
     144                else if (mostConcreteNodeEquality.isAtLeast(nodeEquality)) { 
     145                    mostConcreteNodeEquality = nodeEquality; 
     146                     
     147                } 
     148                 
     149                if ((requiredEqualityLevel != null) && 
     150                    (mostConcreteNodeEquality.isAtLeast(requiredEqualityLevel))) 
     151                { 
     152                    // if we found one child of the selection that is as equal as required, then 
     153                    // we can consider the selection to be sufficiently equal to the other node. 
     154                    // So we break up checking further children. 
     155                    break; 
    99156                } 
    100157            } 
     
    111168 
    112169    } 
     170     
     171    /** 
     172     * <p> 
     173     * TODO: comment 
     174     * </p> 
     175     * 
     176     * @param child1 
     177     * @param child2 
     178     * @param requiredEqualityLevel 
     179     * @return 
     180     */ 
     181    private NodeEquality callRuleManager(ITaskTreeNode child1, 
     182                                         ITaskTreeNode child2, 
     183                                         NodeEquality  requiredEqualityLevel) 
     184    { 
     185        if (requiredEqualityLevel == null) { 
     186            return mRuleManager.compare(child1, child2); 
     187        } 
     188        else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 
     189            return requiredEqualityLevel; 
     190        } 
     191        else { 
     192            return NodeEquality.UNEQUAL; 
     193        } 
     194    } 
    113195} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeComparisonRule.java

    r1113 r1125  
    3030    /** 
    3131     * <p> 
     32     * checks if the rule is applicable for comparing the two provided nodes 
     33     * </p> 
     34     *  
     35     * @param node1 the first task tree node to compare 
     36     * @param node2 the second task tree node to compare 
     37     *  
     38     * @return true, if the rule is applicable, false else 
     39     */ 
     40    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2); 
     41 
     42    /** 
     43     * <p> 
     44     * checks, if the provided nodes are lexically equal 
     45     * </p> 
     46     *  
     47     * @param node1 the first task tree node to compare 
     48     * @param node2 the second task tree node to compare 
     49     *  
     50     * @return true, if the nodes are equal, false else 
     51     */ 
     52    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 
     53 
     54    /** 
     55     * <p> 
     56     * checks, if the provided nodes are syntactically equal 
     57     * </p> 
     58     *  
     59     * @param node1 the first task tree node to compare 
     60     * @param node2 the second task tree node to compare 
     61     *  
     62     * @return true, if the nodes are equal, false else 
     63     */ 
     64    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 
     65 
     66    /** 
     67     * <p> 
     68     * checks, if the provided nodes are semantically equal 
     69     * </p> 
     70     *  
     71     * @param node1 the first task tree node to compare 
     72     * @param node2 the second task tree node to compare 
     73     *  
     74     * @return true, if the nodes are equal, false else 
     75     */ 
     76    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2); 
     77 
     78    /** 
     79     * <p> 
    3280     * compares two nodes with each other. The result of the method is either a node equality or 
    3381     * null. If it is null, it means, that the rule is not able to correctly compare the two given 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeEqualityRuleManager.java

    r1113 r1125  
    7272     *                               manager before a call to this method. 
    7373     */ 
    74     public NodeEquality applyRules(ITaskTreeNode node1, ITaskTreeNode node2) 
     74    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) 
    7575        throws IllegalStateException 
    7676    { 
     
    8383 
    8484        for (NodeComparisonRule rule : mRuleIndex) { 
    85             nodeEquality = rule.compare(node1, node2); 
    86  
    87             if (nodeEquality != null) { 
    88                 // LOG.warning("used rule " + rule + " for equality check"); 
    89                 return nodeEquality; 
     85            if (rule.isApplicable(node1, node2)) { 
     86                nodeEquality = rule.compare(node1, node2); 
     87                if (nodeEquality != null) { 
     88                    // LOG.warning("used rule " + rule + " for equality check"); 
     89                    return nodeEquality; 
     90                } 
    9091            } 
    9192        } 
     
    9697    } 
    9798 
     99    /** 
     100     * <p> 
     101     * TODO: comment 
     102     * </p> 
     103     * 
     104     * @param child1 
     105     * @param child2 
     106     * @param equalityLevel 
     107     * @return 
     108     */ 
     109    public boolean areAtLeastEqual(ITaskTreeNode node1, 
     110                                   ITaskTreeNode node2, 
     111                                   NodeEquality  equalityLevel) 
     112    { 
     113        if (equalityLevel == null) { 
     114            throw new IllegalArgumentException("required equality level must not be null"); 
     115        } 
     116         
     117        switch (equalityLevel) { 
     118            case IDENTICAL: 
     119                return areIdentical(node1, node2); 
     120            case LEXICALLY_EQUAL: 
     121                return areLexicallyEqual(node1, node2); 
     122            case SYNTACTICALLY_EQUAL: 
     123                return areSyntacticallyEqual(node1, node2); 
     124            case SEMANTICALLY_EQUAL: 
     125                return areSemanticallyEqual(node1, node2); 
     126            case UNEQUAL: 
     127                return !areSemanticallyEqual(node1, node2); 
     128            default: 
     129                throw new IllegalArgumentException("unknown required equality: " + equalityLevel); 
     130        } 
     131    } 
     132 
     133    /** 
     134     * <p> 
     135     * TODO: comment 
     136     * </p> 
     137     * 
     138     * @param child1 
     139     * @param child2 
     140     * @return 
     141     */ 
     142    public boolean areIdentical(ITaskTreeNode node1, ITaskTreeNode node2) { 
     143        if (mRuleIndex == null) { 
     144            throw new IllegalStateException("not initialized"); 
     145        } 
     146         
     147        for (NodeComparisonRule rule : mRuleIndex) { 
     148            if (rule.isApplicable(node1, node2) && rule.areLexicallyEqual(node1, node2)) { 
     149                 return true; 
     150            } 
     151        } 
     152 
     153        return false; 
     154    } 
     155 
     156    /** 
     157     * <p> 
     158     * TODO: comment 
     159     * </p> 
     160     * 
     161     * @param child1 
     162     * @param child2 
     163     * @return 
     164     */ 
     165    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     166        if (mRuleIndex == null) { 
     167            throw new IllegalStateException("not initialized"); 
     168        } 
     169         
     170        for (NodeComparisonRule rule : mRuleIndex) { 
     171            if (rule.isApplicable(node1, node2) && rule.areLexicallyEqual(node1, node2)) { 
     172                 return true; 
     173            } 
     174        } 
     175 
     176        return false; 
     177    } 
     178 
     179    /** 
     180     * <p> 
     181     * TODO: comment 
     182     * </p> 
     183     * 
     184     * @param child1 
     185     * @param child2 
     186     * @return 
     187     */ 
     188    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     189        if (mRuleIndex == null) { 
     190            throw new IllegalStateException("not initialized"); 
     191        } 
     192         
     193        for (NodeComparisonRule rule : mRuleIndex) { 
     194            if (rule.isApplicable(node1, node2) && rule.areSyntacticallyEqual(node1, node2)) { 
     195                 return true; 
     196            } 
     197        } 
     198 
     199        return false; 
     200    } 
     201 
     202    /** 
     203     * <p> 
     204     * TODO: comment 
     205     * </p> 
     206     * 
     207     * @param child1 
     208     * @param child2 
     209     * @return 
     210     */ 
     211    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     212        if (mRuleIndex == null) { 
     213            throw new IllegalStateException("not initialized"); 
     214        } 
     215         
     216        for (NodeComparisonRule rule : mRuleIndex) { 
     217            if (rule.isApplicable(node1, node2) && rule.areSemanticallyEqual(node1, node2)) { 
     218                 return true; 
     219            } 
     220        } 
     221 
     222        return false; 
     223    } 
     224 
    98225} 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/NodeIdentityRule.java

    r1113 r1125  
    2929public class NodeIdentityRule implements NodeComparisonRule { 
    3030 
    31     /* 
    32      * (non-Javadoc) 
    33      *  
    34      * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 
     31    /* (non-Javadoc) 
     32     * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     33     */ 
     34    @Override 
     35    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     36        return (node1 == node2); 
     37    } 
     38 
     39    /* (non-Javadoc) 
     40     * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     41     */ 
     42    @Override 
     43    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     44        return (node1 == node2); 
     45    } 
     46 
     47    /* (non-Javadoc) 
     48     * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     49     */ 
     50    @Override 
     51    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     52        return (node1 == node2); 
     53    } 
     54 
     55    /* (non-Javadoc) 
     56     * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     57     */ 
     58    @Override 
     59    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     60        return (node1 == node2); 
     61    } 
     62 
     63    /* (non-Javadoc) 
     64     * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
    3565     */ 
    3666    @Override 
    3767    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    38         if (node1 == node2) { 
     68        if (isApplicable(node1, node2)) { 
    3969            return NodeEquality.IDENTICAL; 
    4070        } 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/SelectionComparisonRule.java

    r1113 r1125  
    1414 
    1515package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     16 
     17import java.util.List; 
    1618 
    1719import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
     
    5153    } 
    5254 
    53     /* 
    54      * (non-Javadoc) 
     55    /* (non-Javadoc) 
     56     * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     57     */ 
     58    @Override 
     59    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     60        return (node1 instanceof ISelection) && (node2 instanceof ISelection); 
     61    } 
     62 
     63    /* (non-Javadoc) 
     64     * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     65     */ 
     66    @Override 
     67    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     68        NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
     69        return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     70    } 
     71 
     72    /* (non-Javadoc) 
     73     * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     74     */ 
     75    @Override 
     76    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     77        NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
     78        return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     79    } 
     80 
     81    /* (non-Javadoc) 
     82     * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     83     */ 
     84    @Override 
     85    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     86        NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
     87        return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     88    } 
     89 
     90    /* (non-Javadoc) 
     91     * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
     92     */ 
     93    @Override 
     94    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
     95        return getEquality(node1, node2, null); 
     96    } 
     97 
     98    /** 
    5599     *  
    56      * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 
    57      */ 
    58     @Override 
    59     public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    60         if ((!(node1 instanceof ISelection)) || (!(node2 instanceof ISelection))) { 
    61             return null; 
    62         } 
    63  
    64         if (node1 == node2) { 
    65             return NodeEquality.IDENTICAL; 
    66         } 
    67  
    68         // if both sequences do not have children, they are identical. If only one of them has 
    69         // children, they are unequal. 
    70         if ((node1.getChildren().size() == 0) && (node2.getChildren().size() == 0)) { 
     100     */ 
     101    private NodeEquality getEquality(ITaskTreeNode node1, 
     102                                     ITaskTreeNode node2, 
     103                                     NodeEquality  requiredEqualityLevel) 
     104    { 
     105        List<ITaskTreeNode> children1 = node1.getChildren(); 
     106        List<ITaskTreeNode> children2 = node2.getChildren(); 
     107 
     108        // if both selections do not have children, they are lexically equal. If only one of them 
     109        // has children, they are unequal. 
     110        if ((children1.size() == 0) && (children2.size() == 0)) { 
    71111            return NodeEquality.LEXICALLY_EQUAL; 
    72112        } 
    73         else if ((node1.getChildren().size() == 0) || (node2.getChildren().size() == 0)) { 
     113        else if ((children1.size() == 0) || (children2.size() == 0)) { 
    74114            return NodeEquality.UNEQUAL; 
    75115        } 
    76116 
    77         NodeEquality selectionEquality = NodeEquality.LEXICALLY_EQUAL; 
    78  
    79         // compare each child of selection one with each child of selection two 
     117        NodeEquality selectionEquality; 
     118 
     119        if (requiredEqualityLevel == null) { 
     120            // calculate the common equality level for all children of both selections. 
     121            // do it in both directions to ensure commutative comparison 
     122            selectionEquality = getCommonEqualityLevel(children1, children2); 
     123            if (selectionEquality != NodeEquality.UNEQUAL) { 
     124                return selectionEquality.getCommonDenominator 
     125                    (getCommonEqualityLevel(children2, children1)); 
     126            } 
     127            else { 
     128                return NodeEquality.UNEQUAL; 
     129            } 
     130        } 
     131        else { 
     132            // we are searching for a specific equality 
     133            if (checkEqualityLevel(children1, children2, requiredEqualityLevel) && 
     134                checkEqualityLevel(children2, children1, requiredEqualityLevel)) 
     135            { 
     136                return requiredEqualityLevel; 
     137            } 
     138            else { 
     139                return NodeEquality.UNEQUAL; 
     140            } 
     141        } 
     142    } 
     143 
     144    /** 
     145     * <p> 
     146     * TODO: comment 
     147     * </p> 
     148     * 
     149     * @param children1 
     150     * @param children2 
     151     * @param requiredEqualityLevel 
     152     */ 
     153    private NodeEquality getCommonEqualityLevel(List<ITaskTreeNode> children1, 
     154                                                List<ITaskTreeNode> children2) 
     155    { 
     156        NodeEquality listEquality = NodeEquality.LEXICALLY_EQUAL; 
     157         
    80158        NodeEquality childEquality; 
    81159        NodeEquality currentEquality; 
    82         for (ITaskTreeNode child1 : node1.getChildren()) { 
     160        for (ITaskTreeNode child1 : children1) { 
    83161            childEquality = null; 
    84             for (ITaskTreeNode child2 : node2.getChildren()) { 
    85                 currentEquality = mRuleManager.applyRules(child1, child2); 
     162            for (ITaskTreeNode child2 : children2) { 
     163                currentEquality = callRuleManager(child1, child2, null); 
    86164                if ((currentEquality != null) && (currentEquality != NodeEquality.UNEQUAL)) { 
    87165                    if (childEquality == null) { 
     
    91169                        childEquality = childEquality.getCommonDenominator(currentEquality); 
    92170                    } 
    93                 } 
    94             } 
    95              
    96             if (childEquality != null) { 
    97                 selectionEquality = selectionEquality.getCommonDenominator(childEquality); 
    98             } 
    99             else { 
    100                 return NodeEquality.UNEQUAL; 
    101             } 
    102         } 
    103  
    104         // compare each child of selection two with each child of selection one 
    105         for (ITaskTreeNode child2 : node2.getChildren()) { 
    106             childEquality = null; 
    107             for (ITaskTreeNode child1 : node1.getChildren()) { 
    108                 currentEquality = mRuleManager.applyRules(child1, child2); 
    109                 if ((currentEquality != null) && (currentEquality != NodeEquality.UNEQUAL)) { 
    110                     if (childEquality == null) { 
    111                         childEquality = currentEquality; 
    112                     } 
    113                     else { 
    114                         childEquality = childEquality.getCommonDenominator(currentEquality); 
     171                     
     172                    if (childEquality == NodeEquality.SEMANTICALLY_EQUAL) { 
     173                        // as we calculate only the common denominator, we can break up here for 
     174                        // the current child. We will not improve the denominator anymore 
     175                        break; 
    115176                    } 
    116177                } 
    117178            } 
    118179             
    119             if (childEquality != null) { 
    120                 selectionEquality = selectionEquality.getCommonDenominator(childEquality); 
     180            if (childEquality == null) { 
     181                // we did not find any child in the second list, that is equal to the searched 
     182                // child 
     183                return NodeEquality.UNEQUAL; 
    121184            } 
    122185            else { 
    123                 return NodeEquality.UNEQUAL; 
    124             } 
    125         } 
    126  
    127         return selectionEquality; 
     186                listEquality = listEquality.getCommonDenominator(childEquality); 
     187            } 
     188        } 
     189 
     190        return listEquality; 
     191    } 
     192 
     193    /** 
     194     * <p> 
     195     * TODO: comment 
     196     * </p> 
     197     * 
     198     * @param children1 
     199     * @param children2 
     200     * @param requiredEqualityLevel 
     201     */ 
     202    private boolean checkEqualityLevel(List<ITaskTreeNode> children1, 
     203                                       List<ITaskTreeNode> children2, 
     204                                       NodeEquality        requiredEqualityLevel) 
     205    { 
     206        NodeEquality childEquality; 
     207        NodeEquality currentEquality; 
     208        for (ITaskTreeNode child1 : children1) { 
     209            childEquality = null; 
     210            for (ITaskTreeNode child2 : children2) { 
     211                currentEquality = callRuleManager(child1, child2, requiredEqualityLevel); 
     212                if ((currentEquality != null) && (currentEquality.isAtLeast(requiredEqualityLevel))) 
     213                { 
     214                    // we found at least one equal child with sufficient equality in the 
     215                    // second list. So be can break up for this child. 
     216                    childEquality = currentEquality; 
     217                    break; 
     218                } 
     219            } 
     220             
     221            if (childEquality == null) { 
     222                // we did not find any child in the second list, that is equal to the searched 
     223                // child 
     224                return false; 
     225            } 
     226        } 
     227 
     228        // for all children, we found an equality  
     229        return true; 
     230    } 
     231 
     232    /** 
     233     * <p> 
     234     * TODO: comment 
     235     * </p> 
     236     * 
     237     * @param child1 
     238     * @param child2 
     239     * @param requiredEqualityLevel 
     240     * @return 
     241     */ 
     242    private NodeEquality callRuleManager(ITaskTreeNode child1, 
     243                                         ITaskTreeNode child2, 
     244                                         NodeEquality  requiredEqualityLevel) 
     245    { 
     246        if (requiredEqualityLevel == null) { 
     247            return mRuleManager.compare(child1, child2); 
     248        } 
     249        else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 
     250            return requiredEqualityLevel; 
     251        } 
     252        else { 
     253            return NodeEquality.UNEQUAL; 
     254        } 
    128255    } 
    129256 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/SequenceComparisonRule.java

    r1113 r1125  
    1414 
    1515package de.ugoe.cs.autoquest.tasktrees.nodeequality; 
     16 
     17import java.util.List; 
    1618 
    1719import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
     
    4749    } 
    4850 
    49     /* 
    50      * (non-Javadoc) 
    51      *  
    52      * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) 
     51    /* (non-Javadoc) 
     52     * @see NodeComparisonRule#isApplicable(ITaskTreeNode, ITaskTreeNode) 
     53     */ 
     54    @Override 
     55    public boolean isApplicable(ITaskTreeNode node1, ITaskTreeNode node2) { 
     56        return (node1 instanceof ISequence) && (node2 instanceof ISequence); 
     57    } 
     58 
     59    /* (non-Javadoc) 
     60     * @see NodeComparisonRule#areLexicallyEqual(ITaskTreeNode, ITaskTreeNode) 
     61     */ 
     62    @Override 
     63    public boolean areLexicallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     64        NodeEquality equality = getEquality(node1, node2, NodeEquality.LEXICALLY_EQUAL); 
     65        return (equality != null) && (equality.isAtLeast(NodeEquality.LEXICALLY_EQUAL)); 
     66    } 
     67 
     68    /* (non-Javadoc) 
     69     * @see NodeComparisonRule#areSyntacticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     70     */ 
     71    @Override 
     72    public boolean areSyntacticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     73        NodeEquality equality = getEquality(node1, node2, NodeEquality.SYNTACTICALLY_EQUAL); 
     74        return (equality != null) && (equality.isAtLeast(NodeEquality.SYNTACTICALLY_EQUAL)); 
     75    } 
     76 
     77    /* (non-Javadoc) 
     78     * @see NodeComparisonRule#areSemanticallyEqual(ITaskTreeNode, ITaskTreeNode) 
     79     */ 
     80    @Override 
     81    public boolean areSemanticallyEqual(ITaskTreeNode node1, ITaskTreeNode node2) { 
     82        NodeEquality equality = getEquality(node1, node2, NodeEquality.SEMANTICALLY_EQUAL); 
     83        return (equality != null) && (equality.isAtLeast(NodeEquality.SEMANTICALLY_EQUAL)); 
     84    } 
     85 
     86    /* (non-Javadoc) 
     87     * @see NodeComparisonRule#compare(ITaskTreeNode, ITaskTreeNode) 
    5388     */ 
    5489    @Override 
    5590    public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { 
    56         if ((!(node1 instanceof ISequence)) || (!(node2 instanceof ISequence))) { 
    57             return null; 
    58         } 
     91        return getEquality(node1, node2, null); 
     92    } 
    5993 
    60         if (node1 == node2) { 
    61             return NodeEquality.IDENTICAL; 
    62         } 
     94    /** 
     95     *  
     96     */ 
     97    private NodeEquality getEquality(ITaskTreeNode node1, 
     98                                     ITaskTreeNode node2, 
     99                                     NodeEquality  requiredEqualityLevel) 
     100    { 
     101        List<ITaskTreeNode> children1 = node1.getChildren(); 
     102        List<ITaskTreeNode> children2 = node2.getChildren(); 
    63103 
    64104        // if both sequences do not have children, they are equal although this doesn't make sense 
    65         if ((node1.getChildren().size() == 0) && (node2.getChildren().size() == 0)) { 
     105        if ((children1.size() == 0) && (children2.size() == 0)) { 
    66106            return NodeEquality.LEXICALLY_EQUAL; 
    67107        } 
    68108 
    69         if (node1.getChildren().size() != node2.getChildren().size()) { 
     109        if (children1.size() != children2.size()) { 
    70110            return NodeEquality.UNEQUAL; 
    71111        } 
    72112 
    73113        NodeEquality resultingEquality = NodeEquality.LEXICALLY_EQUAL; 
    74         for (int i = 0; i < node1.getChildren().size(); i++) { 
    75             ITaskTreeNode child1 = node1.getChildren().get(i); 
    76             ITaskTreeNode child2 = node2.getChildren().get(i); 
     114        for (int i = 0; i < children1.size(); i++) { 
     115            ITaskTreeNode child1 = children1.get(i); 
     116            ITaskTreeNode child2 = children2.get(i); 
    77117 
    78             NodeEquality nodeEquality = mRuleManager.applyRules(child1, child2); 
     118            NodeEquality nodeEquality = callRuleManager(child1, child2, requiredEqualityLevel); 
    79119 
    80120            if ((nodeEquality == null) || (nodeEquality == NodeEquality.UNEQUAL)) { 
     
    88128    } 
    89129 
     130    /** 
     131     * <p> 
     132     * TODO: comment 
     133     * </p> 
     134     * 
     135     * @param child1 
     136     * @param child2 
     137     * @param requiredEqualityLevel 
     138     * @return 
     139     */ 
     140    private NodeEquality callRuleManager(ITaskTreeNode child1, 
     141                                         ITaskTreeNode child2, 
     142                                         NodeEquality  requiredEqualityLevel) 
     143    { 
     144        if (requiredEqualityLevel == null) { 
     145            return mRuleManager.compare(child1, child2); 
     146        } 
     147        else if (mRuleManager.areAtLeastEqual(child1, child2, requiredEqualityLevel)) { 
     148            return requiredEqualityLevel; 
     149        } 
     150        else { 
     151            return NodeEquality.UNEQUAL; 
     152        } 
     153    } 
    90154} 
Note: See TracChangeset for help on using the changeset viewer.