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

Thu, 15 Nov 2012 19:54:20 -0800

author
jjg
date
Thu, 15 Nov 2012 19:54:20 -0800
changeset 1412
400a4e8accd3
parent 1410
bfec2a1cc869
child 1606
ccbe7ffdd867
permissions
-rw-r--r--

8002079: update DocFile to use a JavaFileManager
Reviewed-by: darcy

duke@1 1 /*
jjg@1357 2 * Copyright (c) 2003, 2012, 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 {
bpatel@766 123 contentTree = packageWriter.getPackageHeader(
bpatel@766 124 Util.getPackageName(packageDoc));
bpatel@766 125 buildChildren(node, contentTree);
bpatel@766 126 packageWriter.addPackageFooter(contentTree);
bpatel@766 127 packageWriter.printDocument(contentTree);
bpatel@766 128 packageWriter.close();
jjg@1383 129 Util.copyDocFiles(configuration, packageDoc);
bpatel@766 130 }
bpatel@766 131
bpatel@766 132 /**
bpatel@766 133 * Build the content for the package doc.
bpatel@766 134 *
bpatel@766 135 * @param node the XML element that specifies which components to document
bpatel@766 136 * @param contentTree the content tree to which the package contents
bpatel@766 137 * will be added
bpatel@766 138 */
bpatel@766 139 public void buildContent(XMLNode node, Content contentTree) {
bpatel@766 140 Content packageContentTree = packageWriter.getContentHeader();
bpatel@766 141 buildChildren(node, packageContentTree);
bpatel@766 142 contentTree.addContent(packageContentTree);
bpatel@766 143 }
bpatel@766 144
bpatel@766 145 /**
bpatel@766 146 * Build the package summary.
bpatel@766 147 *
bpatel@766 148 * @param node the XML element that specifies which components to document
bpatel@766 149 * @param packageContentTree the package content tree to which the summaries will
bpatel@766 150 * be added
bpatel@766 151 */
bpatel@766 152 public void buildSummary(XMLNode node, Content packageContentTree) {
bpatel@766 153 Content summaryContentTree = packageWriter.getSummaryHeader();
bpatel@766 154 buildChildren(node, summaryContentTree);
bpatel@766 155 packageContentTree.addContent(summaryContentTree);
bpatel@766 156 }
bpatel@766 157
bpatel@766 158 /**
bpatel@766 159 * Build the summary for the interfaces in this package.
bpatel@766 160 *
bpatel@766 161 * @param node the XML element that specifies which components to document
bpatel@766 162 * @param summaryContentTree the summary tree to which the interface summary
bpatel@766 163 * will be added
bpatel@766 164 */
bpatel@766 165 public void buildInterfaceSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 166 String interfaceTableSummary =
bpatel@766 167 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 168 configuration.getText("doclet.Interface_Summary"),
bpatel@766 169 configuration.getText("doclet.interfaces"));
bpatel@766 170 String[] interfaceTableHeader = new String[] {
bpatel@766 171 configuration.getText("doclet.Interface"),
bpatel@766 172 configuration.getText("doclet.Description")
bpatel@766 173 };
bpatel@766 174 ClassDoc[] interfaces =
bpatel@766 175 packageDoc.isIncluded()
bpatel@766 176 ? packageDoc.interfaces()
bpatel@766 177 : configuration.classDocCatalog.interfaces(
bpatel@766 178 Util.getPackageName(packageDoc));
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));
bpatel@766 208 if (classes.length > 0) {
bpatel@766 209 packageWriter.addClassesSummary(
bpatel@766 210 classes,
bpatel@766 211 configuration.getText("doclet.Class_Summary"),
bpatel@766 212 classTableSummary, classTableHeader, summaryContentTree);
duke@1 213 }
bpatel@766 214 }
duke@1 215
bpatel@766 216 /**
bpatel@766 217 * Build the summary for the enums in this package.
bpatel@766 218 *
bpatel@766 219 * @param node the XML element that specifies which components to document
bpatel@766 220 * @param summaryContentTree the summary tree to which the enum summary will
bpatel@766 221 * be added
bpatel@766 222 */
bpatel@766 223 public void buildEnumSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 224 String enumTableSummary =
bpatel@766 225 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 226 configuration.getText("doclet.Enum_Summary"),
bpatel@766 227 configuration.getText("doclet.enums"));
bpatel@766 228 String[] enumTableHeader = new String[] {
bpatel@766 229 configuration.getText("doclet.Enum"),
bpatel@766 230 configuration.getText("doclet.Description")
bpatel@766 231 };
bpatel@766 232 ClassDoc[] enums =
bpatel@766 233 packageDoc.isIncluded()
bpatel@766 234 ? packageDoc.enums()
bpatel@766 235 : configuration.classDocCatalog.enums(
bpatel@766 236 Util.getPackageName(packageDoc));
bpatel@766 237 if (enums.length > 0) {
bpatel@766 238 packageWriter.addClassesSummary(
bpatel@766 239 enums,
bpatel@766 240 configuration.getText("doclet.Enum_Summary"),
bpatel@766 241 enumTableSummary, enumTableHeader, summaryContentTree);
duke@1 242 }
bpatel@766 243 }
duke@1 244
bpatel@766 245 /**
bpatel@766 246 * Build the summary for the exceptions in this package.
bpatel@766 247 *
bpatel@766 248 * @param node the XML element that specifies which components to document
bpatel@766 249 * @param summaryContentTree the summary tree to which the exception summary will
bpatel@766 250 * be added
bpatel@766 251 */
bpatel@766 252 public void buildExceptionSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 253 String exceptionTableSummary =
bpatel@766 254 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 255 configuration.getText("doclet.Exception_Summary"),
bpatel@766 256 configuration.getText("doclet.exceptions"));
bpatel@766 257 String[] exceptionTableHeader = new String[] {
bpatel@766 258 configuration.getText("doclet.Exception"),
bpatel@766 259 configuration.getText("doclet.Description")
bpatel@766 260 };
bpatel@766 261 ClassDoc[] exceptions =
bpatel@766 262 packageDoc.isIncluded()
bpatel@766 263 ? packageDoc.exceptions()
bpatel@766 264 : configuration.classDocCatalog.exceptions(
bpatel@766 265 Util.getPackageName(packageDoc));
bpatel@766 266 if (exceptions.length > 0) {
bpatel@766 267 packageWriter.addClassesSummary(
bpatel@766 268 exceptions,
bpatel@766 269 configuration.getText("doclet.Exception_Summary"),
bpatel@766 270 exceptionTableSummary, exceptionTableHeader, summaryContentTree);
duke@1 271 }
bpatel@766 272 }
duke@1 273
bpatel@766 274 /**
bpatel@766 275 * Build the summary for the errors in this package.
bpatel@766 276 *
bpatel@766 277 * @param node the XML element that specifies which components to document
bpatel@766 278 * @param summaryContentTree the summary tree to which the error summary will
bpatel@766 279 * be added
bpatel@766 280 */
bpatel@766 281 public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 282 String errorTableSummary =
bpatel@766 283 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 284 configuration.getText("doclet.Error_Summary"),
bpatel@766 285 configuration.getText("doclet.errors"));
bpatel@766 286 String[] errorTableHeader = new String[] {
bpatel@766 287 configuration.getText("doclet.Error"),
bpatel@766 288 configuration.getText("doclet.Description")
bpatel@766 289 };
bpatel@766 290 ClassDoc[] errors =
bpatel@766 291 packageDoc.isIncluded()
bpatel@766 292 ? packageDoc.errors()
bpatel@766 293 : configuration.classDocCatalog.errors(
bpatel@766 294 Util.getPackageName(packageDoc));
bpatel@766 295 if (errors.length > 0) {
bpatel@766 296 packageWriter.addClassesSummary(
bpatel@766 297 errors,
bpatel@766 298 configuration.getText("doclet.Error_Summary"),
bpatel@766 299 errorTableSummary, errorTableHeader, summaryContentTree);
duke@1 300 }
bpatel@766 301 }
duke@1 302
bpatel@766 303 /**
bpatel@766 304 * Build the summary for the annotation type in this package.
bpatel@766 305 *
bpatel@766 306 * @param node the XML element that specifies which components to document
bpatel@766 307 * @param summaryContentTree the summary tree to which the annotation type
bpatel@766 308 * summary will be added
bpatel@766 309 */
bpatel@766 310 public void buildAnnotationTypeSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 311 String annotationtypeTableSummary =
bpatel@766 312 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 313 configuration.getText("doclet.Annotation_Types_Summary"),
bpatel@766 314 configuration.getText("doclet.annotationtypes"));
bpatel@766 315 String[] annotationtypeTableHeader = new String[] {
bpatel@766 316 configuration.getText("doclet.AnnotationType"),
bpatel@766 317 configuration.getText("doclet.Description")
bpatel@766 318 };
bpatel@766 319 ClassDoc[] annotationTypes =
bpatel@766 320 packageDoc.isIncluded()
bpatel@766 321 ? packageDoc.annotationTypes()
bpatel@766 322 : configuration.classDocCatalog.annotationTypes(
bpatel@766 323 Util.getPackageName(packageDoc));
bpatel@766 324 if (annotationTypes.length > 0) {
bpatel@766 325 packageWriter.addClassesSummary(
bpatel@766 326 annotationTypes,
bpatel@766 327 configuration.getText("doclet.Annotation_Types_Summary"),
bpatel@766 328 annotationtypeTableSummary, annotationtypeTableHeader,
bpatel@766 329 summaryContentTree);
duke@1 330 }
bpatel@766 331 }
duke@1 332
bpatel@766 333 /**
bpatel@766 334 * Build the description of the summary.
bpatel@766 335 *
bpatel@766 336 * @param node the XML element that specifies which components to document
bpatel@766 337 * @param packageContentTree the tree to which the package description will
bpatel@766 338 * be added
bpatel@766 339 */
bpatel@766 340 public void buildPackageDescription(XMLNode node, Content packageContentTree) {
bpatel@766 341 if (configuration.nocomment) {
bpatel@766 342 return;
duke@1 343 }
bpatel@766 344 packageWriter.addPackageDescription(packageContentTree);
bpatel@766 345 }
duke@1 346
bpatel@766 347 /**
bpatel@766 348 * Build the tags of the summary.
bpatel@766 349 *
bpatel@766 350 * @param node the XML element that specifies which components to document
bpatel@766 351 * @param packageContentTree the tree to which the package tags will be added
bpatel@766 352 */
bpatel@766 353 public void buildPackageTags(XMLNode node, Content packageContentTree) {
bpatel@766 354 if (configuration.nocomment) {
bpatel@766 355 return;
duke@1 356 }
bpatel@766 357 packageWriter.addPackageTags(packageContentTree);
bpatel@766 358 }
duke@1 359 }

mercurial