Set result = new HashSet();
StringTokenizer tk = new StringTokenizer(actions, ",");
while (tk.hasMoreTokens()) {
String item = tk.nextToken().trim();
if (!item.equals("")) {
result.add(item);
}
}
return result;
ResourceCollection rc = getResourceCollection();
Iterator iter = rc.iterator();
if (!(iter.hasNext())) {
return Collections.EMPTY_SET;
}
SortedBag b = new SortedBag(comp);
while (iter.hasNext()) {
b.add(iter.next());
}
return b;
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/Permissions.java
|
|
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/resources/Sort.java
|
Method name: Set parseActions(String)
|
|
Method name: Collection getCollection()
|
Number of AST nodes: 7
|
|
Number of AST nodes: 8
|
|
1 | Set result = new HashSet();↵ | | |
|
2 | StringTokenizer tk = new StringTokenizer(actions, ",");↵ | | |
|
3 | while (tk.hasMoreTokens()) {↵ | | |
|
4 | String item = tk.nextToken().trim(↵ | | 1 | ResourceCollection rc = getResourceCollection();↵
|
| | | 2 | Iterator iter = rc.iterator();↵
|
| | | 3 | if (!(iter.hasNext())) {↵
|
| | | 4 | return Collections.EMPTY_SET;↵
|
| | | 5 | }↵
|
5 | );↵ | | 6 | SortedBag b = new SortedBag(comp);↵
|
6 | if (!item.equals("")) {↵ | | 7 | while (iter.hasNext()) {↵
|
7 | result.add(item);↵ | | 8 | ↵
|
8 | ↵ | | 9 | b.add(iter.next());↵
|
9 | }↵ | | 10 | }↵
|
10 | }↵ | | |
|
11 | return result; | | 11 | return b;
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1 |
Clones location | Clones are in different classes |
Number of node comparisons | 7 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 2.7 |
Clone type | Type 3 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
| | | 1 | ResourceCollection rc = getResourceCollection(); |
| | | 2 | Iterator iter = rc.iterator(); |
4 | String item = tk.nextToken().trim(); | | | |
5 | if (!item.equals("")) | | 3 | if (!(iter.hasNext())) |
| | | 4 | return Collections.EMPTY_SET; |
6 | | | | |
Precondition Violations (2)
Row |
Violation |
1 | Unmatched statement String item=tk.nextToken().trim(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched return Collections.EMPTY_SET; |