try {
Integer.parseInt(portField.getText());
} catch (NumberFormatException nfe) {
int length = portField.getText().length();
if (length > 0) {
JOptionPane.showMessageDialog(this, "Only digits allowed", "Invalid data",
JOptionPane.WARNING_MESSAGE);
// Drop the last character:
portField.setText(portField.getText().substring(0, length-1));
}
}
enableRestart();
try {
Integer.parseInt(field.getText());
} catch (NumberFormatException nfe) {
int length = field.getText().length();
if (length > 0) {
JOptionPane.showMessageDialog(this, "Only digits allowed", "Invalid data",
JOptionPane.WARNING_MESSAGE);
// Drop the last character:
field.setText(field.getText().substring(0, length-1));
}
}
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
|
|
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/assertions/gui/HTMLAssertionGui.java
|
Method name: void keyReleased(KeyEvent)
|
|
Method name: void validateInteger(JTextField)
|
Number of AST nodes: 3
|
|
Number of AST nodes: 2
|
|
1 | try {↵ | | 1 | try {↵
|
2 | Integer.parseInt(portField.getText());↵ | | 2 | Integer.parseInt(field.getText());↵
|
3 | } catch (NumberFormatException nfe) {↵ | | 3 | } catch (NumberFormatException nfe) {↵
|
4 | int length = portField.getText().length();↵ | | 4 | int length = field.getText().length();↵
|
5 | if (length > 0) {↵ | | 5 | if (length > 0) {↵
|
6 | JOptionPane.showMessageDialog(this, "Only digits allowed", "Invalid data",↵ | | 6 | JOptionPane.showMessageDialog(this, "Only digits allowed", "Invalid data",↵
|
7 | JOptionPane.WARNING_MESSAGE);↵ | | 7 | JOptionPane.WARNING_MESSAGE);↵
|
8 | // Drop the last character:↵ | | 8 | // Drop the last character:↵
|
9 | portField.setText(portField.getText().substring(0, length-1));↵ | | 9 | field.setText(field.getText().substring(0, length-1));↵
|
10 | }↵ | | 10 | }↵
|
11 | }↵ | | 11 | ↵
|
12 | enableRestart(); | | 12 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.9 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 4 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 2 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.9 |
Clone type | Type 3 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
3 | try | | 1 | try |
4 | Integer.parseInt(portField.getText()); | | 2 | Integer.parseInt(field.getText()); |
5 | enableRestart(); | | | |
Precondition Violations (0)
Row |
Violation |