if (node.hasChildNodes()) { 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); } }
NodeList topChildren = topElement.getChildNodes(); int numChildren = topChildren.getLength(); for (int i = 0; i < numChildren; i++) { addNodeRecursively(topChildren.item(i), prefix, null); }
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 addNodeRecursively(Node, String, Object) Method name: void execute()
Number of AST nodes: 5 Number of AST nodes: 4
1
if (node.hasChildNodes()) {
2
            NodeList nodeChildren = node.getChildNodes();
1
NodeList topChildren = topElement.getChildNodes();
3
            int numChildren = nodeChildren.getLength();
2
                  int numChildren = topChildren.getLength();
4
            for (int i = 0; i < numChildren; i++) {
3
                  for (int i = 0; i < numChildren; i++) {
5
                // For each child, pass the object added by
4
    
6
                // processNode to its children -- in other word, each
7
                // object can pass information along to its children.
8
                addNodeRecursively(nodeChildren.item(i), nodePrefix,
5
                addNodeRecursively(topChildren.item(i), prefix,
9
                                   nodeObject);
6
 null);
10
            }
7
          
11
        }
8
        }
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.2
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.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    8
    NodeList nodeChildren = node.getChildNodes();
    8
    NodeList nodeChildren = node.getChildNodes();
    21
    NodeList topChildren = topElement.getChildNodes();
    Differences
    Expression1Expression2Difference
    nodeChildrentopChildrenVARIABLE_NAME_MISMATCH
    nodetopElementVARIABLE_NAME_MISMATCH
    org.w3c.dom.Nodeorg.w3c.dom.ElementVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.w3c.dom.Node of variable node does not match with type org.w3c.dom.Element of variable topElement
    • Make classes org.w3c.dom.Node and org.w3c.dom.Element extend a common superclass
    21
    NodeList topChildren = topElement.getChildNodes();
    9
    int numChildren = nodeChildren.getLength();
    9
    int numChildren = nodeChildren.getLength();
    22
    int numChildren = topChildren.getLength();
    Differences
    Expression1Expression2Difference
    nodeChildrentopChildrenVARIABLE_NAME_MISMATCH
    22
    int numChildren = topChildren.getLength();
    10
    for (int i = 0; i < numChildren; i++)
    23
    for (int i = 0; i < numChildren; i++)
    11
    addNodeRecursively(nodeChildren.item(i), nodePrefix, nodeObject);
    11
    addNodeRecursively(nodeChildren.item(i), nodePrefix, nodeObject);
    24
    addNodeRecursively(topChildren.item(i), prefix, null);
    Differences
    Expression1Expression2Difference
    nodeChildrentopChildrenVARIABLE_NAME_MISMATCH
    nodePrefixprefixVARIABLE_NAME_MISMATCH
    nodeObjectnullTYPE_COMPATIBLE_REPLACEMENT
    24
    addNodeRecursively(topChildren.item(i), prefix, null);
    Precondition Violations (1)
    Row Violation
    1Type org.w3c.dom.Node of variable node does not match with type org.w3c.dom.Element of variable topElement