src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java

Wed, 18 Sep 2013 17:13:26 -0700

author
bpatel
date
Wed, 18 Sep 2013 17:13:26 -0700
changeset 2035
a2a5ad0853ed
parent 1746
bd51ca92c013
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8015249: javadoc fails to document static final fields in annotation types
Reviewed-by: jjg

duke@1 1 /*
jjg@1606 2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.internal.toolkit.builders;
duke@1 27
bpatel@766 28 import java.io.*;
jjg@1357 29
bpatel@766 30 import com.sun.javadoc.*;
jjg@1357 31 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 32 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 33
duke@1 34 /**
duke@1 35 * Builds the summary for a given package.
duke@1 36 *
jjg@1359 37 * <p><b>This is NOT part of any supported API.
jjg@1359 38 * If you write code that depends on this, you do so at your own risk.
jjg@1359 39 * This code and its internal interfaces are subject to change or
jjg@1359 40 * deletion without notice.</b>
duke@1 41 *
duke@1 42 * @author Jamie Ho
bpatel@243 43 * @author Bhavesh Patel (Modified)
duke@1 44 * @since 1.5
duke@1 45 */
duke@1 46 public class PackageSummaryBuilder extends AbstractBuilder {
bpatel@766 47 /**
bpatel@766 48 * The root element of the package summary XML is {@value}.
bpatel@766 49 */
bpatel@766 50 public static final String ROOT = "PackageDoc";
duke@1 51
bpatel@766 52 /**
bpatel@766 53 * The package being documented.
bpatel@766 54 */
jjg@1410 55 private final PackageDoc packageDoc;
duke@1 56
bpatel@766 57 /**
bpatel@766 58 * The doclet specific writer that will output the result.
bpatel@766 59 */
jjg@1410 60 private final PackageSummaryWriter packageWriter;
duke@1 61
bpatel@766 62 /**
bpatel@766 63 * The content that will be added to the package summary documentation tree.
bpatel@766 64 */
bpatel@766 65 private Content contentTree;
duke@1 66
jjg@1410 67 /**
jjg@1410 68 * Construct a new PackageSummaryBuilder.
jjg@1410 69 *
jjg@1410 70 * @param context the build context.
jjg@1410 71 * @param pkg the package being documented.
jjg@1410 72 * @param packageWriter the doclet specific writer that will output the
jjg@1410 73 * result.
jjg@1410 74 */
jjg@1410 75 private PackageSummaryBuilder(Context context,
jjg@1410 76 PackageDoc pkg,
jjg@1410 77 PackageSummaryWriter packageWriter) {
jjg@1410 78 super(context);
jjg@1410 79 this.packageDoc = pkg;
jjg@1410 80 this.packageWriter = packageWriter;
bpatel@766 81 }
bpatel@766 82
bpatel@766 83 /**
bpatel@766 84 * Construct a new PackageSummaryBuilder.
jjg@1410 85 *
jjg@1410 86 * @param context the build context.
bpatel@766 87 * @param pkg the package being documented.
bpatel@766 88 * @param packageWriter the doclet specific writer that will output the
bpatel@766 89 * result.
bpatel@766 90 *
bpatel@766 91 * @return an instance of a PackageSummaryBuilder.
bpatel@766 92 */
jjg@1410 93 public static PackageSummaryBuilder getInstance(Context context,
jjg@1410 94 PackageDoc pkg, PackageSummaryWriter packageWriter) {
jjg@1410 95 return new PackageSummaryBuilder(context, pkg, packageWriter);
bpatel@766 96 }
bpatel@766 97
bpatel@766 98 /**
bpatel@766 99 * Build the package summary.
bpatel@766 100 */
bpatel@766 101 public void build() throws IOException {
bpatel@766 102 if (packageWriter == null) {
bpatel@766 103 //Doclet does not support this output.
bpatel@766 104 return;
duke@1 105 }
jjg@1410 106 build(layoutParser.parseXML(ROOT), contentTree);
bpatel@766 107 }
duke@1 108
bpatel@766 109 /**
bpatel@766 110 * {@inheritDoc}
bpatel@766 111 */
bpatel@766 112 public String getName() {
bpatel@766 113 return ROOT;
bpatel@766 114 }
bpatel@766 115
bpatel@766 116 /**
bpatel@766 117 * Build the package documentation.
bpatel@766 118 *
bpatel@766 119 * @param node the XML element that specifies which components to document
bpatel@766 120 * @param contentTree the content tree to which the documentation will be added
bpatel@766 121 */
bpatel@766 122 public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception {
jjg@1746 123 contentTree = packageWriter.getPackageHeader(Util.getPackageName(packageDoc));
bpatel@766 124 buildChildren(node, contentTree);
bpatel@766 125 packageWriter.addPackageFooter(contentTree);
bpatel@766 126 packageWriter.printDocument(contentTree);
bpatel@766 127 packageWriter.close();
jjg@1383 128 Util.copyDocFiles(configuration, packageDoc);
bpatel@766 129 }
bpatel@766 130
bpatel@766 131 /**
bpatel@766 132 * Build the content for the package doc.
bpatel@766 133 *
bpatel@766 134 * @param node the XML element that specifies which components to document
bpatel@766 135 * @param contentTree the content tree to which the package contents
bpatel@766 136 * will be added
bpatel@766 137 */
bpatel@766 138 public void buildContent(XMLNode node, Content contentTree) {
bpatel@766 139 Content packageContentTree = packageWriter.getContentHeader();
bpatel@766 140 buildChildren(node, packageContentTree);
bpatel@766 141 contentTree.addContent(packageContentTree);
bpatel@766 142 }
bpatel@766 143
bpatel@766 144 /**
bpatel@766 145 * Build the package summary.
bpatel@766 146 *
bpatel@766 147 * @param node the XML element that specifies which components to document
bpatel@766 148 * @param packageContentTree the package content tree to which the summaries will
bpatel@766 149 * be added
bpatel@766 150 */
bpatel@766 151 public void buildSummary(XMLNode node, Content packageContentTree) {
bpatel@766 152 Content summaryContentTree = packageWriter.getSummaryHeader();
bpatel@766 153 buildChildren(node, summaryContentTree);
bpatel@766 154 packageContentTree.addContent(summaryContentTree);
bpatel@766 155 }
bpatel@766 156
bpatel@766 157 /**
bpatel@766 158 * Build the summary for the interfaces in this package.
bpatel@766 159 *
bpatel@766 160 * @param node the XML element that specifies which components to document
bpatel@766 161 * @param summaryContentTree the summary tree to which the interface summary
bpatel@766 162 * will be added
bpatel@766 163 */
bpatel@766 164 public void buildInterfaceSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 165 String interfaceTableSummary =
bpatel@766 166 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 167 configuration.getText("doclet.Interface_Summary"),
bpatel@766 168 configuration.getText("doclet.interfaces"));
bpatel@766 169 String[] interfaceTableHeader = new String[] {
bpatel@766 170 configuration.getText("doclet.Interface"),
bpatel@766 171 configuration.getText("doclet.Description")
bpatel@766 172 };
bpatel@766 173 ClassDoc[] interfaces =
bpatel@766 174 packageDoc.isIncluded()
bpatel@766 175 ? packageDoc.interfaces()
bpatel@766 176 : configuration.classDocCatalog.interfaces(
bpatel@766 177 Util.getPackageName(packageDoc));
jjg@1606 178 interfaces = Util.filterOutPrivateClasses(interfaces, configuration.javafx);
bpatel@766 179 if (interfaces.length > 0) {
bpatel@766 180 packageWriter.addClassesSummary(
bpatel@766 181 interfaces,
bpatel@766 182 configuration.getText("doclet.Interface_Summary"),
bpatel@766 183 interfaceTableSummary, interfaceTableHeader, summaryContentTree);
duke@1 184 }
bpatel@766 185 }
duke@1 186
bpatel@766 187 /**
bpatel@766 188 * Build the summary for the classes in this package.
bpatel@766 189 *
bpatel@766 190 * @param node the XML element that specifies which components to document
bpatel@766 191 * @param summaryContentTree the summary tree to which the class summary will
bpatel@766 192 * be added
bpatel@766 193 */
bpatel@766 194 public void buildClassSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 195 String classTableSummary =
bpatel@766 196 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 197 configuration.getText("doclet.Class_Summary"),
bpatel@766 198 configuration.getText("doclet.classes"));
bpatel@766 199 String[] classTableHeader = new String[] {
bpatel@766 200 configuration.getText("doclet.Class"),
bpatel@766 201 configuration.getText("doclet.Description")
bpatel@766 202 };
bpatel@766 203 ClassDoc[] classes =
bpatel@766 204 packageDoc.isIncluded()
bpatel@766 205 ? packageDoc.ordinaryClasses()
bpatel@766 206 : configuration.classDocCatalog.ordinaryClasses(
bpatel@766 207 Util.getPackageName(packageDoc));
jjg@1606 208 classes = Util.filterOutPrivateClasses(classes, configuration.javafx);
bpatel@766 209 if (classes.length > 0) {
bpatel@766 210 packageWriter.addClassesSummary(
bpatel@766 211 classes,
bpatel@766 212 configuration.getText("doclet.Class_Summary"),
bpatel@766 213 classTableSummary, classTableHeader, summaryContentTree);
duke@1 214 }
bpatel@766 215 }
duke@1 216
bpatel@766 217 /**
bpatel@766 218 * Build the summary for the enums in this package.
bpatel@766 219 *
bpatel@766 220 * @param node the XML element that specifies which components to document
bpatel@766 221 * @param summaryContentTree the summary tree to which the enum summary will
bpatel@766 222 * be added
bpatel@766 223 */
bpatel@766 224 public void buildEnumSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 225 String enumTableSummary =
bpatel@766 226 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 227 configuration.getText("doclet.Enum_Summary"),
bpatel@766 228 configuration.getText("doclet.enums"));
bpatel@766 229 String[] enumTableHeader = new String[] {
bpatel@766 230 configuration.getText("doclet.Enum"),
bpatel@766 231 configuration.getText("doclet.Description")
bpatel@766 232 };
bpatel@766 233 ClassDoc[] enums =
bpatel@766 234 packageDoc.isIncluded()
bpatel@766 235 ? packageDoc.enums()
bpatel@766 236 : configuration.classDocCatalog.enums(
bpatel@766 237 Util.getPackageName(packageDoc));
jjg@1606 238 enums = Util.filterOutPrivateClasses(enums, configuration.javafx);
bpatel@766 239 if (enums.length > 0) {
bpatel@766 240 packageWriter.addClassesSummary(
bpatel@766 241 enums,
bpatel@766 242 configuration.getText("doclet.Enum_Summary"),
bpatel@766 243 enumTableSummary, enumTableHeader, summaryContentTree);
duke@1 244 }
bpatel@766 245 }
duke@1 246
bpatel@766 247 /**
bpatel@766 248 * Build the summary for the exceptions in this package.
bpatel@766 249 *
bpatel@766 250 * @param node the XML element that specifies which components to document
bpatel@766 251 * @param summaryContentTree the summary tree to which the exception summary will
bpatel@766 252 * be added
bpatel@766 253 */
bpatel@766 254 public void buildExceptionSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 255 String exceptionTableSummary =
bpatel@766 256 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 257 configuration.getText("doclet.Exception_Summary"),
bpatel@766 258 configuration.getText("doclet.exceptions"));
bpatel@766 259 String[] exceptionTableHeader = new String[] {
bpatel@766 260 configuration.getText("doclet.Exception"),
bpatel@766 261 configuration.getText("doclet.Description")
bpatel@766 262 };
bpatel@766 263 ClassDoc[] exceptions =
bpatel@766 264 packageDoc.isIncluded()
bpatel@766 265 ? packageDoc.exceptions()
bpatel@766 266 : configuration.classDocCatalog.exceptions(
bpatel@766 267 Util.getPackageName(packageDoc));
jjg@1606 268 exceptions = Util.filterOutPrivateClasses(exceptions, configuration.javafx);
bpatel@766 269 if (exceptions.length > 0) {
bpatel@766 270 packageWriter.addClassesSummary(
bpatel@766 271 exceptions,
bpatel@766 272 configuration.getText("doclet.Exception_Summary"),
bpatel@766 273 exceptionTableSummary, exceptionTableHeader, summaryContentTree);
duke@1 274 }
bpatel@766 275 }
duke@1 276
bpatel@766 277 /**
bpatel@766 278 * Build the summary for the errors in this package.
bpatel@766 279 *
bpatel@766 280 * @param node the XML element that specifies which components to document
bpatel@766 281 * @param summaryContentTree the summary tree to which the error summary will
bpatel@766 282 * be added
bpatel@766 283 */
bpatel@766 284 public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 285 String errorTableSummary =
bpatel@766 286 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 287 configuration.getText("doclet.Error_Summary"),
bpatel@766 288 configuration.getText("doclet.errors"));
bpatel@766 289 String[] errorTableHeader = new String[] {
bpatel@766 290 configuration.getText("doclet.Error"),
bpatel@766 291 configuration.getText("doclet.Description")
bpatel@766 292 };
bpatel@766 293 ClassDoc[] errors =
bpatel@766 294 packageDoc.isIncluded()
bpatel@766 295 ? packageDoc.errors()
bpatel@766 296 : configuration.classDocCatalog.errors(
bpatel@766 297 Util.getPackageName(packageDoc));
jjg@1606 298 errors = Util.filterOutPrivateClasses(errors, configuration.javafx);
bpatel@766 299 if (errors.length > 0) {
bpatel@766 300 packageWriter.addClassesSummary(
bpatel@766 301 errors,
bpatel@766 302 configuration.getText("doclet.Error_Summary"),
bpatel@766 303 errorTableSummary, errorTableHeader, summaryContentTree);
duke@1 304 }
bpatel@766 305 }
duke@1 306
bpatel@766 307 /**
bpatel@766 308 * Build the summary for the annotation type in this package.
bpatel@766 309 *
bpatel@766 310 * @param node the XML element that specifies which components to document
bpatel@766 311 * @param summaryContentTree the summary tree to which the annotation type
bpatel@766 312 * summary will be added
bpatel@766 313 */
bpatel@766 314 public void buildAnnotationTypeSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 315 String annotationtypeTableSummary =
bpatel@766 316 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 317 configuration.getText("doclet.Annotation_Types_Summary"),
bpatel@766 318 configuration.getText("doclet.annotationtypes"));
bpatel@766 319 String[] annotationtypeTableHeader = new String[] {
bpatel@766 320 configuration.getText("doclet.AnnotationType"),
bpatel@766 321 configuration.getText("doclet.Description")
bpatel@766 322 };
bpatel@766 323 ClassDoc[] annotationTypes =
bpatel@766 324 packageDoc.isIncluded()
bpatel@766 325 ? packageDoc.annotationTypes()
bpatel@766 326 : configuration.classDocCatalog.annotationTypes(
bpatel@766 327 Util.getPackageName(packageDoc));
jjg@1606 328 annotationTypes = Util.filterOutPrivateClasses(annotationTypes, configuration.javafx);
bpatel@766 329 if (annotationTypes.length > 0) {
bpatel@766 330 packageWriter.addClassesSummary(
bpatel@766 331 annotationTypes,
bpatel@766 332 configuration.getText("doclet.Annotation_Types_Summary"),
bpatel@766 333 annotationtypeTableSummary, annotationtypeTableHeader,
bpatel@766 334 summaryContentTree);
duke@1 335 }
bpatel@766 336 }
duke@1 337
bpatel@766 338 /**
bpatel@766 339 * Build the description of the summary.
bpatel@766 340 *
bpatel@766 341 * @param node the XML element that specifies which components to document
bpatel@766 342 * @param packageContentTree the tree to which the package description will
bpatel@766 343 * be added
bpatel@766 344 */
bpatel@766 345 public void buildPackageDescription(XMLNode node, Content packageContentTree) {
bpatel@766 346 if (configuration.nocomment) {
bpatel@766 347 return;
duke@1 348 }
bpatel@766 349 packageWriter.addPackageDescription(packageContentTree);
bpatel@766 350 }
duke@1 351
bpatel@766 352 /**
bpatel@766 353 * Build the tags of the summary.
bpatel@766 354 *
bpatel@766 355 * @param node the XML element that specifies which components to document
bpatel@766 356 * @param packageContentTree the tree to which the package tags will be added
bpatel@766 357 */
bpatel@766 358 public void buildPackageTags(XMLNode node, Content packageContentTree) {
bpatel@766 359 if (configuration.nocomment) {
bpatel@766 360 return;
duke@1 361 }
bpatel@766 362 packageWriter.addPackageTags(packageContentTree);
bpatel@766 363 }
duke@1 364 }

mercurial