if (needQPEncoding(body)) { bodyPart.getHeader().setContentTransferEncoding("quoted-printable"); // check if the charset is US-ASCII then there is something wrong // -> switch to UTF-8 and write to log-file if( charsetName.equalsIgnoreCase("us-ascii")){ charsetName = "UTF-8"; LOG.info("Charset was US-ASCII but text has 8-bit chars -> switched to UTF-8"); } } bodyPart.getHeader().putContentParameter("charset", charsetName); // to allow empty messages if (body.length() == 0) { body = " "; } bodyPart.setBody(new CharSequenceSource(body)); return bodyPart;
if (needQPEncoding(body)) { bodyPart.getHeader().setContentTransferEncoding("quoted-printable"); // check if the charset is US-ASCII then there is something wrong // -> switch to UTF-8 and write to log-file if( charsetName.equalsIgnoreCase("us-ascii")){ charsetName = "UTF-8"; LOG.info("Charset was US-ASCII but text has 8-bit chars -> switched to UTF-8"); } } // write charset to header bodyPart.getHeader().putContentParameter("charset", charsetName); // to allow empty messages if (body.length() == 0) { body = " "; } bodyPart.setBody(new CharSequenceSource(body)); return bodyPart;
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/composer/MessageComposer.java File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/composer/MessageComposer.java
Method name: StreamableMimePart composeHtmlMimePart(boolean) Method name: StreamableMimePart composeTextMimePart(boolean)
Number of AST nodes: 10 Number of AST nodes: 10
1
if (needQPEncoding(body)) {
1
if (needQPEncoding(body)) {
2
			bodyPart.getHeader().setContentTransferEncoding("quoted-printable");
2
			bodyPart.getHeader().setContentTransferEncoding("quoted-printable");
3
			
3
			// check if the charset is US-ASCII then there is something wrong
4
			// check if the charset is US-ASCII then there is something wrong
4
			// -> switch to UTF-8 and write to log-file
5
			// -> switch to UTF-8 and write to log-file
5
			if( charsetName.equalsIgnoreCase("us-ascii")){
6
			if( charsetName.equalsIgnoreCase("us-ascii")){
6
				charsetName = "UTF-8";
7
				charsetName = "UTF-8";
7
				LOG.info("Charset was US-ASCII but text has 8-bit chars -> switched to UTF-8");
8
				LOG.info("Charset was US-ASCII but text has 8-bit chars -> switched to UTF-8");
8
			}
9
			}
9
		}
10
		}
11
		
12
		// write charset to header
10
		bodyPart.getHeader().putContentParameter("charset", charsetName);
13
		bodyPart.getHeader().putContentParameter("charset", charsetName);
14
		
11
		// to allow empty messages
15
		// to allow empty messages
12
		if (body.length() == 0) {
16
		if (body.length() == 0) {
13
			body = " ";
17
			body = " ";
14
		}
18
		}
15
		bodyPart.setBody(new CharSequenceSource(body));
19
		bodyPart.setBody(new CharSequenceSource(body));
16
		return bodyPart;
20
		return bodyPart;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons26
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.2
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    36
    if (needQPEncoding(body))
    13
    if (needQPEncoding(body))
    37
    bodyPart.getHeader().setContentTransferEncoding("quoted-printable");
    14
    bodyPart.getHeader().setContentTransferEncoding("quoted-printable");
    38
    if (charsetName.equalsIgnoreCase("us-ascii"))
    15
    if (charsetName.equalsIgnoreCase("us-ascii"))
    39
    charsetName = "UTF-8";
    16
    charsetName = "UTF-8";
    40
    LOG.info("Charset was US-ASCII but text has 8-bit chars -> switched to UTF-8");
    17
    LOG.info("Charset was US-ASCII but text has 8-bit chars -> switched to UTF-8");
    41
    bodyPart.getHeader().putContentParameter("charset", charsetName);
    18
    bodyPart.getHeader().putContentParameter("charset", charsetName);
    42
    if (body.length() == 0)
    19
    if (body.length() == 0)
    43
    body = " ";
    20
    body = " ";
    44
    bodyPart.setBody(new CharSequenceSource(body));
    21
    bodyPart.setBody(new CharSequenceSource(body));
    45
    return bodyPart;
    22
    return bodyPart;
    Precondition Violations (0)
    Row Violation