161-1-2

if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } // work out the minimum value... if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeLowerBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double minimum = Double.POSITIVE_INFINITY; int seriesCount = dataset.getRowCount(); int itemCount = dataset.getColumnCount(); for (int series = 0; series < seriesCount; series++) { for (int item = 0; item < itemCount; item++) { Number value; if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; value = icd.getStartValue(series, item); } else { value = dataset.getValue(series, item); } if (value != null) { minimum = Math.min(minimum, value.doubleValue()); } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Double(minimum); } }
if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } // work out the minimum value... if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeUpperBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getRowCount(); int itemCount = dataset.getColumnCount(); for (int series = 0; series < seriesCount; series++) { for (int item = 0; item < itemCount; item++) { Number value; if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; value = icd.getEndValue(series, item); } else { value = dataset.getValue(series, item); } if (value != null) { maximum = Math.max(maximum, value.doubleValue()); } } } if (maximum == Double.NEGATIVE_INFINITY) { return null; } else { return new Double(maximum); } }

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 findMinimumRangeValue(CategoryDataset)` |  | Method name: `Number findMaximumRangeValue(CategoryDataset)`
Number of AST nodes: 20 |  | Number of AST nodes: 20

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

            // work out the minimum value...↵

4

            // work out the minimum value...↵

5

            if (dataset instanceof RangeInfo) {↵

5

            if (dataset instanceof RangeInfo) {↵

6

                RangeInfo info = (RangeInfo) dataset;↵

6

                RangeInfo info = (RangeInfo) dataset;↵

7

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

7

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

8

            }↵

8

            }↵

9

            // hasn't implemented RangeInfo, so we'll have to iterate...↵

9

            // hasn't implemented RangeInfo, so we'll have to iterate...↵

10

            else {↵

10

            else {↵

11

                double minimum = Double.POSITIVE_INFINITY;↵

11

                double maximum = Double.NEGATIVE_INFINITY;↵

12

                int seriesCount = dataset.getRowCount();↵

12

                int seriesCount = dataset.getRowCount();↵

13

                int itemCount = dataset.getColumnCount();↵

13

                int itemCount = dataset.getColumnCount();↵

14

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

14

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

15

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

15

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

16

                        Number value;↵

16

                        Number value;↵

17

                        if (dataset instanceof IntervalCategoryDataset) {↵

17

                        if (dataset instanceof IntervalCategoryDataset) {↵

18

                            IntervalCategoryDataset icd↵

18

                            IntervalCategoryDataset icd↵

19

                                = (IntervalCategoryDataset) dataset;↵

19

                                = (IntervalCategoryDataset) dataset;↵

20

                            value = icd.getStartValue(series, item);↵

20

                            value = icd.getEndValue(series, item);↵

21

                        }↵

21

                        }↵

22

                        else {↵

22

                        else {↵

23

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

23

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

24

                        }↵

24

                        }↵

25

                        if (value != null) {↵

25

                        if (value != null) {↵

26

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

26

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

27

                        }↵

27

                        }↵

28

                    }↵

28

                    }↵

29

                }↵

29

                }↵

30

                if (minimum == Double.POSITIVE_INFINITY) {↵

30

                if (maximum == Double.NEGATIVE_INFINITY) {↵

31

                    return null;↵

31

                    return null;↵

32

                }↵

32

                }↵

33

                else {↵

33

                else {↵

34

                    return new Double(minimum);↵

34

                    return new Double(maximum);↵

35

                }↵

35

                }↵

36

            }

36

            }

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 | 98

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 20
   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) | 3.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

       if (dataset instanceof RangeInfo)

   3

       if (dataset instanceof RangeInfo)

   4

       RangeInfo info = (RangeInfo)dataset;

   4

       RangeInfo info = (RangeInfo)dataset;

   5

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

   5 | return new Double(info.getRangeLowerBound(true));
   5 | return new Double(info.getRangeUpperBound(true));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getRangeLowerBound | getRangeUpperBound | METHOD_INVOCATION_NAME_MISMATCH

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

   5

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

       else

       else

   6

       double minimum = Double.POSITIVE_INFINITY;

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

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

   6

       double maximum = Double.NEGATIVE_INFINITY;

   7

       int seriesCount = dataset.getRowCount();

   7

       int seriesCount = dataset.getRowCount();

   8

       int itemCount = dataset.getColumnCount();

   8

       int itemCount = dataset.getColumnCount();

   9

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

   9

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

   10

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

   10

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

   11

       Number value;

   11

       Number value;

   12

       if (dataset instanceof IntervalCategoryDataset)

   12

       if (dataset instanceof IntervalCategoryDataset)

   13

       IntervalCategoryDataset icd = (IntervalCategoryDataset)dataset;

   13

       IntervalCategoryDataset icd = (IntervalCategoryDataset)dataset;

   14

       value = icd.getStartValue(series, item);

   14 | value = icd.getStartValue(series, item);
   14 | value = icd.getEndValue(series, item);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   getStartValue | getEndValue | METHOD_INVOCATION_NAME_MISMATCH

   Preondition Violations
   Expression icd.getStartValue(series,item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression icd.getEndValue(series,item) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   14

       value = icd.getEndValue(series, item);

       else

       else

   15

       value = dataset.getValue(series, item);

   15

       value = dataset.getValue(series, item);

   16

       if (value != null)

   16

       if (value != null)

   17

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

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

   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.doubleValue()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression Math.max(maximum,value.doubleValue()) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   17

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

   18

       if (minimum == Double.POSITIVE_INFINITY)

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

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

   18

       if (maximum == Double.NEGATIVE_INFINITY)

   19

       return null;

   19

       return null;

       else

       else

   20

       return new Double(minimum);

   20 | return new Double(minimum);
   20 | return new Double(maximum);

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

   20

       return new Double(maximum);

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Expression info.getRangeLowerBound(true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   2 | Expression info.getRangeUpperBound(true) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression icd.getStartValue(series,item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression icd.getEndValue(series,item) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Expression Math.min(minimum,value.doubleValue()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression Math.max(maximum,value.doubleValue()) cannot be parameterized, because it has dependencies to/from statements that will be extracted