NodeList topChildren = topElement.getChildNodes(); int numChildren = topChildren.getLength(); for (int i = 0; i < numChildren; i++) { addNodeRecursively(topChildren.item(i), prefix, null); }
NodeList nodeChildren = node.getChildNodes(); int numChildren = nodeChildren.getLength(); for (int i = 0; i < numChildren; i++) { // For each child, pass the object added by // processNode to its children -- in other word, each // object can pass information along to its children. addNodeRecursively(nodeChildren.item(i), nodePrefix, nodeObject); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/XmlProperty.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/XmlProperty.java
Method name: void execute() Method name: void addNodeRecursively(Node, String, Object)
Number of AST nodes: 4 Number of AST nodes: 4
1
NodeList topChildren = topElement.getChildNodes();
1
NodeList nodeChildren = node.getChildNodes();
2
                  int numChildren = topChildren.getLength();
2
            int numChildren = nodeChildren.getLength();
3
      
4
            for (int i = 0; i < numChildren; i++) {
3
            for (int i = 0; i < numChildren; i++) {
5
    
4
                // For each child, pass the object added by
5
                // processNode to its children -- in other word, each
6
                // object can pass information along to its children.
6
                addNodeRecursively(topChildren.item(i), prefix, null);
7
                addNodeRecursively(nodeChildren.item(i), nodePrefix,
7
      
8
                                   nodeObject);
8
            }
9
            }
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 declared in the same class
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    21
    NodeList topChildren = topElement.getChildNodes();
    21
    NodeList topChildren = topElement.getChildNodes();
    8
    NodeList nodeChildren = node.getChildNodes();
    Differences
    Expression1Expression2Difference
    topChildrennodeChildrenVARIABLE_NAME_MISMATCH
    topElementnodeVARIABLE_NAME_MISMATCH
    org.w3c.dom.Elementorg.w3c.dom.NodeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.w3c.dom.Element of variable topElement does not match with type org.w3c.dom.Node of variable node
    • Make classes org.w3c.dom.Element and org.w3c.dom.Node extend a common superclass
    8
    NodeList nodeChildren = node.getChildNodes();
    22
    int numChildren = topChildren.getLength();
    22
    int numChildren = topChildren.getLength();
    9
    int numChildren = nodeChildren.getLength();
    Differences
    Expression1Expression2Difference
    topChildrennodeChildrenVARIABLE_NAME_MISMATCH
    9
    int numChildren = nodeChildren.getLength();
    23
    for (int i = 0; i < numChildren; i++)
    10
    for (int i = 0; i < numChildren; i++)
    24
    addNodeRecursively(topChildren.item(i), prefix, null);
    24
    addNodeRecursively(topChildren.item(i), prefix, null);
    11
    addNodeRecursively(nodeChildren.item(i), nodePrefix, nodeObject);
    Differences
    Expression1Expression2Difference
    topChildrennodeChildrenVARIABLE_NAME_MISMATCH
    prefixnodePrefixVARIABLE_NAME_MISMATCH
    nullnodeObjectTYPE_COMPATIBLE_REPLACEMENT
    11
    addNodeRecursively(nodeChildren.item(i), nodePrefix, nodeObject);
    Precondition Violations (1)
    Row Violation
    1Type org.w3c.dom.Element of variable topElement does not match with type org.w3c.dom.Node of variable node