author | briangoetz |
Wed, 18 Dec 2013 16:05:18 -0500 | |
changeset 22163 | 3651128c74eb |
parent 22159 | 682da512ec17 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14542
diff
changeset
|
2 |
* Copyright (c) 2003, 2013, 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.builders; |
|
27 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
28 |
import java.io.*; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
29 |
import java.util.*; |
14258 | 30 |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
31 |
import com.sun.javadoc.*; |
14258 | 32 |
import com.sun.tools.doclets.internal.toolkit.*; |
10 | 33 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
34 |
||
35 |
/** |
|
36 |
* Builds the Constants Summary Page. |
|
37 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
38 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
39 |
* 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:
14259
diff
changeset
|
40 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
41 |
* deletion without notice.</b> |
10 | 42 |
* |
43 |
* @author Jamie Ho |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
44 |
* @author Bhavesh Patel (Modified) |
10 | 45 |
* @since 1.5 |
46 |
*/ |
|
47 |
public class ConstantsSummaryBuilder extends AbstractBuilder { |
|
48 |
||
49 |
/** |
|
50 |
* The root element of the constant summary XML is {@value}. |
|
51 |
*/ |
|
52 |
public static final String ROOT = "ConstantSummary"; |
|
53 |
||
54 |
/** |
|
55 |
* The maximum number of package directories shown in the constant |
|
56 |
* value index. |
|
57 |
*/ |
|
58 |
public static final int MAX_CONSTANT_VALUE_INDEX_LENGTH = 2; |
|
59 |
||
60 |
/** |
|
61 |
* The writer used to write the results. |
|
62 |
*/ |
|
14542 | 63 |
protected final ConstantsSummaryWriter writer; |
10 | 64 |
|
65 |
/** |
|
66 |
* The set of ClassDocs that have constant fields. |
|
67 |
*/ |
|
14542 | 68 |
protected final Set<ClassDoc> classDocsWithConstFields; |
10 | 69 |
|
70 |
/** |
|
71 |
* The set of printed package headers. |
|
72 |
*/ |
|
868 | 73 |
protected Set<String> printedPackageHeaders; |
10 | 74 |
|
75 |
/** |
|
76 |
* The current package being documented. |
|
77 |
*/ |
|
78 |
private PackageDoc currentPackage; |
|
79 |
||
80 |
/** |
|
81 |
* The current class being documented. |
|
82 |
*/ |
|
83 |
private ClassDoc currentClass; |
|
84 |
||
85 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
86 |
* The content tree for the constant summary documentation. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
87 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
88 |
private Content contentTree; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
89 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
90 |
/** |
10 | 91 |
* Construct a new ConstantsSummaryBuilder. |
92 |
* |
|
14542 | 93 |
* @param context the build context. |
94 |
* @param writer the writer for the summary. |
|
10 | 95 |
*/ |
14542 | 96 |
private ConstantsSummaryBuilder(Context context, |
97 |
ConstantsSummaryWriter writer) { |
|
98 |
super(context); |
|
99 |
this.writer = writer; |
|
22163 | 100 |
this.classDocsWithConstFields = new HashSet<>(); |
10 | 101 |
} |
102 |
||
103 |
/** |
|
104 |
* Construct a ConstantsSummaryBuilder. |
|
105 |
* |
|
14542 | 106 |
* @param context the build context. |
10 | 107 |
* @param writer the writer for the summary. |
108 |
*/ |
|
14542 | 109 |
public static ConstantsSummaryBuilder getInstance(Context context, |
110 |
ConstantsSummaryWriter writer) { |
|
111 |
return new ConstantsSummaryBuilder(context, writer); |
|
10 | 112 |
} |
113 |
||
114 |
/** |
|
115 |
* {@inheritDoc} |
|
116 |
*/ |
|
117 |
public void build() throws IOException { |
|
118 |
if (writer == null) { |
|
119 |
//Doclet does not support this output. |
|
120 |
return; |
|
121 |
} |
|
14542 | 122 |
build(layoutParser.parseXML(ROOT), contentTree); |
10 | 123 |
} |
124 |
||
125 |
/** |
|
126 |
* {@inheritDoc} |
|
127 |
*/ |
|
128 |
public String getName() { |
|
129 |
return ROOT; |
|
130 |
} |
|
131 |
||
132 |
/** |
|
133 |
* Build the constant summary. |
|
134 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
135 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
136 |
* @param contentTree the content tree to which the documentation will be added |
10 | 137 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
138 |
public void buildConstantSummary(XMLNode node, Content contentTree) throws Exception { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
139 |
contentTree = writer.getHeader(); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
140 |
buildChildren(node, contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
141 |
writer.addFooter(contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
142 |
writer.printDocument(contentTree); |
10 | 143 |
writer.close(); |
144 |
} |
|
145 |
||
146 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
147 |
* Build the list of packages. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
148 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
149 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
150 |
* @param contentTree the content tree to which the content list will be added |
10 | 151 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
152 |
public void buildContents(XMLNode node, Content contentTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
153 |
Content contentListTree = writer.getContentsHeader(); |
22163 | 154 |
printedPackageHeaders = new HashSet<>(); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
155 |
for (PackageDoc pkg : configuration.packages) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
156 |
if (hasConstantField(pkg) && !hasPrintedPackageIndex(pkg.name())) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
157 |
writer.addLinkToPackageContent(pkg, |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
158 |
parsePackageName(pkg.name()), |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
159 |
printedPackageHeaders, contentListTree); |
10 | 160 |
} |
161 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
162 |
contentTree.addContent(writer.getContentsList(contentListTree)); |
10 | 163 |
} |
164 |
||
165 |
/** |
|
166 |
* Build the summary for each documented package. |
|
167 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
168 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
169 |
* @param contentTree the tree to which the summaries will be added |
10 | 170 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
171 |
public void buildConstantSummaries(XMLNode node, Content contentTree) { |
22163 | 172 |
printedPackageHeaders = new HashSet<>(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
173 |
Content summariesTree = writer.getConstantSummaries(); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
174 |
for (PackageDoc aPackage : configuration.packages) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
175 |
if (hasConstantField(aPackage)) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
176 |
currentPackage = aPackage; |
10 | 177 |
//Build the documentation for the current package. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
178 |
buildChildren(node, summariesTree); |
10 | 179 |
} |
180 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
181 |
contentTree.addContent(summariesTree); |
10 | 182 |
} |
183 |
||
184 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
185 |
* Build the header for the given package. |
10 | 186 |
* |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
187 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
188 |
* @param summariesTree the tree to which the package header will be added |
10 | 189 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
190 |
public void buildPackageHeader(XMLNode node, Content summariesTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
191 |
String parsedPackageName = parsePackageName(currentPackage.name()); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
192 |
if (! printedPackageHeaders.contains(parsedPackageName)) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
193 |
writer.addPackageName(currentPackage, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
194 |
parsePackageName(currentPackage.name()), summariesTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
195 |
printedPackageHeaders.add(parsedPackageName); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
196 |
} |
10 | 197 |
} |
198 |
||
199 |
/** |
|
200 |
* Build the summary for the current class. |
|
201 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
202 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
203 |
* @param summariesTree the tree to which the class constant summary will be added |
10 | 204 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
205 |
public void buildClassConstantSummary(XMLNode node, Content summariesTree) { |
10 | 206 |
ClassDoc[] classes = currentPackage.name().length() > 0 ? |
207 |
currentPackage.allClasses() : |
|
208 |
configuration.classDocCatalog.allClasses( |
|
209 |
DocletConstants.DEFAULT_PACKAGE_NAME); |
|
210 |
Arrays.sort(classes); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
211 |
Content classConstantTree = writer.getClassConstantHeader(); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
212 |
for (ClassDoc doc : classes) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
213 |
if (!classDocsWithConstFields.contains(doc) || |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
214 |
!doc.isIncluded()) { |
10 | 215 |
continue; |
216 |
} |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
217 |
currentClass = doc; |
10 | 218 |
//Build the documentation for the current class. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
219 |
buildChildren(node, classConstantTree); |
10 | 220 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
221 |
summariesTree.addContent(classConstantTree); |
10 | 222 |
} |
223 |
||
224 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
225 |
* Build the summary of constant members in the class. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
226 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
227 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
228 |
* @param classConstantTree the tree to which the constant members table |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
229 |
* will be added |
10 | 230 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
231 |
public void buildConstantMembers(XMLNode node, Content classConstantTree) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
232 |
new ConstantFieldBuilder(currentClass).buildMembersSummary(node, classConstantTree); |
10 | 233 |
} |
234 |
||
235 |
/** |
|
236 |
* Return true if the given package has constant fields to document. |
|
237 |
* |
|
238 |
* @param pkg the package being checked. |
|
239 |
* @return true if the given package has constant fields to document. |
|
240 |
*/ |
|
241 |
private boolean hasConstantField(PackageDoc pkg) { |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
242 |
ClassDoc[] classes |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
243 |
= (pkg.name().length() > 0) |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
244 |
? pkg.allClasses() |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
245 |
: configuration.classDocCatalog.allClasses(DocletConstants.DEFAULT_PACKAGE_NAME); |
10 | 246 |
boolean found = false; |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
247 |
for (ClassDoc doc : classes) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
248 |
if (doc.isIncluded() && hasConstantField(doc)) { |
10 | 249 |
found = true; |
250 |
} |
|
251 |
} |
|
252 |
return found; |
|
253 |
} |
|
254 |
||
255 |
/** |
|
256 |
* Return true if the given class has constant fields to document. |
|
257 |
* |
|
258 |
* @param classDoc the class being checked. |
|
259 |
* @return true if the given package has constant fields to document. |
|
260 |
*/ |
|
261 |
private boolean hasConstantField (ClassDoc classDoc) { |
|
262 |
VisibleMemberMap visibleMemberMapFields = new VisibleMemberMap(classDoc, |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14542
diff
changeset
|
263 |
VisibleMemberMap.FIELDS, configuration); |
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
264 |
List<?> fields = visibleMemberMapFields.getLeafClassMembers(configuration); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
265 |
for (Object f : fields) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
266 |
FieldDoc field = (FieldDoc) f; |
10 | 267 |
if (field.constantValueExpression() != null) { |
268 |
classDocsWithConstFields.add(classDoc); |
|
269 |
return true; |
|
270 |
} |
|
271 |
} |
|
272 |
return false; |
|
273 |
} |
|
274 |
||
275 |
/** |
|
276 |
* Return true if the given package name has been printed. Also |
|
277 |
* return true if the root of this package has been printed. |
|
278 |
* |
|
279 |
* @param pkgname the name of the package to check. |
|
280 |
*/ |
|
281 |
private boolean hasPrintedPackageIndex(String pkgname) { |
|
868 | 282 |
String[] list = printedPackageHeaders.toArray(new String[] {}); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
283 |
for (String packageHeader : list) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
16319
diff
changeset
|
284 |
if (pkgname.startsWith(packageHeader)) { |
10 | 285 |
return true; |
286 |
} |
|
287 |
} |
|
288 |
return false; |
|
289 |
} |
|
290 |
||
291 |
/** |
|
292 |
* Print the table of constants. |
|
293 |
* |
|
294 |
* @author Jamie Ho |
|
295 |
* @since 1.4 |
|
296 |
*/ |
|
297 |
private class ConstantFieldBuilder { |
|
298 |
||
299 |
/** |
|
300 |
* The map used to get the visible variables. |
|
301 |
*/ |
|
302 |
protected VisibleMemberMap visibleMemberMapFields = null; |
|
303 |
||
304 |
/** |
|
305 |
* The map used to get the visible variables. |
|
306 |
*/ |
|
307 |
protected VisibleMemberMap visibleMemberMapEnumConst = null; |
|
308 |
||
309 |
/** |
|
310 |
* The classdoc that we are examining constants for. |
|
311 |
*/ |
|
312 |
protected ClassDoc classdoc; |
|
313 |
||
314 |
/** |
|
315 |
* Construct a ConstantFieldSubWriter. |
|
316 |
* @param classdoc the classdoc that we are examining constants for. |
|
317 |
*/ |
|
318 |
public ConstantFieldBuilder(ClassDoc classdoc) { |
|
319 |
this.classdoc = classdoc; |
|
320 |
visibleMemberMapFields = new VisibleMemberMap(classdoc, |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14542
diff
changeset
|
321 |
VisibleMemberMap.FIELDS, configuration); |
10 | 322 |
visibleMemberMapEnumConst = new VisibleMemberMap(classdoc, |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14542
diff
changeset
|
323 |
VisibleMemberMap.ENUM_CONSTANTS, configuration); |
10 | 324 |
} |
325 |
||
326 |
/** |
|
327 |
* Builds the table of constants for a given class. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
328 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
329 |
* @param node the XML element that specifies which components to document |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
330 |
* @param classConstantTree the tree to which the class constants table |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
331 |
* will be added |
10 | 332 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
333 |
protected void buildMembersSummary(XMLNode node, Content classConstantTree) { |
22163 | 334 |
List<FieldDoc> members = new ArrayList<>(members()); |
10 | 335 |
if (members.size() > 0) { |
336 |
Collections.sort(members); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
337 |
writer.addConstantMembers(classdoc, members, classConstantTree); |
10 | 338 |
} |
339 |
} |
|
340 |
||
341 |
/** |
|
342 |
* Return the list of visible constant fields for the given classdoc. |
|
343 |
* @return the list of visible constant fields for the given classdoc. |
|
344 |
*/ |
|
868 | 345 |
protected List<FieldDoc> members() { |
346 |
List<ProgramElementDoc> l = visibleMemberMapFields.getLeafClassMembers(configuration); |
|
10 | 347 |
l.addAll(visibleMemberMapEnumConst.getLeafClassMembers(configuration)); |
868 | 348 |
Iterator<ProgramElementDoc> iter; |
10 | 349 |
|
350 |
if(l != null){ |
|
351 |
iter = l.iterator(); |
|
352 |
} else { |
|
353 |
return null; |
|
354 |
} |
|
22163 | 355 |
List<FieldDoc> inclList = new LinkedList<>(); |
10 | 356 |
FieldDoc member; |
357 |
while(iter.hasNext()){ |
|
358 |
member = (FieldDoc)iter.next(); |
|
359 |
if(member.constantValue() != null){ |
|
360 |
inclList.add(member); |
|
361 |
} |
|
362 |
} |
|
363 |
return inclList; |
|
364 |
} |
|
365 |
} |
|
366 |
||
367 |
/** |
|
368 |
* Parse the package name. We only want to display package name up to |
|
369 |
* 2 levels. |
|
370 |
*/ |
|
371 |
private String parsePackageName(String pkgname) { |
|
372 |
int index = -1; |
|
373 |
for (int j = 0; j < MAX_CONSTANT_VALUE_INDEX_LENGTH; j++) { |
|
374 |
index = pkgname.indexOf(".", index + 1); |
|
375 |
} |
|
376 |
if (index != -1) { |
|
377 |
pkgname = pkgname.substring(0, index); |
|
378 |
} |
|
379 |
return pkgname; |
|
380 |
} |
|
381 |
} |