author | ohair |
Tue, 28 Dec 2010 15:54:52 -0800 | |
changeset 7681 | 1f0819a3341f |
parent 7614 | cfadc977ca75 |
child 14258 | 8d2148961366 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
7681 | 2 |
* Copyright (c) 2003, 2010, 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.*; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
30 |
import com.sun.javadoc.*; |
10 | 31 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
32 |
import com.sun.tools.doclets.internal.toolkit.*; |
|
33 |
||
34 |
/** |
|
35 |
* Builds the Constants Summary Page. |
|
36 |
* |
|
37 |
* This code is not part of an API. |
|
38 |
* It is implementation that is subject to change. |
|
39 |
* Do not use it as an API |
|
40 |
* |
|
41 |
* @author Jamie Ho |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
42 |
* @author Bhavesh Patel (Modified) |
10 | 43 |
* @since 1.5 |
44 |
*/ |
|
45 |
public class ConstantsSummaryBuilder extends AbstractBuilder { |
|
46 |
||
47 |
/** |
|
48 |
* The root element of the constant summary XML is {@value}. |
|
49 |
*/ |
|
50 |
public static final String ROOT = "ConstantSummary"; |
|
51 |
||
52 |
/** |
|
53 |
* The maximum number of package directories shown in the constant |
|
54 |
* value index. |
|
55 |
*/ |
|
56 |
public static final int MAX_CONSTANT_VALUE_INDEX_LENGTH = 2; |
|
57 |
||
58 |
/** |
|
59 |
* The writer used to write the results. |
|
60 |
*/ |
|
61 |
protected ConstantsSummaryWriter writer; |
|
62 |
||
63 |
/** |
|
64 |
* The set of ClassDocs that have constant fields. |
|
65 |
*/ |
|
868 | 66 |
protected Set<ClassDoc> classDocsWithConstFields; |
10 | 67 |
|
68 |
/** |
|
69 |
* The set of printed package headers. |
|
70 |
*/ |
|
868 | 71 |
protected Set<String> printedPackageHeaders; |
10 | 72 |
|
73 |
/** |
|
74 |
* The current package being documented. |
|
75 |
*/ |
|
76 |
private PackageDoc currentPackage; |
|
77 |
||
78 |
/** |
|
79 |
* The current class being documented. |
|
80 |
*/ |
|
81 |
private ClassDoc currentClass; |
|
82 |
||
83 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
84 |
* 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
|
85 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
86 |
private Content contentTree; |
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 |
/** |
10 | 89 |
* Construct a new ConstantsSummaryBuilder. |
90 |
* |
|
91 |
* @param configuration the current configuration of the |
|
92 |
* doclet. |
|
93 |
*/ |
|
94 |
private ConstantsSummaryBuilder(Configuration configuration) { |
|
95 |
super(configuration); |
|
96 |
} |
|
97 |
||
98 |
/** |
|
99 |
* Construct a ConstantsSummaryBuilder. |
|
100 |
* |
|
101 |
* @param configuration the configuration used in this run |
|
102 |
* of the doclet. |
|
103 |
* @param writer the writer for the summary. |
|
104 |
*/ |
|
105 |
public static ConstantsSummaryBuilder getInstance( |
|
106 |
Configuration configuration, ConstantsSummaryWriter writer) { |
|
107 |
ConstantsSummaryBuilder builder = new ConstantsSummaryBuilder( |
|
108 |
configuration); |
|
109 |
builder.writer = writer; |
|
868 | 110 |
builder.classDocsWithConstFields = new HashSet<ClassDoc>(); |
10 | 111 |
return builder; |
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 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
122 |
build(LayoutParser.getInstance(configuration).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(); |
10 | 154 |
PackageDoc[] packages = configuration.packages; |
868 | 155 |
printedPackageHeaders = new HashSet<String>(); |
10 | 156 |
for (int i = 0; i < packages.length; i++) { |
157 |
if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
158 |
writer.addLinkToPackageContent(packages[i], |
10 | 159 |
parsePackageName(packages[i].name()), |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
160 |
printedPackageHeaders, contentListTree); |
10 | 161 |
} |
162 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
163 |
contentTree.addContent(writer.getContentsList(contentListTree)); |
10 | 164 |
} |
165 |
||
166 |
/** |
|
167 |
* Build the summary for each documented package. |
|
168 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
169 |
* @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
|
170 |
* @param contentTree the tree to which the summaries will be added |
10 | 171 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
172 |
public void buildConstantSummaries(XMLNode node, Content contentTree) { |
10 | 173 |
PackageDoc[] packages = configuration.packages; |
868 | 174 |
printedPackageHeaders = new HashSet<String>(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
175 |
Content summariesTree = writer.getConstantSummaries(); |
10 | 176 |
for (int i = 0; i < packages.length; i++) { |
177 |
if (hasConstantField(packages[i])) { |
|
178 |
currentPackage = packages[i]; |
|
179 |
//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
|
180 |
buildChildren(node, summariesTree); |
10 | 181 |
} |
182 |
} |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
183 |
contentTree.addContent(summariesTree); |
10 | 184 |
} |
185 |
||
186 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
187 |
* Build the header for the given package. |
10 | 188 |
* |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
189 |
* @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
|
190 |
* @param summariesTree the tree to which the package header will be added |
10 | 191 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
192 |
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
|
193 |
String parsedPackageName = parsePackageName(currentPackage.name()); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
194 |
if (! printedPackageHeaders.contains(parsedPackageName)) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
195 |
writer.addPackageName(currentPackage, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
196 |
parsePackageName(currentPackage.name()), summariesTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
197 |
printedPackageHeaders.add(parsedPackageName); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
198 |
} |
10 | 199 |
} |
200 |
||
201 |
/** |
|
202 |
* Build the summary for the current class. |
|
203 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
204 |
* @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
|
205 |
* @param summariesTree the tree to which the class constant summary will be added |
10 | 206 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
207 |
public void buildClassConstantSummary(XMLNode node, Content summariesTree) { |
10 | 208 |
ClassDoc[] classes = currentPackage.name().length() > 0 ? |
209 |
currentPackage.allClasses() : |
|
210 |
configuration.classDocCatalog.allClasses( |
|
211 |
DocletConstants.DEFAULT_PACKAGE_NAME); |
|
212 |
Arrays.sort(classes); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
213 |
Content classConstantTree = writer.getClassConstantHeader(); |
10 | 214 |
for (int i = 0; i < classes.length; i++) { |
215 |
if (! classDocsWithConstFields.contains(classes[i]) || |
|
216 |
! classes[i].isIncluded()) { |
|
217 |
continue; |
|
218 |
} |
|
219 |
currentClass = classes[i]; |
|
220 |
//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
|
221 |
buildChildren(node, classConstantTree); |
10 | 222 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
223 |
summariesTree.addContent(classConstantTree); |
10 | 224 |
} |
225 |
||
226 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
227 |
* 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
|
228 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
229 |
* @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
|
230 |
* @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
|
231 |
* will be added |
10 | 232 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
233 |
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
|
234 |
new ConstantFieldBuilder(currentClass).buildMembersSummary(node, classConstantTree); |
10 | 235 |
} |
236 |
||
237 |
/** |
|
238 |
* Return true if the given package has constant fields to document. |
|
239 |
* |
|
240 |
* @param pkg the package being checked. |
|
241 |
* @return true if the given package has constant fields to document. |
|
242 |
*/ |
|
243 |
private boolean hasConstantField(PackageDoc pkg) { |
|
244 |
ClassDoc[] classes; |
|
245 |
if (pkg.name().length() > 0) { |
|
246 |
classes = pkg.allClasses(); |
|
247 |
} else { |
|
248 |
classes = configuration.classDocCatalog.allClasses( |
|
249 |
DocletConstants.DEFAULT_PACKAGE_NAME); |
|
250 |
} |
|
251 |
boolean found = false; |
|
252 |
for (int j = 0; j < classes.length; j++){ |
|
253 |
if (classes[j].isIncluded() && hasConstantField(classes[j])) { |
|
254 |
found = true; |
|
255 |
} |
|
256 |
} |
|
257 |
return found; |
|
258 |
} |
|
259 |
||
260 |
/** |
|
261 |
* Return true if the given class has constant fields to document. |
|
262 |
* |
|
263 |
* @param classDoc the class being checked. |
|
264 |
* @return true if the given package has constant fields to document. |
|
265 |
*/ |
|
266 |
private boolean hasConstantField (ClassDoc classDoc) { |
|
267 |
VisibleMemberMap visibleMemberMapFields = new VisibleMemberMap(classDoc, |
|
268 |
VisibleMemberMap.FIELDS, configuration.nodeprecated); |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
269 |
List<?> fields = visibleMemberMapFields.getLeafClassMembers(configuration); |
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
270 |
for (Iterator<?> iter = fields.iterator(); iter.hasNext(); ) { |
10 | 271 |
FieldDoc field = (FieldDoc) iter.next(); |
272 |
if (field.constantValueExpression() != null) { |
|
273 |
classDocsWithConstFields.add(classDoc); |
|
274 |
return true; |
|
275 |
} |
|
276 |
} |
|
277 |
return false; |
|
278 |
} |
|
279 |
||
280 |
/** |
|
281 |
* Return true if the given package name has been printed. Also |
|
282 |
* return true if the root of this package has been printed. |
|
283 |
* |
|
284 |
* @param pkgname the name of the package to check. |
|
285 |
*/ |
|
286 |
private boolean hasPrintedPackageIndex(String pkgname) { |
|
868 | 287 |
String[] list = printedPackageHeaders.toArray(new String[] {}); |
10 | 288 |
for (int i = 0; i < list.length; i++) { |
289 |
if (pkgname.startsWith(list[i])) { |
|
290 |
return true; |
|
291 |
} |
|
292 |
} |
|
293 |
return false; |
|
294 |
} |
|
295 |
||
296 |
/** |
|
297 |
* Print the table of constants. |
|
298 |
* |
|
299 |
* @author Jamie Ho |
|
300 |
* @since 1.4 |
|
301 |
*/ |
|
302 |
private class ConstantFieldBuilder { |
|
303 |
||
304 |
/** |
|
305 |
* The map used to get the visible variables. |
|
306 |
*/ |
|
307 |
protected VisibleMemberMap visibleMemberMapFields = null; |
|
308 |
||
309 |
/** |
|
310 |
* The map used to get the visible variables. |
|
311 |
*/ |
|
312 |
protected VisibleMemberMap visibleMemberMapEnumConst = null; |
|
313 |
||
314 |
/** |
|
315 |
* The classdoc that we are examining constants for. |
|
316 |
*/ |
|
317 |
protected ClassDoc classdoc; |
|
318 |
||
319 |
/** |
|
320 |
* Construct a ConstantFieldSubWriter. |
|
321 |
* @param classdoc the classdoc that we are examining constants for. |
|
322 |
*/ |
|
323 |
public ConstantFieldBuilder(ClassDoc classdoc) { |
|
324 |
this.classdoc = classdoc; |
|
325 |
visibleMemberMapFields = new VisibleMemberMap(classdoc, |
|
326 |
VisibleMemberMap.FIELDS, configuration.nodeprecated); |
|
327 |
visibleMemberMapEnumConst = new VisibleMemberMap(classdoc, |
|
328 |
VisibleMemberMap.ENUM_CONSTANTS, configuration.nodeprecated); |
|
329 |
} |
|
330 |
||
331 |
/** |
|
332 |
* 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
|
333 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
334 |
* @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
|
335 |
* @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
|
336 |
* will be added |
10 | 337 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
338 |
protected void buildMembersSummary(XMLNode node, Content classConstantTree) { |
868 | 339 |
List<FieldDoc> members = new ArrayList<FieldDoc>(members()); |
10 | 340 |
if (members.size() > 0) { |
341 |
Collections.sort(members); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
342 |
writer.addConstantMembers(classdoc, members, classConstantTree); |
10 | 343 |
} |
344 |
} |
|
345 |
||
346 |
/** |
|
347 |
* Return the list of visible constant fields for the given classdoc. |
|
348 |
* @param cd the classdoc to examine. |
|
349 |
* @return the list of visible constant fields for the given classdoc. |
|
350 |
*/ |
|
868 | 351 |
protected List<FieldDoc> members() { |
352 |
List<ProgramElementDoc> l = visibleMemberMapFields.getLeafClassMembers(configuration); |
|
10 | 353 |
l.addAll(visibleMemberMapEnumConst.getLeafClassMembers(configuration)); |
868 | 354 |
Iterator<ProgramElementDoc> iter; |
10 | 355 |
|
356 |
if(l != null){ |
|
357 |
iter = l.iterator(); |
|
358 |
} else { |
|
359 |
return null; |
|
360 |
} |
|
868 | 361 |
List<FieldDoc> inclList = new LinkedList<FieldDoc>(); |
10 | 362 |
FieldDoc member; |
363 |
while(iter.hasNext()){ |
|
364 |
member = (FieldDoc)iter.next(); |
|
365 |
if(member.constantValue() != null){ |
|
366 |
inclList.add(member); |
|
367 |
} |
|
368 |
} |
|
369 |
return inclList; |
|
370 |
} |
|
371 |
} |
|
372 |
||
373 |
/** |
|
374 |
* Parse the package name. We only want to display package name up to |
|
375 |
* 2 levels. |
|
376 |
*/ |
|
377 |
private String parsePackageName(String pkgname) { |
|
378 |
int index = -1; |
|
379 |
for (int j = 0; j < MAX_CONSTANT_VALUE_INDEX_LENGTH; j++) { |
|
380 |
index = pkgname.indexOf(".", index + 1); |
|
381 |
} |
|
382 |
if (index != -1) { |
|
383 |
pkgname = pkgname.substring(0, index); |
|
384 |
} |
|
385 |
return pkgname; |
|
386 |
} |
|
387 |
} |