297-3-4

int result; // CASE 1 : Comparing to another Month object // -------------------------------------------- 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; } return result;
int result; // CASE 1 : Comparing to another Quarter object // -------------------------------------------- if (o1 instanceof Quarter) { Quarter q = (Quarter) o1; result = this.year - q.getYearValue(); if (result == 0) { result = this.quarter - q.getQuarter(); } } // 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; } return result;

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/Quarter.java
Method name: `int compareTo(Object)` |  | Method name: `int compareTo(Object)`
Number of AST nodes: 10 |  | Number of AST nodes: 10

1

    int result;↵

1

    int result;↵

2

            // CASE 1 : Comparing to another Month object↵

2

            // CASE 1 : Comparing to another Quarter object↵

3

            // --------------------------------------------↵

3

            // --------------------------------------------↵

4

            if (o1 instanceof Month) {↵

4

            if (o1 instanceof Quarter) {↵

5

                Month m = (Month) o1;↵

5

                Quarter q = (Quarter) o1;↵

6

                result = this.year - m.getYearValue();↵

6

                result = this.year - q.getYearValue();↵

7

                if (result == 0) {↵

7

                if (result == 0) {↵

8

                    result = this.month - m.getMonth();↵

8

                    result = this.quarter - q.getQuarter();↵

9

                }↵

9

                }↵

10

            }↵

10

            }↵

11

            // CASE 2 : Comparing to another TimePeriod object↵

11

            // CASE 2 : Comparing to another TimePeriod object↵

12

            // -----------------------------------------------↵

12

            // -----------------------------------------------↵

13

            else if (o1 instanceof RegularTimePeriod) {↵

13

            else if (o1 instanceof RegularTimePeriod) {↵

14

                // more difficult case - evaluate later...↵

14

                // more difficult case - evaluate later...↵

15

                result = 0;↵

15

                result = 0;↵

16

            }↵

16

            }↵

17

            // CASE 3 : Comparing to a non-TimePeriod object↵

17

            // CASE 3 : Comparing to a non-TimePeriod object↵

18

            // ---------------------------------------------↵

18

            // ---------------------------------------------↵

19

            else {↵

19

            else {↵

20

                // consider time periods to be ordered after general objects↵

20

                // consider time periods to be ordered after general objects↵

21

                result = 1;↵

21

                result = 1;↵

22

            }↵

22

            }↵

23

            return result;

23

            return result;

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.2
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 26

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 2
   Number of unmapped statements in the second code fragment | 2
   Time elapsed for statement mapping (ms) | 1.3
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       int result;

   1

       int result;

   2

       if (o1 instanceof Month)

   2 | if (o1 instanceof Month)
   2 | if (o1 instanceof Quarter)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Month | org.jfree.data.time.Quarter | SUBCLASS_TYPE_MISMATCH

   2

       if (o1 instanceof Quarter)

   3

       Month m = (Month)o1;

   3 | Month m = (Month)o1;
   3 | Quarter q = (Quarter)o1;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Month | org.jfree.data.time.Quarter | SUBCLASS_TYPE_MISMATCH
   m | q | VARIABLE_NAME_MISMATCH
   org.jfree.data.time.Month | org.jfree.data.time.Quarter | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.time.Month | org.jfree.data.time.Quarter | SUBCLASS_TYPE_MISMATCH

   3

       Quarter q = (Quarter)o1;

   4 | result = this.year - q.getYearValue();

   Preondition Violations
   Unmatched statement result=this.year - q.getYearValue(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   4

       result = this.year - q.getYearValue();

   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.quarter - q.getQuarter();

   Preondition Violations
   Unmatched statement result=this.quarter - q.getQuarter(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   6

       result = this.quarter - q.getQuarter();

   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;

   10

       return result;

   10

       return result;

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | Unmatched statement result=this.year - q.getYearValue(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | 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
   3 | Unmatched statement result=this.quarter - q.getQuarter(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   4 | 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
   5 | Clone fragment #1 returns variables result, m , while Clone fragment #2 returns variables result, q