@Override protected void updateListeners(Object oldOwner, Object newOwner) { Set<Object[]> l = new HashSet<Object[]>(); if (newOwner != null) { /* Don't listen to all property names * We only need to listen to its "type", and "remove". */ l.add(new Object[] {newOwner, new String[] {"type", "remove"}}); // register for events from the type Object type = Model.getFacade().getType(newOwner); if (Model.getFacade().isAClassifier(type)) { if (Model.getFacade().isAClassifierInState(type)) { Object classifier = Model.getFacade().getType(type); l.add(new Object[] {classifier, "name"}); l.add(new Object[] {type, "inState"}); Collection states = Model.getFacade().getInStates(type); Iterator i = states.iterator(); while (i.hasNext()) { l.add(new Object[] {i.next(), "name"}); } } else { l.add(new Object[] {type, "name"}); } } } updateElementListeners(l); }
@Override protected void updateListeners(Object oldOwner, Object newOwner) { Set<Object[]> listeners = new HashSet<Object[]>(); if (newOwner != null) { listeners.add(new Object[] {newOwner, null}); // register for tagDefinitions: for (Object td : Model.getFacade().getTagDefinitions(newOwner)) { listeners.add(new Object[] {td, new String[] {"name", "tagType", "multiplicity"}}); } /* TODO: constraints, ... */ } updateElementListeners(listeners); }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/activity/ui/FigObjectFlowState.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigStereotypeDeclaration.java
Method name: void updateListeners(Object, Object) Method name: void updateListeners(Object, Object)
Number of AST nodes: 2 Number of AST nodes: 2
1
@Override
1
@Override
2
    protected void updateListeners(Object oldOwner, Object newOwner) {
2
    protected void updateListeners(Object oldOwner, Object newOwner) {
3
        Set<Object[]> l = new HashSet<Object[]>();
3
        
4
4
        Set<Object[]> listeners = new HashSet<Object[]>();
5
        if (newOwner != null) {
5
        if (newOwner != null) {
6
            /* Don't listen to all property names
6
            listeners.add(new Object[] {newOwner, null});
7
             * We only need to listen to its "type", and "remove". */
7
            // register for tagDefinitions:
8
            l.add(new Object[] {newOwner, new String[] {"type", "remove"}});
8
            for (Object td : Model.getFacade().getTagDefinitions(newOwner)) {
9
            // register for events from the type
9
                listeners.add(new Object[] {td,
10
            Object type = Model.getFacade().getType(newOwner);
10
                    new String[] {"name", "tagType", "multiplicity"}});
11
            if (Model.getFacade().isAClassifier(type)) {
11
            }
12
                if (Model.getFacade().isAClassifierInState(type)) {
12
            /* TODO: constraints, ... */
13
                    Object classifier = Model.getFacade().getType(type);
13
        }
14
                    l.add(new Object[] {classifier, "name"});
14
        updateElementListeners(listeners);
15
                    l.add(new Object[] {type, "inState"});
15
    }
16
                    Collection states = Model.getFacade().getInStates(type);
17
                    Iterator i = states.iterator();
18
                    while (i.hasNext()) {
19
                        l.add(new Object[] {i.next(), "name"});
20
                    }
21
                } else {
22
                    l.add(new Object[] {type, "name"});
23
                }
24
            }
25
        }
26
27
        updateElementListeners(l);
28
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    12
    while (i.hasNext())
    12
    while (i.hasNext())
    4
    for (Object td : Model.getFacade().getTagDefinitions(newOwner))
    Differences
    Expression1Expression2Difference
    statesModel.getFacade().getTagDefinitions(newOwner)TYPE_COMPATIBLE_REPLACEMENT
    4
    for (Object td : Model.getFacade().getTagDefinitions(newOwner))
                                                                                                                                                                      
    5
    listeners.add(new Object[] {td, new String[] {"name", "tagType", "multiplicity"}});
    Preondition Violations
    Unmatched statement listeners.add(new Object[]{td,new String[]{"name","tagType","multiplicity"}}); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    listeners.add(new Object[] {td, new String[] {"name", "tagType", "multiplicity"}});
    13
    l.add(new Object[] {i.next(), "name"});
                                                                                      
    Precondition Violations (2)
    Row Violation
    1Unmatched statement listeners.add(new Object[]{td,new String[]{"name","tagType","multiplicity"}}); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Clone fragment #1 returns variables , while Clone fragment #2 returns variables td