author | jjg |
Fri, 27 May 2016 13:06:58 -0700 | |
changeset 38617 | d93a7f64e231 |
parent 26270 | a3635e6d3d78 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
2 |
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.doclets.internal.toolkit.util; |
|
27 |
||
14258 | 28 |
import java.util.*; |
29 |
||
10 | 30 |
import com.sun.javadoc.*; |
14258 | 31 |
import com.sun.tools.doclets.internal.toolkit.*; |
10 | 32 |
|
33 |
/** |
|
34 |
* Build Class Hierarchy for all the Classes. This class builds the Class |
|
35 |
* Tree and the Interface Tree separately. |
|
36 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
37 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
38 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
39 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
40 |
* deletion without notice.</b> |
10 | 41 |
* |
42 |
* @see java.util.HashMap |
|
43 |
* @see java.util.List |
|
44 |
* @see com.sun.javadoc.Type |
|
45 |
* @see com.sun.javadoc.ClassDoc |
|
46 |
* @author Atul M Dambalkar |
|
47 |
*/ |
|
38617 | 48 |
@Deprecated |
10 | 49 |
public class ClassTree { |
50 |
||
51 |
/** |
|
52 |
* List of baseclasses. Contains only java.lang.Object. Can be used to get |
|
53 |
* the mapped listing of sub-classes. |
|
54 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
55 |
final private SortedSet<ClassDoc> baseclasses; |
10 | 56 |
|
57 |
/** |
|
58 |
* Mapping for each Class with their SubClasses |
|
59 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
60 |
final private Map<ClassDoc, SortedSet<ClassDoc>> subclasses = new HashMap<>(); |
10 | 61 |
|
62 |
/** |
|
63 |
* List of base-interfaces. Contains list of all the interfaces who do not |
|
64 |
* have super-interfaces. Can be used to get the mapped listing of |
|
65 |
* sub-interfaces. |
|
66 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
67 |
final private SortedSet<ClassDoc> baseinterfaces; |
10 | 68 |
|
69 |
/** |
|
70 |
* Mapping for each Interface with their SubInterfaces |
|
71 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
72 |
final private Map<ClassDoc, SortedSet<ClassDoc>> subinterfaces = new HashMap<>(); |
10 | 73 |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
74 |
final private SortedSet<ClassDoc> baseEnums; |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
75 |
final private Map<ClassDoc, SortedSet<ClassDoc>> subEnums = new HashMap<>(); |
10 | 76 |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
77 |
final private SortedSet<ClassDoc> baseAnnotationTypes; |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
78 |
final private Map<ClassDoc, SortedSet<ClassDoc>> subAnnotationTypes = new HashMap<>(); |
10 | 79 |
|
80 |
/** |
|
81 |
* Mapping for each Interface with classes who implement it. |
|
82 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
83 |
final private Map<ClassDoc, SortedSet<ClassDoc>> implementingclasses = new HashMap<>(); |
10 | 84 |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
85 |
private final Configuration configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
86 |
private final Utils utils; |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
87 |
private final Comparator<Doc> comparator; |
10 | 88 |
/** |
89 |
* Constructor. Build the Tree using the Root of this Javadoc run. |
|
90 |
* |
|
91 |
* @param configuration the configuration of the doclet. |
|
92 |
* @param noDeprecated Don't add deprecated classes in the class tree, if |
|
93 |
* true. |
|
94 |
*/ |
|
95 |
public ClassTree(Configuration configuration, boolean noDeprecated) { |
|
96 |
configuration.message.notice("doclet.Building_Tree"); |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
97 |
this.configuration = configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
98 |
this.utils = configuration.utils; |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
99 |
comparator = utils.makeGeneralPurposeComparator(); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
100 |
baseAnnotationTypes = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
101 |
baseEnums = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
102 |
baseclasses = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
103 |
baseinterfaces = new TreeSet<>(comparator); |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
104 |
buildTree(configuration.root.classes()); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
105 |
|
10 | 106 |
} |
107 |
||
108 |
/** |
|
109 |
* Constructor. Build the Tree using the Root of this Javadoc run. |
|
110 |
* |
|
111 |
* @param root Root of the Document. |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
112 |
* @param configuration The current configuration of the doclet. |
10 | 113 |
*/ |
114 |
public ClassTree(RootDoc root, Configuration configuration) { |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
115 |
this.configuration = configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
116 |
this.utils = configuration.utils; |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
117 |
comparator = utils.makeGeneralPurposeComparator(); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
118 |
baseAnnotationTypes = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
119 |
baseEnums = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
120 |
baseclasses = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
121 |
baseinterfaces = new TreeSet<>(comparator); |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
122 |
buildTree(root.classes()); |
10 | 123 |
} |
124 |
||
125 |
/** |
|
126 |
* Constructor. Build the tree for the given array of classes. |
|
127 |
* |
|
128 |
* @param classes Array of classes. |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
129 |
* @param configuration The current configuration of the doclet. |
10 | 130 |
*/ |
131 |
public ClassTree(ClassDoc[] classes, Configuration configuration) { |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
132 |
this.configuration = configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
133 |
this.utils = configuration.utils; |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
134 |
comparator = utils.makeGeneralPurposeComparator(); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
135 |
baseAnnotationTypes = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
136 |
baseEnums = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
137 |
baseclasses = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
138 |
baseinterfaces = new TreeSet<>(comparator); |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
139 |
buildTree(classes); |
10 | 140 |
} |
141 |
||
142 |
/** |
|
143 |
* Generate mapping for the sub-classes for every class in this run. |
|
144 |
* Return the sub-class list for java.lang.Object which will be having |
|
145 |
* sub-class listing for itself and also for each sub-class itself will |
|
146 |
* have their own sub-class lists. |
|
147 |
* |
|
148 |
* @param classes all the classes in this run. |
|
149 |
* @param configuration the current configuration of the doclet. |
|
150 |
*/ |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
151 |
private void buildTree(ClassDoc[] classes) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
152 |
for (ClassDoc aClass : classes) { |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
153 |
// In the tree page (e.g overview-tree.html) do not include |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
154 |
// information of classes which are deprecated or are a part of a |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
155 |
// deprecated package. |
10 | 156 |
if (configuration.nodeprecated && |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
157 |
(utils.isDeprecated(aClass) || |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
158 |
utils.isDeprecated(aClass.containingPackage()))) { |
10 | 159 |
continue; |
160 |
} |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
161 |
|
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
162 |
if (configuration.javafx |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
163 |
&& aClass.tags("treatAsPrivate").length > 0) { |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
164 |
continue; |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
165 |
} |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14260
diff
changeset
|
166 |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
167 |
if (aClass.isEnum()) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
168 |
processType(aClass, configuration, baseEnums, subEnums); |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
169 |
} else if (aClass.isClass()) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
170 |
processType(aClass, configuration, baseclasses, subclasses); |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
171 |
} else if (aClass.isInterface()) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
172 |
processInterface(aClass); |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
173 |
} else if (aClass.isAnnotationType()) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
174 |
processType(aClass, configuration, baseAnnotationTypes, |
10 | 175 |
subAnnotationTypes); |
176 |
} |
|
177 |
} |
|
178 |
} |
|
179 |
||
180 |
/** |
|
181 |
* For the class passed map it to it's own sub-class listing. |
|
182 |
* For the Class passed, get the super class, |
|
183 |
* if superclass is non null, (it is not "java.lang.Object") |
|
184 |
* get the "value" from the hashmap for this key Class |
|
185 |
* if entry not found create one and get that. |
|
186 |
* add this Class as a sub class in the list |
|
187 |
* Recurse till hits java.lang.Object Null SuperClass. |
|
188 |
* |
|
189 |
* @param cd class for which sub-class mapping to be generated. |
|
190 |
* @param configuration the current configurtation of the doclet. |
|
191 |
*/ |
|
192 |
private void processType(ClassDoc cd, Configuration configuration, |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
193 |
Collection<ClassDoc> bases, Map<ClassDoc, SortedSet<ClassDoc>> subs) { |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
194 |
ClassDoc superclass = utils.getFirstVisibleSuperClassCD(cd, configuration); |
10 | 195 |
if (superclass != null) { |
196 |
if (!add(subs, superclass, cd)) { |
|
197 |
return; |
|
198 |
} else { |
|
199 |
processType(superclass, configuration, bases, subs); |
|
200 |
} |
|
201 |
} else { // cd is java.lang.Object, add it once to the list |
|
202 |
if (!bases.contains(cd)) { |
|
203 |
bases.add(cd); |
|
204 |
} |
|
205 |
} |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
206 |
List<Type> intfacs = utils.getAllInterfaces(cd, configuration); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
207 |
for (Type intfac : intfacs) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
208 |
add(implementingclasses, intfac.asClassDoc(), cd); |
10 | 209 |
} |
210 |
} |
|
211 |
||
212 |
/** |
|
213 |
* For the interface passed get the interfaces which it extends, and then |
|
214 |
* put this interface in the sub-interface list of those interfaces. Do it |
|
215 |
* recursively. If a interface doesn't have super-interface just attach |
|
216 |
* that interface in the list of all the baseinterfaces. |
|
217 |
* |
|
218 |
* @param cd Interface under consideration. |
|
219 |
*/ |
|
220 |
private void processInterface(ClassDoc cd) { |
|
221 |
ClassDoc[] intfacs = cd.interfaces(); |
|
222 |
if (intfacs.length > 0) { |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
223 |
for (ClassDoc intfac : intfacs) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
224 |
if (!add(subinterfaces, intfac, cd)) { |
10 | 225 |
return; |
226 |
} else { |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
227 |
processInterface(intfac); // Recurse |
10 | 228 |
} |
229 |
} |
|
230 |
} else { |
|
231 |
// we need to add all the interfaces who do not have |
|
232 |
// super-interfaces to baseinterfaces list to traverse them |
|
233 |
if (!baseinterfaces.contains(cd)) { |
|
234 |
baseinterfaces.add(cd); |
|
235 |
} |
|
236 |
} |
|
237 |
} |
|
238 |
||
239 |
/** |
|
240 |
* Adjust the Class Tree. Add the class interface in to it's super-class' |
|
241 |
* or super-interface's sub-interface list. |
|
242 |
* |
|
243 |
* @param map the entire map. |
|
244 |
* @param superclass java.lang.Object or the super-interface. |
|
245 |
* @param cd sub-interface to be mapped. |
|
246 |
* @returns boolean true if class added, false if class already processed. |
|
247 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
248 |
private boolean add(Map<ClassDoc, SortedSet<ClassDoc>> map, ClassDoc superclass, ClassDoc cd) { |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
249 |
SortedSet<ClassDoc> list = map.get(superclass); |
10 | 250 |
if (list == null) { |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
251 |
list = new TreeSet<>(comparator); |
10 | 252 |
map.put(superclass, list); |
253 |
} |
|
254 |
if (list.contains(cd)) { |
|
255 |
return false; |
|
256 |
} else { |
|
257 |
list.add(cd); |
|
258 |
} |
|
259 |
return true; |
|
260 |
} |
|
261 |
||
262 |
/** |
|
263 |
* From the map return the list of sub-classes or sub-interfaces. If list |
|
264 |
* is null create a new one and return it. |
|
265 |
* |
|
266 |
* @param map The entire map. |
|
267 |
* @param cd class for which the sub-class list is requested. |
|
268 |
* @returns List Sub-Class list for the class passed. |
|
269 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
270 |
private SortedSet<ClassDoc> get(Map<ClassDoc, SortedSet<ClassDoc>> map, ClassDoc cd) { |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
271 |
SortedSet<ClassDoc> aset = map.get(cd); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
272 |
if (aset == null) { |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
273 |
return new TreeSet<>(comparator); |
10 | 274 |
} |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
275 |
return aset; |
10 | 276 |
} |
277 |
||
278 |
/** |
|
279 |
* Return the sub-class list for the class passed. |
|
280 |
* |
|
281 |
* @param cd class whose sub-class list is required. |
|
282 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
283 |
public SortedSet<ClassDoc> subclasses(ClassDoc cd) { |
10 | 284 |
return get(subclasses, cd); |
285 |
} |
|
286 |
||
287 |
/** |
|
288 |
* Return the sub-interface list for the interface passed. |
|
289 |
* |
|
290 |
* @param cd interface whose sub-interface list is required. |
|
291 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
292 |
public SortedSet<ClassDoc> subinterfaces(ClassDoc cd) { |
10 | 293 |
return get(subinterfaces, cd); |
294 |
} |
|
295 |
||
296 |
/** |
|
297 |
* Return the list of classes which implement the interface passed. |
|
298 |
* |
|
299 |
* @param cd interface whose implementing-classes list is required. |
|
300 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
301 |
public SortedSet<ClassDoc> implementingclasses(ClassDoc cd) { |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
302 |
SortedSet<ClassDoc> result = get(implementingclasses, cd); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
303 |
SortedSet<ClassDoc> intfcs = allSubs(cd, false); |
10 | 304 |
|
305 |
//If class x implements a subinterface of cd, then it follows |
|
306 |
//that class x implements cd. |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
307 |
Iterator<ClassDoc> subInterfacesIter = intfcs.iterator(); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
308 |
while (subInterfacesIter.hasNext()) { |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
309 |
Iterator<ClassDoc> implementingClassesIter |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
310 |
= implementingclasses(subInterfacesIter.next()).iterator(); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
311 |
while (implementingClassesIter.hasNext()) { |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
312 |
ClassDoc c = implementingClassesIter.next(); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
313 |
if (!result.contains(c)) { |
10 | 314 |
result.add(c); |
315 |
} |
|
316 |
} |
|
317 |
} |
|
318 |
return result; |
|
319 |
} |
|
320 |
||
321 |
/** |
|
322 |
* Return the sub-class/interface list for the class/interface passed. |
|
323 |
* |
|
324 |
* @param cd class/interface whose sub-class/interface list is required. |
|
325 |
* @param isEnum true if the subclasses should be forced to come from the |
|
326 |
* enum tree. |
|
327 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
328 |
public SortedSet<ClassDoc> subs(ClassDoc cd, boolean isEnum) { |
10 | 329 |
if (isEnum) { |
330 |
return get(subEnums, cd); |
|
331 |
} else if (cd.isAnnotationType()) { |
|
332 |
return get(subAnnotationTypes, cd); |
|
333 |
} else if (cd.isInterface()) { |
|
334 |
return get(subinterfaces, cd); |
|
335 |
} else if (cd.isClass()) { |
|
336 |
return get(subclasses, cd); |
|
337 |
} else { |
|
338 |
return null; |
|
339 |
} |
|
340 |
||
341 |
} |
|
342 |
||
343 |
/** |
|
344 |
* Return a list of all direct or indirect, sub-classes and subinterfaces |
|
345 |
* of the ClassDoc argument. |
|
346 |
* |
|
347 |
* @param cd ClassDoc whose sub-classes or sub-interfaces are requested. |
|
348 |
* @param isEnum true if the subclasses should be forced to come from the |
|
349 |
* enum tree. |
|
350 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
351 |
public SortedSet<ClassDoc> allSubs(ClassDoc cd, boolean isEnum) { |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
352 |
// new entries added to the list are searched as well |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
353 |
List<ClassDoc> list = new ArrayList<>(subs(cd, isEnum)); |
10 | 354 |
for (int i = 0; i < list.size(); i++) { |
868 | 355 |
cd = list.get(i); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
356 |
SortedSet<ClassDoc> tlist = subs(cd, isEnum); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
357 |
for (ClassDoc tcd : tlist) { |
10 | 358 |
if (!list.contains(tcd)) { |
359 |
list.add(tcd); |
|
360 |
} |
|
361 |
} |
|
362 |
} |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
363 |
SortedSet<ClassDoc> oset = new TreeSet<>(comparator); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
364 |
oset.addAll(list); |
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
365 |
return oset; |
10 | 366 |
} |
367 |
||
368 |
/** |
|
369 |
* Return the base-classes list. This will have only one element namely |
|
370 |
* thw classdoc for java.lang.Object, since this is the base class for all |
|
371 |
* classes. |
|
372 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
373 |
public SortedSet<ClassDoc> baseclasses() { |
10 | 374 |
return baseclasses; |
375 |
} |
|
376 |
||
377 |
/** |
|
378 |
* Return the list of base interfaces. This is the list of interfaces |
|
379 |
* which do not have super-interface. |
|
380 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
381 |
public SortedSet<ClassDoc> baseinterfaces() { |
10 | 382 |
return baseinterfaces; |
383 |
} |
|
384 |
||
385 |
/** |
|
386 |
* Return the list of base enums. This is the list of enums |
|
387 |
* which do not have super-enums. |
|
388 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
389 |
public SortedSet<ClassDoc> baseEnums() { |
10 | 390 |
return baseEnums; |
391 |
} |
|
392 |
||
393 |
/** |
|
394 |
* Return the list of base annotation types. This is the list of |
|
395 |
* annotation types which do not have super-annotation types. |
|
396 |
*/ |
|
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
397 |
public SortedSet<ClassDoc> baseAnnotationTypes() { |
10 | 398 |
return baseAnnotationTypes; |
399 |
} |
|
400 |
} |