if ("propertiesfile".equals(type)) { Properties props = getPropertiesFromFile(params[i].getValue()); for (Enumeration e = props.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); String value = props.getProperty(key); hash.put(key, value); } }
if (additionalUserProperties != null) { for (Enumeration e = additionalUserProperties.keys(); e.hasMoreElements();) { String key = (String) e.nextElement(); String property = additionalUserProperties.getProperty(key); definedProps.put(key, property); } }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/filters/ReplaceTokens.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/Main.java
Method name: void initialize() Method name: void startAnt(String[], Properties, ClassLoader)
Number of AST nodes: 6 Number of AST nodes: 5
1
if ("propertiesfile".equals(type)) {
1
if (
2
                        Prop
2
additionalUserProperties != null) {
3
erties props = getPropertiesFromFile(params[i].getValue());
3
            for (Enumeration e = additionalUserProperties.keys();
4
                        for (Enumeration e = props.keys(); e.hasMoreElements();) {
4
                    e.hasMoreElements();) {
5
                            String key = (String) e.nextElement();
5
                String key = (String) e.nextElement();
6
                            String value = props.getProperty(key);
6
                String property = additionalUserProperties.getProperty(key);
7
                            hash.put(key, value);
7
                
8
                        }
9
            
8
definedProps.put(key, property);
9
            }
10
        }
10
        }
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.3
Clones locationClones are in different classes
Number of node comparisons18
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.4
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    22
    Properties props = getPropertiesFromFile(params[i].getValue());
    22
    Properties props = getPropertiesFromFile(params[i].getValue());
    Preondition Violations
    Unmatched statement Properties props=getPropertiesFromFile(params[i].getValue()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                      
    23
    for (Enumeration e = props.keys(); e.hasMoreElements(); )
    23
    for (Enumeration e = props.keys(); e.hasMoreElements(); )
    5
    for (Enumeration e = additionalUserProperties.keys(); e.hasMoreElements(); )
    Differences
    Expression1Expression2Difference
    propsadditionalUserPropertiesVARIABLE_NAME_MISMATCH
    5
    for (Enumeration e = additionalUserProperties.keys(); e.hasMoreElements(); )
    24
    String key = (String)e.nextElement();
    6
    String key = (String)e.nextElement();
    25
    String value = props.getProperty(key);
    25
    String value = props.getProperty(key);
    7
    String property = additionalUserProperties.getProperty(key);
    Differences
    Expression1Expression2Difference
    valuepropertyVARIABLE_NAME_MISMATCH
    propsadditionalUserPropertiesVARIABLE_NAME_MISMATCH
    7
    String property = additionalUserProperties.getProperty(key);
    26
    hash.put(key, value);
    26
    hash.put(key, value);
    8
    definedProps.put(key, property);
    Differences
    Expression1Expression2Difference
    valuepropertyVARIABLE_NAME_MISMATCH
    hashdefinedPropsVARIABLE_NAME_MISMATCH
    java.util.Hashtablejava.util.PropertiesVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Hashtable of variable hash does not match with type java.util.Properties of variable definedProps
    • Make classes java.util.Hashtable and java.util.Properties extend a common superclass
    8
    definedProps.put(key, property);
    Precondition Violations (2)
    Row Violation
    1Unmatched statement Properties props=getPropertiesFromFile(params[i].getValue()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Type java.util.Hashtable of variable hash does not match with type java.util.Properties of variable definedProps