28 import com.sun.tools.doclets.internal.toolkit.util.*; |
28 import com.sun.tools.doclets.internal.toolkit.util.*; |
29 import com.sun.tools.doclets.internal.toolkit.*; |
29 import com.sun.tools.doclets.internal.toolkit.*; |
30 import com.sun.javadoc.*; |
30 import com.sun.javadoc.*; |
31 import java.io.*; |
31 import java.io.*; |
32 import java.util.*; |
32 import java.util.*; |
33 import java.lang.reflect.*; |
|
34 |
33 |
35 /** |
34 /** |
36 * Builds the Constants Summary Page. |
35 * Builds the Constants Summary Page. |
37 * |
36 * |
38 * This code is not part of an API. |
37 * This code is not part of an API. |
107 } |
106 } |
108 |
107 |
109 /** |
108 /** |
110 * {@inheritDoc} |
109 * {@inheritDoc} |
111 */ |
110 */ |
112 public void invokeMethod(String methodName, Class<?>[] paramClasses, |
|
113 Object[] params) |
|
114 throws Exception { |
|
115 if (DEBUG) { |
|
116 configuration.root.printError("DEBUG: " + this.getClass().getName() |
|
117 + "." + methodName); |
|
118 } |
|
119 Method method = this.getClass().getMethod(methodName, paramClasses); |
|
120 method.invoke(this, params); |
|
121 } |
|
122 |
|
123 /** |
|
124 * {@inheritDoc} |
|
125 */ |
|
126 public void build() throws IOException { |
111 public void build() throws IOException { |
127 if (writer == null) { |
112 if (writer == null) { |
128 //Doclet does not support this output. |
113 //Doclet does not support this output. |
129 return; |
114 return; |
130 } |
115 } |
142 * Build the constant summary. |
127 * Build the constant summary. |
143 * |
128 * |
144 * @param elements the list of elements describing constant summary |
129 * @param elements the list of elements describing constant summary |
145 * documentation. |
130 * documentation. |
146 */ |
131 */ |
147 public void buildConstantSummary(List<?> elements) throws Exception { |
132 public void buildConstantSummary(XMLNode node) throws Exception { |
148 build(elements); |
133 buildChildren(node); |
149 writer.close(); |
134 writer.close(); |
150 } |
135 } |
151 |
136 |
152 /** |
137 /** |
153 * Build the header. |
138 * Build the header. |
154 */ |
139 */ |
155 public void buildHeader() { |
140 public void buildHeader(XMLNode node) { |
156 writer.writeHeader(); |
141 writer.writeHeader(); |
157 } |
142 } |
158 |
143 |
159 /** |
144 /** |
160 * Build the footer. |
145 * Build the footer. |
161 */ |
146 */ |
162 public void buildFooter() { |
147 public void buildFooter(XMLNode node) { |
163 writer.writeFooter(); |
148 writer.writeFooter(); |
164 } |
149 } |
165 |
150 |
166 /** |
151 /** |
167 * Build the table of contents. |
152 * Build the table of contents. |
168 */ |
153 */ |
169 public void buildContents() { |
154 public void buildContents(XMLNode node) { |
170 writer.writeContentsHeader(); |
155 writer.writeContentsHeader(); |
171 PackageDoc[] packages = configuration.packages; |
156 PackageDoc[] packages = configuration.packages; |
172 printedPackageHeaders = new HashSet<String>(); |
157 printedPackageHeaders = new HashSet<String>(); |
173 for (int i = 0; i < packages.length; i++) { |
158 for (int i = 0; i < packages.length; i++) { |
174 if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) { |
159 if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) { |
184 * Build the summary for each documented package. |
169 * Build the summary for each documented package. |
185 * |
170 * |
186 * @param elements the XML elements that represent the components |
171 * @param elements the XML elements that represent the components |
187 * of documentation for each package. |
172 * of documentation for each package. |
188 */ |
173 */ |
189 public void buildConstantSummaries(List<?> elements) { |
174 public void buildConstantSummaries(XMLNode node) { |
190 PackageDoc[] packages = configuration.packages; |
175 PackageDoc[] packages = configuration.packages; |
191 printedPackageHeaders = new HashSet<String>(); |
176 printedPackageHeaders = new HashSet<String>(); |
192 for (int i = 0; i < packages.length; i++) { |
177 for (int i = 0; i < packages.length; i++) { |
193 if (hasConstantField(packages[i])) { |
178 if (hasConstantField(packages[i])) { |
194 currentPackage = packages[i]; |
179 currentPackage = packages[i]; |
195 //Build the documentation for the current package. |
180 //Build the documentation for the current package. |
196 build(elements); |
181 buildChildren(node); |
197 } |
182 } |
198 } |
183 } |
199 } |
184 } |
200 |
185 |
201 /** |
186 /** |
202 * Build the summary for the current package. |
187 * Build the summary for the current package. |
203 * |
188 * |
204 * @param elements the list of XML elements that make up package |
189 * @param elements the list of XML elements that make up package |
205 * documentation. |
190 * documentation. |
206 */ |
191 */ |
207 public void buildPackageConstantSummary(List<?> elements) { |
192 public void buildPackageConstantSummary(XMLNode node) { |
208 build(elements); |
193 buildChildren(node); |
209 } |
194 } |
210 |
195 |
211 /** |
196 /** |
212 * Build the summary for the current class. |
197 * Build the summary for the current class. |
213 * |
198 * |
214 * @param elements the list of XML elements that make up the class |
199 * @param elements the list of XML elements that make up the class |
215 * constant summary. |
200 * constant summary. |
216 */ |
201 */ |
217 public void buildClassConstantSummary(List<?> elements) { |
202 public void buildClassConstantSummary(XMLNode node) { |
218 ClassDoc[] classes = currentPackage.name().length() > 0 ? |
203 ClassDoc[] classes = currentPackage.name().length() > 0 ? |
219 currentPackage.allClasses() : |
204 currentPackage.allClasses() : |
220 configuration.classDocCatalog.allClasses( |
205 configuration.classDocCatalog.allClasses( |
221 DocletConstants.DEFAULT_PACKAGE_NAME); |
206 DocletConstants.DEFAULT_PACKAGE_NAME); |
222 Arrays.sort(classes); |
207 Arrays.sort(classes); |
225 ! classes[i].isIncluded()) { |
210 ! classes[i].isIncluded()) { |
226 continue; |
211 continue; |
227 } |
212 } |
228 currentClass = classes[i]; |
213 currentClass = classes[i]; |
229 //Build the documentation for the current class. |
214 //Build the documentation for the current class. |
230 build(elements); |
215 buildChildren(node); |
231 } |
216 } |
232 } |
217 } |
233 |
218 |
234 /** |
219 /** |
235 * Build the header for the given class. |
220 * Build the header for the given class. |
236 */ |
221 */ |
237 public void buildPackageHeader() { |
222 public void buildPackageHeader(XMLNode node) { |
238 String parsedPackageName = parsePackageName(currentPackage.name()); |
223 String parsedPackageName = parsePackageName(currentPackage.name()); |
239 if (! printedPackageHeaders.contains(parsedPackageName)) { |
224 if (! printedPackageHeaders.contains(parsedPackageName)) { |
240 writer.writePackageName(currentPackage, |
225 writer.writePackageName(currentPackage, |
241 parsePackageName(currentPackage.name())); |
226 parsePackageName(currentPackage.name())); |
242 printedPackageHeaders.add(parsedPackageName); |
227 printedPackageHeaders.add(parsedPackageName); |
244 } |
229 } |
245 |
230 |
246 /** |
231 /** |
247 * Build the header for the given class. |
232 * Build the header for the given class. |
248 */ |
233 */ |
249 public void buildClassHeader() { |
234 public void buildClassHeader(XMLNode node) { |
250 writer.writeConstantMembersHeader(currentClass); |
235 writer.writeConstantMembersHeader(currentClass); |
251 } |
236 } |
252 |
237 |
253 /** |
238 /** |
254 * Print summary of constant members in the |
239 * Print summary of constant members in the |
255 * class. |
240 * class. |
256 */ |
241 */ |
257 public void buildConstantMembers() { |
242 public void buildConstantMembers(XMLNode node) { |
258 new ConstantFieldBuilder(currentClass).buildMembersSummary(); |
243 new ConstantFieldBuilder(currentClass).buildMembersSummary(node); |
259 } |
244 } |
260 |
245 |
261 /** |
246 /** |
262 * Build the footer for the given class. |
247 * Build the footer for the given class. |
263 */ |
248 */ |
264 public void buildClassFooter() { |
249 public void buildClassFooter(XMLNode node) { |
265 writer.writeConstantMembersFooter(currentClass); |
250 writer.writeConstantMembersFooter(currentClass); |
266 } |
251 } |
267 |
252 |
268 /** |
253 /** |
269 * Return true if the given package has constant fields to document. |
254 * Return true if the given package has constant fields to document. |
360 } |
345 } |
361 |
346 |
362 /** |
347 /** |
363 * Builds the table of constants for a given class. |
348 * Builds the table of constants for a given class. |
364 */ |
349 */ |
365 protected void buildMembersSummary() { |
350 protected void buildMembersSummary(XMLNode node) { |
366 List<FieldDoc> members = new ArrayList<FieldDoc>(members()); |
351 List<FieldDoc> members = new ArrayList<FieldDoc>(members()); |
367 if (members.size() > 0) { |
352 if (members.size() > 0) { |
368 Collections.sort(members); |
353 Collections.sort(members); |
369 writer.writeConstantMembers(classdoc, members); |
354 writer.writeConstantMembers(classdoc, members); |
370 } |
355 } |