month = SerialDate.stringToMonthCode(s2); if (month == -1) { throw new TimePeriodFormatException( "Can't evaluate the month." ); } result = new Month(month, year); } else { year = Month.evaluateAsYear(s2); if (year != null) { month = SerialDate.stringToMonthCode(s1); if (month == -1) { throw new TimePeriodFormatException( "Can't evaluate the month." ); } result = new Month(month, year);
if (y != null) { w = Week.stringToWeek(s2); if (w == -1) { throw new TimePeriodFormatException( "Can't evaluate the week."); } result = new Week(w, y); } else { y = Week.evaluateAsYear(s2); if (y != null) { w = Week.stringToWeek(s1); if (w == -1) { throw new TimePeriodFormatException( "Can't evaluate the week."); } result = new Week(w, y); } else { throw new TimePeriodFormatException( "Can't evaluate the year."); } }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/time/Month.java File path: /jfreechart-1.0.10/src/org/jfree/data/time/Week.java
Method name: Month parseMonth(String) Method name: Week parseWeek(String)
Number of AST nodes: 9 Number of AST nodes: 12
1
month = SerialDate.stringToMonthCode
1
if (y != null) {
2
(s2);
2
                    w = Week.stringToWeek(s2);
3
                    if (month == -1) {
3
                    if (w == -1) {
4
                        throw new TimePeriodFormatException(
4
                        throw new TimePeriodFormatException(
5
                            "Can't evaluate the month."
5
                                "Can't evaluate the 
6
                        );
6
week.");
7
                    }
7
                    }
8
                    result = new Month(month, year);
8
                    result = new Week(w, y);
9
                }
9
                }
10
                else {
10
                else {
11
                    year = Month.evaluateAsYear(s2);
11
                    y = Week.evaluateAsYear(s2);
12
                    if (year != null) {
12
                    if (y != null) {
13
                        month = SerialDate.stringToMonthCode(s1);
13
                        w = Week.stringToWeek(s1);
14
                        if (month == -1) {
14
                        if (w == -1) {
15
                            throw new TimePeriodFormatException(
15
                            throw new TimePeriodFormatException(
16
                                "Can't evaluate the month."
16
                                    "Can't evaluate the week.");
17
                   
17
                        }
18
         );
18
                        result = new Week(w, y);
19
          
19
                    }
20
              }
20
                    else {
21
                        result = new Month(mon
21
                        throw new TimePeriodFormatException(
22
th, year);
22
                                "Can't evaluate the year.");
23
                    }
24
                }
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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons7
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                            
    11
    w = Week.stringToWeek(s2);
    11
    month = SerialDate.stringToMonthCode(s2);
                                                                                          
    12
    if (month == -1)
    12
    if (month == -1)
    12
    if (w == -1)
    Differences
    Expression1Expression2Difference
    monthwVARIABLE_NAME_MISMATCH
    12
    if (w == -1)
    13
    throw new TimePeriodFormatException("Can't evaluate the month.");
    13
    throw new TimePeriodFormatException("Can't evaluate the month.");
    13
    throw new TimePeriodFormatException("Can't evaluate the week.");
    Differences
    Expression1Expression2Difference
    "Can't evaluate the month.""Can't evaluate the week."LITERAL_VALUE_MISMATCH
    13
    throw new TimePeriodFormatException("Can't evaluate the week.");
    Precondition Violations (0)
    Row Violation