if (this.allowDuplicateXValues) { // need to make sure we are adding *after* any duplicates int size = this.data.size(); while (index < size && item.compareTo(this.data.get(index)) == 0) { index++; } if (index < this.data.size()) { this.data.add(index, item); } else { this.data.add(item); } } else { throw new SeriesException("X-value already exists."); }
if (this.allowDuplicateXValues) { // need to make sure we are adding *after* any duplicates int size = this.data.size(); while (index < size && item.compareTo(this.data.get(index)) == 0) { index++; } if (index < this.data.size()) { this.data.add(index, item); } else { this.data.add(item); } } else { throw new SeriesException("X-value already exists."); }
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/ComparableObjectSeries.java File path: /jfreechart-1.0.10/src/org/jfree/data/xy/XYSeries.java
Method name: void add(ComparableObjectItem, boolean) Method name: void add(XYDataItem, boolean)
Number of AST nodes: 8 Number of AST nodes: 8
1
if (this.allowDuplicateXValues) {
1
if (this.allowDuplicateXValues) {
2
                    // need to make sure we are adding *after* any duplicates
2
                    // need to make sure we are adding *after* any duplicates
3
                    int size = this.data.size();
3
                    int size = this.data.size();
4
                    while (index < size 
4
                    while (index < size
5
                           && item.compareTo(this.data.get(index)) == 0) {
5
                           && item.compareTo(this.data.get(index)) == 0) {
6
                        index++;
6
                        index++;
7
                    }
7
                    }
8
                    if (index < this.data.size()) {
8
                    if (index < this.data.size()) {
9
                        this.data.add(index, item);
9
                        this.data.add(index, item);
10
                    }
10
                    }
11
                    else {
11
                    else {
12
                        this.data.add(item);
12
                        this.data.add(item);
13
                    }
13
                    }
14
                }
14
                }
15
                else {
15
                else {
16
                    throw new SeriesException("X-value already exists.");
16
                    throw new SeriesException("X-value already exists.");
17
                }
17
                }
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.7
Clones locationClones are in different classes having the same super class
Number of node comparisons30
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    7
    if (this.allowDuplicateXValues)
    7
    if (this.allowDuplicateXValues)
    8
    int size = this.data.size();
    8
    int size = this.data.size();
    9
    while (index < size && item.compareTo(this.data.get(index)) == 0)
    9
    while (index < size && item.compareTo(this.data.get(index)) == 0)
    9
    while (index < size && item.compareTo(this.data.get(index)) == 0)
    Differences
    Expression1Expression2Difference
    org.jfree.data.ComparableObjectItemorg.jfree.data.xy.XYDataItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    • Make classes org.jfree.data.ComparableObjectItem and org.jfree.data.xy.XYDataItem extend a common superclass
    9
    while (index < size && item.compareTo(this.data.get(index)) == 0)
    10
    index++;
    10
    index++;
    11
    if (index < this.data.size())
    11
    if (index < this.data.size())
    12
    this.data.add(index, item);
    12
    this.data.add(index, item);
    12
    this.data.add(index, item);
    Differences
    Expression1Expression2Difference
    org.jfree.data.ComparableObjectItemorg.jfree.data.xy.XYDataItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    • Make classes org.jfree.data.ComparableObjectItem and org.jfree.data.xy.XYDataItem extend a common superclass
    12
    this.data.add(index, item);
    else
    else
    13
    this.data.add(item);
    13
    this.data.add(item);
    13
    this.data.add(item);
    Differences
    Expression1Expression2Difference
    org.jfree.data.ComparableObjectItemorg.jfree.data.xy.XYDataItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    • Make classes org.jfree.data.ComparableObjectItem and org.jfree.data.xy.XYDataItem extend a common superclass
    13
    this.data.add(item);
    else
    else
    14
    throw new SeriesException("X-value already exists.");
    14
    throw new SeriesException("X-value already exists.");
    Precondition Violations (3)
    Row Violation
    1Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    2Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    3Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item