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

Tue, 25 May 2010 15:54:51 -0700

author
ohair
date
Tue, 25 May 2010 15:54:51 -0700
changeset 554
9d9f26857129
parent 243
edd944553131
child 589
4177f5bdd189
permissions
-rw-r--r--

6943119: Rebrand source copyright notices
Reviewed-by: darcy

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

mercurial