ArrayList al = (ArrayList) nsURIByElement.get(element); if (al == null) { al = new ArrayList(); nsURIByElement.put(element, al); } al.add(uri);
List list = (List) prefixMapping.get(prefix); if (list == null) { list = new ArrayList(); prefixMapping.put(prefix, list); } list.add(uri);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/DOMElementWriter.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/helper/AntXMLContext.java
Method name: void addNSDefinition(Element, String) Method name: void startPrefixMapping(String, String)
Number of AST nodes: 5 Number of AST nodes: 5
1
ArrayList al = (ArrayList) nsURIByElement.get(element);
1
List list = (List) prefixMapping.get(prefix);
2
        if (al == null) {
2
        if (list == null) {
3
            al = new ArrayList();
3
            list = new ArrayList();
4
            nsURIByElement.put(element, al);
4
            prefixMapping.put(prefix, list);
5
        }
5
        }
6
        al.add(uri);
6
        list.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 comparisons13
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                              
    1
    List list = (List)prefixMapping.get(prefix);
    1
    ArrayList al = (ArrayList)nsURIByElement.get(element);
                                                                                                                  
    2
    if (al == null)
    2
    if (al == null)
    2
    if (list == null)
    Differences
    Expression1Expression2Difference
    allistVARIABLE_NAME_MISMATCH
    java.util.ArrayListjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.ArrayList of variable al does not match with type java.util.List of variable list
    • Make classes java.util.ArrayList and java.util.List extend a common superclass
    2
    if (list == null)
                                                    
    3
    list = new ArrayList();
    Preondition Violations
    Unmatched statement list=new ArrayList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    list = new ArrayList();
    3
    al = new ArrayList();
    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
                                                
    4
    nsURIByElement.put(element, al);
    4
    nsURIByElement.put(element, al);
    4
    prefixMapping.put(prefix, list);
    Differences
    Expression1Expression2Difference
    elementprefixVARIABLE_NAME_MISMATCH
    org.w3c.dom.Elementjava.lang.StringVARIABLE_TYPE_MISMATCH
    nsURIByElementprefixMappingVARIABLE_NAME_MISMATCH
    java.util.HashMapjava.util.MapVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.w3c.dom.Element of variable element does not match with type java.lang.String of variable prefix
    • Make classes org.w3c.dom.Element and java.lang.String extend a common superclass
    Type java.util.HashMap of variable nsURIByElement does not match with type java.util.Map of variable prefixMapping
    • Make classes java.util.HashMap and java.util.Map extend a common superclass
    4
    prefixMapping.put(prefix, list);
    5
    al.add(uri);
    5
    al.add(uri);
    5
    list.add(uri);
    Differences
    Expression1Expression2Difference
    allistVARIABLE_NAME_MISMATCH
    java.util.ArrayListjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.ArrayList of variable al does not match with type java.util.List of variable list
    • Make classes java.util.ArrayList and java.util.List extend a common superclass
    5
    list.add(uri);
    Precondition Violations (6)
    Row Violation
    1Type java.util.ArrayList of variable al does not match with type java.util.List of variable list
    2Unmatched statement list=new ArrayList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement al=new ArrayList(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Type org.w3c.dom.Element of variable element does not match with type java.lang.String of variable prefix
    5Type java.util.HashMap of variable nsURIByElement does not match with type java.util.Map of variable prefixMapping
    6Type java.util.ArrayList of variable al does not match with type java.util.List of variable list