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

Mon, 21 Jan 2013 00:45:35 -0500

author
bpatel
date
Mon, 21 Jan 2013 00:45:35 -0500
changeset 1568
5f0731e4e5e6
parent 1468
690c41cdab55
child 1735
8ea30d59ac41
permissions
-rw-r--r--

8006124: javadoc/doclet should be updated to support profiles
Reviewed-by: jjg

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@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);
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@1410 188 LinkInfoImpl.CONTEXT_CLASS_HEADER, classDoc, false);
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);
bpatel@766 194 heading.addContent(new RawHtml(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,
bpatel@766 248 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
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());
bpatel@958 252 Content parameterLinks = new RawHtml(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@1410 267 Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
bpatel@766 268 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
bpatel@766 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@1410 288 Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
bpatel@766 289 LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
bpatel@766 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)) {
bpatel@766 363 String typeParameters = getTypeParameterLinks(
jjg@1410 364 new LinkInfoImpl(configuration, LinkInfoImpl.CONTEXT_TREE,
bpatel@766 365 classDoc, false));
bpatel@766 366 if (configuration.shouldExcludeQualifier(
bpatel@766 367 classDoc.containingPackage().name())) {
bpatel@766 368 li.addContent(type.asClassDoc().name());
bpatel@766 369 li.addContent(new RawHtml(typeParameters));
bpatel@766 370 } else {
bpatel@766 371 li.addContent(type.asClassDoc().qualifiedName());
bpatel@766 372 li.addContent(new RawHtml(typeParameters));
bpatel@766 373 }
duke@1 374 } else {
jjg@1410 375 Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
bpatel@766 376 LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
bpatel@766 377 type instanceof ClassDoc ? (ClassDoc) type : type,
bpatel@766 378 configuration.getClassName(type.asClassDoc()), false)));
bpatel@766 379 li.addContent(link);
bpatel@766 380 }
bpatel@766 381 return li;
bpatel@766 382 }
bpatel@766 383
bpatel@766 384 /**
bpatel@766 385 * {@inheritDoc}
bpatel@766 386 */
bpatel@766 387 public void addClassTree(Content classContentTree) {
bpatel@766 388 if (!classDoc.isClass()) {
bpatel@766 389 return;
bpatel@766 390 }
bpatel@766 391 classContentTree.addContent(getClassInheritenceTree(classDoc));
bpatel@766 392 }
bpatel@766 393
bpatel@766 394 /**
bpatel@766 395 * {@inheritDoc}
bpatel@766 396 */
bpatel@766 397 public void addTypeParamInfo(Content classInfoTree) {
bpatel@766 398 if (classDoc.typeParamTags().length > 0) {
bpatel@766 399 TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
bpatel@766 400 getTagletWriterInstance(false));
bpatel@766 401 Content typeParam = new RawHtml(output.toString());
bpatel@766 402 Content dl = HtmlTree.DL(typeParam);
bpatel@766 403 classInfoTree.addContent(dl);
duke@1 404 }
duke@1 405 }
duke@1 406
duke@1 407 /**
duke@1 408 * {@inheritDoc}
duke@1 409 */
bpatel@766 410 public void addSubClassInfo(Content classInfoTree) {
duke@1 411 if (classDoc.isClass()) {
duke@1 412 if (classDoc.qualifiedName().equals("java.lang.Object") ||
bpatel@766 413 classDoc.qualifiedName().equals("org.omg.CORBA.Object")) {
duke@1 414 return; // Don't generate the list, too huge
duke@1 415 }
mcimadamore@184 416 List<ClassDoc> subclasses = classtree.subs(classDoc, false);
duke@1 417 if (subclasses.size() > 0) {
bpatel@766 418 Content label = getResource(
bpatel@766 419 "doclet.Subclasses");
bpatel@766 420 Content dt = HtmlTree.DT(label);
bpatel@766 421 Content dl = HtmlTree.DL(dt);
bpatel@766 422 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
bpatel@766 423 subclasses));
bpatel@766 424 classInfoTree.addContent(dl);
duke@1 425 }
duke@1 426 }
duke@1 427 }
duke@1 428
duke@1 429 /**
duke@1 430 * {@inheritDoc}
duke@1 431 */
bpatel@766 432 public void addSubInterfacesInfo(Content classInfoTree) {
duke@1 433 if (classDoc.isInterface()) {
mcimadamore@184 434 List<ClassDoc> subInterfaces = classtree.allSubs(classDoc, false);
duke@1 435 if (subInterfaces.size() > 0) {
bpatel@766 436 Content label = getResource(
bpatel@766 437 "doclet.Subinterfaces");
bpatel@766 438 Content dt = HtmlTree.DT(label);
bpatel@766 439 Content dl = HtmlTree.DL(dt);
bpatel@766 440 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
bpatel@766 441 subInterfaces));
bpatel@766 442 classInfoTree.addContent(dl);
duke@1 443 }
duke@1 444 }
duke@1 445 }
duke@1 446
duke@1 447 /**
duke@1 448 * {@inheritDoc}
duke@1 449 */
bpatel@766 450 public void addInterfaceUsageInfo (Content classInfoTree) {
bpatel@766 451 if (! classDoc.isInterface()) {
bpatel@766 452 return;
bpatel@766 453 }
bpatel@766 454 if (classDoc.qualifiedName().equals("java.lang.Cloneable") ||
bpatel@766 455 classDoc.qualifiedName().equals("java.io.Serializable")) {
bpatel@766 456 return; // Don't generate the list, too big
bpatel@766 457 }
bpatel@766 458 List<ClassDoc> implcl = classtree.implementingclasses(classDoc);
bpatel@766 459 if (implcl.size() > 0) {
bpatel@766 460 Content label = getResource(
bpatel@766 461 "doclet.Implementing_Classes");
bpatel@766 462 Content dt = HtmlTree.DT(label);
bpatel@766 463 Content dl = HtmlTree.DL(dt);
bpatel@766 464 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
bpatel@766 465 implcl));
bpatel@766 466 classInfoTree.addContent(dl);
duke@1 467 }
duke@1 468 }
duke@1 469
duke@1 470 /**
duke@1 471 * {@inheritDoc}
duke@1 472 */
bpatel@766 473 public void addImplementedInterfacesInfo(Content classInfoTree) {
bpatel@766 474 //NOTE: we really should be using ClassDoc.interfaceTypes() here, but
bpatel@766 475 // it doesn't walk up the tree like we want it to.
bpatel@766 476 List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
bpatel@766 477 if (classDoc.isClass() && interfaceArray.size() > 0) {
bpatel@766 478 Content label = getResource(
bpatel@766 479 "doclet.All_Implemented_Interfaces");
bpatel@766 480 Content dt = HtmlTree.DT(label);
bpatel@766 481 Content dl = HtmlTree.DL(dt);
bpatel@766 482 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
bpatel@766 483 interfaceArray));
bpatel@766 484 classInfoTree.addContent(dl);
bpatel@766 485 }
bpatel@766 486 }
bpatel@766 487
bpatel@766 488 /**
bpatel@766 489 * {@inheritDoc}
bpatel@766 490 */
bpatel@766 491 public void addSuperInterfacesInfo(Content classInfoTree) {
duke@1 492 //NOTE: we really should be using ClassDoc.interfaceTypes() here, but
duke@1 493 // it doesn't walk up the tree like we want it to.
mcimadamore@184 494 List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
duke@1 495 if (classDoc.isInterface() && interfaceArray.size() > 0) {
bpatel@766 496 Content label = getResource(
bpatel@766 497 "doclet.All_Superinterfaces");
bpatel@766 498 Content dt = HtmlTree.DT(label);
bpatel@766 499 Content dl = HtmlTree.DL(dt);
bpatel@766 500 dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
bpatel@766 501 interfaceArray));
bpatel@766 502 classInfoTree.addContent(dl);
duke@1 503 }
duke@1 504 }
duke@1 505
duke@1 506 /**
bpatel@766 507 * {@inheritDoc}
duke@1 508 */
bpatel@766 509 public void addNestedClassInfo(Content classInfoTree) {
bpatel@766 510 ClassDoc outerClass = classDoc.containingClass();
bpatel@766 511 if (outerClass != null) {
bpatel@766 512 Content label;
bpatel@766 513 if (outerClass.isInterface()) {
bpatel@766 514 label = getResource(
bpatel@766 515 "doclet.Enclosing_Interface");
bpatel@766 516 } else {
bpatel@766 517 label = getResource(
bpatel@766 518 "doclet.Enclosing_Class");
bpatel@766 519 }
bpatel@766 520 Content dt = HtmlTree.DT(label);
bpatel@766 521 Content dl = HtmlTree.DL(dt);
bpatel@766 522 Content dd = new HtmlTree(HtmlTag.DD);
jjg@1410 523 dd.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
jjg@1410 524 LinkInfoImpl.CONTEXT_CLASS, outerClass, false))));
bpatel@766 525 dl.addContent(dd);
bpatel@766 526 classInfoTree.addContent(dl);
bpatel@766 527 }
bpatel@766 528 }
bpatel@766 529
bpatel@766 530 /**
bpatel@766 531 * {@inheritDoc}
bpatel@766 532 */
bpatel@1468 533 public void addFunctionalInterfaceInfo (Content classInfoTree) {
bpatel@1468 534 if (classDoc.isFunctionalInterface()) {
bpatel@1468 535 Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
bpatel@1468 536 Content dl = HtmlTree.DL(dt);
bpatel@1468 537 Content dd = new HtmlTree(HtmlTag.DD);
bpatel@1468 538 dd.addContent(getResource("doclet.Functional_Interface_Message"));
bpatel@1468 539 dl.addContent(dd);
bpatel@1468 540 classInfoTree.addContent(dl);
bpatel@1468 541 }
bpatel@1468 542 }
bpatel@1468 543
bpatel@1468 544 /**
bpatel@1468 545 * {@inheritDoc}
bpatel@1468 546 */
bpatel@766 547 public void addClassDeprecationInfo(Content classInfoTree) {
bpatel@766 548 Content hr = new HtmlTree(HtmlTag.HR);
bpatel@766 549 classInfoTree.addContent(hr);
bpatel@766 550 Tag[] deprs = classDoc.tags("deprecated");
bpatel@766 551 if (Util.isDeprecated(classDoc)) {
bpatel@766 552 Content strong = HtmlTree.STRONG(deprecatedPhrase);
bpatel@766 553 Content div = HtmlTree.DIV(HtmlStyle.block, strong);
bpatel@766 554 if (deprs.length > 0) {
bpatel@766 555 Tag[] commentTags = deprs[0].inlineTags();
bpatel@766 556 if (commentTags.length > 0) {
bpatel@766 557 div.addContent(getSpace());
bpatel@766 558 addInlineDeprecatedComment(classDoc, deprs[0], div);
bpatel@766 559 }
bpatel@766 560 }
bpatel@766 561 classInfoTree.addContent(div);
bpatel@766 562 }
bpatel@766 563 }
bpatel@766 564
bpatel@766 565 /**
bpatel@766 566 * Get links to the given classes.
bpatel@766 567 *
bpatel@766 568 * @param context the id of the context where the link will be printed
bpatel@766 569 * @param list the list of classes
bpatel@766 570 * @return a content tree for the class list
bpatel@766 571 */
bpatel@766 572 private Content getClassLinks(int context, List<?> list) {
duke@1 573 Object[] typeList = list.toArray();
bpatel@766 574 Content dd = new HtmlTree(HtmlTag.DD);
duke@1 575 for (int i = 0; i < list.size(); i++) {
duke@1 576 if (i > 0) {
bpatel@766 577 Content separator = new StringContent(", ");
bpatel@766 578 dd.addContent(separator);
duke@1 579 }
duke@1 580 if (typeList[i] instanceof ClassDoc) {
bpatel@766 581 Content link = new RawHtml(getLink(
jjg@1410 582 new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i]))));
bpatel@766 583 dd.addContent(link);
duke@1 584 } else {
bpatel@766 585 Content link = new RawHtml(getLink(
jjg@1410 586 new LinkInfoImpl(configuration, context, (Type)(typeList[i]))));
bpatel@766 587 dd.addContent(link);
duke@1 588 }
duke@1 589 }
bpatel@766 590 return dd;
duke@1 591 }
duke@1 592
bpatel@766 593 /**
bpatel@766 594 * {@inheritDoc}
bpatel@766 595 */
bpatel@766 596 protected Content getNavLinkTree() {
jjg@1372 597 Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
jjg@1373 598 treeLabel, "", "");
bpatel@766 599 Content li = HtmlTree.LI(treeLinkContent);
bpatel@766 600 return li;
duke@1 601 }
duke@1 602
bpatel@766 603 /**
bpatel@766 604 * Add summary details to the navigation bar.
bpatel@766 605 *
bpatel@766 606 * @param subDiv the content tree to which the summary detail links will be added
bpatel@766 607 */
bpatel@766 608 protected void addSummaryDetailLinks(Content subDiv) {
duke@1 609 try {
bpatel@766 610 Content div = HtmlTree.DIV(getNavSummaryLinks());
bpatel@766 611 div.addContent(getNavDetailLinks());
bpatel@766 612 subDiv.addContent(div);
duke@1 613 } catch (Exception e) {
duke@1 614 e.printStackTrace();
duke@1 615 throw new DocletAbortException();
duke@1 616 }
duke@1 617 }
duke@1 618
bpatel@766 619 /**
bpatel@766 620 * Get summary links for navigation bar.
bpatel@766 621 *
bpatel@766 622 * @return the content tree for the navigation summary links
bpatel@766 623 */
bpatel@766 624 protected Content getNavSummaryLinks() throws Exception {
bpatel@766 625 Content li = HtmlTree.LI(summaryLabel);
bpatel@766 626 li.addContent(getSpace());
bpatel@766 627 Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
duke@1 628 MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
bpatel@766 629 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
duke@1 630 String[] navLinkLabels = new String[] {
duke@1 631 "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
bpatel@766 632 "doclet.navMethod"
duke@1 633 };
duke@1 634 for (int i = 0; i < navLinkLabels.length; i++ ) {
bpatel@766 635 Content liNav = new HtmlTree(HtmlTag.LI);
duke@1 636 if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
duke@1 637 continue;
duke@1 638 }
duke@1 639 if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) {
duke@1 640 continue;
duke@1 641 }
duke@1 642 AbstractMemberWriter writer =
duke@1 643 ((AbstractMemberWriter) memberSummaryBuilder.
bpatel@766 644 getMemberSummaryWriter(i));
duke@1 645 if (writer == null) {
bpatel@766 646 liNav.addContent(getResource(navLinkLabels[i]));
duke@1 647 } else {
bpatel@766 648 writer.addNavSummaryLink(
bpatel@766 649 memberSummaryBuilder.members(i),
bpatel@766 650 memberSummaryBuilder.getVisibleMemberMap(i), liNav);
duke@1 651 }
duke@1 652 if (i < navLinkLabels.length-1) {
bpatel@766 653 addNavGap(liNav);
duke@1 654 }
bpatel@766 655 ulNav.addContent(liNav);
duke@1 656 }
bpatel@766 657 return ulNav;
duke@1 658 }
duke@1 659
duke@1 660 /**
bpatel@766 661 * Get detail links for the navigation bar.
duke@1 662 *
bpatel@766 663 * @return the content tree for the detail links
duke@1 664 */
bpatel@766 665 protected Content getNavDetailLinks() throws Exception {
bpatel@766 666 Content li = HtmlTree.LI(detailLabel);
bpatel@766 667 li.addContent(getSpace());
bpatel@766 668 Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
duke@1 669 MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
bpatel@766 670 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
duke@1 671 String[] navLinkLabels = new String[] {
duke@1 672 "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
bpatel@766 673 "doclet.navMethod"
duke@1 674 };
duke@1 675 for (int i = 1; i < navLinkLabels.length; i++ ) {
bpatel@766 676 Content liNav = new HtmlTree(HtmlTag.LI);
duke@1 677 AbstractMemberWriter writer =
bpatel@766 678 ((AbstractMemberWriter) memberSummaryBuilder.
duke@1 679 getMemberSummaryWriter(i));
duke@1 680 if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
duke@1 681 continue;
duke@1 682 }
duke@1 683 if (i == VisibleMemberMap.CONSTRUCTORS && classDoc.isEnum()) {
duke@1 684 continue;
duke@1 685 }
duke@1 686 if (writer == null) {
bpatel@766 687 liNav.addContent(getResource(navLinkLabels[i]));
duke@1 688 } else {
bpatel@766 689 writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav);
duke@1 690 }
duke@1 691 if (i < navLinkLabels.length - 1) {
bpatel@766 692 addNavGap(liNav);
duke@1 693 }
bpatel@766 694 ulNav.addContent(liNav);
duke@1 695 }
bpatel@766 696 return ulNav;
duke@1 697 }
duke@1 698
duke@1 699 /**
bpatel@766 700 * Add gap between navigation bar elements.
bpatel@766 701 *
bpatel@766 702 * @param liNav the content tree to which the gap will be added
duke@1 703 */
bpatel@766 704 protected void addNavGap(Content liNav) {
bpatel@766 705 liNav.addContent(getSpace());
bpatel@766 706 liNav.addContent("|");
bpatel@766 707 liNav.addContent(getSpace());
duke@1 708 }
duke@1 709
duke@1 710 /**
duke@1 711 * Return the classDoc being documented.
duke@1 712 *
duke@1 713 * @return the classDoc being documented.
duke@1 714 */
duke@1 715 public ClassDoc getClassDoc() {
duke@1 716 return classDoc;
duke@1 717 }
duke@1 718 }

mercurial