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

Tue, 25 Dec 2012 17:23:59 -0800

author
bpatel
date
Tue, 25 Dec 2012 17:23:59 -0800
changeset 1468
690c41cdab55
parent 1410
bfec2a1cc869
child 1568
5f0731e4e5e6
permissions
-rw-r--r--

8004893: the javadoc/doclet needs to be updated to accommodate lambda changes
Reviewed-by: jjg

duke@1 1 /*
jjg@1357 2 * Copyright (c) 1997, 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.formats.html;
duke@1 27
jjg@1364 28 import java.io.IOException;
bpatel@233 29 import java.util.*;
bpatel@233 30
bpatel@233 31 import com.sun.javadoc.*;
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@1410 127 Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
bpatel@766 128 LinkInfoImpl.CONTEXT_CLASS, prev, "",
bpatel@766 129 configuration.getText("doclet.Prev_Class"), 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@1410 145 Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
bpatel@766 146 LinkInfoImpl.CONTEXT_CLASS, next, "",
bpatel@766 147 configuration.getText("doclet.Next_Class"), 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);
duke@1 168 if (pkgname.length() > 0) {
bpatel@766 169 Content pkgNameContent = new StringContent(pkgname);
bpatel@943 170 Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
bpatel@943 171 div.addContent(pkgNameDiv);
duke@1 172 }
jjg@1410 173 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
jjg@1410 174 LinkInfoImpl.CONTEXT_CLASS_HEADER, classDoc, false);
duke@1 175 //Let's not link to ourselves in the header.
duke@1 176 linkInfo.linkToSelf = false;
bpatel@766 177 Content headerContent = new StringContent(header);
bpatel@766 178 Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
bpatel@766 179 HtmlStyle.title, headerContent);
bpatel@766 180 heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
bpatel@766 181 div.addContent(heading);
bpatel@766 182 bodyTree.addContent(div);
bpatel@766 183 return bodyTree;
duke@1 184 }
duke@1 185
duke@1 186 /**
duke@1 187 * {@inheritDoc}
duke@1 188 */
bpatel@766 189 public Content getClassContentHeader() {
bpatel@766 190 return getContentHeader();
duke@1 191 }
duke@1 192
duke@1 193 /**
duke@1 194 * {@inheritDoc}
duke@1 195 */
bpatel@766 196 public void addFooter(Content contentTree) {
bpatel@766 197 contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
bpatel@766 198 addNavLinks(false, contentTree);
bpatel@766 199 addBottom(contentTree);
bpatel@766 200 }
bpatel@766 201
bpatel@766 202 /**
bpatel@766 203 * {@inheritDoc}
bpatel@766 204 */
jjg@1364 205 public void printDocument(Content contentTree) throws IOException {
bpatel@766 206 printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc),
bpatel@766 207 true, contentTree);
bpatel@766 208 }
bpatel@766 209
bpatel@766 210 /**
bpatel@766 211 * {@inheritDoc}
bpatel@766 212 */
bpatel@766 213 public Content getClassInfoTreeHeader() {
bpatel@766 214 return getMemberTreeHeader();
bpatel@766 215 }
bpatel@766 216
bpatel@766 217 /**
bpatel@766 218 * {@inheritDoc}
bpatel@766 219 */
bpatel@766 220 public Content getClassInfo(Content classInfoTree) {
bpatel@766 221 return getMemberTree(HtmlStyle.description, classInfoTree);
bpatel@766 222 }
bpatel@766 223
bpatel@766 224 /**
bpatel@766 225 * {@inheritDoc}
bpatel@766 226 */
bpatel@766 227 public void addClassSignature(String modifiers, Content classInfoTree) {
duke@1 228 boolean isInterface = classDoc.isInterface();
bpatel@766 229 classInfoTree.addContent(new HtmlTree(HtmlTag.BR));
bpatel@766 230 Content pre = new HtmlTree(HtmlTag.PRE);
bpatel@766 231 addAnnotationInfo(classDoc, pre);
bpatel@766 232 pre.addContent(modifiers);
jjg@1410 233 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
bpatel@766 234 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
duke@1 235 //Let's not link to ourselves in the signature.
duke@1 236 linkInfo.linkToSelf = false;
bpatel@958 237 Content className = new StringContent(classDoc.name());
bpatel@958 238 Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
jjg@1410 239 if (configuration.linksource) {
bpatel@958 240 addSrcLink(classDoc, className, pre);
bpatel@958 241 pre.addContent(parameterLinks);
duke@1 242 } else {
bpatel@958 243 Content span = HtmlTree.SPAN(HtmlStyle.strong, className);
bpatel@958 244 span.addContent(parameterLinks);
bpatel@958 245 pre.addContent(span);
duke@1 246 }
duke@1 247 if (!isInterface) {
duke@1 248 Type superclass = Util.getFirstVisibleSuperClass(classDoc,
jjg@1410 249 configuration);
duke@1 250 if (superclass != null) {
bpatel@793 251 pre.addContent(DocletConstants.NL);
bpatel@766 252 pre.addContent("extends ");
jjg@1410 253 Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
bpatel@766 254 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
bpatel@766 255 superclass)));
bpatel@766 256 pre.addContent(link);
duke@1 257 }
duke@1 258 }
duke@1 259 Type[] implIntfacs = classDoc.interfaceTypes();
duke@1 260 if (implIntfacs != null && implIntfacs.length > 0) {
duke@1 261 int counter = 0;
duke@1 262 for (int i = 0; i < implIntfacs.length; i++) {
duke@1 263 ClassDoc classDoc = implIntfacs[i].asClassDoc();
duke@1 264 if (! (classDoc.isPublic() ||
jjg@1410 265 Util.isLinkable(classDoc, configuration))) {
duke@1 266 continue;
duke@1 267 }
duke@1 268 if (counter == 0) {
bpatel@793 269 pre.addContent(DocletConstants.NL);
bpatel@766 270 pre.addContent(isInterface? "extends " : "implements ");
duke@1 271 } else {
bpatel@766 272 pre.addContent(", ");
duke@1 273 }
jjg@1410 274 Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
bpatel@766 275 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
bpatel@766 276 implIntfacs[i])));
bpatel@766 277 pre.addContent(link);
duke@1 278 counter++;
duke@1 279 }
duke@1 280 }
bpatel@766 281 classInfoTree.addContent(pre);
duke@1 282 }
duke@1 283
duke@1 284 /**
duke@1 285 * {@inheritDoc}
duke@1 286 */
bpatel@766 287 public void addClassDescription(Content classInfoTree) {
duke@1 288 if(!configuration.nocomment) {
duke@1 289 // generate documentation for the class.
duke@1 290 if (classDoc.inlineTags().length > 0) {
bpatel@766 291 addInlineComment(classDoc, classInfoTree);
duke@1 292 }
duke@1 293 }
duke@1 294 }
duke@1 295
duke@1 296 /**
duke@1 297 * {@inheritDoc}
duke@1 298 */
bpatel@766 299 public void addClassTagInfo(Content classInfoTree) {
duke@1 300 if(!configuration.nocomment) {
duke@1 301 // Print Information about all the tags here
bpatel@766 302 addTagsInfo(classDoc, classInfoTree);
bpatel@766 303 }
bpatel@766 304 }
bpatel@766 305
bpatel@766 306 /**
bpatel@766 307 * Get the class hierarchy tree for the given class.
bpatel@766 308 *
bpatel@766 309 * @param type the class to print the hierarchy for
bpatel@766 310 * @return a content tree for class inheritence
bpatel@766 311 */
bpatel@766 312 private Content getClassInheritenceTree(Type type) {
bpatel@766 313 Type sup;
bpatel@766 314 HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
bpatel@766 315 classTreeUl.addStyle(HtmlStyle.inheritance);
bpatel@766 316 Content liTree = null;
bpatel@766 317 do {
bpatel@766 318 sup = Util.getFirstVisibleSuperClass(
bpatel@766 319 type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
jjg@1410 320 configuration);
bpatel@766 321 if (sup != null) {
bpatel@766 322 HtmlTree ul = new HtmlTree(HtmlTag.UL);
bpatel@766 323 ul.addStyle(HtmlStyle.inheritance);
bpatel@766 324 ul.addContent(getTreeForClassHelper(type));
bpatel@766 325 if (liTree != null)
bpatel@766 326 ul.addContent(liTree);
bpatel@766 327 Content li = HtmlTree.LI(ul);
bpatel@766 328 liTree = li;
bpatel@766 329 type = sup;
bpatel@766 330 }
bpatel@766 331 else
bpatel@766 332 classTreeUl.addContent(getTreeForClassHelper(type));
bpatel@766 333 }
bpatel@766 334 while (sup != null);
bpatel@766 335 if (liTree != null)
bpatel@766 336 classTreeUl.addContent(liTree);
bpatel@766 337 return classTreeUl;
bpatel@766 338 }
bpatel@766 339
bpatel@766 340 /**
bpatel@766 341 * Get the class helper tree for the given class.
bpatel@766 342 *
bpatel@766 343 * @param type the class to print the helper for
bpatel@766 344 * @return a content tree for class helper
bpatel@766 345 */
bpatel@766 346 private Content getTreeForClassHelper(Type type) {
bpatel@766 347 Content li = new HtmlTree(HtmlTag.LI);
bpatel@766 348 if (type.equals(classDoc)) {
bpatel@766 349 String typeParameters = getTypeParameterLinks(
jjg@1410 350 new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_TREE,
bpatel@766 351 classDoc, false));
bpatel@766 352 if (configuration.shouldExcludeQualifier(
bpatel@766 353 classDoc.containingPackage().name())) {
bpatel@766 354 li.addContent(type.asClassDoc().name());
bpatel@766 355 li.addContent(new RawHtml(typeParameters));
bpatel@766 356 } else {
bpatel@766 357 li.addContent(type.asClassDoc().qualifiedName());
bpatel@766 358 li.addContent(new RawHtml(typeParameters));
bpatel@766 359 }
duke@1 360 } else {
jjg@1410 361 Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
bpatel@766 362 LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
bpatel@766 363 type instanceof ClassDoc ? (ClassDoc) type : type,
bpatel@766 364 configuration.getClassName(type.asClassDoc()), false)));
bpatel@766 365 li.addContent(link);
bpatel@766 366 }
bpatel@766 367 return li;
bpatel@766 368 }
bpatel@766 369
bpatel@766 370 /**
bpatel@766 371 * {@inheritDoc}
bpatel@766 372 */
bpatel@766 373 public void addClassTree(Content classContentTree) {
bpatel@766 374 if (!classDoc.isClass()) {
bpatel@766 375 return;
bpatel@766 376 }
bpatel@766 377 classContentTree.addContent(getClassInheritenceTree(classDoc));
bpatel@766 378 }
bpatel@766 379
bpatel@766 380 /**
bpatel@766 381 * {@inheritDoc}
bpatel@766 382 */
bpatel@766 383 public void addTypeParamInfo(Content classInfoTree) {
bpatel@766 384 if (classDoc.typeParamTags().length > 0) {
bpatel@766 385 TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
bpatel@766 386 getTagletWriterInstance(false));
bpatel@766 387 Content typeParam = new RawHtml(output.toString());
bpatel@766 388 Content dl = HtmlTree.DL(typeParam);
bpatel@766 389 classInfoTree.addContent(dl);
duke@1 390 }
duke@1 391 }
duke@1 392
duke@1 393 /**
duke@1 394 * {@inheritDoc}
duke@1 395 */
bpatel@766 396 public void addSubClassInfo(Content classInfoTree) {
duke@1 397 if (classDoc.isClass()) {
duke@1 398 if (classDoc.qualifiedName().equals("java.lang.Object") ||
bpatel@766 399 classDoc.qualifiedName().equals("org.omg.CORBA.Object")) {
duke@1 400 return; // Don't generate the list, too huge
duke@1 401 }
mcimadamore@184 402 List<ClassDoc> subclasses = classtree.subs(classDoc, false);
duke@1 403 if (subclasses.size() > 0) {
bpatel@766 404 Content label = getResource(
bpatel@766 405 "doclet.Subclasses");
bpatel@766 406 Content dt = HtmlTree.DT(label);
bpatel@766 407 Content dl = HtmlTree.DL(dt);
bpatel@766 408 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
bpatel@766 409 subclasses));
bpatel@766 410 classInfoTree.addContent(dl);
duke@1 411 }
duke@1 412 }
duke@1 413 }
duke@1 414
duke@1 415 /**
duke@1 416 * {@inheritDoc}
duke@1 417 */
bpatel@766 418 public void addSubInterfacesInfo(Content classInfoTree) {
duke@1 419 if (classDoc.isInterface()) {
mcimadamore@184 420 List<ClassDoc> subInterfaces = classtree.allSubs(classDoc, false);
duke@1 421 if (subInterfaces.size() > 0) {
bpatel@766 422 Content label = getResource(
bpatel@766 423 "doclet.Subinterfaces");
bpatel@766 424 Content dt = HtmlTree.DT(label);
bpatel@766 425 Content dl = HtmlTree.DL(dt);
bpatel@766 426 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
bpatel@766 427 subInterfaces));
bpatel@766 428 classInfoTree.addContent(dl);
duke@1 429 }
duke@1 430 }
duke@1 431 }
duke@1 432
duke@1 433 /**
duke@1 434 * {@inheritDoc}
duke@1 435 */
bpatel@766 436 public void addInterfaceUsageInfo (Content classInfoTree) {
bpatel@766 437 if (! classDoc.isInterface()) {
bpatel@766 438 return;
bpatel@766 439 }
bpatel@766 440 if (classDoc.qualifiedName().equals("java.lang.Cloneable") ||
bpatel@766 441 classDoc.qualifiedName().equals("java.io.Serializable")) {
bpatel@766 442 return; // Don't generate the list, too big
bpatel@766 443 }
bpatel@766 444 List<ClassDoc> implcl = classtree.implementingclasses(classDoc);
bpatel@766 445 if (implcl.size() > 0) {
bpatel@766 446 Content label = getResource(
bpatel@766 447 "doclet.Implementing_Classes");
bpatel@766 448 Content dt = HtmlTree.DT(label);
bpatel@766 449 Content dl = HtmlTree.DL(dt);
bpatel@766 450 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
bpatel@766 451 implcl));
bpatel@766 452 classInfoTree.addContent(dl);
duke@1 453 }
duke@1 454 }
duke@1 455
duke@1 456 /**
duke@1 457 * {@inheritDoc}
duke@1 458 */
bpatel@766 459 public void addImplementedInterfacesInfo(Content classInfoTree) {
bpatel@766 460 //NOTE: we really should be using ClassDoc.interfaceTypes() here, but
bpatel@766 461 // it doesn't walk up the tree like we want it to.
bpatel@766 462 List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
bpatel@766 463 if (classDoc.isClass() && interfaceArray.size() > 0) {
bpatel@766 464 Content label = getResource(
bpatel@766 465 "doclet.All_Implemented_Interfaces");
bpatel@766 466 Content dt = HtmlTree.DT(label);
bpatel@766 467 Content dl = HtmlTree.DL(dt);
bpatel@766 468 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
bpatel@766 469 interfaceArray));
bpatel@766 470 classInfoTree.addContent(dl);
bpatel@766 471 }
bpatel@766 472 }
bpatel@766 473
bpatel@766 474 /**
bpatel@766 475 * {@inheritDoc}
bpatel@766 476 */
bpatel@766 477 public void addSuperInterfacesInfo(Content classInfoTree) {
duke@1 478 //NOTE: we really should be using ClassDoc.interfaceTypes() here, but
duke@1 479 // it doesn't walk up the tree like we want it to.
mcimadamore@184 480 List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
duke@1 481 if (classDoc.isInterface() && interfaceArray.size() > 0) {
bpatel@766 482 Content label = getResource(
bpatel@766 483 "doclet.All_Superinterfaces");
bpatel@766 484 Content dt = HtmlTree.DT(label);
bpatel@766 485 Content dl = HtmlTree.DL(dt);
bpatel@766 486 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
bpatel@766 487 interfaceArray));
bpatel@766 488 classInfoTree.addContent(dl);
duke@1 489 }
duke@1 490 }
duke@1 491
duke@1 492 /**
bpatel@766 493 * {@inheritDoc}
duke@1 494 */
bpatel@766 495 public void addNestedClassInfo(Content classInfoTree) {
bpatel@766 496 ClassDoc outerClass = classDoc.containingClass();
bpatel@766 497 if (outerClass != null) {
bpatel@766 498 Content label;
bpatel@766 499 if (outerClass.isInterface()) {
bpatel@766 500 label = getResource(
bpatel@766 501 "doclet.Enclosing_Interface");
bpatel@766 502 } else {
bpatel@766 503 label = getResource(
bpatel@766 504 "doclet.Enclosing_Class");
bpatel@766 505 }
bpatel@766 506 Content dt = HtmlTree.DT(label);
bpatel@766 507 Content dl = HtmlTree.DL(dt);
bpatel@766 508 Content dd = new HtmlTree(HtmlTag.DD);
jjg@1410 509 dd.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
jjg@1410 510 LinkInfoImpl.CONTEXT_CLASS, outerClass, false))));
bpatel@766 511 dl.addContent(dd);
bpatel@766 512 classInfoTree.addContent(dl);
bpatel@766 513 }
bpatel@766 514 }
bpatel@766 515
bpatel@766 516 /**
bpatel@766 517 * {@inheritDoc}
bpatel@766 518 */
bpatel@1468 519 public void addFunctionalInterfaceInfo (Content classInfoTree) {
bpatel@1468 520 if (classDoc.isFunctionalInterface()) {
bpatel@1468 521 Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
bpatel@1468 522 Content dl = HtmlTree.DL(dt);
bpatel@1468 523 Content dd = new HtmlTree(HtmlTag.DD);
bpatel@1468 524 dd.addContent(getResource("doclet.Functional_Interface_Message"));
bpatel@1468 525 dl.addContent(dd);
bpatel@1468 526 classInfoTree.addContent(dl);
bpatel@1468 527 }
bpatel@1468 528 }
bpatel@1468 529
bpatel@1468 530 /**
bpatel@1468 531 * {@inheritDoc}
bpatel@1468 532 */
bpatel@766 533 public void addClassDeprecationInfo(Content classInfoTree) {
bpatel@766 534 Content hr = new HtmlTree(HtmlTag.HR);
bpatel@766 535 classInfoTree.addContent(hr);
bpatel@766 536 Tag[] deprs = classDoc.tags("deprecated");
bpatel@766 537 if (Util.isDeprecated(classDoc)) {
bpatel@766 538 Content strong = HtmlTree.STRONG(deprecatedPhrase);
bpatel@766 539 Content div = HtmlTree.DIV(HtmlStyle.block, strong);
bpatel@766 540 if (deprs.length > 0) {
bpatel@766 541 Tag[] commentTags = deprs[0].inlineTags();
bpatel@766 542 if (commentTags.length > 0) {
bpatel@766 543 div.addContent(getSpace());
bpatel@766 544 addInlineDeprecatedComment(classDoc, deprs[0], div);
bpatel@766 545 }
bpatel@766 546 }
bpatel@766 547 classInfoTree.addContent(div);
bpatel@766 548 }
bpatel@766 549 }
bpatel@766 550
bpatel@766 551 /**
bpatel@766 552 * Get links to the given classes.
bpatel@766 553 *
bpatel@766 554 * @param context the id of the context where the link will be printed
bpatel@766 555 * @param list the list of classes
bpatel@766 556 * @return a content tree for the class list
bpatel@766 557 */
bpatel@766 558 private Content getClassLinks(int context, List<?> list) {
duke@1 559 Object[] typeList = list.toArray();
bpatel@766 560 Content dd = new HtmlTree(HtmlTag.DD);
duke@1 561 for (int i = 0; i < list.size(); i++) {
duke@1 562 if (i > 0) {
bpatel@766 563 Content separator = new StringContent(", ");
bpatel@766 564 dd.addContent(separator);
duke@1 565 }
duke@1 566 if (typeList[i] instanceof ClassDoc) {
bpatel@766 567 Content link = new RawHtml(getLink(
jjg@1410 568 new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i]))));
bpatel@766 569 dd.addContent(link);
duke@1 570 } else {
bpatel@766 571 Content link = new RawHtml(getLink(
jjg@1410 572 new LinkInfoImpl(configuration, context, (Type)(typeList[i]))));
bpatel@766 573 dd.addContent(link);
duke@1 574 }
duke@1 575 }
bpatel@766 576 return dd;
duke@1 577 }
duke@1 578
bpatel@766 579 /**
bpatel@766 580 * {@inheritDoc}
bpatel@766 581 */
bpatel@766 582 protected Content getNavLinkTree() {
jjg@1372 583 Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
jjg@1373 584 treeLabel, "", "");
bpatel@766 585 Content li = HtmlTree.LI(treeLinkContent);
bpatel@766 586 return li;
duke@1 587 }
duke@1 588
bpatel@766 589 /**
bpatel@766 590 * Add summary details to the navigation bar.
bpatel@766 591 *
bpatel@766 592 * @param subDiv the content tree to which the summary detail links will be added
bpatel@766 593 */
bpatel@766 594 protected void addSummaryDetailLinks(Content subDiv) {
duke@1 595 try {
bpatel@766 596 Content div = HtmlTree.DIV(getNavSummaryLinks());
bpatel@766 597 div.addContent(getNavDetailLinks());
bpatel@766 598 subDiv.addContent(div);
duke@1 599 } catch (Exception e) {
duke@1 600 e.printStackTrace();
duke@1 601 throw new DocletAbortException();
duke@1 602 }
duke@1 603 }
duke@1 604
bpatel@766 605 /**
bpatel@766 606 * Get summary links for navigation bar.
bpatel@766 607 *
bpatel@766 608 * @return the content tree for the navigation summary links
bpatel@766 609 */
bpatel@766 610 protected Content getNavSummaryLinks() throws Exception {
bpatel@766 611 Content li = HtmlTree.LI(summaryLabel);
bpatel@766 612 li.addContent(getSpace());
bpatel@766 613 Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
duke@1 614 MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
bpatel@766 615 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
duke@1 616 String[] navLinkLabels = new String[] {
duke@1 617 "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
bpatel@766 618 "doclet.navMethod"
duke@1 619 };
duke@1 620 for (int i = 0; i < navLinkLabels.length; i++ ) {
bpatel@766 621 Content liNav = new HtmlTree(HtmlTag.LI);
duke@1 622 if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
duke@1 623 continue;
duke@1 624 }
duke@1 625 if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) {
duke@1 626 continue;
duke@1 627 }
duke@1 628 AbstractMemberWriter writer =
duke@1 629 ((AbstractMemberWriter) memberSummaryBuilder.
bpatel@766 630 getMemberSummaryWriter(i));
duke@1 631 if (writer == null) {
bpatel@766 632 liNav.addContent(getResource(navLinkLabels[i]));
duke@1 633 } else {
bpatel@766 634 writer.addNavSummaryLink(
bpatel@766 635 memberSummaryBuilder.members(i),
bpatel@766 636 memberSummaryBuilder.getVisibleMemberMap(i), liNav);
duke@1 637 }
duke@1 638 if (i < navLinkLabels.length-1) {
bpatel@766 639 addNavGap(liNav);
duke@1 640 }
bpatel@766 641 ulNav.addContent(liNav);
duke@1 642 }
bpatel@766 643 return ulNav;
duke@1 644 }
duke@1 645
duke@1 646 /**
bpatel@766 647 * Get detail links for the navigation bar.
duke@1 648 *
bpatel@766 649 * @return the content tree for the detail links
duke@1 650 */
bpatel@766 651 protected Content getNavDetailLinks() throws Exception {
bpatel@766 652 Content li = HtmlTree.LI(detailLabel);
bpatel@766 653 li.addContent(getSpace());
bpatel@766 654 Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
duke@1 655 MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
bpatel@766 656 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
duke@1 657 String[] navLinkLabels = new String[] {
duke@1 658 "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
bpatel@766 659 "doclet.navMethod"
duke@1 660 };
duke@1 661 for (int i = 1; i < navLinkLabels.length; i++ ) {
bpatel@766 662 Content liNav = new HtmlTree(HtmlTag.LI);
duke@1 663 AbstractMemberWriter writer =
bpatel@766 664 ((AbstractMemberWriter) memberSummaryBuilder.
duke@1 665 getMemberSummaryWriter(i));
duke@1 666 if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
duke@1 667 continue;
duke@1 668 }
duke@1 669 if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) {
duke@1 670 continue;
duke@1 671 }
duke@1 672 if (writer == null) {
bpatel@766 673 liNav.addContent(getResource(navLinkLabels[i]));
duke@1 674 } else {
bpatel@766 675 writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav);
duke@1 676 }
duke@1 677 if (i < navLinkLabels.length - 1) {
bpatel@766 678 addNavGap(liNav);
duke@1 679 }
bpatel@766 680 ulNav.addContent(liNav);
duke@1 681 }
bpatel@766 682 return ulNav;
duke@1 683 }
duke@1 684
duke@1 685 /**
bpatel@766 686 * Add gap between navigation bar elements.
bpatel@766 687 *
bpatel@766 688 * @param liNav the content tree to which the gap will be added
duke@1 689 */
bpatel@766 690 protected void addNavGap(Content liNav) {
bpatel@766 691 liNav.addContent(getSpace());
bpatel@766 692 liNav.addContent("|");
bpatel@766 693 liNav.addContent(getSpace());
duke@1 694 }
duke@1 695
duke@1 696 /**
duke@1 697 * Return the classDoc being documented.
duke@1 698 *
duke@1 699 * @return the classDoc being documented.
duke@1 700 */
duke@1 701 public ClassDoc getClassDoc() {
duke@1 702 return classDoc;
duke@1 703 }
duke@1 704 }

mercurial