1283-1-4

int year = this.serialDate.getYYYY(); int month = this.serialDate.getMonth(); int day = this.serialDate.getDayOfMonth(); calendar.clear(); calendar.set(year, month - 1, day, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime();
int year = this.day.getYear(); int month = this.day.getMonth() - 1; int dom = this.day.getDayOfMonth(); calendar.set(year, month, dom, this.hour, 59, 59); calendar.set(Calendar.MILLISECOND, 999); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime();

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/time/Day.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/time/Hour.java
Method name: `long getFirstMillisecond(Calendar)` |  | Method name: `long getLastMillisecond(Calendar)`
Number of AST nodes: 7 |  | Number of AST nodes: 6

1

    int year = this.serialDate.getYYYY();↵

1

    int year = this.day.getYear();↵

2

            int month = this.serialDate.getMonth();↵

2

            int month = this.day.getMonth() - 1;↵

3

            int day = this.serialDate.getDayOfMonth();↵

3

            int dom = this.day.getDayOfMonth();↵

4

            calendar.clear();↵

5

            calendar.set(year, month - 1, day, 0, 0, 0);↵

4

            calendar.set(year, month, dom, this.hour, 59, 59);↵

6

            calendar.set(Calendar.MILLISECOND, 0);↵

5

            calendar.set(Calendar.MILLISECOND, 999);↵

7

            //return calendar.getTimeInMillis();  // this won't work for JDK 1.3↵

6

            //return calendar.getTimeInMillis();  // this won't work for JDK 1.3↵

8

            return calendar.getTime().getTime();

7

            return calendar.getTime().getTime();

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

1. {Non-refactorable}

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

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

   1

       int year = this.day.getYear();

   1

       int year = this.serialDate.getYYYY();

   2

       int month = this.serialDate.getMonth();

   2 | int month = this.serialDate.getMonth();
   2 | int month = this.day.getMonth() - 1;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   this.serialDate.getMonth() | this.day.getMonth() - 1 | TYPE_COMPATIBLE_REPLACEMENT

   2

       int month = this.day.getMonth() - 1;

   3

       int day = this.serialDate.getDayOfMonth();

   3 | int day = this.serialDate.getDayOfMonth();
   3 | int dom = this.day.getDayOfMonth();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   day | dom | VARIABLE_NAME_MISMATCH
   serialDate | day | VARIABLE_NAME_MISMATCH
   org.jfree.date.SerialDate | org.jfree.data.time.Day | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.date.SerialDate of variable this.serialDate does not match with type org.jfree.data.time.Day of variable this.day
   - Make classes org.jfree.date.SerialDate and org.jfree.data.time.Day extend a common superclass

   3

       int dom = this.day.getDayOfMonth();

   4

       calendar.clear();

   4 | calendar.clear();
   4 | calendar.set(year, month, dom, this.hour, 59, 59);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   clear | set | METHOD_INVOCATION_NAME_MISMATCH
   calendar.clear() | calendar.set(year,month,dom,this.hour,59,59) | ARGUMENT_NUMBER_MISMATCH

   Preondition Violations
   Expression calendar.set(year,month,dom,this.hour,59,59) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression calendar.clear() is a void method call, and thus it cannot be parameterized
   Expression calendar.set(year,month,dom,this.hour,59,59) is a void method call, and thus it cannot be parameterized
   Expression calendar.set(year,month,dom,this.hour,59,59) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression calendar.clear() is a void method call, and thus it cannot be parameterized
   Expression calendar.set(year,month,dom,this.hour,59,59) is a void method call, and thus it cannot be parameterized

   4

       calendar.set(year, month, dom, this.hour, 59, 59);

   5

       calendar.set(year, month - 1, day, 0, 0, 0);

   5 | calendar.set(year, month - 1, day, 0, 0, 0);
   5 | calendar.set(Calendar.MILLISECOND, 999);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   calendar.set(year,month - 1,day,0,0,0) | calendar.set(Calendar.MILLISECOND,999) | ARGUMENT_NUMBER_MISMATCH

   Preondition Violations
   Expression calendar.set(year,month - 1,day,0,0,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression calendar.set(Calendar.MILLISECOND,999) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression calendar.set(year,month - 1,day,0,0,0) is a void method call, and thus it cannot be parameterized
   Expression calendar.set(Calendar.MILLISECOND,999) is a void method call, and thus it cannot be parameterized

   5

       calendar.set(Calendar.MILLISECOND, 999);

   6

       calendar.set(Calendar.MILLISECOND, 0);

   6 | calendar.set(Calendar.MILLISECOND, 0);

   Preondition Violations
   Unmatched statement calendar.set(Calendar.MILLISECOND,0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   7

       return calendar.getTime().getTime();

   6

       return calendar.getTime().getTime();

   Precondition Violations (12)
   Row | Violation
   --- | ---
   1 | Type org.jfree.date.SerialDate of variable this.serialDate does not match with type org.jfree.data.time.Day of variable this.day
   2 | Expression calendar.set(year,month,dom,this.hour,59,59) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression calendar.clear() is a void method call, and thus it cannot be parameterized
   4 | Expression calendar.set(year,month,dom,this.hour,59,59) is a void method call, and thus it cannot be parameterized
   5 | Expression calendar.set(year,month,dom,this.hour,59,59) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression calendar.clear() is a void method call, and thus it cannot be parameterized
   7 | Expression calendar.set(year,month,dom,this.hour,59,59) is a void method call, and thus it cannot be parameterized
   8 | Expression calendar.set(year,month - 1,day,0,0,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   9 | Expression calendar.set(Calendar.MILLISECOND,999) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Expression calendar.set(year,month - 1,day,0,0,0) is a void method call, and thus it cannot be parameterized
   11 | Expression calendar.set(Calendar.MILLISECOND,999) is a void method call, and thus it cannot be parameterized
   12 | Unmatched statement calendar.set(Calendar.MILLISECOND,0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted