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/AjpSampler.java | |||
Method name: String replaceAllChars(String, char, String)
|
Method name: String encode(String)
|
|||
Number of AST nodes: 4 | Number of AST nodes: 4 | |||
1 | /** | 1 | private String encode(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 | char[] chars = value.toCharArray(); | |
4 | * | 4 | for (int i = 0; i < chars.length; i++) | |
5 | * @param source | 5 | { | |
6 | * input string | 6 | if (chars[i] == '\\')//$NON-NLS-1$ | |
7 | * @param search | 7 | { | |
8 | * char to look for (no regular expressions) | 8 | newValue.append("\\\\");//$NON-NLS-1$ | |
9 | * @param replace | 9 | } | |
10 | * string to replace the search string | 10 | else | |
11 | * @return the output string | 11 | { | |
12 | */ | 12 | newValue.append(chars[i]); | |
13 | public static String replaceAllChars(String source, char search, String replace) { | 13 | } | |
14 | char[] chars = source.toCharArray(); | 14 | } | |
15 | StringBuilder sb = new StringBuilder(source.length()+20); | 15 | return newValue.toString(); | |
16 | for(char c : chars){ | 16 | } | |
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 | 4 |
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 | 0.714 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | for (char c : chars) | 3 | for (int i = 0; i < chars.length; i++) | ||||||||||||||||
4 | if (c == search) |
| 4 | if (chars[i] == '\\') | |||||||||||||||
5 | sb.append(replace); |
| 5 | newValue.append("\\\\"); | |||||||||||||||
else | else | ||||||||||||||||||
6 | sb.append(c); |
| 6 | newValue.append(chars[i]); |
Row | Violation |
---|---|
1 | Expression c cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression chars[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression c cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression chars[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted |