public class CustomCategoryURLGenerator implements CategoryURLGenerator, Cloneable, PublicCloneable, Serializable { /** Storage for the URLs. */ private ArrayList urlSeries = new ArrayList(); /** * Default constructor. */ public CustomCategoryURLGenerator() { super(); } /** * Returns the number of URL lists stored by the renderer. * * @return The list count. */ public int getListCount() { return this.urlSeries.size(); } /** * Returns the number of URLs in a given list. * * @param list the list index (zero based). * * @return The URL count. */ public int getURLCount(int list) { int result = 0; List urls = (List) this.urlSeries.get(list); if (urls != null) { result = urls.size(); } return result; } /** * Returns the URL for an item. * * @param series the series index. * @param item the item index. * * @return The URL (possibly null). */ public String getURL(int series, int item) { String result = null; if (series < getListCount()) { List urls = (List) this.urlSeries.get(series); if (urls != null) { if (item < urls.size()) { result = (String) urls.get(item); } } } return result; } /** * Generates a URL. * * @param dataset the dataset (ignored in this implementation). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return A string containing the URL (possibly null). */ public String generateURL(CategoryDataset dataset, int series, int item) { return getURL(series, item); } /** * Adds a list of URLs. * * @param urls the list of URLs (null permitted). */ public void addURLSeries(List urls) { List listToAdd = null; if (urls != null) { listToAdd = new java.util.ArrayList(urls); } this.urlSeries.add(listToAdd); } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CustomCategoryURLGenerator)) { return false; } CustomCategoryURLGenerator generator = (CustomCategoryURLGenerator) obj; int listCount = getListCount(); if (listCount != generator.getListCount()) { return false; } for (int series = 0; series < listCount; series++) { int urlCount = getURLCount(series); if (urlCount != generator.getURLCount(series)) { return false; } for (int item = 0; item < urlCount; item++) { String u1 = getURL(series, item); String u2 = generator.getURL(series, item); if (u1 != null) { if (!u1.equals(u2)) { return false; } } else { if (u2 != null) { return false; } } } } return true; } /** * Returns a new generator that is a copy of, and independent from, this * generator. * * @return A clone. */ public Object clone() throws CloneNotSupportedException { CustomCategoryURLGenerator clone = (CustomCategoryURLGenerator) super.clone(); clone.urlSeries = new java.util.ArrayList(this.urlSeries); return clone;
public class CustomXYURLGenerator implements XYURLGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8565933356596551832L; /** Storage for the URLs. */ private ArrayList urlSeries = new ArrayList(); /** * Default constructor. */ public CustomXYURLGenerator() { super(); } /** * Returns the number of URL lists stored by the renderer. * * @return The list count. */ public int getListCount() { return this.urlSeries.size(); } /** * Returns the number of URLs in a given list. * * @param list the list index (zero based). * * @return The URL count. */ public int getURLCount(int list) { int result = 0; List urls = (List) this.urlSeries.get(list); if (urls != null) { result = urls.size(); } return result; } /** * Returns the URL for an item. * * @param series the series index. * @param item the item index. * * @return The URL (possibly null). */ public String getURL(int series, int item) { String result = null; if (series < getListCount()) { List urls = (List) this.urlSeries.get(series); if (urls != null) { if (item < urls.size()) { result = (String) urls.get(item); } } } return result; } /** * Generates a URL. * * @param dataset the dataset. * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return A string containing the URL (possibly null). */ public String generateURL(XYDataset dataset, int series, int item) { return getURL(series, item); } /** * Adds a list of URLs. * * @param urls the list of URLs (null permitted, the list * is copied). */ public void addURLSeries(List urls) { List listToAdd = null; if (urls != null) { listToAdd = new java.util.ArrayList(urls); } this.urlSeries.add(listToAdd); } /** * Tests this generator for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CustomXYURLGenerator)) { return false; } CustomXYURLGenerator that = (CustomXYURLGenerator) obj; int listCount = getListCount(); if (listCount != that.getListCount()) { return false; } for (int series = 0; series < listCount; series++) { int urlCount = getURLCount(series); if (urlCount != that.getURLCount(series)) { return false; } for (int item = 0; item < urlCount; item++) { String u1 = getURL(series, item); String u2 = that.getURL(series, item); if (u1 != null) { if (!u1.equals(u2)) { return false; } } else { if (u2 != null) { return false; } } } } return true; } /** * Returns a new generator that is a copy of, and independent from, this * generator. * * @return A clone. */ public Object clone() throws CloneNotSupportedException { CustomXYURLGenerator clone = (CustomXYURLGenerator) super.clone(); clone.urlSeries = new java.util.ArrayList(this.urlSeries); return clone;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/urls/CustomCategoryURLGenerator.java File path: /jfreechart-1.0.10/src/org/jfree/chart/urls/CustomXYURLGenerator.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class CustomCategoryURLGenerator implements CategoryURLGenerator,
1
public class CustomXYURLGenerator implements XYURLGenerator,
2
        Cloneable,
2
 Cloneable,
3
 PublicCloneable, Serializable {
3
        PublicCloneable, Serializable {
4
    /** For serialization. */
5
    private static final long serialVersionUID = -8565933356596551832L;
4
    /** Storage for the URLs. */
6
    /** Storage for the URLs. */
5
    private ArrayList urlSeries = new ArrayList();
7
    private ArrayList urlSeries = new ArrayList();
6
    /**
8
    /**
7
     * Default constructor.
9
     * Default constructor.
8
     */
10
     */
9
    public CustomCategoryURLGenerator() {
11
    public CustomXYURLGenerator() {
10
        super();
12
        super();
11
    }
13
    }
12
    /**
14
    /**
13
     * Returns the number of URL lists stored by the renderer.
15
     * Returns the number of URL lists stored by the renderer.
14
     *
16
     *
15
     * @return The list count.
17
     * @return The list count.
16
     */
18
     */
17
    public int getListCount() {
19
    public int getListCount() {
18
        return this.urlSeries.size();
20
        return this.urlSeries.size();
19
    }
21
    }
20
    /**
22
    /**
21
     * Returns the number of URLs in a given list.
23
     * Returns the number of URLs in a given list.
22
     *
24
     *
23
     * @param list  the list index (zero based).
25
     * @param list  the list index (zero based).
24
     *
26
     *
25
     * @return The URL count.
27
     * @return The URL count.
26
     */
28
     */
27
    public int getURLCount(int list) {
29
    public int getURLCount(int list) {
28
        int result = 0;
30
        int result = 0;
29
        List urls = (List) this.urlSeries.get(list);
31
        List urls = (List) this.urlSeries.get(list);
30
        if (urls != null) {
32
        if (urls != null) {
31
            result = urls.size();
33
            result = urls.size();
32
        }
34
        }
33
        return result;
35
        return result;
34
    }
36
    }
35
    /**
37
    /**
36
     * Returns the URL for an item.
38
     * Returns the URL for an item.
37
     *
39
     *
38
     * @param series  the series index.
40
     * @param series  the series index.
39
     * @param item  the item index.
41
     * @param item  the item index.
40
     *
42
     *
41
     * @return The URL (possibly null).
43
     * @return The URL (possibly null).
42
     */
44
     */
43
    public String getURL(int series, int item) {
45
    public String getURL(int series, int item) {
44
        String result = null;
46
        String result = null;
45
        if (series < getListCount()) {
47
        if (series < getListCount()) {
46
            List urls = (List) this.urlSeries.get(series);
48
            List urls = (List) this.urlSeries.get(series);
47
            if (urls != null) {
49
            if (urls != null) {
48
                if (item < urls.size()) {
50
                if (item < urls.size()) {
49
                    result = (String) urls.get(item);
51
                    result = (String) urls.get(item);
50
                }
52
                }
51
            }
53
            }
52
        }
54
        }
53
        return result;
55
        return result;
54
    }
56
    }
55
    /**
57
    /**
56
     * Generates a URL.
58
     * Generates a URL.
57
     *
59
     *
58
     * @param dataset  the dataset (ignored in this implementation).
60
     * @param dataset  the dataset.
59
     * @param series  the series (zero-based index).
61
     * @param series  the series (zero-based index).
60
     * @param item  the item (zero-based index).
62
     * @param item  the item (zero-based index).
61
     *
63
     *
62
     * @return A string containing the URL (possibly null).
64
     * @return A string containing the URL (possibly null).
63
     */
65
     */
64
    public String generateURL(CategoryDataset dataset, int series, int item) {
66
    public String generateURL(XYDataset dataset, int series, int item) {
65
        return getURL(series, item);
67
        return getURL(series, item);
66
    }
68
    }
67
    /**
69
    /**
68
     * Adds a list of URLs.
70
     * Adds a list of URLs.
69
     *
71
     *
70
     * @param urls  the list of URLs (null permitted
72
     * @param urls  the list of URLs (null permitted, the list
71
).
73
     *     is copied).
72
     */
74
     */
73
    public void addURLSeries(List urls) {
75
    public void addURLSeries(List urls) {
74
        List listToAdd = null;
76
        List listToAdd = null;
75
        if (urls != null) {
77
        if (urls != null) {
76
            listToAdd = new java.util.ArrayList(urls);
78
            listToAdd = new java.util.ArrayList(urls);
77
        }
79
        }
78
        this.urlSeries.add(listToAdd);
80
        this.urlSeries.add(listToAdd);
79
    }
81
    }
80
    /**
82
    /**
81
     * Tests if this object is equal to another.
83
     * Tests this 
82
     *
83
     * @param obj  the other object
84
generator for equality with an arbitrary object.
85
     *
84
.
86
     * @param obj  the object (null permitted).
85
     *
87
     *
86
     * @return A boolean.
88
     * @return A boolean.
87
     */
89
     */
88
    public boolean equals(Object obj) {
90
    public boolean equals(Object obj) {
89
        if (obj == this) {
91
        if (obj == this) {
90
            return true;
92
            return true;
91
        }
93
        }
92
        if (!(obj instanceof CustomCategoryURLGenerator)) {
94
        if (!(obj instanceof CustomXYURLGenerator)) {
93
            return false;
95
            return false;
94
        }
96
        }
95
        CustomCategoryURLGenerator generator = (CustomCategoryURLGenerator) obj;
97
        CustomXYURLGenerator that = (CustomXYURLGenerator) obj;
96
        int listCount = getListCount();
98
        int listCount = getListCount();
97
        if (listCount != generator.getListCount()) {
99
        if (listCount != that.getListCount()) {
98
            return false;
100
            return false;
99
        }
101
        }
100
        for (int series = 0; series < listCount; series++) {
102
        for (int series = 0; series < listCount; series++) {
101
            int urlCount = getURLCount(series);
103
            int urlCount = getURLCount(series);
102
            if (urlCount != generator.getURLCount(series)) {
104
            if (urlCount != that.getURLCount(series)) {
103
                return false;
105
                return false;
104
            }
106
            }
105
            for (int item = 0; item < urlCount; item++) {
107
            for (int item = 0; item < urlCount; item++) {
106
                String u1 = getURL(series, item);
108
                String u1 = getURL(series, item);
107
                String u2 = generator.getURL(series, item);
109
                String u2 = that.getURL(series, item);
108
                if (u1 != null) {
110
                if (u1 != null) {
109
                    if (!u1.equals(u2)) {
111
                    if (!u1.equals(u2)) {
110
                        return false;
112
                        return false;
111
                    }
113
                    }
112
                }
114
                }
113
 else {
115
                else {
114
                    if (u2 != null) {
116
                    if (u2 != null) {
115
                        return false;
117
                        return false;
116
                    }
118
                    }
117
                }
119
                }
118
            }
120
            }
119
        }
121
        }
120
        return true;
122
        return true;
121
    }
123
    }
122
    /**
124
    /**
123
     * Returns a new generator that is a copy of, and independent from, this
125
     * Returns a new generator that is a copy of, and independent from, this
124
     * generator.
126
     * generator.
125
     *
127
     *
126
     * @return A clone.
128
     * @return A clone.
127
     */
129
     */
128
    public Object clone() throws CloneNotSupportedException {
130
    public Object clone() throws CloneNotSupportedException {
129
        CustomCategoryURLGenerator clone
131
        CustomXYURLGenerator clone
130
                = (CustomCategoryURLGenerator) super.clone();
132
 = (CustomXYURLGenerator) super.clone();
131
        clone.urlSeries = new java.util.ArrayList(this.urlSeries);
133
        clone.urlSeries = new java.util.ArrayList(this.urlSeries);
132
        return clone;
134
        return clone;
133
    
135
    
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0