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