143-1-2

if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Number result = null; // if the dataset implements DomainInfo, life is easy if (dataset instanceof DomainInfo) { DomainInfo info = (DomainInfo) dataset; return new Double(info.getDomainLowerBound(true)); } else { double minimum = Double.POSITIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value; if (dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; value = intervalXYData.getStartXValue(series, item); } else { value = dataset.getXValue(series, item); } if (!Double.isNaN(value)) { minimum = Math.min(minimum, value); } } } if (minimum == Double.POSITIVE_INFINITY) { result = null; } else { result = new Double(minimum); } } return result;
if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Number result = null; // if the dataset implements DomainInfo, life is easy if (dataset instanceof DomainInfo) { DomainInfo info = (DomainInfo) dataset; return new Double(info.getDomainUpperBound(true)); } // hasn't implemented DomainInfo, so iterate... else { double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value; if (dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; value = intervalXYData.getEndXValue(series, item); } else { value = dataset.getXValue(series, item); } if (!Double.isNaN(value)) { maximum = Math.max(maximum, value); } } } if (maximum == Double.NEGATIVE_INFINITY) { result = null; } else { result = new Double(maximum); } } return result;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/general/DatasetUtilities.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/general/DatasetUtilities.java
Method name: `Number findMinimumDomainValue(XYDataset)` |  | Method name: `Number findMaximumDomainValue(XYDataset)`
Number of AST nodes: 22 |  | Number of AST nodes: 22

1

    if (dataset == null) {↵

1

    if (dataset == null) {↵

2

                throw new IllegalArgumentException("Null 'dataset' argument.");↵

2

                throw new IllegalArgumentException("Null 'dataset' argument.");↵

3

            }↵

3

            }↵

4

            Number result = null;↵

4

            Number result = null;↵

5

            // if the dataset implements DomainInfo, life is easy↵

5

            // if the dataset implements DomainInfo, life is easy↵

6

            if (dataset instanceof DomainInfo) {↵

6

            if (dataset instanceof DomainInfo) {↵

7

                DomainInfo info = (DomainInfo) dataset;↵

7

                DomainInfo info = (DomainInfo) dataset;↵

8

                return new Double(info.getDomainLowerBound(true));↵

8

                return new Double(info.getDomainUpperBound(true));↵

9

            }
    ↵

9

            }
    ↵

10

            // hasn't implemented DomainInfo, so iterate...
    ↵

10

            else {↵

11

            else {↵

11

                double minimum = Double.POSITIVE_INFINITY;↵

12

                double maximum = Double.NEGATIVE_INFINITY;↵

12

                int seriesCount = dataset.getSeriesCount();↵

13

                int seriesCount = dataset.getSeriesCount();↵

13

                for (int series = 0; series < seriesCount; series++) {↵

14

                for (int series = 0; series < seriesCount; series++) {↵

14

                    int itemCount = dataset.getItemCount(series);↵

15

                    int itemCount = dataset.getItemCount(series);↵

15

                    for (int item = 0; item < itemCount; item++) {↵

16

                    for (int item = 0; item < itemCount; item++) {↵

16

                        double value;↵

17

                        double value;↵

17

                        if (dataset instanceof IntervalXYDataset) {↵

18

                        if (dataset instanceof IntervalXYDataset) {↵

18

                            IntervalXYDataset intervalXYData↵

19

                            IntervalXYDataset intervalXYData↵

19

                                = (IntervalXYDataset) dataset;↵

20

                                = (IntervalXYDataset) dataset;↵

20

                            value = intervalXYData.getStartXValue(series, item);↵

21

                            value = intervalXYData.getEndXValue(series, item);↵

21

                        }↵

22

                        }↵

22

                        else {↵

23

                        else {↵

23

                            value = dataset.getXValue(series, item);↵

24

                            value = dataset.getXValue(series, item);↵

24

                        }↵

25

                        }↵

25

                        if (!Double.isNaN(value)) {↵

26

                        if (!Double.isNaN(value)) {↵

26

                            minimum = Math.min(minimum, value);↵

27

                            maximum = Math.max(maximum, value);↵

27

                        }↵

28

                        }↵

28

                    }↵

29

                    }↵

29

                }↵

30

                }↵

30

                if (minimum == Double.POSITIVE_INFINITY) {↵

31

                if (maximum == Double.NEGATIVE_INFINITY) {↵

31

                    result = null;↵

32

                    result = null;↵

32

                }↵

33

                }↵

33

                else {↵

34

                else {↵

34

                    result = new Double(minimum);↵

35

                    result = new Double(maximum);↵

35

                }↵

36

                }↵

36

            }↵

37

            }↵

37

            return result;

38

            return result;

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.6
Clones location | Clones are declared in the same class
Number of node comparisons | 92

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 22
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 4.9
   Clone type | Type 2

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

   1

       if (dataset == null)

   1

       if (dataset == null)

   2

       throw new IllegalArgumentException("Null 'dataset' argument.");

   2

       throw new IllegalArgumentException("Null 'dataset' argument.");

   3

       Number result = null;

   3

       Number result = null;

   4

       if (dataset instanceof DomainInfo)

   4

       if (dataset instanceof DomainInfo)

   5

       DomainInfo info = (DomainInfo)dataset;

   5

       DomainInfo info = (DomainInfo)dataset;

   6

       return new Double(info.getDomainLowerBound(true));

   6 | return new Double(info.getDomainLowerBound(true));
   6 | return new Double(info.getDomainUpperBound(true));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getDomainLowerBound | getDomainUpperBound | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression info.getDomainLowerBound(true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression info.getDomainUpperBound(true) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   6

       return new Double(info.getDomainUpperBound(true));

       else

       else

   7

       double minimum = Double.POSITIVE_INFINITY;

   7 | double minimum = Double.POSITIVE_INFINITY;
   7 | double maximum = Double.NEGATIVE_INFINITY;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   minimum | maximum | VARIABLE_NAME_MISMATCH
   POSITIVE_INFINITY | NEGATIVE_INFINITY | VARIABLE_NAME_MISMATCH

   7

       double maximum = Double.NEGATIVE_INFINITY;

   8

       int seriesCount = dataset.getSeriesCount();

   8

       int seriesCount = dataset.getSeriesCount();

   9

       for (int series = 0; series < seriesCount; series++)

   9

       for (int series = 0; series < seriesCount; series++)

   10

       int itemCount = dataset.getItemCount(series);

   10

       int itemCount = dataset.getItemCount(series);

   11

       for (int item = 0; item < itemCount; item++)

   11

       for (int item = 0; item < itemCount; item++)

   12

       double value;

   12

       double value;

   13

       if (dataset instanceof IntervalXYDataset)

   13

       if (dataset instanceof IntervalXYDataset)

   14

       IntervalXYDataset intervalXYData = (IntervalXYDataset)dataset;

   14

       IntervalXYDataset intervalXYData = (IntervalXYDataset)dataset;

   15

       value = intervalXYData.getStartXValue(series, item);

   15 | value = intervalXYData.getStartXValue(series, item);
   15 | value = intervalXYData.getEndXValue(series, item);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getStartXValue | getEndXValue | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression intervalXYData.getStartXValue(series,item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression intervalXYData.getEndXValue(series,item) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   15

       value = intervalXYData.getEndXValue(series, item);

       else

       else

   16

       value = dataset.getXValue(series, item);

   16

       value = dataset.getXValue(series, item);

   17

       if (!Double.isNaN(value))

   17

       if (!Double.isNaN(value))

   18

       minimum = Math.min(minimum, value);

   18 | minimum = Math.min(minimum, value);
   18 | maximum = Math.max(maximum, value);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   minimum | maximum | VARIABLE_NAME_MISMATCH
   min | max | METHOD_INVOCATION_NAME_MISMATCH
   minimum | maximum | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression Math.min(minimum,value) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression Math.max(maximum,value) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   18

       maximum = Math.max(maximum, value);

   19

       if (minimum == Double.POSITIVE_INFINITY)

   19 | if (minimum == Double.POSITIVE_INFINITY)
   19 | if (maximum == Double.NEGATIVE_INFINITY)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   minimum | maximum | VARIABLE_NAME_MISMATCH
   POSITIVE_INFINITY | NEGATIVE_INFINITY | VARIABLE_NAME_MISMATCH

   19

       if (maximum == Double.NEGATIVE_INFINITY)

   20

       result = null;

   20

       result = null;

       else

       else

   21

       result = new Double(minimum);

   21 | result = new Double(minimum);
   21 | result = new Double(maximum);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   minimum | maximum | VARIABLE_NAME_MISMATCH

   21

       result = new Double(maximum);

   22

       return result;

   22

       return result;

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Expression info.getDomainLowerBound(true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression info.getDomainUpperBound(true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression intervalXYData.getStartXValue(series,item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression intervalXYData.getEndXValue(series,item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Expression Math.min(minimum,value) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression Math.max(maximum,value) cannot be parameterized, because it has dependencies to/from statements that will be extracted