File thisLink = (File) litr.next(); File parent = thisLink.getParentFile(); Vector v = (Vector) byDir.get(parent); if (v == null) { v = new Vector(); byDir.put(parent, v); } v.addElement(thisLink);
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/unix/Symlink.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/DOMElementWriter.java
Method name: void record() Method name: void addNSDefinition(Element, String)
Number of AST nodes: 7 Number of AST nodes: 5
1
File thisLink = (File) litr.next();
2
                File parent = thisLink.getParentFile();
3
                Vector v = (Vector) byDir.get(parent);
1
ArrayList al = (ArrayList) nsURIByElement.get(element);
4
                if (v == null) {
2
        if (al == null) {
5
                    v = new Vector();
3
            
6
                    byDir
4
al = new ArrayList();
7
.put(parent, v);
5
            nsURIByElement.put(element, al);
8
                }
6
        
9
                v.addElement(thisLink
7
}
10
);
8
        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 comparisons17
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment4
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                  
    1
    ArrayList al = (ArrayList)nsURIByElement.get(element);
                                  
    5
    al.add(uri);
    10
    File thisLink = (File)litr.next();
                                                                            
    11
    File parent = thisLink.getParentFile();
    11
    File parent = thisLink.getParentFile();
    Preondition Violations
    Unmatched statement File parent=thisLink.getParentFile(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
    12
    Vector v = (Vector)byDir.get(parent);
    12
    Vector v = (Vector)byDir.get(parent);
    Preondition Violations
    Unmatched statement Vector v=(Vector)byDir.get(parent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                  
    13
    if (v == null)
    13
    if (v == null)
    2
    if (al == null)
    Differences
    Expression1Expression2Difference
    valVARIABLE_NAME_MISMATCH
    java.util.Vectorjava.util.ArrayListSUBCLASS_TYPE_MISMATCH
    2
    if (al == null)
    14
    v = new Vector();
    14
    v = new Vector();
    3
    al = new ArrayList();
    Differences
    Expression1Expression2Difference
    valVARIABLE_NAME_MISMATCH
    java.util.Vectorjava.util.ArrayListSUBCLASS_TYPE_MISMATCH
    java.util.Vectorjava.util.ArrayListSUBCLASS_TYPE_MISMATCH
    3
    al = new ArrayList();
    15
    byDir.put(parent, v);
    15
    byDir.put(parent, v);
    4
    nsURIByElement.put(element, al);
    Differences
    Expression1Expression2Difference
    parentelementVARIABLE_NAME_MISMATCH
    java.io.Fileorg.w3c.dom.ElementVARIABLE_TYPE_MISMATCH
    byDirnsURIByElementVARIABLE_NAME_MISMATCH
    java.util.Hashtablejava.util.HashMapVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.io.File of variable parent does not match with type org.w3c.dom.Element of variable element
    • Make classes java.io.File and org.w3c.dom.Element extend a common superclass
    Type java.util.Hashtable of variable byDir 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);
    16
    v.addElement(thisLink);
                                                          
    Precondition Violations (5)
    Row Violation
    1Unmatched statement File parent=thisLink.getParentFile(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Vector v=(Vector)byDir.get(parent); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type java.io.File of variable parent does not match with type org.w3c.dom.Element of variable element
    4Type java.util.Hashtable of variable byDir does not match with type java.util.HashMap of variable nsURIByElement
    5Clone fragment #1 returns variable v with type java.util.Vector , while Clone fragment #2 returns variable al with type java.util.ArrayList