Hour result; if (this.hour != FIRST_HOUR_IN_DAY) { result = new Hour(this.hour - 1, this.day); } else { // we are at the first hour in the day... Day prevDay = (Day) this.day.previous(); if (prevDay != null) { result = new Hour(LAST_HOUR_IN_DAY, prevDay); } else { result = null; } } return result;
RegularTimePeriod result = null; if (this.millisecond != LAST_MILLISECOND_IN_SECOND) { result = new Millisecond(this.millisecond + 1, getSecond()); } else { Second next = (Second) getSecond().next(); if (next != null) { result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next); } } 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/Millisecond.java
Method name: RegularTimePeriod previous() Method name: RegularTimePeriod next()
Number of AST nodes: 8 Number of AST nodes: 7
1
Hour result;
1
RegularTimePeriod result = null;
2
        if (this.hour != FIRST_HOUR_IN_DAY) {
2
        if (this.
3
            result = new Hour(this.hour - 1, this.day);
4
        }
5
        else { // we are at the first hour in the day...
6
            Day prevDay = (Day) this.day.previous
3
millisecond != LAST_MILLISECOND_IN_SECOND) {
4
            result = new Millisecond(this.millisecond + 1, getSecond());
5
        }
6
        else {
7
();
7
            Second next = (Second) getSecond().next();
8
            if (prevDay != null) {
8
            if (next != null) {
9
                result = new Hour(LAST_HOUR_IN_DAY, prevDay);
9
                result = new 
10
            }
11
            else {
12
                result = null;
10
Millisecond(FIRST_MILLISECOND_IN_SECOND, next);
13
            }
11
            }
14
        }
12
        }
15
        return result;
13
        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.2
Clones locationClones are in different classes having the same super class
Number of node comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)8.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                      
    1
    RegularTimePeriod result = null;
    1
    Hour result;
                                  
    2
    if (this.hour != FIRST_HOUR_IN_DAY)
    2
    if (this.hour != FIRST_HOUR_IN_DAY)
    2
    if (this.millisecond != LAST_MILLISECOND_IN_SECOND)
    Differences
    Expression1Expression2Difference
    hourmillisecondVARIABLE_NAME_MISMATCH
    byteintVARIABLE_TYPE_MISMATCH
    FIRST_HOUR_IN_DAYLAST_MILLISECOND_IN_SECONDVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type byte of variable this.hour does not match with type int of variable this.millisecond
    2
    if (this.millisecond != LAST_MILLISECOND_IN_SECOND)
                                                                                                                            
    3
    result = new Millisecond(this.millisecond + 1, getSecond());
    Preondition Violations
    Unmatched statement result=new Millisecond(this.millisecond + 1,getSecond()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement result=new Millisecond(this.millisecond + 1,getSecond()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    3
    result = new Millisecond(this.millisecond + 1, getSecond());
    3
    result = new Hour(this.hour - 1, this.day);
    3
    result = new Hour(this.hour - 1, this.day);
    Preondition Violations
    Unmatched statement result=new Hour(this.hour - 1,this.day); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement result=new Hour(this.hour - 1,this.day); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                          
    else
    else
    4
    Day prevDay = (Day)this.day.previous();
    4
    Day prevDay = (Day)this.day.previous();
    4
    Second next = (Second)getSecond().next();
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Dayorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    prevDaynextVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    previousnextMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    this.daygetSecond()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (Second)getSecond().next() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression getSecond().next() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression getSecond() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    4
    Second next = (Second)getSecond().next();
                                          
    5
    if (next != null)
    Preondition Violations
    Unmatched statement if(next != null) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    if (next != null)
                                                                                                                            
    6
    result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next);
    Preondition Violations
    Unmatched statement result=new Millisecond(FIRST_MILLISECOND_IN_SECOND,next); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6
    result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next);
    5
    if (prevDay != null)
    5
    if (prevDay != null)
    Preondition Violations
    Unmatched statement if(prevDay != null) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                
    6
    result = new Hour(LAST_HOUR_IN_DAY, prevDay);
    6
    result = new Hour(LAST_HOUR_IN_DAY, prevDay);
    Preondition Violations
    Unmatched statement result=new Hour(LAST_HOUR_IN_DAY,prevDay); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                              
    else
            
    7
    result = null;
                                  
    8
    return result;
    8
    return result;
    7
    return result;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Hourorg.jfree.data.time.RegularTimePeriodSUBCLASS_TYPE_MISMATCH
    7
    return result;
    Precondition Violations (13)
    Row Violation
    1Type byte of variable this.hour does not match with type int of variable this.millisecond
    2Unmatched statement result=new Millisecond(this.millisecond + 1,getSecond()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement result=new Millisecond(this.millisecond + 1,getSecond()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    4Unmatched statement result=new Hour(this.hour - 1,this.day); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement result=new Hour(this.hour - 1,this.day); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    6Expression (Second)getSecond().next() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    7Expression getSecond().next() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    8Expression getSecond() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    9Unmatched statement if(next != null) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement result=new Millisecond(FIRST_MILLISECOND_IN_SECOND,next); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement if(prevDay != null) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement result=new Hour(LAST_HOUR_IN_DAY,prevDay); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Clone fragment #1 returns variable prevDay with type org.jfree.data.time.Day , while Clone fragment #2 returns variable next with type org.jfree.data.time.Second