if (o1 instanceof Month) { Month m = (Month) o1; result = this.year - m.getYearValue(); if (result == 0) { result = this.month - m.getMonth(); } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; }
if (o1 instanceof Week) { Week w = (Week) o1; result = this.year - w.getYear().getYear(); if (result == 0) { result = this.week - w.getWeek(); } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; }
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: int compareTo(Object) Method name: int compareTo(Object)
Number of AST nodes: 8 Number of AST nodes: 8
1
if (o1 instanceof Month) {
1
if (o1 instanceof Week) {
2
            Month m = (Month) o1;
2
            Week w = (Week) o1;
3
            result = this.year - m.getYearValue();
3
            result = this.year - w.getYear().getYear();
4
            if (result == 0) {
4
            if (result == 0) {
5
                result = this.month - m.getMonth();
5
                result = this.week - w.getWeek();
6
            }
6
            }
7
        }
7
        }
8
        // CASE 2 : Comparing to another TimePeriod object
8
        // CASE 2 : Comparing to another TimePeriod object
9
        // -----------------------------------------------
9
        // -----------------------------------------------
10
        else if (o1 instanceof RegularTimePeriod) {
10
        else if (o1 instanceof RegularTimePeriod) {
11
            // more difficult case - evaluate later...
11
            // more difficult case - evaluate later...
12
            result = 0;
12
            result = 0;
13
        }
13
        }
14
        // CASE 3 : Comparing to a non-TimePeriod object
14
        // CASE 3 : Comparing to a non-TimePeriod object
15
        // ---------------------------------------------
15
        // ---------------------------------------------
16
        else {
16
        else {
17
            // consider time periods to be ordered after general objects
17
            // consider time periods to be ordered after general objects
18
            result = 1;
18
            result = 1;
19
        }
19
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes having the same super class
Number of node comparisons22
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)3.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    if (o1 instanceof Month)
    2
    if (o1 instanceof Month)
    2
    if (o1 instanceof Week)
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Monthorg.jfree.data.time.WeekSUBCLASS_TYPE_MISMATCH
    2
    if (o1 instanceof Week)
    3
    Month m = (Month)o1;
    3
    Month m = (Month)o1;
    3
    Week w = (Week)o1;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Monthorg.jfree.data.time.WeekSUBCLASS_TYPE_MISMATCH
    mwVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.WeekSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Monthorg.jfree.data.time.WeekSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (Month)o1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (Week)o1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    Week w = (Week)o1;
                                                                                            
    4
    result = this.year - w.getYear().getYear();
    Preondition Violations
    Unmatched statement result=this.year - w.getYear().getYear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    result = this.year - w.getYear().getYear();
    4
    result = this.year - m.getYearValue();
    4
    result = this.year - m.getYearValue();
    Preondition Violations
    Unmatched statement result=this.year - m.getYearValue(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                  
    5
    if (result == 0)
    5
    if (result == 0)
                                                                        
    6
    result = this.week - w.getWeek();
    Preondition Violations
    Unmatched statement result=this.week - w.getWeek(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    result = this.week - w.getWeek();
    6
    result = this.month - m.getMonth();
    6
    result = this.month - m.getMonth();
    Preondition Violations
    Unmatched statement result=this.month - m.getMonth(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                            
    7
    else if (o1 instanceof RegularTimePeriod)
    7
    else if (o1 instanceof RegularTimePeriod)
    8
    result = 0;
    8
    result = 0;
    else
    else
    9
    result = 1;
    9
    result = 1;
    Precondition Violations (7)
    Row Violation
    1Expression (Month)o1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression (Week)o1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement result=this.year - w.getYear().getYear(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement result=this.year - m.getYearValue(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement result=this.week - w.getWeek(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement result=this.month - m.getMonth(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Clone fragment #1 returns variables m, result , while Clone fragment #2 returns variables w, result