if (!getInitialized()) { initialize(); setInitialized(true); } while (line == null || line.length() == 0) { line = lineTokenizer.getToken(in); if (line == null) { return -1; } line = headFilter(line); linePos = 0; } int ch = line.charAt(linePos); linePos++; if (linePos == line.length()) { line = null; } return ch;
if (!getInitialized()) { initialize(); setInitialized(true); } while (line == null || line.length() == 0) { line = lineTokenizer.getToken(in); line = tailFilter(line); if (line == null) { return -1; } linePos = 0; } int ch = line.charAt(linePos); linePos++; if (linePos == line.length()) { line = null; } return ch;
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/filters/HeadFilter.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/filters/TailFilter.java
Method name: int read() Method name: int read()
Number of AST nodes: 14 Number of AST nodes: 14
1
if (!getInitialized()) {
1
if (!getInitialized()) {
2
            initialize();
2
            initialize();
3
            setInitialized(true);
3
            setInitialized(true);
4
        }
4
        }
5
        while (line == null || line.length() == 0) {
5
        while (line == null || line.length() == 0) {
6
            line = lineTokenizer.getToken(in);
6
            line = lineTokenizer.getToken(in);
7
            line = tailFilter(line);
7
            if (line == null) {
8
            if (line == null) {
8
                return -1;
9
                return -1;
9
            }
10
            }
10
            line = headFilter(line);
11
            linePos = 0;
11
            linePos = 0;
12
        }
12
        }
13
        int ch = line.charAt(linePos);
13
        int ch = line.charAt(linePos);
14
        linePos++;
14
        linePos++;
15
        if (linePos == line.length()) {
15
        if (linePos == line.length()) {
16
            line = null;
16
            line = null;
17
        }
17
        }
18
        return ch;
18
        return ch;
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.9
Clones locationClones are in different classes having the same super class
Number of node comparisons45
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)4.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (!getInitialized())
    1
    if (!getInitialized())
    2
    initialize();
    2
    initialize();
    3
    setInitialized(true);
    3
    setInitialized(true);
    4
    while (line == null || line.length() == 0)
    4
    while (line == null || line.length() == 0)
    5
    line = lineTokenizer.getToken(in);
    5
    line = lineTokenizer.getToken(in);
    6
    if (line == null)
    7
    if (line == null)
    7
    return -1;
    8
    return -1;
    8
    line = headFilter(line);
    8
    line = headFilter(line);
    6
    line = tailFilter(line);
    Differences
    Expression1Expression2Difference
    headFiltertailFilterMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression headFilter(line) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method headFilter
    Expression tailFilter(line) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method tailFilter
    6
    line = tailFilter(line);
    9
    linePos = 0;
    9
    linePos = 0;
    10
    int ch = line.charAt(linePos);
    10
    int ch = line.charAt(linePos);
    11
    linePos++;
    11
    linePos++;
    12
    if (linePos == line.length())
    12
    if (linePos == line.length())
    13
    line = null;
    13
    line = null;
    14
    return ch;
    14
    return ch;
    Precondition Violations (2)
    Row Violation
    1Expression headFilter(line) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression tailFilter(line) cannot be parameterized, because it has dependencies to/from statements that will be extracted