File path: /apache-jmeter-2.11/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java | File path: /apache-jmeter-2.11/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java | |||
Method name: String replaceAllChars(String, char, String)
|
Method name: String encodeBackSlashes(String)
|
|||
Number of AST nodes: 4 | Number of AST nodes: 5 | |||
1 | /** | 1 | protected static String encodeBackSlashes(String value) { | |
2 | * Version of String.replaceAll() for JDK1.3 | 2 | StringBuilder newValue = new StringBuilder(); | |
3 | * See below for another version which replaces strings rather than chars | 3 | for (int i = 0; i < value.length(); i++) { | |
4 | * | 4 | char charAt = value.charAt(i); | |
5 | * @param source | 5 | if (charAt == '\\') { // $NON-NLS-1$ | |
6 | * input string | 6 | newValue.append("\\\\"); // $NON-NLS-1$ | |
7 | * @param search | 7 | } else { | |
8 | * char to look for (no regular expressions) | 8 | newValue.append(charAt); | |
9 | * @param replace | 9 | } | |
10 | * string to replace the search string | 10 | } | |
11 | * @return the output string | 11 | return newValue.toString(); | |
12 | */ | 12 | } | |
13 | public static String replaceAllChars(String source, char search, String replace) { | |||
14 | char[] chars = source.toCharArray(); | |||
15 | StringBuilder sb = new StringBuilder(source.length()+20); | |||
16 | for(char c : chars){ | |||
17 | if (c == search){ | |||
18 | sb.append(replace); | |||
19 | } else { | |||
20 | sb.append(c); | |||
21 | } | |||
22 | } | |||
23 | return sb.toString(); | |||
24 | } | |||
See real code fragment | See real code fragment |
Number of mapped statements | 5 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.0 |
Similarity Score | 1.000 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | for (char c : chars) |
| 2 | for (int i = 0; i < value.length(); i++) | ||||||||||||||||||
|
| 3 | char charAt = value.charAt(i); | |||||||||||||||||||
4 | if (c == search) |
| 4 | if (charAt == '\\') | ||||||||||||||||||
5 | sb.append(replace); |
| 5 | newValue.append("\\\\"); | ||||||||||||||||||
else | else | |||||||||||||||||||||
6 | sb.append(c); |
| 6 | newValue.append(charAt); |
Row | Violation |
---|---|
1 | Type char[] of variable chars does not match with type java.lang.String of variable value |
2 | Type char[] of variable chars does not match with type java.lang.String of variable value |
3 | Type char[] of variable chars does not match with type java.lang.String of variable value |