Section cloned = new Section(); cloned.setName(name); Enumeration e = getAttributeKeys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); Attribute attribute = getAttribute(key); cloned.storeAttribute(new Attribute(attribute.getName(), attribute.getValue())); } return cloned;
List sorted = new ArrayList(props.size()); Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); sorted.add(new Tuple(name, props.getProperty(name))); } Collections.sort(sorted); return sorted;
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Manifest.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
Method name: Object clone() Method name: List sortProperties(Properties)
Number of AST nodes: 8 Number of AST nodes: 7
1
Section cloned = new Section();
2
            cloned.setName(name);
3
    
1
List sorted = new ArrayList(props.size());
4
        Enumeration e = getAttributeKeys();
2
        Enumeration e = props.propertyNames();
5
            while (e.hasMoreElements()) {
3
        while (e.hasMoreElements()) {
6
                String key = (String) e.nextElement();
4
            String name = (String) e.nextElement();
7
                Attribute attribute = getAttribute(key);
5
            
8
                cloned.storeAttribute(new Attribute(attribute.getName(),
9
                                                    attribute.getValue()));
10
            }
11
    
6
sorted.add(new Tuple(name, props.getProperty(name)));
7
        }
8
        Collections.sort(sorted);
12
        return cloned;
9
        return sorted;
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 comparisons28
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment5
    Time elapsed for statement mapping (ms)1.5
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                          
    1
    List sorted = new ArrayList(props.size());
    1
    Section cloned = new Section();
                                                                    
                                                                                  
    2
    Enumeration e = props.propertyNames();
    2
    cloned.setName(name);
                                                    
    3
    Enumeration e = getAttributeKeys();
                                                                            
    4
    while (e.hasMoreElements())
    3
    while (e.hasMoreElements())
    5
    String key = (String)e.nextElement();
    5
    String key = (String)e.nextElement();
    4
    String name = (String)e.nextElement();
    Differences
    Expression1Expression2Difference
    keynameVARIABLE_NAME_MISMATCH
    4
    String name = (String)e.nextElement();
                                                                                                                  
    5
    sorted.add(new Tuple(name, props.getProperty(name)));
    Preondition Violations
    Unmatched statement sorted.add(new Tuple(name,props.getProperty(name))); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    sorted.add(new Tuple(name, props.getProperty(name)));
    6
    Attribute attribute = getAttribute(key);
    6
    Attribute attribute = getAttribute(key);
    Preondition Violations
    Unmatched statement Attribute attribute=getAttribute(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
    7
    cloned.storeAttribute(new Attribute(attribute.getName(), attribute.getValue()));
    7
    cloned.storeAttribute(new Attribute(attribute.getName(), attribute.getValue()));
    Preondition Violations
    Unmatched statement cloned.storeAttribute(new Attribute(attribute.getName(),attribute.getValue())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                        
                                                            
    6
    Collections.sort(sorted);
                                      
    7
    return sorted;
    Preondition Violations
    Unmatched return sorted;
    7
    return sorted;
    8
    return cloned;
    8
    return cloned;
    Preondition Violations
    Unmatched return cloned;
                                      
    Precondition Violations (5)
    Row Violation
    1Unmatched statement sorted.add(new Tuple(name,props.getProperty(name))); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Attribute attribute=getAttribute(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement cloned.storeAttribute(new Attribute(attribute.getName(),attribute.getValue())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched return sorted;
    5Unmatched return cloned;