List nestedElementList = (List) nestedElementMap.get(name); if (nestedElementList == null) { nestedElementList = new ArrayList(); nestedElementMap.put(name, nestedElementList); } Object element = getScript().createNestedElement(name); nestedElementList.add(element); return element;
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/script/ScriptDefBase.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/DOMElementWriter.java
Method name: Object createDynamicElement(String) Method name: void addNSDefinition(Element, String)
Number of AST nodes: 7 Number of AST nodes: 5
1
List nestedElementList = (List) nestedElementMap.get(name);
1
ArrayList al = (ArrayList) nsURIByElement.get(element);
2
        if (nestedElementList == null) {
2
        if (al == null) {
3
            nestedElementList = new ArrayList();
3
            al = new ArrayList();
4
            nestedElementMap.put(name, nestedElementList);
4
            nsURIByElement.put(element, al);
5
        }
5
        }
6
        Object element = getScript().createNestedElement(name);
6
        
7
        nestedElementList.add(element);
8
        return element;
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 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.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                  
    1
    ArrayList al = (ArrayList)nsURIByElement.get(element);
    1
    List nestedElementList = (List)nestedElementMap.get(name);
                                                                                                                          
    2
    if (nestedElementList == null)
    2
    if (nestedElementList == null)
    2
    if (al == null)
    Differences
    Expression1Expression2Difference
    nestedElementListalVARIABLE_NAME_MISMATCH
    java.util.Listjava.util.ArrayListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List of variable nestedElementList does not match with type java.util.ArrayList of variable al
    • Make classes java.util.List 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();
    3
    nestedElementList = new ArrayList();
    3
    nestedElementList = new ArrayList();
    Preondition Violations
    Unmatched statement nestedElementList=new ArrayList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                              
    4
    nestedElementMap.put(name, nestedElementList);
    4
    nestedElementMap.put(name, nestedElementList);
    4
    nsURIByElement.put(element, al);
    Differences
    Expression1Expression2Difference
    nameelementVARIABLE_NAME_MISMATCH
    java.lang.Stringorg.w3c.dom.ElementVARIABLE_TYPE_MISMATCH
    nestedElementMapnsURIByElementVARIABLE_NAME_MISMATCH
    java.util.Mapjava.util.HashMapVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable name 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.Map of variable nestedElementMap does not match with type java.util.HashMap of variable nsURIByElement
    • Make classes java.util.Map and java.util.HashMap extend a common superclass
    4
    nsURIByElement.put(element, al);
    5
    Object element = getScript().createNestedElement(name);
                                                                                                                    
    6
    nestedElementList.add(element);
    6
    nestedElementList.add(element);
    5
    al.add(uri);
    Differences
    Expression1Expression2Difference
    elementuriVARIABLE_NAME_MISMATCH
    java.lang.Objectjava.lang.StringVARIABLE_TYPE_MISMATCH
    nestedElementListalVARIABLE_NAME_MISMATCH
    java.util.Listjava.util.ArrayListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Object of variable element does not match with type java.lang.String of variable uri
    • Make classes java.lang.Object and java.lang.String extend a common superclass
    Type java.util.List of variable nestedElementList does not match with type java.util.ArrayList of variable al
    • Make classes java.util.List and java.util.ArrayList extend a common superclass
    5
    al.add(uri);
    7
    return element;
    7
    return element;
    Preondition Violations
    Unmatched return element;
                                        
    Precondition Violations (8)
    Row Violation
    1Type java.util.List of variable nestedElementList does not match with type java.util.ArrayList of variable al
    2Unmatched statement al=new ArrayList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement nestedElementList=new ArrayList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Type java.lang.String of variable name does not match with type org.w3c.dom.Element of variable element
    5Type java.util.Map of variable nestedElementMap does not match with type java.util.HashMap of variable nsURIByElement
    6Type java.lang.Object of variable element does not match with type java.lang.String of variable uri
    7Type java.util.List of variable nestedElementList does not match with type java.util.ArrayList of variable al
    8Unmatched return element;