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

Tue, 28 Dec 2010 15:54:52 -0800

author
ohair
date
Tue, 28 Dec 2010 15:54:52 -0800
changeset 798
4868a36f6fd8
parent 766
90af8d87741f
child 1357
c75be5bc5283
permissions
-rw-r--r--

6962318: Update copyright year
Reviewed-by: xdono

duke@1 1 /*
ohair@798 2 * Copyright (c) 2003, 2010, 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.*;
bpatel@766 29 import com.sun.javadoc.*;
duke@1 30 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 31 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 32
duke@1 33 /**
duke@1 34 * Builds the summary for a given package.
duke@1 35 *
duke@1 36 * This code is not part of an API.
duke@1 37 * It is implementation that is subject to change.
duke@1 38 * Do not use it as an API
duke@1 39 *
duke@1 40 * @author Jamie Ho
bpatel@243 41 * @author Bhavesh Patel (Modified)
duke@1 42 * @since 1.5
duke@1 43 */
duke@1 44 public class PackageSummaryBuilder extends AbstractBuilder {
bpatel@766 45 /**
bpatel@766 46 * The root element of the package summary XML is {@value}.
bpatel@766 47 */
bpatel@766 48 public static final String ROOT = "PackageDoc";
duke@1 49
bpatel@766 50 /**
bpatel@766 51 * The package being documented.
bpatel@766 52 */
bpatel@766 53 private PackageDoc packageDoc;
duke@1 54
bpatel@766 55 /**
bpatel@766 56 * The doclet specific writer that will output the result.
bpatel@766 57 */
bpatel@766 58 private PackageSummaryWriter packageWriter;
duke@1 59
bpatel@766 60 /**
bpatel@766 61 * The content that will be added to the package summary documentation tree.
bpatel@766 62 */
bpatel@766 63 private Content contentTree;
duke@1 64
bpatel@766 65 private PackageSummaryBuilder(Configuration configuration) {
bpatel@766 66 super(configuration);
bpatel@766 67 }
bpatel@766 68
bpatel@766 69 /**
bpatel@766 70 * Construct a new PackageSummaryBuilder.
bpatel@766 71 * @param configuration the current configuration of the doclet.
bpatel@766 72 * @param pkg the package being documented.
bpatel@766 73 * @param packageWriter the doclet specific writer that will output the
bpatel@766 74 * result.
bpatel@766 75 *
bpatel@766 76 * @return an instance of a PackageSummaryBuilder.
bpatel@766 77 */
bpatel@766 78 public static PackageSummaryBuilder getInstance(
bpatel@766 79 Configuration configuration,
bpatel@766 80 PackageDoc pkg,
bpatel@766 81 PackageSummaryWriter packageWriter) {
bpatel@766 82 PackageSummaryBuilder builder =
bpatel@766 83 new PackageSummaryBuilder(configuration);
bpatel@766 84 builder.packageDoc = pkg;
bpatel@766 85 builder.packageWriter = packageWriter;
bpatel@766 86 return builder;
bpatel@766 87 }
bpatel@766 88
bpatel@766 89 /**
bpatel@766 90 * Build the package summary.
bpatel@766 91 */
bpatel@766 92 public void build() throws IOException {
bpatel@766 93 if (packageWriter == null) {
bpatel@766 94 //Doclet does not support this output.
bpatel@766 95 return;
duke@1 96 }
bpatel@766 97 build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
bpatel@766 98 }
duke@1 99
bpatel@766 100 /**
bpatel@766 101 * {@inheritDoc}
bpatel@766 102 */
bpatel@766 103 public String getName() {
bpatel@766 104 return ROOT;
bpatel@766 105 }
bpatel@766 106
bpatel@766 107 /**
bpatel@766 108 * Build the package documentation.
bpatel@766 109 *
bpatel@766 110 * @param node the XML element that specifies which components to document
bpatel@766 111 * @param contentTree the content tree to which the documentation will be added
bpatel@766 112 */
bpatel@766 113 public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception {
bpatel@766 114 contentTree = packageWriter.getPackageHeader(
bpatel@766 115 Util.getPackageName(packageDoc));
bpatel@766 116 buildChildren(node, contentTree);
bpatel@766 117 packageWriter.addPackageFooter(contentTree);
bpatel@766 118 packageWriter.printDocument(contentTree);
bpatel@766 119 packageWriter.close();
bpatel@766 120 Util.copyDocFiles(
bpatel@766 121 configuration,
bpatel@766 122 Util.getPackageSourcePath(configuration, packageDoc),
bpatel@766 123 DirectoryManager.getDirectoryPath(packageDoc)
bpatel@766 124 + File.separator
bpatel@766 125 + DocletConstants.DOC_FILES_DIR_NAME,
bpatel@766 126 true);
bpatel@766 127 }
bpatel@766 128
bpatel@766 129 /**
bpatel@766 130 * Build the content for the package doc.
bpatel@766 131 *
bpatel@766 132 * @param node the XML element that specifies which components to document
bpatel@766 133 * @param contentTree the content tree to which the package contents
bpatel@766 134 * will be added
bpatel@766 135 */
bpatel@766 136 public void buildContent(XMLNode node, Content contentTree) {
bpatel@766 137 Content packageContentTree = packageWriter.getContentHeader();
bpatel@766 138 buildChildren(node, packageContentTree);
bpatel@766 139 contentTree.addContent(packageContentTree);
bpatel@766 140 }
bpatel@766 141
bpatel@766 142 /**
bpatel@766 143 * Build the package summary.
bpatel@766 144 *
bpatel@766 145 * @param node the XML element that specifies which components to document
bpatel@766 146 * @param packageContentTree the package content tree to which the summaries will
bpatel@766 147 * be added
bpatel@766 148 */
bpatel@766 149 public void buildSummary(XMLNode node, Content packageContentTree) {
bpatel@766 150 Content summaryContentTree = packageWriter.getSummaryHeader();
bpatel@766 151 buildChildren(node, summaryContentTree);
bpatel@766 152 packageContentTree.addContent(summaryContentTree);
bpatel@766 153 }
bpatel@766 154
bpatel@766 155 /**
bpatel@766 156 * Build the summary for the interfaces in this package.
bpatel@766 157 *
bpatel@766 158 * @param node the XML element that specifies which components to document
bpatel@766 159 * @param summaryContentTree the summary tree to which the interface summary
bpatel@766 160 * will be added
bpatel@766 161 */
bpatel@766 162 public void buildInterfaceSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 163 String interfaceTableSummary =
bpatel@766 164 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 165 configuration.getText("doclet.Interface_Summary"),
bpatel@766 166 configuration.getText("doclet.interfaces"));
bpatel@766 167 String[] interfaceTableHeader = new String[] {
bpatel@766 168 configuration.getText("doclet.Interface"),
bpatel@766 169 configuration.getText("doclet.Description")
bpatel@766 170 };
bpatel@766 171 ClassDoc[] interfaces =
bpatel@766 172 packageDoc.isIncluded()
bpatel@766 173 ? packageDoc.interfaces()
bpatel@766 174 : configuration.classDocCatalog.interfaces(
bpatel@766 175 Util.getPackageName(packageDoc));
bpatel@766 176 if (interfaces.length > 0) {
bpatel@766 177 packageWriter.addClassesSummary(
bpatel@766 178 interfaces,
bpatel@766 179 configuration.getText("doclet.Interface_Summary"),
bpatel@766 180 interfaceTableSummary, interfaceTableHeader, summaryContentTree);
duke@1 181 }
bpatel@766 182 }
duke@1 183
bpatel@766 184 /**
bpatel@766 185 * Build the summary for the classes in this package.
bpatel@766 186 *
bpatel@766 187 * @param node the XML element that specifies which components to document
bpatel@766 188 * @param summaryContentTree the summary tree to which the class summary will
bpatel@766 189 * be added
bpatel@766 190 */
bpatel@766 191 public void buildClassSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 192 String classTableSummary =
bpatel@766 193 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 194 configuration.getText("doclet.Class_Summary"),
bpatel@766 195 configuration.getText("doclet.classes"));
bpatel@766 196 String[] classTableHeader = new String[] {
bpatel@766 197 configuration.getText("doclet.Class"),
bpatel@766 198 configuration.getText("doclet.Description")
bpatel@766 199 };
bpatel@766 200 ClassDoc[] classes =
bpatel@766 201 packageDoc.isIncluded()
bpatel@766 202 ? packageDoc.ordinaryClasses()
bpatel@766 203 : configuration.classDocCatalog.ordinaryClasses(
bpatel@766 204 Util.getPackageName(packageDoc));
bpatel@766 205 if (classes.length > 0) {
bpatel@766 206 packageWriter.addClassesSummary(
bpatel@766 207 classes,
bpatel@766 208 configuration.getText("doclet.Class_Summary"),
bpatel@766 209 classTableSummary, classTableHeader, summaryContentTree);
duke@1 210 }
bpatel@766 211 }
duke@1 212
bpatel@766 213 /**
bpatel@766 214 * Build the summary for the enums in this package.
bpatel@766 215 *
bpatel@766 216 * @param node the XML element that specifies which components to document
bpatel@766 217 * @param summaryContentTree the summary tree to which the enum summary will
bpatel@766 218 * be added
bpatel@766 219 */
bpatel@766 220 public void buildEnumSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 221 String enumTableSummary =
bpatel@766 222 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 223 configuration.getText("doclet.Enum_Summary"),
bpatel@766 224 configuration.getText("doclet.enums"));
bpatel@766 225 String[] enumTableHeader = new String[] {
bpatel@766 226 configuration.getText("doclet.Enum"),
bpatel@766 227 configuration.getText("doclet.Description")
bpatel@766 228 };
bpatel@766 229 ClassDoc[] enums =
bpatel@766 230 packageDoc.isIncluded()
bpatel@766 231 ? packageDoc.enums()
bpatel@766 232 : configuration.classDocCatalog.enums(
bpatel@766 233 Util.getPackageName(packageDoc));
bpatel@766 234 if (enums.length > 0) {
bpatel@766 235 packageWriter.addClassesSummary(
bpatel@766 236 enums,
bpatel@766 237 configuration.getText("doclet.Enum_Summary"),
bpatel@766 238 enumTableSummary, enumTableHeader, summaryContentTree);
duke@1 239 }
bpatel@766 240 }
duke@1 241
bpatel@766 242 /**
bpatel@766 243 * Build the summary for the exceptions in this package.
bpatel@766 244 *
bpatel@766 245 * @param node the XML element that specifies which components to document
bpatel@766 246 * @param summaryContentTree the summary tree to which the exception summary will
bpatel@766 247 * be added
bpatel@766 248 */
bpatel@766 249 public void buildExceptionSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 250 String exceptionTableSummary =
bpatel@766 251 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 252 configuration.getText("doclet.Exception_Summary"),
bpatel@766 253 configuration.getText("doclet.exceptions"));
bpatel@766 254 String[] exceptionTableHeader = new String[] {
bpatel@766 255 configuration.getText("doclet.Exception"),
bpatel@766 256 configuration.getText("doclet.Description")
bpatel@766 257 };
bpatel@766 258 ClassDoc[] exceptions =
bpatel@766 259 packageDoc.isIncluded()
bpatel@766 260 ? packageDoc.exceptions()
bpatel@766 261 : configuration.classDocCatalog.exceptions(
bpatel@766 262 Util.getPackageName(packageDoc));
bpatel@766 263 if (exceptions.length > 0) {
bpatel@766 264 packageWriter.addClassesSummary(
bpatel@766 265 exceptions,
bpatel@766 266 configuration.getText("doclet.Exception_Summary"),
bpatel@766 267 exceptionTableSummary, exceptionTableHeader, summaryContentTree);
duke@1 268 }
bpatel@766 269 }
duke@1 270
bpatel@766 271 /**
bpatel@766 272 * Build the summary for the errors in this package.
bpatel@766 273 *
bpatel@766 274 * @param node the XML element that specifies which components to document
bpatel@766 275 * @param summaryContentTree the summary tree to which the error summary will
bpatel@766 276 * be added
bpatel@766 277 */
bpatel@766 278 public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 279 String errorTableSummary =
bpatel@766 280 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 281 configuration.getText("doclet.Error_Summary"),
bpatel@766 282 configuration.getText("doclet.errors"));
bpatel@766 283 String[] errorTableHeader = new String[] {
bpatel@766 284 configuration.getText("doclet.Error"),
bpatel@766 285 configuration.getText("doclet.Description")
bpatel@766 286 };
bpatel@766 287 ClassDoc[] errors =
bpatel@766 288 packageDoc.isIncluded()
bpatel@766 289 ? packageDoc.errors()
bpatel@766 290 : configuration.classDocCatalog.errors(
bpatel@766 291 Util.getPackageName(packageDoc));
bpatel@766 292 if (errors.length > 0) {
bpatel@766 293 packageWriter.addClassesSummary(
bpatel@766 294 errors,
bpatel@766 295 configuration.getText("doclet.Error_Summary"),
bpatel@766 296 errorTableSummary, errorTableHeader, summaryContentTree);
duke@1 297 }
bpatel@766 298 }
duke@1 299
bpatel@766 300 /**
bpatel@766 301 * Build the summary for the annotation type in this package.
bpatel@766 302 *
bpatel@766 303 * @param node the XML element that specifies which components to document
bpatel@766 304 * @param summaryContentTree the summary tree to which the annotation type
bpatel@766 305 * summary will be added
bpatel@766 306 */
bpatel@766 307 public void buildAnnotationTypeSummary(XMLNode node, Content summaryContentTree) {
bpatel@766 308 String annotationtypeTableSummary =
bpatel@766 309 configuration.getText("doclet.Member_Table_Summary",
bpatel@766 310 configuration.getText("doclet.Annotation_Types_Summary"),
bpatel@766 311 configuration.getText("doclet.annotationtypes"));
bpatel@766 312 String[] annotationtypeTableHeader = new String[] {
bpatel@766 313 configuration.getText("doclet.AnnotationType"),
bpatel@766 314 configuration.getText("doclet.Description")
bpatel@766 315 };
bpatel@766 316 ClassDoc[] annotationTypes =
bpatel@766 317 packageDoc.isIncluded()
bpatel@766 318 ? packageDoc.annotationTypes()
bpatel@766 319 : configuration.classDocCatalog.annotationTypes(
bpatel@766 320 Util.getPackageName(packageDoc));
bpatel@766 321 if (annotationTypes.length > 0) {
bpatel@766 322 packageWriter.addClassesSummary(
bpatel@766 323 annotationTypes,
bpatel@766 324 configuration.getText("doclet.Annotation_Types_Summary"),
bpatel@766 325 annotationtypeTableSummary, annotationtypeTableHeader,
bpatel@766 326 summaryContentTree);
duke@1 327 }
bpatel@766 328 }
duke@1 329
bpatel@766 330 /**
bpatel@766 331 * Build the description of the summary.
bpatel@766 332 *
bpatel@766 333 * @param node the XML element that specifies which components to document
bpatel@766 334 * @param packageContentTree the tree to which the package description will
bpatel@766 335 * be added
bpatel@766 336 */
bpatel@766 337 public void buildPackageDescription(XMLNode node, Content packageContentTree) {
bpatel@766 338 if (configuration.nocomment) {
bpatel@766 339 return;
duke@1 340 }
bpatel@766 341 packageWriter.addPackageDescription(packageContentTree);
bpatel@766 342 }
duke@1 343
bpatel@766 344 /**
bpatel@766 345 * Build the tags of the summary.
bpatel@766 346 *
bpatel@766 347 * @param node the XML element that specifies which components to document
bpatel@766 348 * @param packageContentTree the tree to which the package tags will be added
bpatel@766 349 */
bpatel@766 350 public void buildPackageTags(XMLNode node, Content packageContentTree) {
bpatel@766 351 if (configuration.nocomment) {
bpatel@766 352 return;
duke@1 353 }
bpatel@766 354 packageWriter.addPackageTags(packageContentTree);
bpatel@766 355 }
duke@1 356 }

mercurial