int count = 0; boolean sucess = false; StringBuffer strbuf = new StringBuffer(); BufferedReader in = new BufferedReader(new FileReader(file)); String str; // parse line by line while ((str = in.readLine()) != null) { // if user cancelled task exit immediately if (worker.cancelled() == true) { return; } // if line doesn't start with "From" or line length is 0 // -> save everything in StringBuffer if ((str.startsWith("From ") == false) || (str.length() == 0)) { strbuf.append(str + "\n"); } else { // line contains "@" (evolution mbox style) or // -> import message in Columba if (str.indexOf("@") != -1) { if (strbuf.length() != 0) { // found new message saveMessage(strbuf.toString(), worker, getDestinationFolder()); count++; sucess = true; } strbuf = new StringBuffer(); } else { strbuf.append(str + "\n"); } } } // save last message, because while loop aborted before being able to // save message if ((sucess == true) && (strbuf.length() > 0)) { saveMessage(strbuf.toString(), worker, getDestinationFolder()); } in.close();
int count = 0; boolean sucess = false; StringBuffer strbuf = new StringBuffer(); BufferedReader in = new BufferedReader(new FileReader(file)); String str; // parse line by line while ((str = in.readLine()) != null) { // if user cancelled task exit immediately if (worker.cancelled()) { return; } // if line doesn't start with "From" or line length is 0 // -> save everything in StringBuffer if (!str.startsWith("From ") || str.length() == 0) { strbuf.append(str + "\n"); } else { // line contains "-" (mozilla mbox style) // -> import message in Columba if (str.indexOf("-") != -1) { if (strbuf.length() != 0) { // found new message saveMessage(strbuf.toString(), worker, getDestinationFolder()); count++; sucess = true; } strbuf = new StringBuffer(); } else { strbuf.append(str + "\n"); } } } // save last message, because while loop aborted before being able to // save message if (sucess && strbuf.length() > 0) { saveMessage(strbuf.toString(), worker, getDestinationFolder()); } in.close();
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/folder/mailboximport/EvolutionImporter.java File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/folder/mailboximport/MozillaImporter.java
Method name: void importMailboxFile(File, IWorkerStatusController, IMailbox) Method name: void importMailboxFile(File, IWorkerStatusController, IMailbox)
Number of AST nodes: 20 Number of AST nodes: 20
1
int count = 0;
1
int count = 0;
2
        boolean sucess = false;
2
        boolean sucess = false;
3
        StringBuffer strbuf = new StringBuffer();
3
        StringBuffer strbuf = new StringBuffer();
4
        BufferedReader in = new BufferedReader(new FileReader(file));
4
        BufferedReader in = new BufferedReader(new FileReader(file));
5
        String str;
5
        String str;
6
        // parse line by line
6
        // parse line by line
7
        while ((str = in.readLine()) != null) {
7
        while ((str = in.readLine()) != null) {
8
            // if user cancelled task exit immediately
8
            // if user cancelled task exit immediately
9
            if (worker.cancelled() == true) {
9
            if (worker.cancelled()) {
10
                return;
10
                return;
11
            }
11
            }
12
            // if line doesn't start with "From" or line length is 0
12
            // if line doesn't start with "From" or line length is 0
13
            //  -> save everything in StringBuffer
13
            //  -> save everything in StringBuffer
14
            if ((str.startsWith("From ") == false) || (str.length() == 0)) {
14
            if (!str.startsWith("From ") || str.length() == 0) {
15
                strbuf.append(str + "\n");
15
                strbuf.append(str + "\n");
16
            } else {
16
            } else {
17
                // line contains "@" (evolution mbox style) or
17
                // line contains "-" (mozilla mbox style)
18
                //  -> import message in Columba
18
                //  -> import message in Columba
19
                if (str.indexOf("@") != -1) {
19
                if (str.indexOf("-") != -1) {
20
                    if (strbuf.length() != 0) {
20
                    if (strbuf.length() != 0) {
21
                        // found new message
21
                        // found new message
22
                        saveMessage(strbuf.toString(), worker,
22
                        saveMessage(strbuf.toString(), worker,
23
                            getDestinationFolder());
23
                            getDestinationFolder());
24
                        count++;
24
                        count++;
25
                        sucess = true;
25
                        sucess = true;
26
                    }
26
                    }
27
                    strbuf = new StringBuffer();
27
                    strbuf = new StringBuffer();
28
                } else {
28
                } else {
29
                    strbuf.append(str + "\n");
29
                    strbuf.append(str + "\n");
30
                }
30
                }
31
            }
31
            }
32
        }
32
        }
33
        // save last message, because while loop aborted before being able to
33
        // save last message, because while loop aborted before being able to
34
        // save message
34
        // save message
35
        if ((sucess == true) && (strbuf.length() > 0)) {
35
        if (sucess && strbuf.length() > 0) {
36
            saveMessage(strbuf.toString(), worker, getDestinationFolder());
36
            saveMessage(strbuf.toString(), worker, getDestinationFolder());
37
        }
37
        }
38
        in.close();
38
        in.close();
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)1.4
Clones locationClones are in different classes having the same super class
Number of node comparisons49
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)5.6
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    int count = 0;
    1
    int count = 0;
    2
    boolean sucess = false;
    2
    boolean sucess = false;
    3
    StringBuffer strbuf = new StringBuffer();
    3
    StringBuffer strbuf = new StringBuffer();
    4
    BufferedReader in = new BufferedReader(new FileReader(file));
    4
    BufferedReader in = new BufferedReader(new FileReader(file));
    5
    String str;
    5
    String str;
    6
    while ((str = in.readLine()) != null)
    6
    while ((str = in.readLine()) != null)
                                                      
    7
    if (worker.cancelled())
                        
    8
    return;
    Preondition Violations
    Unmatched return;
    8
    return;
    7
    if (worker.cancelled() == true)
                                                                      
    8
    return;
    8
    return;
    Preondition Violations
    Unmatched return;
                        
    9
    if ((str.startsWith("From ") == false) || (str.length() == 0))
    9
    if ((str.startsWith("From ") == false) || (str.length() == 0))
    9
    if (!str.startsWith("From ") || str.length() == 0)
    Differences
    Expression1Expression2Difference
    (str.startsWith("From ") == false)!str.startsWith("From ")TYPE_COMPATIBLE_REPLACEMENT
    (str.length() == 0)str.length() == 0INFIX_RIGHT_OPERAND_MISMATCH
    Preondition Violations
    Expression (str.startsWith("From ") == false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression !str.startsWith("From ") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (str.length() == 0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression str.length() == 0 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    if (!str.startsWith("From ") || str.length() == 0)
    10
    strbuf.append(str + "\n");
    10
    strbuf.append(str + "\n");
    else
    else
    11
    if (str.indexOf("@") != -1)
    11
    if (str.indexOf("@") != -1)
    11
    if (str.indexOf("-") != -1)
    Differences
    Expression1Expression2Difference
    "@""-"LITERAL_VALUE_MISMATCH
    11
    if (str.indexOf("-") != -1)
    12
    if (strbuf.length() != 0)
    12
    if (strbuf.length() != 0)
    13
    saveMessage(strbuf.toString(), worker, getDestinationFolder());
    13
    saveMessage(strbuf.toString(), worker, getDestinationFolder());
    14
    count++;
    14
    count++;
    15
    sucess = true;
    15
    sucess = true;
    16
    strbuf = new StringBuffer();
    16
    strbuf = new StringBuffer();
    else
    else
    17
    strbuf.append(str + "\n");
    17
    strbuf.append(str + "\n");
    18
    if ((sucess == true) && (strbuf.length() > 0))
    18
    if ((sucess == true) && (strbuf.length() > 0))
    18
    if (sucess && strbuf.length() > 0)
    Differences
    Expression1Expression2Difference
    (sucess == true)sucessTYPE_COMPATIBLE_REPLACEMENT
    (strbuf.length() > 0)strbuf.length() > 0INFIX_RIGHT_OPERAND_MISMATCH
    Preondition Violations
    Expression (sucess == true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression sucess cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (strbuf.length() > 0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression strbuf.length() > 0 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18
    if (sucess && strbuf.length() > 0)
    19
    saveMessage(strbuf.toString(), worker, getDestinationFolder());
    19
    saveMessage(strbuf.toString(), worker, getDestinationFolder());
    Precondition Violations (10)
    Row Violation
    1Unmatched return;
    2Unmatched return;
    3Expression (str.startsWith("From ") == false) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression !str.startsWith("From ") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (str.length() == 0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression str.length() == 0 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression (sucess == true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression sucess cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression (strbuf.length() > 0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression strbuf.length() > 0 cannot be parameterized, because it has dependencies to/from statements that will be extracted