if (item == null) { throw new IllegalArgumentException("Null 'item' argument."); } if (this.autoSort) { int index = Collections.binarySearch(this.data, item); if (index < 0) { this.data.add(-index - 1, item); } else { 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."); } } } else { if (!this.allowDuplicateXValues) { // can't allow duplicate values, so we need to check whether // there is an item with the given x-value already int index = indexOf(item.getComparable()); if (index >= 0) { throw new SeriesException("X-value already exists."); } } this.data.add(item); } if (getItemCount() > this.maximumItemCount) { this.data.remove(0); } if (notify) { fireSeriesChanged(); }
if (item == null) { throw new IllegalArgumentException("Null 'item' argument."); } if (this.autoSort) { int index = Collections.binarySearch(this.data, item); if (index < 0) { this.data.add(-index - 1, item); } else { 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."); } } } else { if (!this.allowDuplicateXValues) { // can't allow duplicate values, so we need to check whether // there is an item with the given x-value already int index = indexOf(item.getX()); if (index >= 0) { throw new SeriesException("X-value already exists."); } } this.data.add(item); } if (getItemCount() > this.maximumItemCount) { this.data.remove(0); } if (notify) { fireSeriesChanged(); }
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: 23 Number of AST nodes: 23
1
if (item == null) {
1
if (item == null) {
2
            throw new IllegalArgumentException("Null 'item' argument.");
2
            throw new IllegalArgumentException("Null 'item' argument.");
3
        }
3
        }
4
        if (this.autoSort) {
4
        if (this.autoSort) {
5
            int index = Collections.binarySearch(this.data, item);
5
            int index = Collections.binarySearch(this.data, item);
6
            if (index < 0) {
6
            if (index < 0) {
7
                this.data.add(-index - 1, item);
7
                this.data.add(-index - 1, item);
8
            }
8
            }
9
            else {
9
            else {
10
                if (this.allowDuplicateXValues) {
10
                if (this.allowDuplicateXValues) {
11
                    // need to make sure we are adding *after* any duplicates
11
                    // need to make sure we are adding *after* any duplicates
12
                    int size = this.data.size();
12
                    int size = this.data.size();
13
                    while (index < size 
13
                    while (index < size
14
                           && item.compareTo(this.data.get(index)) == 0) {
14
                           && item.compareTo(this.data.get(index)) == 0) {
15
                        index++;
15
                        index++;
16
                    }
16
                    }
17
                    if (index < this.data.size()) {
17
                    if (index < this.data.size()) {
18
                        this.data.add(index, item);
18
                        this.data.add(index, item);
19
                    }
19
                    }
20
                    else {
20
                    else {
21
                        this.data.add(item);
21
                        this.data.add(item);
22
                    }
22
                    }
23
                }
23
                }
24
                else {
24
                else {
25
                    throw new SeriesException("X-value already exists.");
25
                    throw new SeriesException("X-value already exists.");
26
                }
26
                }
27
            }
27
            }
28
        }
28
        }
29
        else {
29
        else {
30
            if (!this.allowDuplicateXValues) {
30
            if (!this.allowDuplicateXValues) {
31
                // can't allow duplicate values, so we need to check whether
31
                // can't allow duplicate values, so we need to check whether
32
                // there is an item with the given x-value already
32
                // there is an item with the given x-value already
33
                int index = indexOf(item.getComparable());
33
                int index = indexOf(item.getX());
34
                if (index >= 0) {
34
                if (index >= 0) {
35
                    throw new SeriesException("X-value already exists.");      
35
                    throw new SeriesException("X-value already exists.");
36
                }
36
                }
37
            }
37
            }
38
            this.data.add(item);
38
            this.data.add(item);
39
        }
39
        }
40
        if (getItemCount() > this.maximumItemCount) {
40
        if (getItemCount() > this.maximumItemCount) {
41
            this.data.remove(0);
41
            this.data.remove(0);
42
        }                    
42
        }
43
        if (notify) {
43
        if (notify) {
44
            fireSeriesChanged();
44
            fireSeriesChanged();
45
        }
45
        }
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)2.4
Clones locationClones are in different classes having the same super class
Number of node comparisons72
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements23
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)88.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (item == null)
    1
    if (item == null)
    1
    if (item == null)
    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
    1
    if (item == null)
    2
    throw new IllegalArgumentException("Null 'item' argument.");
    2
    throw new IllegalArgumentException("Null 'item' argument.");
    3
    if (this.autoSort)
    3
    if (this.autoSort)
    4
    int index = Collections.binarySearch(this.data, item);
    4
    int index = Collections.binarySearch(this.data, item);
    4
    int index = Collections.binarySearch(this.data, 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
    4
    int index = Collections.binarySearch(this.data, item);
    5
    if (index < 0)
    5
    if (index < 0)
    6
    this.data.add(-index - 1, item);
    6
    this.data.add(-index - 1, item);
    6
    this.data.add(-index - 1, 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
    6
    this.data.add(-index - 1, item);
    else
    else
    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.");
    else
    else
    15
    if (!this.allowDuplicateXValues)
    15
    if (!this.allowDuplicateXValues)
    16
    int index = indexOf(item.getComparable());
    16
    int index = indexOf(item.getComparable());
    16
    int index = indexOf(item.getX());
    Differences
    Expression1Expression2Difference
    getComparablegetXMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Comparablejava.lang.NumberVARIABLE_TYPE_MISMATCH
    org.jfree.data.ComparableObjectItemorg.jfree.data.xy.XYDataItemVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression item.getComparable() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression item.getX() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.Comparable of variable item.getComparable() does not match with type java.lang.Number of variable item.getX()
    • Make classes java.lang.Comparable and java.lang.Number extend a common superclass
    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
    16
    int index = indexOf(item.getX());
    17
    if (index >= 0)
    17
    if (index >= 0)
    18
    throw new SeriesException("X-value already exists.");
    18
    throw new SeriesException("X-value already exists.");
    19
    this.data.add(item);
    19
    this.data.add(item);
    19
    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
    19
    this.data.add(item);
    20
    if (getItemCount() > this.maximumItemCount)
    20
    if (getItemCount() > this.maximumItemCount)
    21
    this.data.remove(0);
    21
    this.data.remove(0);
    22
    if (notify)
    22
    if (notify)
    23
    fireSeriesChanged();
    23
    fireSeriesChanged();
    Precondition Violations (11)
    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
    4Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    5Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    6Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    7Expression item.getComparable() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression item.getX() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Type java.lang.Comparable of variable item.getComparable() does not match with type java.lang.Number of variable item.getX()
    10Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item
    11Type org.jfree.data.ComparableObjectItem of variable item does not match with type org.jfree.data.xy.XYDataItem of variable item