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

Tue, 14 May 2013 10:14:52 -0700

author
jjg
date
Tue, 14 May 2013 10:14:52 -0700
changeset 1738
6ea964c78845
parent 1736
74cd21f2c2fe
child 1744
76a691e3e961
permissions
-rw-r--r--

8011651: simplify LinkInfoImpl API
Reviewed-by: darcy

duke@1 1 /*
bpatel@1568 2 * Copyright (c) 1997, 2013, 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.formats.html;
duke@1 27
bpatel@233 28 import java.util.*;
bpatel@233 29
bpatel@233 30 import com.sun.javadoc.*;
bpatel@1568 31 import com.sun.tools.javac.jvm.Profile;
jjg@1357 32 import com.sun.tools.doclets.formats.html.markup.*;
duke@1 33 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 34 import com.sun.tools.doclets.internal.toolkit.builders.*;
duke@1 35 import com.sun.tools.doclets.internal.toolkit.taglets.*;
jjg@1357 36 import com.sun.tools.doclets.internal.toolkit.util.*;
jjg@1410 37 import java.io.IOException;
duke@1 38
duke@1 39 /**
duke@1 40 * Generate the Class Information Page.
jjg@1359 41 *
jjg@1359 42 * <p><b>This is NOT part of any supported API.
jjg@1359 43 * If you write code that depends on this, you do so at your own risk.
jjg@1359 44 * This code and its internal interfaces are subject to change or
jjg@1359 45 * deletion without notice.</b>
jjg@1359 46 *
duke@1 47 * @see com.sun.javadoc.ClassDoc
duke@1 48 * @see java.util.Collections
duke@1 49 * @see java.util.List
duke@1 50 * @see java.util.ArrayList
duke@1 51 * @see java.util.HashMap
duke@1 52 *
duke@1 53 * @author Atul M Dambalkar
duke@1 54 * @author Robert Field
bpatel@766 55 * @author Bhavesh Patel (Modified)
duke@1 56 */
duke@1 57 public class ClassWriterImpl extends SubWriterHolderWriter
duke@1 58 implements ClassWriter {
duke@1 59
jjg@1410 60 protected final ClassDoc classDoc;
duke@1 61
jjg@1410 62 protected final ClassTree classtree;
duke@1 63
jjg@1410 64 protected final ClassDoc prev;
duke@1 65
jjg@1410 66 protected final ClassDoc next;
duke@1 67
duke@1 68 /**
jjg@1410 69 * @param configuration the configuration data for the doclet
duke@1 70 * @param classDoc the class being documented.
duke@1 71 * @param prevClass the previous class that was documented.
duke@1 72 * @param nextClass the next class being documented.
duke@1 73 * @param classTree the class tree for the given class.
duke@1 74 */
jjg@1410 75 public ClassWriterImpl (ConfigurationImpl configuration, ClassDoc classDoc,
duke@1 76 ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
jjg@1410 77 throws IOException {
jjg@1410 78 super(configuration, DocPath.forClass(classDoc));
duke@1 79 this.classDoc = classDoc;
duke@1 80 configuration.currentcd = classDoc;
duke@1 81 this.classtree = classTree;
duke@1 82 this.prev = prevClass;
duke@1 83 this.next = nextClass;
duke@1 84 }
duke@1 85
duke@1 86 /**
bpatel@766 87 * Get this package link.
bpatel@766 88 *
bpatel@766 89 * @return a content tree for the package link
duke@1 90 */
bpatel@766 91 protected Content getNavLinkPackage() {
jjg@1373 92 Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
bpatel@766 93 packageLabel);
bpatel@766 94 Content li = HtmlTree.LI(linkContent);
bpatel@766 95 return li;
duke@1 96 }
duke@1 97
duke@1 98 /**
bpatel@766 99 * Get the class link.
bpatel@766 100 *
bpatel@766 101 * @return a content tree for the class link
duke@1 102 */
bpatel@766 103 protected Content getNavLinkClass() {
bpatel@766 104 Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
bpatel@766 105 return li;
duke@1 106 }
duke@1 107
duke@1 108 /**
bpatel@766 109 * Get the class use link.
bpatel@766 110 *
bpatel@766 111 * @return a content tree for the class use link
duke@1 112 */
bpatel@766 113 protected Content getNavLinkClassUse() {
jjg@1373 114 Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
bpatel@766 115 Content li = HtmlTree.LI(linkContent);
bpatel@766 116 return li;
duke@1 117 }
duke@1 118
duke@1 119 /**
bpatel@766 120 * Get link to previous class.
bpatel@766 121 *
bpatel@766 122 * @return a content tree for the previous class link
duke@1 123 */
bpatel@766 124 public Content getNavLinkPrevious() {
bpatel@766 125 Content li;
bpatel@766 126 if (prev != null) {
jjg@1736 127 Content prevLink = getLink(new LinkInfoImpl(configuration,
jjg@1738 128 LinkInfoImpl.Kind.CLASS, prev)
jjg@1738 129 .label(configuration.getText("doclet.Prev_Class")).strong(true));
bpatel@766 130 li = HtmlTree.LI(prevLink);
duke@1 131 }
bpatel@766 132 else
bpatel@766 133 li = HtmlTree.LI(prevclassLabel);
bpatel@766 134 return li;
duke@1 135 }
duke@1 136
duke@1 137 /**
bpatel@766 138 * Get link to next class.
bpatel@766 139 *
bpatel@766 140 * @return a content tree for the next class link
duke@1 141 */
bpatel@766 142 public Content getNavLinkNext() {
bpatel@766 143 Content li;
bpatel@766 144 if (next != null) {
jjg@1736 145 Content nextLink = getLink(new LinkInfoImpl(configuration,
jjg@1738 146 LinkInfoImpl.Kind.CLASS, next)
jjg@1738 147 .label(configuration.getText("doclet.Next_Class")).strong(true));
bpatel@766 148 li = HtmlTree.LI(nextLink);
duke@1 149 }
bpatel@766 150 else
bpatel@766 151 li = HtmlTree.LI(nextclassLabel);
bpatel@766 152 return li;
duke@1 153 }
duke@1 154
duke@1 155 /**
duke@1 156 * {@inheritDoc}
duke@1 157 */
bpatel@766 158 public Content getHeader(String header) {
duke@1 159 String pkgname = (classDoc.containingPackage() != null)?
duke@1 160 classDoc.containingPackage().name(): "";
duke@1 161 String clname = classDoc.name();
bpatel@766 162 Content bodyTree = getBody(true, getWindowTitle(clname));
bpatel@766 163 addTop(bodyTree);
bpatel@766 164 addNavLinks(true, bodyTree);
bpatel@766 165 bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
bpatel@766 166 HtmlTree div = new HtmlTree(HtmlTag.DIV);
bpatel@766 167 div.addStyle(HtmlStyle.header);
bpatel@1568 168 if (configuration.showProfiles) {
bpatel@1568 169 String sep = "";
bpatel@1568 170 int profile = configuration.profiles.getProfile(getTypeNameForProfile(classDoc));
bpatel@1568 171 if (profile > 0) {
bpatel@1568 172 Content profNameContent = new StringContent();
bpatel@1568 173 for (int i = profile; i < configuration.profiles.getProfileCount(); i++) {
bpatel@1568 174 profNameContent.addContent(sep);
bpatel@1568 175 profNameContent.addContent(Profile.lookup(i).name);
bpatel@1568 176 sep = ", ";
bpatel@1568 177 }
bpatel@1568 178 Content profileNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, profNameContent);
bpatel@1568 179 div.addContent(profileNameDiv);
bpatel@1568 180 }
bpatel@1568 181 }
duke@1 182 if (pkgname.length() > 0) {
bpatel@766 183 Content pkgNameContent = new StringContent(pkgname);
bpatel@943 184 Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
bpatel@943 185 div.addContent(pkgNameDiv);
duke@1 186 }
jjg@1410 187 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
jjg@1738 188 LinkInfoImpl.Kind.CLASS_HEADER, classDoc);
duke@1 189 //Let's not link to ourselves in the header.
duke@1 190 linkInfo.linkToSelf = false;
bpatel@766 191 Content headerContent = new StringContent(header);
bpatel@766 192 Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
bpatel@766 193 HtmlStyle.title, headerContent);
jjg@1736 194 heading.addContent(getTypeParameterLinks(linkInfo));
bpatel@766 195 div.addContent(heading);
bpatel@766 196 bodyTree.addContent(div);
bpatel@766 197 return bodyTree;
duke@1 198 }
duke@1 199
duke@1 200 /**
duke@1 201 * {@inheritDoc}
duke@1 202 */
bpatel@766 203 public Content getClassContentHeader() {
bpatel@766 204 return getContentHeader();
duke@1 205 }
duke@1 206
duke@1 207 /**
duke@1 208 * {@inheritDoc}
duke@1 209 */
bpatel@766 210 public void addFooter(Content contentTree) {
bpatel@766 211 contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
bpatel@766 212 addNavLinks(false, contentTree);
bpatel@766 213 addBottom(contentTree);
bpatel@766 214 }
bpatel@766 215
bpatel@766 216 /**
bpatel@766 217 * {@inheritDoc}
bpatel@766 218 */
jjg@1364 219 public void printDocument(Content contentTree) throws IOException {
bpatel@766 220 printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc),
bpatel@766 221 true, contentTree);
bpatel@766 222 }
bpatel@766 223
bpatel@766 224 /**
bpatel@766 225 * {@inheritDoc}
bpatel@766 226 */
bpatel@766 227 public Content getClassInfoTreeHeader() {
bpatel@766 228 return getMemberTreeHeader();
bpatel@766 229 }
bpatel@766 230
bpatel@766 231 /**
bpatel@766 232 * {@inheritDoc}
bpatel@766 233 */
bpatel@766 234 public Content getClassInfo(Content classInfoTree) {
bpatel@766 235 return getMemberTree(HtmlStyle.description, classInfoTree);
bpatel@766 236 }
bpatel@766 237
bpatel@766 238 /**
bpatel@766 239 * {@inheritDoc}
bpatel@766 240 */
bpatel@766 241 public void addClassSignature(String modifiers, Content classInfoTree) {
duke@1 242 boolean isInterface = classDoc.isInterface();
bpatel@766 243 classInfoTree.addContent(new HtmlTree(HtmlTag.BR));
bpatel@766 244 Content pre = new HtmlTree(HtmlTag.PRE);
bpatel@766 245 addAnnotationInfo(classDoc, pre);
bpatel@766 246 pre.addContent(modifiers);
jjg@1410 247 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
jjg@1738 248 LinkInfoImpl.Kind.CLASS_SIGNATURE, classDoc);
duke@1 249 //Let's not link to ourselves in the signature.
duke@1 250 linkInfo.linkToSelf = false;
bpatel@958 251 Content className = new StringContent(classDoc.name());
jjg@1736 252 Content parameterLinks = getTypeParameterLinks(linkInfo);
jjg@1410 253 if (configuration.linksource) {
bpatel@958 254 addSrcLink(classDoc, className, pre);
bpatel@958 255 pre.addContent(parameterLinks);
duke@1 256 } else {
bpatel@958 257 Content span = HtmlTree.SPAN(HtmlStyle.strong, className);
bpatel@958 258 span.addContent(parameterLinks);
bpatel@958 259 pre.addContent(span);
duke@1 260 }
duke@1 261 if (!isInterface) {
duke@1 262 Type superclass = Util.getFirstVisibleSuperClass(classDoc,
jjg@1410 263 configuration);
duke@1 264 if (superclass != null) {
bpatel@793 265 pre.addContent(DocletConstants.NL);
bpatel@766 266 pre.addContent("extends ");
jjg@1736 267 Content link = getLink(new LinkInfoImpl(configuration,
jjg@1735 268 LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
jjg@1736 269 superclass));
bpatel@766 270 pre.addContent(link);
duke@1 271 }
duke@1 272 }
duke@1 273 Type[] implIntfacs = classDoc.interfaceTypes();
duke@1 274 if (implIntfacs != null && implIntfacs.length > 0) {
duke@1 275 int counter = 0;
duke@1 276 for (int i = 0; i < implIntfacs.length; i++) {
duke@1 277 ClassDoc classDoc = implIntfacs[i].asClassDoc();
duke@1 278 if (! (classDoc.isPublic() ||
jjg@1410 279 Util.isLinkable(classDoc, configuration))) {
duke@1 280 continue;
duke@1 281 }
duke@1 282 if (counter == 0) {
bpatel@793 283 pre.addContent(DocletConstants.NL);
bpatel@766 284 pre.addContent(isInterface? "extends " : "implements ");
duke@1 285 } else {
bpatel@766 286 pre.addContent(", ");
duke@1 287 }
jjg@1736 288 Content link = getLink(new LinkInfoImpl(configuration,
jjg@1735 289 LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
jjg@1736 290 implIntfacs[i]));
bpatel@766 291 pre.addContent(link);
duke@1 292 counter++;
duke@1 293 }
duke@1 294 }
bpatel@766 295 classInfoTree.addContent(pre);
duke@1 296 }
duke@1 297
duke@1 298 /**
duke@1 299 * {@inheritDoc}
duke@1 300 */
bpatel@766 301 public void addClassDescription(Content classInfoTree) {
duke@1 302 if(!configuration.nocomment) {
duke@1 303 // generate documentation for the class.
duke@1 304 if (classDoc.inlineTags().length > 0) {
bpatel@766 305 addInlineComment(classDoc, classInfoTree);
duke@1 306 }
duke@1 307 }
duke@1 308 }
duke@1 309
duke@1 310 /**
duke@1 311 * {@inheritDoc}
duke@1 312 */
bpatel@766 313 public void addClassTagInfo(Content classInfoTree) {
duke@1 314 if(!configuration.nocomment) {
duke@1 315 // Print Information about all the tags here
bpatel@766 316 addTagsInfo(classDoc, classInfoTree);
bpatel@766 317 }
bpatel@766 318 }
bpatel@766 319
bpatel@766 320 /**
bpatel@766 321 * Get the class hierarchy tree for the given class.
bpatel@766 322 *
bpatel@766 323 * @param type the class to print the hierarchy for
bpatel@766 324 * @return a content tree for class inheritence
bpatel@766 325 */
bpatel@766 326 private Content getClassInheritenceTree(Type type) {
bpatel@766 327 Type sup;
bpatel@766 328 HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
bpatel@766 329 classTreeUl.addStyle(HtmlStyle.inheritance);
bpatel@766 330 Content liTree = null;
bpatel@766 331 do {
bpatel@766 332 sup = Util.getFirstVisibleSuperClass(
bpatel@766 333 type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
jjg@1410 334 configuration);
bpatel@766 335 if (sup != null) {
bpatel@766 336 HtmlTree ul = new HtmlTree(HtmlTag.UL);
bpatel@766 337 ul.addStyle(HtmlStyle.inheritance);
bpatel@766 338 ul.addContent(getTreeForClassHelper(type));
bpatel@766 339 if (liTree != null)
bpatel@766 340 ul.addContent(liTree);
bpatel@766 341 Content li = HtmlTree.LI(ul);
bpatel@766 342 liTree = li;
bpatel@766 343 type = sup;
bpatel@766 344 }
bpatel@766 345 else
bpatel@766 346 classTreeUl.addContent(getTreeForClassHelper(type));
bpatel@766 347 }
bpatel@766 348 while (sup != null);
bpatel@766 349 if (liTree != null)
bpatel@766 350 classTreeUl.addContent(liTree);
bpatel@766 351 return classTreeUl;
bpatel@766 352 }
bpatel@766 353
bpatel@766 354 /**
bpatel@766 355 * Get the class helper tree for the given class.
bpatel@766 356 *
bpatel@766 357 * @param type the class to print the helper for
bpatel@766 358 * @return a content tree for class helper
bpatel@766 359 */
bpatel@766 360 private Content getTreeForClassHelper(Type type) {
bpatel@766 361 Content li = new HtmlTree(HtmlTag.LI);
bpatel@766 362 if (type.equals(classDoc)) {
jjg@1736 363 Content typeParameters = getTypeParameterLinks(
jjg@1735 364 new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
jjg@1738 365 classDoc));
bpatel@766 366 if (configuration.shouldExcludeQualifier(
bpatel@766 367 classDoc.containingPackage().name())) {
bpatel@766 368 li.addContent(type.asClassDoc().name());
jjg@1736 369 li.addContent(typeParameters);
bpatel@766 370 } else {
bpatel@766 371 li.addContent(type.asClassDoc().qualifiedName());
jjg@1736 372 li.addContent(typeParameters);
bpatel@766 373 }
duke@1 374 } else {
jjg@1736 375 Content link = getLink(new LinkInfoImpl(configuration,
jjg@1738 376 LinkInfoImpl.Kind.CLASS_TREE_PARENT, type)
jjg@1738 377 .label(configuration.getClassName(type.asClassDoc())));
bpatel@766 378 li.addContent(link);
bpatel@766 379 }
bpatel@766 380 return li;
bpatel@766 381 }
bpatel@766 382
bpatel@766 383 /**
bpatel@766 384 * {@inheritDoc}
bpatel@766 385 */
bpatel@766 386 public void addClassTree(Content classContentTree) {
bpatel@766 387 if (!classDoc.isClass()) {
bpatel@766 388 return;
bpatel@766 389 }
bpatel@766 390 classContentTree.addContent(getClassInheritenceTree(classDoc));
bpatel@766 391 }
bpatel@766 392
bpatel@766 393 /**
bpatel@766 394 * {@inheritDoc}
bpatel@766 395 */
bpatel@766 396 public void addTypeParamInfo(Content classInfoTree) {
bpatel@766 397 if (classDoc.typeParamTags().length > 0) {
bpatel@766 398 TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
bpatel@766 399 getTagletWriterInstance(false));
bpatel@766 400 Content typeParam = new RawHtml(output.toString());
bpatel@766 401 Content dl = HtmlTree.DL(typeParam);
bpatel@766 402 classInfoTree.addContent(dl);
duke@1 403 }
duke@1 404 }
duke@1 405
duke@1 406 /**
duke@1 407 * {@inheritDoc}
duke@1 408 */
bpatel@766 409 public void addSubClassInfo(Content classInfoTree) {
duke@1 410 if (classDoc.isClass()) {
duke@1 411 if (classDoc.qualifiedName().equals("java.lang.Object") ||
bpatel@766 412 classDoc.qualifiedName().equals("org.omg.CORBA.Object")) {
duke@1 413 return; // Don't generate the list, too huge
duke@1 414 }
mcimadamore@184 415 List<ClassDoc> subclasses = classtree.subs(classDoc, false);
duke@1 416 if (subclasses.size() > 0) {
bpatel@766 417 Content label = getResource(
bpatel@766 418 "doclet.Subclasses");
bpatel@766 419 Content dt = HtmlTree.DT(label);
bpatel@766 420 Content dl = HtmlTree.DL(dt);
jjg@1735 421 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES,
bpatel@766 422 subclasses));
bpatel@766 423 classInfoTree.addContent(dl);
duke@1 424 }
duke@1 425 }
duke@1 426 }
duke@1 427
duke@1 428 /**
duke@1 429 * {@inheritDoc}
duke@1 430 */
bpatel@766 431 public void addSubInterfacesInfo(Content classInfoTree) {
duke@1 432 if (classDoc.isInterface()) {
mcimadamore@184 433 List<ClassDoc> subInterfaces = classtree.allSubs(classDoc, false);
duke@1 434 if (subInterfaces.size() > 0) {
bpatel@766 435 Content label = getResource(
bpatel@766 436 "doclet.Subinterfaces");
bpatel@766 437 Content dt = HtmlTree.DT(label);
bpatel@766 438 Content dl = HtmlTree.DL(dt);
jjg@1735 439 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES,
bpatel@766 440 subInterfaces));
bpatel@766 441 classInfoTree.addContent(dl);
duke@1 442 }
duke@1 443 }
duke@1 444 }
duke@1 445
duke@1 446 /**
duke@1 447 * {@inheritDoc}
duke@1 448 */
bpatel@766 449 public void addInterfaceUsageInfo (Content classInfoTree) {
bpatel@766 450 if (! classDoc.isInterface()) {
bpatel@766 451 return;
bpatel@766 452 }
bpatel@766 453 if (classDoc.qualifiedName().equals("java.lang.Cloneable") ||
bpatel@766 454 classDoc.qualifiedName().equals("java.io.Serializable")) {
bpatel@766 455 return; // Don't generate the list, too big
bpatel@766 456 }
bpatel@766 457 List<ClassDoc> implcl = classtree.implementingclasses(classDoc);
bpatel@766 458 if (implcl.size() > 0) {
bpatel@766 459 Content label = getResource(
bpatel@766 460 "doclet.Implementing_Classes");
bpatel@766 461 Content dt = HtmlTree.DT(label);
bpatel@766 462 Content dl = HtmlTree.DL(dt);
jjg@1735 463 dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES,
bpatel@766 464 implcl));
bpatel@766 465 classInfoTree.addContent(dl);
duke@1 466 }
duke@1 467 }
duke@1 468
duke@1 469 /**
duke@1 470 * {@inheritDoc}
duke@1 471 */
bpatel@766 472 public void addImplementedInterfacesInfo(Content classInfoTree) {
bpatel@766 473 //NOTE: we really should be using ClassDoc.interfaceTypes() here, but
bpatel@766 474 // it doesn't walk up the tree like we want it to.
bpatel@766 475 List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
bpatel@766 476 if (classDoc.isClass() && interfaceArray.size() > 0) {
bpatel@766 477 Content label = getResource(
bpatel@766 478 "doclet.All_Implemented_Interfaces");
bpatel@766 479 Content dt = HtmlTree.DT(label);
bpatel@766 480 Content dl = HtmlTree.DL(dt);
jjg@1735 481 dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES,
bpatel@766 482 interfaceArray));
bpatel@766 483 classInfoTree.addContent(dl);
bpatel@766 484 }
bpatel@766 485 }
bpatel@766 486
bpatel@766 487 /**
bpatel@766 488 * {@inheritDoc}
bpatel@766 489 */
bpatel@766 490 public void addSuperInterfacesInfo(Content classInfoTree) {
duke@1 491 //NOTE: we really should be using ClassDoc.interfaceTypes() here, but
duke@1 492 // it doesn't walk up the tree like we want it to.
mcimadamore@184 493 List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
duke@1 494 if (classDoc.isInterface() && interfaceArray.size() > 0) {
bpatel@766 495 Content label = getResource(
bpatel@766 496 "doclet.All_Superinterfaces");
bpatel@766 497 Content dt = HtmlTree.DT(label);
bpatel@766 498 Content dl = HtmlTree.DL(dt);
jjg@1735 499 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES,
bpatel@766 500 interfaceArray));
bpatel@766 501 classInfoTree.addContent(dl);
duke@1 502 }
duke@1 503 }
duke@1 504
duke@1 505 /**
bpatel@766 506 * {@inheritDoc}
duke@1 507 */
bpatel@766 508 public void addNestedClassInfo(Content classInfoTree) {
bpatel@766 509 ClassDoc outerClass = classDoc.containingClass();
bpatel@766 510 if (outerClass != null) {
bpatel@766 511 Content label;
bpatel@766 512 if (outerClass.isInterface()) {
bpatel@766 513 label = getResource(
bpatel@766 514 "doclet.Enclosing_Interface");
bpatel@766 515 } else {
bpatel@766 516 label = getResource(
bpatel@766 517 "doclet.Enclosing_Class");
bpatel@766 518 }
bpatel@766 519 Content dt = HtmlTree.DT(label);
bpatel@766 520 Content dl = HtmlTree.DL(dt);
bpatel@766 521 Content dd = new HtmlTree(HtmlTag.DD);
jjg@1736 522 dd.addContent(getLink(new LinkInfoImpl(configuration,
jjg@1738 523 LinkInfoImpl.Kind.CLASS, outerClass)));
bpatel@766 524 dl.addContent(dd);
bpatel@766 525 classInfoTree.addContent(dl);
bpatel@766 526 }
bpatel@766 527 }
bpatel@766 528
bpatel@766 529 /**
bpatel@766 530 * {@inheritDoc}
bpatel@766 531 */
bpatel@1468 532 public void addFunctionalInterfaceInfo (Content classInfoTree) {
bpatel@1468 533 if (classDoc.isFunctionalInterface()) {
bpatel@1468 534 Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
bpatel@1468 535 Content dl = HtmlTree.DL(dt);
bpatel@1468 536 Content dd = new HtmlTree(HtmlTag.DD);
bpatel@1468 537 dd.addContent(getResource("doclet.Functional_Interface_Message"));
bpatel@1468 538 dl.addContent(dd);
bpatel@1468 539 classInfoTree.addContent(dl);
bpatel@1468 540 }
bpatel@1468 541 }
bpatel@1468 542
bpatel@1468 543 /**
bpatel@1468 544 * {@inheritDoc}
bpatel@1468 545 */
bpatel@766 546 public void addClassDeprecationInfo(Content classInfoTree) {
bpatel@766 547 Content hr = new HtmlTree(HtmlTag.HR);
bpatel@766 548 classInfoTree.addContent(hr);
bpatel@766 549 Tag[] deprs = classDoc.tags("deprecated");
bpatel@766 550 if (Util.isDeprecated(classDoc)) {
bpatel@766 551 Content strong = HtmlTree.STRONG(deprecatedPhrase);
bpatel@766 552 Content div = HtmlTree.DIV(HtmlStyle.block, strong);
bpatel@766 553 if (deprs.length > 0) {
bpatel@766 554 Tag[] commentTags = deprs[0].inlineTags();
bpatel@766 555 if (commentTags.length > 0) {
bpatel@766 556 div.addContent(getSpace());
bpatel@766 557 addInlineDeprecatedComment(classDoc, deprs[0], div);
bpatel@766 558 }
bpatel@766 559 }
bpatel@766 560 classInfoTree.addContent(div);
bpatel@766 561 }
bpatel@766 562 }
bpatel@766 563
bpatel@766 564 /**
bpatel@766 565 * Get links to the given classes.
bpatel@766 566 *
bpatel@766 567 * @param context the id of the context where the link will be printed
bpatel@766 568 * @param list the list of classes
bpatel@766 569 * @return a content tree for the class list
bpatel@766 570 */
jjg@1735 571 private Content getClassLinks(LinkInfoImpl.Kind context, List<?> list) {
duke@1 572 Object[] typeList = list.toArray();
bpatel@766 573 Content dd = new HtmlTree(HtmlTag.DD);
duke@1 574 for (int i = 0; i < list.size(); i++) {
duke@1 575 if (i > 0) {
bpatel@766 576 Content separator = new StringContent(", ");
bpatel@766 577 dd.addContent(separator);
duke@1 578 }
duke@1 579 if (typeList[i] instanceof ClassDoc) {
jjg@1736 580 Content link = getLink(
jjg@1736 581 new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i])));
bpatel@766 582 dd.addContent(link);
duke@1 583 } else {
jjg@1736 584 Content link = getLink(
jjg@1736 585 new LinkInfoImpl(configuration, context, (Type)(typeList[i])));
bpatel@766 586 dd.addContent(link);
duke@1 587 }
duke@1 588 }
bpatel@766 589 return dd;
duke@1 590 }
duke@1 591
bpatel@766 592 /**
bpatel@766 593 * {@inheritDoc}
bpatel@766 594 */
bpatel@766 595 protected Content getNavLinkTree() {
jjg@1372 596 Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
jjg@1373 597 treeLabel, "", "");
bpatel@766 598 Content li = HtmlTree.LI(treeLinkContent);
bpatel@766 599 return li;
duke@1 600 }
duke@1 601
bpatel@766 602 /**
bpatel@766 603 * Add summary details to the navigation bar.
bpatel@766 604 *
bpatel@766 605 * @param subDiv the content tree to which the summary detail links will be added
bpatel@766 606 */
bpatel@766 607 protected void addSummaryDetailLinks(Content subDiv) {
duke@1 608 try {
bpatel@766 609 Content div = HtmlTree.DIV(getNavSummaryLinks());
bpatel@766 610 div.addContent(getNavDetailLinks());
bpatel@766 611 subDiv.addContent(div);
duke@1 612 } catch (Exception e) {
duke@1 613 e.printStackTrace();
duke@1 614 throw new DocletAbortException();
duke@1 615 }
duke@1 616 }
duke@1 617
bpatel@766 618 /**
bpatel@766 619 * Get summary links for navigation bar.
bpatel@766 620 *
bpatel@766 621 * @return the content tree for the navigation summary links
bpatel@766 622 */
bpatel@766 623 protected Content getNavSummaryLinks() throws Exception {
bpatel@766 624 Content li = HtmlTree.LI(summaryLabel);
bpatel@766 625 li.addContent(getSpace());
bpatel@766 626 Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
duke@1 627 MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
bpatel@766 628 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
duke@1 629 String[] navLinkLabels = new String[] {
duke@1 630 "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
bpatel@766 631 "doclet.navMethod"
duke@1 632 };
duke@1 633 for (int i = 0; i < navLinkLabels.length; i++ ) {
bpatel@766 634 Content liNav = new HtmlTree(HtmlTag.LI);
duke@1 635 if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
duke@1 636 continue;
duke@1 637 }
duke@1 638 if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) {
duke@1 639 continue;
duke@1 640 }
duke@1 641 AbstractMemberWriter writer =
duke@1 642 ((AbstractMemberWriter) memberSummaryBuilder.
bpatel@766 643 getMemberSummaryWriter(i));
duke@1 644 if (writer == null) {
bpatel@766 645 liNav.addContent(getResource(navLinkLabels[i]));
duke@1 646 } else {
bpatel@766 647 writer.addNavSummaryLink(
bpatel@766 648 memberSummaryBuilder.members(i),
bpatel@766 649 memberSummaryBuilder.getVisibleMemberMap(i), liNav);
duke@1 650 }
duke@1 651 if (i < navLinkLabels.length-1) {
bpatel@766 652 addNavGap(liNav);
duke@1 653 }
bpatel@766 654 ulNav.addContent(liNav);
duke@1 655 }
bpatel@766 656 return ulNav;
duke@1 657 }
duke@1 658
duke@1 659 /**
bpatel@766 660 * Get detail links for the navigation bar.
duke@1 661 *
bpatel@766 662 * @return the content tree for the detail links
duke@1 663 */
bpatel@766 664 protected Content getNavDetailLinks() throws Exception {
bpatel@766 665 Content li = HtmlTree.LI(detailLabel);
bpatel@766 666 li.addContent(getSpace());
bpatel@766 667 Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
duke@1 668 MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
bpatel@766 669 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
duke@1 670 String[] navLinkLabels = new String[] {
duke@1 671 "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
bpatel@766 672 "doclet.navMethod"
duke@1 673 };
duke@1 674 for (int i = 1; i < navLinkLabels.length; i++ ) {
bpatel@766 675 Content liNav = new HtmlTree(HtmlTag.LI);
duke@1 676 AbstractMemberWriter writer =
bpatel@766 677 ((AbstractMemberWriter) memberSummaryBuilder.
duke@1 678 getMemberSummaryWriter(i));
duke@1 679 if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
duke@1 680 continue;
duke@1 681 }
duke@1 682 if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) {
duke@1 683 continue;
duke@1 684 }
duke@1 685 if (writer == null) {
bpatel@766 686 liNav.addContent(getResource(navLinkLabels[i]));
duke@1 687 } else {
bpatel@766 688 writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav);
duke@1 689 }
duke@1 690 if (i < navLinkLabels.length - 1) {
bpatel@766 691 addNavGap(liNav);
duke@1 692 }
bpatel@766 693 ulNav.addContent(liNav);
duke@1 694 }
bpatel@766 695 return ulNav;
duke@1 696 }
duke@1 697
duke@1 698 /**
bpatel@766 699 * Add gap between navigation bar elements.
bpatel@766 700 *
bpatel@766 701 * @param liNav the content tree to which the gap will be added
duke@1 702 */
bpatel@766 703 protected void addNavGap(Content liNav) {
bpatel@766 704 liNav.addContent(getSpace());
bpatel@766 705 liNav.addContent("|");
bpatel@766 706 liNav.addContent(getSpace());
duke@1 707 }
duke@1 708
duke@1 709 /**
duke@1 710 * Return the classDoc being documented.
duke@1 711 *
duke@1 712 * @return the classDoc being documented.
duke@1 713 */
duke@1 714 public ClassDoc getClassDoc() {
duke@1 715 return classDoc;
duke@1 716 }
duke@1 717 }

mercurial