int result; // CASE 1 : Comparing to another Hour object // ----------------------------------------- if (o1 instanceof Hour) { Hour h = (Hour) o1; result = getDay().compareTo(h.getDay()); if (result == 0) { result = this.hour - h.getHour(); } } // 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 Minute object // ------------------------------------------- if (o1 instanceof Minute) { Minute m = (Minute) o1; result = getHour().compareTo(m.getHour()); if (result == 0) { result = this.minute - m.getMinute(); } } // 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/Hour.java File path: /jfreechart-1.0.10/src/org/jfree/data/time/Minute.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 Hour object
2
        // CASE 1 : Comparing to another Minute object
3
        // -----------------------------------------
3
        // -------------------------------------------
4
        if (o1 instanceof Hour) {
4
        if (o1 instanceof Minute) {
5
            Hour h = (Hour) o1;
5
            Minute m = (Minute) o1;
6
            result = getDay().compareTo(h.getDay());
6
            result = getHour().compareTo(m.getHour());
7
            if (result == 0) {
7
            if (result == 0) {
8
                result = this.hour - h.getHour();
8
                result = this.minute - m.getMinute();
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;
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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons26
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)6.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    int result;
    1
    int result;
    2
    if (o1 instanceof Hour)
    2
    if (o1 instanceof Hour)
    2
    if (o1 instanceof Minute)
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    2
    if (o1 instanceof Minute)
    3
    Hour h = (Hour)o1;
    3
    Hour h = (Hour)o1;
    3
    Minute m = (Minute)o1;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    hmVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression (Hour)o1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (Minute)o1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    Minute m = (Minute)o1;
    4
    result = getDay().compareTo(h.getDay());
    4
    result = getDay().compareTo(h.getDay());
    4
    result = getHour().compareTo(m.getHour());
    Differences
    Expression1Expression2Difference
    getDaygetHourMETHOD_INVOCATION_NAME_MISMATCH
    hmVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    getDaygetHourMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression h.getDay() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression m.getHour() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression h cannot be unified with expression m , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public org.jfree.data.time.Day getDay() , public org.jfree.data.time.Hour getHour()
    4
    result = getHour().compareTo(m.getHour());
    5
    if (result == 0)
    5
    if (result == 0)
    6
    result = this.hour - h.getHour();
    6
    result = this.hour - h.getHour();
    6
    result = this.minute - m.getMinute();
    Differences
    Expression1Expression2Difference
    hourminuteVARIABLE_NAME_MISMATCH
    getHourgetMinuteMETHOD_INVOCATION_NAME_MISMATCH
    hmVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression h.getHour() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression m.getMinute() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression h cannot be unified with expression m , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getHour() , public int getMinute()
    6
    result = this.minute - m.getMinute();
    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 (8)
    Row Violation
    1Expression (Hour)o1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression (Minute)o1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression h.getDay() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression m.getHour() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression h cannot be unified with expression m , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public org.jfree.data.time.Day getDay() , public org.jfree.data.time.Hour getHour()
    6Expression h.getHour() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression m.getMinute() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression h cannot be unified with expression m , because common superclass org.jfree.data.time.RegularTimePeriod does not declare member(s) public int getHour() , public int getMinute()