while (depEnum.hasMoreElements()) { String dependentClass = (String) depEnum.nextElement(); Hashtable affectedClasses = (Hashtable) affectedClassMap.get(dependentClass); if (affectedClasses == null) { affectedClasses = new Hashtable(); affectedClassMap.put(dependentClass, affectedClasses); } affectedClasses.put(info.className, info); }
ArrayList al = (ArrayList) nsURIByElement.get(element); if (al == null) { al = new ArrayList(); nsURIByElement.put(element, al); } al.add(uri);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/depend/Depend.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/DOMElementWriter.java
Method name: void determineDependencies() Method name: void addNSDefinition(Element, String)
Number of AST nodes: 7 Number of AST nodes: 5
1
while (depEnum.hasMoreElements()) {
2
                String dependentClass = (String) depEnum.nextElement();
3
                Hashtable affectedClasses
4
                    = (Hashtable) affectedClassMap.get(dependentClass);
5
     
1
ArrayList al = (ArrayList) nsURIByElement.get(element);
6
           if (affectedClasses == null) {
2
        if (al == null) {
7
                    affectedClasses = new Hashtable();
3
            
8
                    affectedClassMap.put(dependentClass, affectedClasses);
9
                }
10
                affectedClasses.put(info.className, info);
11
            }
4
al = new ArrayList();
5
            nsURIByElement.put(element, al);
6
        }
7
        al.add(uri);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are in different classes
Number of node comparisons15
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                  
    1
    ArrayList al = (ArrayList)nsURIByElement.get(element);
                                  
    5
    al.add(uri);
    36
    String dependentClass = (String)depEnum.nextElement();
    36
    String dependentClass = (String)depEnum.nextElement();
    Preondition Violations
    Unmatched statement String dependentClass=(String)depEnum.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                    
    37
    Hashtable affectedClasses = (Hashtable)affectedClassMap.get(dependentClass);
    37
    Hashtable affectedClasses = (Hashtable)affectedClassMap.get(dependentClass);
    Preondition Violations
    Unmatched statement Hashtable affectedClasses=(Hashtable)affectedClassMap.get(dependentClass); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                
    38
    if (affectedClasses == null)
    38
    if (affectedClasses == null)
    2
    if (al == null)
    Differences
    Expression1Expression2Difference
    affectedClassesalVARIABLE_NAME_MISMATCH
    java.util.Hashtablejava.util.ArrayListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Hashtable of variable affectedClasses does not match with type java.util.ArrayList of variable al
    • Make classes java.util.Hashtable and java.util.ArrayList extend a common superclass
    2
    if (al == null)
                                                
    3
    al = new ArrayList();
    Preondition Violations
    Unmatched statement al=new ArrayList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    al = new ArrayList();
    39
    affectedClasses = new Hashtable();
    39
    affectedClasses = new Hashtable();
    Preondition Violations
    Unmatched statement affectedClasses=new Hashtable(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
    40
    affectedClassMap.put(dependentClass, affectedClasses);
    40
    affectedClassMap.put(dependentClass, affectedClasses);
    4
    nsURIByElement.put(element, al);
    Differences
    Expression1Expression2Difference
    dependentClasselementVARIABLE_NAME_MISMATCH
    java.lang.Stringorg.w3c.dom.ElementVARIABLE_TYPE_MISMATCH
    affectedClassMapnsURIByElementVARIABLE_NAME_MISMATCH
    java.util.Hashtablejava.util.HashMapVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable dependentClass does not match with type org.w3c.dom.Element of variable element
    • Make classes java.lang.String and org.w3c.dom.Element extend a common superclass
    Type java.util.Hashtable of variable affectedClassMap does not match with type java.util.HashMap of variable nsURIByElement
    • Make classes java.util.Hashtable and java.util.HashMap extend a common superclass
    4
    nsURIByElement.put(element, al);
    41
    affectedClasses.put(info.className, info);
                                                                                              
    Precondition Violations (7)
    Row Violation
    1Unmatched statement String dependentClass=(String)depEnum.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Hashtable affectedClasses=(Hashtable)affectedClassMap.get(dependentClass); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type java.util.Hashtable of variable affectedClasses does not match with type java.util.ArrayList of variable al
    4Unmatched statement al=new ArrayList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement affectedClasses=new Hashtable(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Type java.lang.String of variable dependentClass does not match with type org.w3c.dom.Element of variable element
    7Type java.util.Hashtable of variable affectedClassMap does not match with type java.util.HashMap of variable nsURIByElement