for (int i = 0; i < exceptionString.length; i++) { long e; if (fmt instanceof NumberFormat) { e = ((NumberFormat) fmt).parse(exceptionString[i]).longValue(); } else { e = timeline.getTime(((SimpleDateFormat) fmt) .parse(exceptionString[i])); } // only add an exception if it is currently an included segment SegmentedTimeline.Segment segment = timeline.getSegment(e); if (segment.inIncludeSegments()) { timeline.addException(e); exceptionList.add(new Long(e)); assertEquals(exceptionList.size(), timeline.getExceptionSegments().size()); assertTrue(segment.inExceptionSegments()); } }
for (int i = 0; i < exceptionString.length; i++) { long e; if (fmt instanceof NumberFormat) { e = ((NumberFormat) fmt).parse(exceptionString[i]).longValue(); } else { e = timeline.getTime(((SimpleDateFormat) fmt) .parse(exceptionString[i])); } timeline.addBaseTimelineException(e); // verify all timeline segments included in the // baseTimeline.segment are now exceptions SegmentedTimeline.Segment segment1 = baseTimeline.getSegment(e); for (SegmentedTimeline.Segment segment2 = timeline.getSegment(segment1.getSegmentStart()); segment2.getSegmentStart() <= segment1.getSegmentEnd(); segment2.inc()) { if (!segment2.inExcludeSegments()) { assertTrue(segment2.inExceptionSegments()); } } }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/axis/junit/SegmentedTimelineTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/axis/junit/SegmentedTimelineTests.java
Method name: long[] verifyFillInExceptions(SegmentedTimeline, String[], Format) Method name: void fillInBaseTimelineExceptions(SegmentedTimeline, String[], Format)
Number of AST nodes: 11 Number of AST nodes: 10
1
for (int i = 0; i < exceptionString.length; i++) {
1
for (int i = 0; i < exceptionString.length; i++) {
2
            long e;
2
            long e;
3
            if (fmt instanceof NumberFormat) {
3
            if (fmt instanceof NumberFormat) {
4
                e = ((NumberFormat) fmt).parse(exceptionString[i]).longValue();
4
                e = ((NumberFormat) fmt).parse(exceptionString[i]).longValue();
5
            }
5
            }
6
            else {
6
            else {
7
                e = timeline.getTime(((SimpleDateFormat) fmt)
7
                e = timeline.getTime(((SimpleDateFormat) fmt)
8
                        .parse(exceptionString[i]));
8
                        .parse(exceptionString[i]));
9
            }
9
            }
10
            // only add an exception if it is currently an included segment
10
            timeline.addBaseTimelineException(e);
11
            // verify all timeline segments included in the 
12
            // baseTimeline.segment are now exceptions
11
            SegmentedTimeline.Segment segment = timeline.getSegment(e);
13
            SegmentedTimeline.Segment segment1 = baseTimeline.getSegment(e);
12
            if (segment.inIncludeSegments()) {
14
            for (Segment
15
edTimeline.Segment segment2 
13
                timeline.addException(e);
16
                    = timeline.
14
                exceptionList.add(new Long(e));
15
                assertEquals(exceptionList.size(), 
16
                        timeline.getException
17
getSegment(segment1.getSegmentStart());
18
                 segment2.getSegmentStart() <= segment1.getSegmentEnd();
19
                 segment2.inc()) {
17
Segments().size());
20
                if (!segment2.inExcludeSegments()) {
18
                assertTrue(segment.inExceptionSegments());
21
                    assertTrue(segment2.inExceptionSegments());
19
            }
22
                }
23
            }
20
        }
24
        }
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)4.1
Clones locationClones are declared in the same class
Number of node comparisons12
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment5
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)16.5
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    5
    long e;
                        
    9
    SegmentedTimeline.Segment segment = timeline.getSegment(e);
    9
    SegmentedTimeline.Segment segment = timeline.getSegment(e);
    Preondition Violations
    Unmatched statement SegmentedTimeline.Segment segment=timeline.getSegment(e); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                            
    10
    if (segment.inIncludeSegments())
    10
    if (segment.inIncludeSegments())
    10
    if (!segment2.inExcludeSegments())
    Differences
    Expression1Expression2Difference
    segment.inIncludeSegments()!segment2.inExcludeSegments()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression segment.inIncludeSegments() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    if (!segment2.inExcludeSegments())
    11
    timeline.addException(e);
    11
    timeline.addException(e);
    Preondition Violations
    Unmatched statement timeline.addException(e); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement timeline.addException(e); 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
                                                              
    12
    exceptionList.add(new Long(e));
    12
    exceptionList.add(new Long(e));
    Preondition Violations
    Unmatched statement exceptionList.add(new Long(e)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                          
    13
    assertEquals(exceptionList.size(), timeline.getExceptionSegments().size());
                                                                                                                                                                
    14
    assertTrue(segment.inExceptionSegments());
    14
    assertTrue(segment.inExceptionSegments());
    11
    assertTrue(segment2.inExceptionSegments());
    Differences
    Expression1Expression2Difference
    segmentsegment2VARIABLE_NAME_MISMATCH
    11
    assertTrue(segment2.inExceptionSegments());
    Precondition Violations (5)
    Row Violation
    1Unmatched statement SegmentedTimeline.Segment segment=timeline.getSegment(e); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression segment.inIncludeSegments() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement timeline.addException(e); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement timeline.addException(e); 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
    5Unmatched statement exceptionList.add(new Long(e)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted