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