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