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