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 recmatches = listChildNodes(child, filter, recurse); final int reclength = recmatches.getLength(); for (int j = 0; j < reclength; j++) { matches.addElement(recmatches.item(i)); }
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/optional/junit/DOMUtil.java
Method name: void addNodeRecursively(Node, String, Object) Method name: NodeList listChildNodes(Node, NodeFilter, boolean)
Number of AST nodes: 5 Number of AST nodes: 4
1
if (node.hasChildNodes()) {
2
            NodeList nodeChildren = node.getChildNodes();
1
NodeList recmatches = listChildNodes(child, filter, recurse);
3
            int numChildren = nodeChildren.getLength();
2
                    final int reclength = recmatches.getLength();
4
            for (int i = 0; i < numChildren; i++) {
3
                    for (int j = 0; j < reclength; j++) {
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,
9
                                   nodeObject);
5
        matches.addElement(recmatches.item(i));
10
            }
6
            
11
        }
7
        }
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 comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    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();
    10
    NodeList recmatches = listChildNodes(child, filter, recurse);
    Differences
    Expression1Expression2Difference
    nodeChildrenrecmatchesVARIABLE_NAME_MISMATCH
    getChildNodeslistChildNodesMETHOD_INVOCATION_NAME_MISMATCH
    node.getChildNodes()listChildNodes(child,filter,recurse)ARGUMENT_NUMBER_MISMATCH
    nodeMISSING_METHOD_INVOCATION_EXPRESSION
    10
    NodeList recmatches = listChildNodes(child, filter, recurse);
    9
    int numChildren = nodeChildren.getLength();
    9
    int numChildren = nodeChildren.getLength();
    Preondition Violations
    Unmatched statement int numChildren=nodeChildren.getLength(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                            
                                                                                                  
    11
    final int reclength = recmatches.getLength();
    Preondition Violations
    Unmatched statement final int reclength=recmatches.getLength(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11
    final int reclength = recmatches.getLength();
    10
    for (int i = 0; i < numChildren; i++)
    10
    for (int i = 0; i < numChildren; i++)
    12
    for (int j = 0; j < reclength; j++)
    Differences
    Expression1Expression2Difference
    ijVARIABLE_NAME_MISMATCH
    ijVARIABLE_NAME_MISMATCH
    numChildrenreclengthVARIABLE_NAME_MISMATCH
    ijVARIABLE_NAME_MISMATCH
    12
    for (int j = 0; j < reclength; j++)
    11
    addNodeRecursively(nodeChildren.item(i), nodePrefix, nodeObject);
    11
    addNodeRecursively(nodeChildren.item(i), nodePrefix, nodeObject);
    13
    matches.addElement(recmatches.item(i));
    Differences
    Expression1Expression2Difference
    addNodeRecursivelyaddElementMETHOD_INVOCATION_NAME_MISMATCH
    addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject)matches.addElement(recmatches.item(i))ARGUMENT_NUMBER_MISMATCH
    matchesMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method addNodeRecursively
    Expression matches.addElement(recmatches.item(i)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject) is a void method call, and thus it cannot be parameterized
    Expression matches.addElement(recmatches.item(i)) is a void method call, and thus it cannot be parameterized
    Expression addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method addNodeRecursively
    Expression matches.addElement(recmatches.item(i)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject) is a void method call, and thus it cannot be parameterized
    Expression matches.addElement(recmatches.item(i)) is a void method call, and thus it cannot be parameterized
    13
    matches.addElement(recmatches.item(i));
    Precondition Violations (10)
    Row Violation
    1Unmatched statement int numChildren=nodeChildren.getLength(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement final int reclength=recmatches.getLength(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Expression addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression matches.addElement(recmatches.item(i)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject) is a void method call, and thus it cannot be parameterized
    6Expression matches.addElement(recmatches.item(i)) is a void method call, and thus it cannot be parameterized
    7Expression addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression matches.addElement(recmatches.item(i)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression addNodeRecursively(nodeChildren.item(i),nodePrefix,nodeObject) is a void method call, and thus it cannot be parameterized
    10Expression matches.addElement(recmatches.item(i)) is a void method call, and thus it cannot be parameterized