src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 2084
6e186ca11ec0
parent 0
959103a6100f
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.tools.doclets.formats.html;
aoqi@0 27
aoqi@0 28 import java.io.IOException;
aoqi@0 29 import java.util.ArrayList;
aoqi@0 30 import java.util.Collections;
aoqi@0 31 import java.util.HashMap;
aoqi@0 32 import java.util.Iterator;
aoqi@0 33 import java.util.List;
aoqi@0 34 import java.util.Map;
aoqi@0 35 import java.util.Set;
aoqi@0 36 import java.util.SortedSet;
aoqi@0 37 import java.util.TreeSet;
aoqi@0 38
aoqi@0 39 import com.sun.javadoc.*;
aoqi@0 40 import com.sun.tools.doclets.formats.html.markup.*;
aoqi@0 41 import com.sun.tools.doclets.internal.toolkit.*;
aoqi@0 42 import com.sun.tools.doclets.internal.toolkit.util.*;
aoqi@0 43
aoqi@0 44 /**
aoqi@0 45 * Generate class usage information.
aoqi@0 46 *
aoqi@0 47 * <p><b>This is NOT part of any supported API.
aoqi@0 48 * If you write code that depends on this, you do so at your own risk.
aoqi@0 49 * This code and its internal interfaces are subject to change or
aoqi@0 50 * deletion without notice.</b>
aoqi@0 51 *
aoqi@0 52 * @author Robert G. Field
aoqi@0 53 * @author Bhavesh Patel (Modified)
aoqi@0 54 */
aoqi@0 55 public class ClassUseWriter extends SubWriterHolderWriter {
aoqi@0 56
aoqi@0 57 final ClassDoc classdoc;
aoqi@0 58 Set<PackageDoc> pkgToPackageAnnotations = null;
aoqi@0 59 final Map<String,List<ProgramElementDoc>> pkgToClassTypeParameter;
aoqi@0 60 final Map<String,List<ProgramElementDoc>> pkgToClassAnnotations;
aoqi@0 61 final Map<String,List<ProgramElementDoc>> pkgToMethodTypeParameter;
aoqi@0 62 final Map<String,List<ProgramElementDoc>> pkgToMethodArgTypeParameter;
aoqi@0 63 final Map<String,List<ProgramElementDoc>> pkgToMethodReturnTypeParameter;
aoqi@0 64 final Map<String,List<ProgramElementDoc>> pkgToMethodAnnotations;
aoqi@0 65 final Map<String,List<ProgramElementDoc>> pkgToMethodParameterAnnotations;
aoqi@0 66 final Map<String,List<ProgramElementDoc>> pkgToFieldTypeParameter;
aoqi@0 67 final Map<String,List<ProgramElementDoc>> pkgToFieldAnnotations;
aoqi@0 68 final Map<String,List<ProgramElementDoc>> pkgToSubclass;
aoqi@0 69 final Map<String,List<ProgramElementDoc>> pkgToSubinterface;
aoqi@0 70 final Map<String,List<ProgramElementDoc>> pkgToImplementingClass;
aoqi@0 71 final Map<String,List<ProgramElementDoc>> pkgToField;
aoqi@0 72 final Map<String,List<ProgramElementDoc>> pkgToMethodReturn;
aoqi@0 73 final Map<String,List<ProgramElementDoc>> pkgToMethodArgs;
aoqi@0 74 final Map<String,List<ProgramElementDoc>> pkgToMethodThrows;
aoqi@0 75 final Map<String,List<ProgramElementDoc>> pkgToConstructorAnnotations;
aoqi@0 76 final Map<String,List<ProgramElementDoc>> pkgToConstructorParameterAnnotations;
aoqi@0 77 final Map<String,List<ProgramElementDoc>> pkgToConstructorArgs;
aoqi@0 78 final Map<String,List<ProgramElementDoc>> pkgToConstructorArgTypeParameter;
aoqi@0 79 final Map<String,List<ProgramElementDoc>> pkgToConstructorThrows;
aoqi@0 80 final SortedSet<PackageDoc> pkgSet;
aoqi@0 81 final MethodWriterImpl methodSubWriter;
aoqi@0 82 final ConstructorWriterImpl constrSubWriter;
aoqi@0 83 final FieldWriterImpl fieldSubWriter;
aoqi@0 84 final NestedClassWriterImpl classSubWriter;
aoqi@0 85 // Summary for various use tables.
aoqi@0 86 final String classUseTableSummary;
aoqi@0 87 final String subclassUseTableSummary;
aoqi@0 88 final String subinterfaceUseTableSummary;
aoqi@0 89 final String fieldUseTableSummary;
aoqi@0 90 final String methodUseTableSummary;
aoqi@0 91 final String constructorUseTableSummary;
aoqi@0 92
aoqi@0 93 /**
aoqi@0 94 * Constructor.
aoqi@0 95 *
aoqi@0 96 * @param filename the file to be generated.
aoqi@0 97 * @throws IOException
aoqi@0 98 * @throws DocletAbortException
aoqi@0 99 */
aoqi@0 100 public ClassUseWriter(ConfigurationImpl configuration,
aoqi@0 101 ClassUseMapper mapper, DocPath filename,
aoqi@0 102 ClassDoc classdoc) throws IOException {
aoqi@0 103 super(configuration, filename);
aoqi@0 104 this.classdoc = classdoc;
aoqi@0 105 if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName()))
aoqi@0 106 pkgToPackageAnnotations = new TreeSet<PackageDoc>(mapper.classToPackageAnnotations.get(classdoc.qualifiedName()));
aoqi@0 107 configuration.currentcd = classdoc;
aoqi@0 108 this.pkgSet = new TreeSet<PackageDoc>();
aoqi@0 109 this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam);
aoqi@0 110 this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations);
aoqi@0 111 this.pkgToMethodTypeParameter = pkgDivide(mapper.classToExecMemberDocTypeParam);
aoqi@0 112 this.pkgToMethodArgTypeParameter = pkgDivide(mapper.classToExecMemberDocArgTypeParam);
aoqi@0 113 this.pkgToFieldTypeParameter = pkgDivide(mapper.classToFieldDocTypeParam);
aoqi@0 114 this.pkgToFieldAnnotations = pkgDivide(mapper.annotationToFieldDoc);
aoqi@0 115 this.pkgToMethodReturnTypeParameter = pkgDivide(mapper.classToExecMemberDocReturnTypeParam);
aoqi@0 116 this.pkgToMethodAnnotations = pkgDivide(mapper.classToExecMemberDocAnnotations);
aoqi@0 117 this.pkgToMethodParameterAnnotations = pkgDivide(mapper.classToExecMemberDocParamAnnotation);
aoqi@0 118 this.pkgToSubclass = pkgDivide(mapper.classToSubclass);
aoqi@0 119 this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface);
aoqi@0 120 this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass);
aoqi@0 121 this.pkgToField = pkgDivide(mapper.classToField);
aoqi@0 122 this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn);
aoqi@0 123 this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs);
aoqi@0 124 this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows);
aoqi@0 125 this.pkgToConstructorAnnotations = pkgDivide(mapper.classToConstructorAnnotations);
aoqi@0 126 this.pkgToConstructorParameterAnnotations = pkgDivide(mapper.classToConstructorParamAnnotation);
aoqi@0 127 this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs);
aoqi@0 128 this.pkgToConstructorArgTypeParameter = pkgDivide(mapper.classToConstructorDocArgTypeParam);
aoqi@0 129 this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows);
aoqi@0 130 //tmp test
aoqi@0 131 if (pkgSet.size() > 0 &&
aoqi@0 132 mapper.classToPackage.containsKey(classdoc.qualifiedName()) &&
aoqi@0 133 !pkgSet.equals(mapper.classToPackage.get(classdoc.qualifiedName()))) {
aoqi@0 134 configuration.root.printWarning("Internal error: package sets don't match: " + pkgSet + " with: " +
aoqi@0 135 mapper.classToPackage.get(classdoc.qualifiedName()));
aoqi@0 136 }
aoqi@0 137 methodSubWriter = new MethodWriterImpl(this);
aoqi@0 138 constrSubWriter = new ConstructorWriterImpl(this);
aoqi@0 139 fieldSubWriter = new FieldWriterImpl(this);
aoqi@0 140 classSubWriter = new NestedClassWriterImpl(this);
aoqi@0 141 classUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
aoqi@0 142 configuration.getText("doclet.classes"));
aoqi@0 143 subclassUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
aoqi@0 144 configuration.getText("doclet.subclasses"));
aoqi@0 145 subinterfaceUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
aoqi@0 146 configuration.getText("doclet.subinterfaces"));
aoqi@0 147 fieldUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
aoqi@0 148 configuration.getText("doclet.fields"));
aoqi@0 149 methodUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
aoqi@0 150 configuration.getText("doclet.methods"));
aoqi@0 151 constructorUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
aoqi@0 152 configuration.getText("doclet.constructors"));
aoqi@0 153 }
aoqi@0 154
aoqi@0 155 /**
aoqi@0 156 * Write out class use pages.
aoqi@0 157 * @throws DocletAbortException
aoqi@0 158 */
aoqi@0 159 public static void generate(ConfigurationImpl configuration,
aoqi@0 160 ClassTree classtree) {
aoqi@0 161 ClassUseMapper mapper = new ClassUseMapper(configuration.root, classtree);
aoqi@0 162 ClassDoc[] classes = configuration.root.classes();
aoqi@0 163 for (int i = 0; i < classes.length; i++) {
aoqi@0 164 // If -nodeprecated option is set and the containing package is marked
aoqi@0 165 // as deprecated, do not generate the class-use page. We will still generate
aoqi@0 166 // the class-use page if the class is marked as deprecated but the containing
aoqi@0 167 // package is not since it could still be linked from that package-use page.
aoqi@0 168 if (!(configuration.nodeprecated &&
aoqi@0 169 Util.isDeprecated(classes[i].containingPackage())))
aoqi@0 170 ClassUseWriter.generate(configuration, mapper, classes[i]);
aoqi@0 171 }
aoqi@0 172 PackageDoc[] pkgs = configuration.packages;
aoqi@0 173 for (int i = 0; i < pkgs.length; i++) {
aoqi@0 174 // If -nodeprecated option is set and the package is marked
aoqi@0 175 // as deprecated, do not generate the package-use page.
aoqi@0 176 if (!(configuration.nodeprecated && Util.isDeprecated(pkgs[i])))
aoqi@0 177 PackageUseWriter.generate(configuration, mapper, pkgs[i]);
aoqi@0 178 }
aoqi@0 179 }
aoqi@0 180
aoqi@0 181 private Map<String,List<ProgramElementDoc>> pkgDivide(Map<String,? extends List<? extends ProgramElementDoc>> classMap) {
aoqi@0 182 Map<String,List<ProgramElementDoc>> map = new HashMap<String,List<ProgramElementDoc>>();
aoqi@0 183 List<? extends ProgramElementDoc> list= classMap.get(classdoc.qualifiedName());
aoqi@0 184 if (list != null) {
aoqi@0 185 Collections.sort(list);
aoqi@0 186 Iterator<? extends ProgramElementDoc> it = list.iterator();
aoqi@0 187 while (it.hasNext()) {
aoqi@0 188 ProgramElementDoc doc = it.next();
aoqi@0 189 PackageDoc pkg = doc.containingPackage();
aoqi@0 190 pkgSet.add(pkg);
aoqi@0 191 List<ProgramElementDoc> inPkg = map.get(pkg.name());
aoqi@0 192 if (inPkg == null) {
aoqi@0 193 inPkg = new ArrayList<ProgramElementDoc>();
aoqi@0 194 map.put(pkg.name(), inPkg);
aoqi@0 195 }
aoqi@0 196 inPkg.add(doc);
aoqi@0 197 }
aoqi@0 198 }
aoqi@0 199 return map;
aoqi@0 200 }
aoqi@0 201
aoqi@0 202 /**
aoqi@0 203 * Generate a class page.
aoqi@0 204 */
aoqi@0 205 public static void generate(ConfigurationImpl configuration,
aoqi@0 206 ClassUseMapper mapper, ClassDoc classdoc) {
aoqi@0 207 ClassUseWriter clsgen;
aoqi@0 208 DocPath path = DocPath.forPackage(classdoc)
aoqi@0 209 .resolve(DocPaths.CLASS_USE)
aoqi@0 210 .resolve(DocPath.forName(classdoc));
aoqi@0 211 try {
aoqi@0 212 clsgen = new ClassUseWriter(configuration,
aoqi@0 213 mapper, path,
aoqi@0 214 classdoc);
aoqi@0 215 clsgen.generateClassUseFile();
aoqi@0 216 clsgen.close();
aoqi@0 217 } catch (IOException exc) {
aoqi@0 218 configuration.standardmessage.
aoqi@0 219 error("doclet.exception_encountered",
aoqi@0 220 exc.toString(), path.getPath());
aoqi@0 221 throw new DocletAbortException(exc);
aoqi@0 222 }
aoqi@0 223 }
aoqi@0 224
aoqi@0 225 /**
aoqi@0 226 * Generate the class use list.
aoqi@0 227 */
aoqi@0 228 protected void generateClassUseFile() throws IOException {
aoqi@0 229 Content body = getClassUseHeader();
aoqi@0 230 HtmlTree div = new HtmlTree(HtmlTag.DIV);
aoqi@0 231 div.addStyle(HtmlStyle.classUseContainer);
aoqi@0 232 if (pkgSet.size() > 0) {
aoqi@0 233 addClassUse(div);
aoqi@0 234 } else {
aoqi@0 235 div.addContent(getResource("doclet.ClassUse_No.usage.of.0",
aoqi@0 236 classdoc.qualifiedName()));
aoqi@0 237 }
aoqi@0 238 body.addContent(div);
aoqi@0 239 addNavLinks(false, body);
aoqi@0 240 addBottom(body);
aoqi@0 241 printHtmlDocument(null, true, body);
aoqi@0 242 }
aoqi@0 243
aoqi@0 244 /**
aoqi@0 245 * Add the class use documentation.
aoqi@0 246 *
aoqi@0 247 * @param contentTree the content tree to which the class use information will be added
aoqi@0 248 */
aoqi@0 249 protected void addClassUse(Content contentTree) throws IOException {
aoqi@0 250 HtmlTree ul = new HtmlTree(HtmlTag.UL);
aoqi@0 251 ul.addStyle(HtmlStyle.blockList);
aoqi@0 252 if (configuration.packages.length > 1) {
aoqi@0 253 addPackageList(ul);
aoqi@0 254 addPackageAnnotationList(ul);
aoqi@0 255 }
aoqi@0 256 addClassList(ul);
aoqi@0 257 contentTree.addContent(ul);
aoqi@0 258 }
aoqi@0 259
aoqi@0 260 /**
aoqi@0 261 * Add the packages list that use the given class.
aoqi@0 262 *
aoqi@0 263 * @param contentTree the content tree to which the packages list will be added
aoqi@0 264 */
aoqi@0 265 protected void addPackageList(Content contentTree) throws IOException {
aoqi@0 266 Content table = HtmlTree.TABLE(HtmlStyle.useSummary, 0, 3, 0, useTableSummary,
aoqi@0 267 getTableCaption(configuration.getResource(
aoqi@0 268 "doclet.ClassUse_Packages.that.use.0",
aoqi@0 269 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc
aoqi@0 270 )))));
aoqi@0 271 table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
aoqi@0 272 Content tbody = new HtmlTree(HtmlTag.TBODY);
aoqi@0 273 Iterator<PackageDoc> it = pkgSet.iterator();
aoqi@0 274 for (int i = 0; it.hasNext(); i++) {
aoqi@0 275 PackageDoc pkg = it.next();
aoqi@0 276 HtmlTree tr = new HtmlTree(HtmlTag.TR);
aoqi@0 277 if (i % 2 == 0) {
aoqi@0 278 tr.addStyle(HtmlStyle.altColor);
aoqi@0 279 } else {
aoqi@0 280 tr.addStyle(HtmlStyle.rowColor);
aoqi@0 281 }
aoqi@0 282 addPackageUse(pkg, tr);
aoqi@0 283 tbody.addContent(tr);
aoqi@0 284 }
aoqi@0 285 table.addContent(tbody);
aoqi@0 286 Content li = HtmlTree.LI(HtmlStyle.blockList, table);
aoqi@0 287 contentTree.addContent(li);
aoqi@0 288 }
aoqi@0 289
aoqi@0 290 /**
aoqi@0 291 * Add the package annotation list.
aoqi@0 292 *
aoqi@0 293 * @param contentTree the content tree to which the package annotation list will be added
aoqi@0 294 */
aoqi@0 295 protected void addPackageAnnotationList(Content contentTree) throws IOException {
aoqi@0 296 if ((!classdoc.isAnnotationType()) ||
aoqi@0 297 pkgToPackageAnnotations == null ||
aoqi@0 298 pkgToPackageAnnotations.isEmpty()) {
aoqi@0 299 return;
aoqi@0 300 }
aoqi@0 301 Content table = HtmlTree.TABLE(HtmlStyle.useSummary, 0, 3, 0, useTableSummary,
aoqi@0 302 getTableCaption(configuration.getResource(
aoqi@0 303 "doclet.ClassUse_PackageAnnotation",
aoqi@0 304 getLink(new LinkInfoImpl(configuration,
aoqi@0 305 LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)))));
aoqi@0 306 table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
aoqi@0 307 Content tbody = new HtmlTree(HtmlTag.TBODY);
aoqi@0 308 Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator();
aoqi@0 309 for (int i = 0; it.hasNext(); i++) {
aoqi@0 310 PackageDoc pkg = it.next();
aoqi@0 311 HtmlTree tr = new HtmlTree(HtmlTag.TR);
aoqi@0 312 if (i % 2 == 0) {
aoqi@0 313 tr.addStyle(HtmlStyle.altColor);
aoqi@0 314 } else {
aoqi@0 315 tr.addStyle(HtmlStyle.rowColor);
aoqi@0 316 }
aoqi@0 317 Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
aoqi@0 318 getPackageLink(pkg, new StringContent(pkg.name())));
aoqi@0 319 tr.addContent(tdFirst);
aoqi@0 320 HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
aoqi@0 321 tdLast.addStyle(HtmlStyle.colLast);
aoqi@0 322 addSummaryComment(pkg, tdLast);
aoqi@0 323 tr.addContent(tdLast);
aoqi@0 324 tbody.addContent(tr);
aoqi@0 325 }
aoqi@0 326 table.addContent(tbody);
aoqi@0 327 Content li = HtmlTree.LI(HtmlStyle.blockList, table);
aoqi@0 328 contentTree.addContent(li);
aoqi@0 329 }
aoqi@0 330
aoqi@0 331 /**
aoqi@0 332 * Add the class list that use the given class.
aoqi@0 333 *
aoqi@0 334 * @param contentTree the content tree to which the class list will be added
aoqi@0 335 */
aoqi@0 336 protected void addClassList(Content contentTree) throws IOException {
aoqi@0 337 HtmlTree ul = new HtmlTree(HtmlTag.UL);
aoqi@0 338 ul.addStyle(HtmlStyle.blockList);
aoqi@0 339 for (Iterator<PackageDoc> it = pkgSet.iterator(); it.hasNext();) {
aoqi@0 340 PackageDoc pkg = it.next();
aoqi@0 341 Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
aoqi@0 342 Content link = getResource("doclet.ClassUse_Uses.of.0.in.1",
aoqi@0 343 getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
aoqi@0 344 classdoc)),
aoqi@0 345 getPackageLink(pkg, Util.getPackageName(pkg)));
aoqi@0 346 Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
aoqi@0 347 li.addContent(heading);
aoqi@0 348 addClassUse(pkg, li);
aoqi@0 349 ul.addContent(li);
aoqi@0 350 }
aoqi@0 351 Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
aoqi@0 352 contentTree.addContent(li);
aoqi@0 353 }
aoqi@0 354
aoqi@0 355 /**
aoqi@0 356 * Add the package use information.
aoqi@0 357 *
aoqi@0 358 * @param pkg the package that uses the given class
aoqi@0 359 * @param contentTree the content tree to which the package use information will be added
aoqi@0 360 */
aoqi@0 361 protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
aoqi@0 362 Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
aoqi@0 363 getHyperLink(pkg.name(), new StringContent(Util.getPackageName(pkg))));
aoqi@0 364 contentTree.addContent(tdFirst);
aoqi@0 365 HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
aoqi@0 366 tdLast.addStyle(HtmlStyle.colLast);
aoqi@0 367 addSummaryComment(pkg, tdLast);
aoqi@0 368 contentTree.addContent(tdLast);
aoqi@0 369 }
aoqi@0 370
aoqi@0 371 /**
aoqi@0 372 * Add the class use information.
aoqi@0 373 *
aoqi@0 374 * @param pkg the package that uses the given class
aoqi@0 375 * @param contentTree the content tree to which the class use information will be added
aoqi@0 376 */
aoqi@0 377 protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
aoqi@0 378 Content classLink = getLink(new LinkInfoImpl(configuration,
aoqi@0 379 LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc));
aoqi@0 380 Content pkgLink = getPackageLink(pkg, Util.getPackageName(pkg));
aoqi@0 381 classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()),
aoqi@0 382 configuration.getResource("doclet.ClassUse_Annotation", classLink,
aoqi@0 383 pkgLink), classUseTableSummary, contentTree);
aoqi@0 384 classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg.name()),
aoqi@0 385 configuration.getResource("doclet.ClassUse_TypeParameter", classLink,
aoqi@0 386 pkgLink), classUseTableSummary, contentTree);
aoqi@0 387 classSubWriter.addUseInfo(pkgToSubclass.get(pkg.name()),
aoqi@0 388 configuration.getResource("doclet.ClassUse_Subclass", classLink,
aoqi@0 389 pkgLink), subclassUseTableSummary, contentTree);
aoqi@0 390 classSubWriter.addUseInfo(pkgToSubinterface.get(pkg.name()),
aoqi@0 391 configuration.getResource("doclet.ClassUse_Subinterface", classLink,
aoqi@0 392 pkgLink), subinterfaceUseTableSummary, contentTree);
aoqi@0 393 classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg.name()),
aoqi@0 394 configuration.getResource("doclet.ClassUse_ImplementingClass", classLink,
aoqi@0 395 pkgLink), classUseTableSummary, contentTree);
aoqi@0 396 fieldSubWriter.addUseInfo(pkgToField.get(pkg.name()),
aoqi@0 397 configuration.getResource("doclet.ClassUse_Field", classLink,
aoqi@0 398 pkgLink), fieldUseTableSummary, contentTree);
aoqi@0 399 fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg.name()),
aoqi@0 400 configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink,
aoqi@0 401 pkgLink), fieldUseTableSummary, contentTree);
aoqi@0 402 fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg.name()),
aoqi@0 403 configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink,
aoqi@0 404 pkgLink), fieldUseTableSummary, contentTree);
aoqi@0 405 methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg.name()),
aoqi@0 406 configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink,
aoqi@0 407 pkgLink), methodUseTableSummary, contentTree);
aoqi@0 408 methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg.name()),
aoqi@0 409 configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink,
aoqi@0 410 pkgLink), methodUseTableSummary, contentTree);
aoqi@0 411 methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg.name()),
aoqi@0 412 configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink,
aoqi@0 413 pkgLink), methodUseTableSummary, contentTree);
aoqi@0 414 methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg.name()),
aoqi@0 415 configuration.getResource("doclet.ClassUse_MethodReturn", classLink,
aoqi@0 416 pkgLink), methodUseTableSummary, contentTree);
aoqi@0 417 methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg.name()),
aoqi@0 418 configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink,
aoqi@0 419 pkgLink), methodUseTableSummary, contentTree);
aoqi@0 420 methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg.name()),
aoqi@0 421 configuration.getResource("doclet.ClassUse_MethodArgs", classLink,
aoqi@0 422 pkgLink), methodUseTableSummary, contentTree);
aoqi@0 423 methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg.name()),
aoqi@0 424 configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink,
aoqi@0 425 pkgLink), methodUseTableSummary, contentTree);
aoqi@0 426 methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg.name()),
aoqi@0 427 configuration.getResource("doclet.ClassUse_MethodThrows", classLink,
aoqi@0 428 pkgLink), methodUseTableSummary, contentTree);
aoqi@0 429 constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg.name()),
aoqi@0 430 configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink,
aoqi@0 431 pkgLink), constructorUseTableSummary, contentTree);
aoqi@0 432 constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg.name()),
aoqi@0 433 configuration.getResource("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
aoqi@0 434 pkgLink), constructorUseTableSummary, contentTree);
aoqi@0 435 constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg.name()),
aoqi@0 436 configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink,
aoqi@0 437 pkgLink), constructorUseTableSummary, contentTree);
aoqi@0 438 constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg.name()),
aoqi@0 439 configuration.getResource("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
aoqi@0 440 pkgLink), constructorUseTableSummary, contentTree);
aoqi@0 441 constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg.name()),
aoqi@0 442 configuration.getResource("doclet.ClassUse_ConstructorThrows", classLink,
aoqi@0 443 pkgLink), constructorUseTableSummary, contentTree);
aoqi@0 444 }
aoqi@0 445
aoqi@0 446 /**
aoqi@0 447 * Get the header for the class use Listing.
aoqi@0 448 *
aoqi@0 449 * @return a content tree representing the class use header
aoqi@0 450 */
aoqi@0 451 protected Content getClassUseHeader() {
aoqi@0 452 String cltype = configuration.getText(classdoc.isInterface()?
aoqi@0 453 "doclet.Interface":"doclet.Class");
aoqi@0 454 String clname = classdoc.qualifiedName();
aoqi@0 455 String title = configuration.getText("doclet.Window_ClassUse_Header",
aoqi@0 456 cltype, clname);
aoqi@0 457 Content bodyTree = getBody(true, getWindowTitle(title));
aoqi@0 458 addTop(bodyTree);
aoqi@0 459 addNavLinks(true, bodyTree);
aoqi@0 460 ContentBuilder headContent = new ContentBuilder();
aoqi@0 461 headContent.addContent(getResource("doclet.ClassUse_Title", cltype));
aoqi@0 462 headContent.addContent(new HtmlTree(HtmlTag.BR));
aoqi@0 463 headContent.addContent(clname);
aoqi@0 464 Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING,
aoqi@0 465 true, HtmlStyle.title, headContent);
aoqi@0 466 Content div = HtmlTree.DIV(HtmlStyle.header, heading);
aoqi@0 467 bodyTree.addContent(div);
aoqi@0 468 return bodyTree;
aoqi@0 469 }
aoqi@0 470
aoqi@0 471 /**
aoqi@0 472 * Get this package link.
aoqi@0 473 *
aoqi@0 474 * @return a content tree for the package link
aoqi@0 475 */
aoqi@0 476 protected Content getNavLinkPackage() {
aoqi@0 477 Content linkContent =
aoqi@0 478 getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel);
aoqi@0 479 Content li = HtmlTree.LI(linkContent);
aoqi@0 480 return li;
aoqi@0 481 }
aoqi@0 482
aoqi@0 483 /**
aoqi@0 484 * Get class page link.
aoqi@0 485 *
aoqi@0 486 * @return a content tree for the class page link
aoqi@0 487 */
aoqi@0 488 protected Content getNavLinkClass() {
aoqi@0 489 Content linkContent = getLink(new LinkInfoImpl(
aoqi@0 490 configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)
aoqi@0 491 .label(configuration.getText("doclet.Class")));
aoqi@0 492 Content li = HtmlTree.LI(linkContent);
aoqi@0 493 return li;
aoqi@0 494 }
aoqi@0 495
aoqi@0 496 /**
aoqi@0 497 * Get the use link.
aoqi@0 498 *
aoqi@0 499 * @return a content tree for the use link
aoqi@0 500 */
aoqi@0 501 protected Content getNavLinkClassUse() {
aoqi@0 502 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
aoqi@0 503 return li;
aoqi@0 504 }
aoqi@0 505
aoqi@0 506 /**
aoqi@0 507 * Get the tree link.
aoqi@0 508 *
aoqi@0 509 * @return a content tree for the tree link
aoqi@0 510 */
aoqi@0 511 protected Content getNavLinkTree() {
aoqi@0 512 Content linkContent = classdoc.containingPackage().isIncluded() ?
aoqi@0 513 getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel) :
aoqi@0 514 getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel);
aoqi@0 515 Content li = HtmlTree.LI(linkContent);
aoqi@0 516 return li;
aoqi@0 517 }
aoqi@0 518 }

mercurial