1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Tue Nov 30 09:38:48 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java Wed Dec 01 11:02:38 2010 -0800 1.3 @@ -32,6 +32,7 @@ 1.4 import com.sun.tools.doclets.internal.toolkit.util.*; 1.5 import com.sun.tools.doclets.internal.toolkit.builders.*; 1.6 import com.sun.tools.doclets.internal.toolkit.taglets.*; 1.7 +import com.sun.tools.doclets.formats.html.markup.*; 1.8 1.9 /** 1.10 * Generate the Class Information Page. 1.11 @@ -43,6 +44,7 @@ 1.12 * 1.13 * @author Atul M Dambalkar 1.14 * @author Robert Field 1.15 + * @author Bhavesh Patel (Modified) 1.16 */ 1.17 public class ClassWriterImpl extends SubWriterHolderWriter 1.18 implements ClassWriter { 1.19 @@ -76,124 +78,173 @@ 1.20 } 1.21 1.22 /** 1.23 - * Print this package link 1.24 + * Get this package link. 1.25 + * 1.26 + * @return a content tree for the package link 1.27 */ 1.28 - protected void navLinkPackage() { 1.29 - navCellStart(); 1.30 - printHyperLink("package-summary.html", "", 1.31 - configuration.getText("doclet.Package"), true, "NavBarFont1"); 1.32 - navCellEnd(); 1.33 + protected Content getNavLinkPackage() { 1.34 + Content linkContent = getHyperLink("package-summary.html", "", 1.35 + packageLabel); 1.36 + Content li = HtmlTree.LI(linkContent); 1.37 + return li; 1.38 } 1.39 1.40 /** 1.41 - * Print class page indicator 1.42 + * Get the class link. 1.43 + * 1.44 + * @return a content tree for the class link 1.45 */ 1.46 - protected void navLinkClass() { 1.47 - navCellRevStart(); 1.48 - fontStyle("NavBarFont1Rev"); 1.49 - strongText("doclet.Class"); 1.50 - fontEnd(); 1.51 - navCellEnd(); 1.52 + protected Content getNavLinkClass() { 1.53 + Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel); 1.54 + return li; 1.55 } 1.56 1.57 /** 1.58 - * Print class use link 1.59 + * Get the class use link. 1.60 + * 1.61 + * @return a content tree for the class use link 1.62 */ 1.63 - protected void navLinkClassUse() { 1.64 - navCellStart(); 1.65 - printHyperLink("class-use/" + filename, "", 1.66 - configuration.getText("doclet.navClassUse"), true, "NavBarFont1"); 1.67 - navCellEnd(); 1.68 + protected Content getNavLinkClassUse() { 1.69 + Content linkContent = getHyperLink("class-use/" + filename, "", useLabel); 1.70 + Content li = HtmlTree.LI(linkContent); 1.71 + return li; 1.72 } 1.73 1.74 /** 1.75 - * Print previous package link 1.76 + * Get link to previous class. 1.77 + * 1.78 + * @return a content tree for the previous class link 1.79 */ 1.80 - protected void navLinkPrevious() { 1.81 - if (prev == null) { 1.82 - printText("doclet.Prev_Class"); 1.83 - } else { 1.84 - printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, prev, "", 1.85 - configuration.getText("doclet.Prev_Class"), true)); 1.86 + public Content getNavLinkPrevious() { 1.87 + Content li; 1.88 + if (prev != null) { 1.89 + Content prevLink = new RawHtml(getLink(new LinkInfoImpl( 1.90 + LinkInfoImpl.CONTEXT_CLASS, prev, "", 1.91 + configuration.getText("doclet.Prev_Class"), true))); 1.92 + li = HtmlTree.LI(prevLink); 1.93 } 1.94 + else 1.95 + li = HtmlTree.LI(prevclassLabel); 1.96 + return li; 1.97 } 1.98 1.99 /** 1.100 - * Print next package link 1.101 + * Get link to next class. 1.102 + * 1.103 + * @return a content tree for the next class link 1.104 */ 1.105 - protected void navLinkNext() { 1.106 - if (next == null) { 1.107 - printText("doclet.Next_Class"); 1.108 - } else { 1.109 - printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, next, "", 1.110 - configuration.getText("doclet.Next_Class"), true)); 1.111 + public Content getNavLinkNext() { 1.112 + Content li; 1.113 + if (next != null) { 1.114 + Content nextLink = new RawHtml(getLink(new LinkInfoImpl( 1.115 + LinkInfoImpl.CONTEXT_CLASS, next, "", 1.116 + configuration.getText("doclet.Next_Class"), true))); 1.117 + li = HtmlTree.LI(nextLink); 1.118 } 1.119 + else 1.120 + li = HtmlTree.LI(nextclassLabel); 1.121 + return li; 1.122 } 1.123 1.124 /** 1.125 * {@inheritDoc} 1.126 */ 1.127 - public void writeHeader(String header) { 1.128 + public Content getHeader(String header) { 1.129 String pkgname = (classDoc.containingPackage() != null)? 1.130 classDoc.containingPackage().name(): ""; 1.131 String clname = classDoc.name(); 1.132 - printHtmlHeader(clname, 1.133 - configuration.metakeywords.getMetaKeywords(classDoc), true); 1.134 - printTop(); 1.135 - navLinks(true); 1.136 - hr(); 1.137 - println("<!-- ======== START OF CLASS DATA ======== -->"); 1.138 - h2(); 1.139 + Content bodyTree = getBody(true, getWindowTitle(clname)); 1.140 + addTop(bodyTree); 1.141 + addNavLinks(true, bodyTree); 1.142 + bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA); 1.143 + HtmlTree div = new HtmlTree(HtmlTag.DIV); 1.144 + div.addStyle(HtmlStyle.header); 1.145 if (pkgname.length() > 0) { 1.146 - font("-1"); print(pkgname); fontEnd(); br(); 1.147 + Content pkgNameContent = new StringContent(pkgname); 1.148 + Content pkgNamePara = HtmlTree.P(HtmlStyle.subTitle, pkgNameContent); 1.149 + div.addContent(pkgNamePara); 1.150 } 1.151 LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER, 1.152 - classDoc, false); 1.153 + classDoc, false); 1.154 //Let's not link to ourselves in the header. 1.155 linkInfo.linkToSelf = false; 1.156 - print(header + getTypeParameterLinks(linkInfo)); 1.157 - h2End(); 1.158 + Content headerContent = new StringContent(header); 1.159 + Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, 1.160 + HtmlStyle.title, headerContent); 1.161 + heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo))); 1.162 + div.addContent(heading); 1.163 + bodyTree.addContent(div); 1.164 + return bodyTree; 1.165 } 1.166 1.167 /** 1.168 * {@inheritDoc} 1.169 */ 1.170 - public void writeFooter() { 1.171 - println("<!-- ========= END OF CLASS DATA ========= -->"); 1.172 - hr(); 1.173 - navLinks(false); 1.174 - printBottom(); 1.175 - printBodyHtmlEnd(); 1.176 + public Content getClassContentHeader() { 1.177 + return getContentHeader(); 1.178 } 1.179 1.180 /** 1.181 * {@inheritDoc} 1.182 */ 1.183 - public void writeClassSignature(String modifiers) { 1.184 + public void addFooter(Content contentTree) { 1.185 + contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA); 1.186 + addNavLinks(false, contentTree); 1.187 + addBottom(contentTree); 1.188 + } 1.189 + 1.190 + /** 1.191 + * {@inheritDoc} 1.192 + */ 1.193 + public void printDocument(Content contentTree) { 1.194 + printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc), 1.195 + true, contentTree); 1.196 + } 1.197 + 1.198 + /** 1.199 + * {@inheritDoc} 1.200 + */ 1.201 + public Content getClassInfoTreeHeader() { 1.202 + return getMemberTreeHeader(); 1.203 + } 1.204 + 1.205 + /** 1.206 + * {@inheritDoc} 1.207 + */ 1.208 + public Content getClassInfo(Content classInfoTree) { 1.209 + return getMemberTree(HtmlStyle.description, classInfoTree); 1.210 + } 1.211 + 1.212 + /** 1.213 + * {@inheritDoc} 1.214 + */ 1.215 + public void addClassSignature(String modifiers, Content classInfoTree) { 1.216 boolean isInterface = classDoc.isInterface(); 1.217 - preNoNewLine(); 1.218 - writeAnnotationInfo(classDoc); 1.219 - print(modifiers); 1.220 + classInfoTree.addContent(new HtmlTree(HtmlTag.BR)); 1.221 + Content pre = new HtmlTree(HtmlTag.PRE); 1.222 + addAnnotationInfo(classDoc, pre); 1.223 + pre.addContent(modifiers); 1.224 LinkInfoImpl linkInfo = new LinkInfoImpl( 1.225 - LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false); 1.226 + LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false); 1.227 //Let's not link to ourselves in the signature. 1.228 linkInfo.linkToSelf = false; 1.229 - String name = classDoc.name() + 1.230 - getTypeParameterLinks(linkInfo); 1.231 + Content name = new RawHtml (classDoc.name() + 1.232 + getTypeParameterLinks(linkInfo)); 1.233 if (configuration().linksource) { 1.234 - printSrcLink(classDoc, name); 1.235 + addSrcLink(classDoc, name, pre); 1.236 } else { 1.237 - strong(name); 1.238 + pre.addContent(HtmlTree.STRONG(name)); 1.239 } 1.240 if (!isInterface) { 1.241 Type superclass = Util.getFirstVisibleSuperClass(classDoc, 1.242 - configuration()); 1.243 + configuration()); 1.244 if (superclass != null) { 1.245 - println(); 1.246 - print("extends "); 1.247 - printLink(new LinkInfoImpl( 1.248 - LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, 1.249 - superclass)); 1.250 + pre.addContent("\n"); 1.251 + pre.addContent("extends "); 1.252 + Content link = new RawHtml(getLink(new LinkInfoImpl( 1.253 + LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, 1.254 + superclass))); 1.255 + pre.addContent(link); 1.256 } 1.257 } 1.258 Type[] implIntfacs = classDoc.interfaceTypes(); 1.259 @@ -202,34 +253,33 @@ 1.260 for (int i = 0; i < implIntfacs.length; i++) { 1.261 ClassDoc classDoc = implIntfacs[i].asClassDoc(); 1.262 if (! (classDoc.isPublic() || 1.263 - Util.isLinkable(classDoc, configuration()))) { 1.264 + Util.isLinkable(classDoc, configuration()))) { 1.265 continue; 1.266 } 1.267 if (counter == 0) { 1.268 - println(); 1.269 - print(isInterface? "extends " : "implements "); 1.270 + pre.addContent("\n"); 1.271 + pre.addContent(isInterface? "extends " : "implements "); 1.272 } else { 1.273 - print(", "); 1.274 + pre.addContent(", "); 1.275 } 1.276 - printLink(new LinkInfoImpl( 1.277 - LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, 1.278 - implIntfacs[i])); 1.279 + Content link = new RawHtml(getLink(new LinkInfoImpl( 1.280 + LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME, 1.281 + implIntfacs[i]))); 1.282 + pre.addContent(link); 1.283 counter++; 1.284 } 1.285 } 1.286 - preEnd(); 1.287 - p(); 1.288 + classInfoTree.addContent(pre); 1.289 } 1.290 1.291 /** 1.292 * {@inheritDoc} 1.293 */ 1.294 - public void writeClassDescription() { 1.295 + public void addClassDescription(Content classInfoTree) { 1.296 if(!configuration.nocomment) { 1.297 // generate documentation for the class. 1.298 if (classDoc.inlineTags().length > 0) { 1.299 - printInlineComment(classDoc); 1.300 - p(); 1.301 + addInlineComment(classDoc, classInfoTree); 1.302 } 1.303 } 1.304 } 1.305 @@ -237,131 +287,118 @@ 1.306 /** 1.307 * {@inheritDoc} 1.308 */ 1.309 - public void writeClassTagInfo() { 1.310 + public void addClassTagInfo(Content classInfoTree) { 1.311 if(!configuration.nocomment) { 1.312 // Print Information about all the tags here 1.313 - printTags(classDoc); 1.314 - hr(); 1.315 - p(); 1.316 + addTagsInfo(classDoc, classInfoTree); 1.317 + } 1.318 + } 1.319 + 1.320 + /** 1.321 + * Get the class hierarchy tree for the given class. 1.322 + * 1.323 + * @param type the class to print the hierarchy for 1.324 + * @return a content tree for class inheritence 1.325 + */ 1.326 + private Content getClassInheritenceTree(Type type) { 1.327 + Type sup; 1.328 + HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL); 1.329 + classTreeUl.addStyle(HtmlStyle.inheritance); 1.330 + Content liTree = null; 1.331 + do { 1.332 + sup = Util.getFirstVisibleSuperClass( 1.333 + type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(), 1.334 + configuration()); 1.335 + if (sup != null) { 1.336 + HtmlTree ul = new HtmlTree(HtmlTag.UL); 1.337 + ul.addStyle(HtmlStyle.inheritance); 1.338 + ul.addContent(getTreeForClassHelper(type)); 1.339 + if (liTree != null) 1.340 + ul.addContent(liTree); 1.341 + Content li = HtmlTree.LI(ul); 1.342 + liTree = li; 1.343 + type = sup; 1.344 + } 1.345 + else 1.346 + classTreeUl.addContent(getTreeForClassHelper(type)); 1.347 + } 1.348 + while (sup != null); 1.349 + if (liTree != null) 1.350 + classTreeUl.addContent(liTree); 1.351 + return classTreeUl; 1.352 + } 1.353 + 1.354 + /** 1.355 + * Get the class helper tree for the given class. 1.356 + * 1.357 + * @param type the class to print the helper for 1.358 + * @return a content tree for class helper 1.359 + */ 1.360 + private Content getTreeForClassHelper(Type type) { 1.361 + Content li = new HtmlTree(HtmlTag.LI); 1.362 + if (type.equals(classDoc)) { 1.363 + String typeParameters = getTypeParameterLinks( 1.364 + new LinkInfoImpl(LinkInfoImpl.CONTEXT_TREE, 1.365 + classDoc, false)); 1.366 + if (configuration.shouldExcludeQualifier( 1.367 + classDoc.containingPackage().name())) { 1.368 + li.addContent(type.asClassDoc().name()); 1.369 + li.addContent(new RawHtml(typeParameters)); 1.370 + } else { 1.371 + li.addContent(type.asClassDoc().qualifiedName()); 1.372 + li.addContent(new RawHtml(typeParameters)); 1.373 + } 1.374 } else { 1.375 - hr(); 1.376 + Content link = new RawHtml(getLink(new LinkInfoImpl( 1.377 + LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT, 1.378 + type instanceof ClassDoc ? (ClassDoc) type : type, 1.379 + configuration.getClassName(type.asClassDoc()), false))); 1.380 + li.addContent(link); 1.381 + } 1.382 + return li; 1.383 + } 1.384 + 1.385 + /** 1.386 + * {@inheritDoc} 1.387 + */ 1.388 + public void addClassTree(Content classContentTree) { 1.389 + if (!classDoc.isClass()) { 1.390 + return; 1.391 + } 1.392 + classContentTree.addContent(getClassInheritenceTree(classDoc)); 1.393 + } 1.394 + 1.395 + /** 1.396 + * {@inheritDoc} 1.397 + */ 1.398 + public void addTypeParamInfo(Content classInfoTree) { 1.399 + if (classDoc.typeParamTags().length > 0) { 1.400 + TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc, 1.401 + getTagletWriterInstance(false)); 1.402 + Content typeParam = new RawHtml(output.toString()); 1.403 + Content dl = HtmlTree.DL(typeParam); 1.404 + classInfoTree.addContent(dl); 1.405 } 1.406 } 1.407 1.408 /** 1.409 * {@inheritDoc} 1.410 */ 1.411 - public void writeClassDeprecationInfo() { 1.412 - hr(); 1.413 - Tag[] deprs = classDoc.tags("deprecated"); 1.414 - if (Util.isDeprecated(classDoc)) { 1.415 - strongText("doclet.Deprecated"); 1.416 - if (deprs.length > 0) { 1.417 - Tag[] commentTags = deprs[0].inlineTags(); 1.418 - if (commentTags.length > 0) { 1.419 - space(); 1.420 - printInlineDeprecatedComment(classDoc, deprs[0]); 1.421 - } 1.422 - } 1.423 - p(); 1.424 - } 1.425 - } 1.426 - 1.427 - /** 1.428 - * Generate the indent and get the line image for the class tree. 1.429 - * For user accessibility, the image includes the alt attribute 1.430 - * "extended by". (This method is not intended for a class 1.431 - * implementing an interface, where "implemented by" would be required.) 1.432 - * 1.433 - * indent integer indicating the number of spaces to indent 1.434 - */ 1.435 - private void writeStep(int indent) { 1.436 - print(spaces(4 * indent - 2)); 1.437 - print("<IMG SRC=\"" + relativepathNoSlash + "/resources/inherit.gif\" " + 1.438 - "ALT=\"" + configuration.getText("doclet.extended_by") + " \">"); 1.439 - } 1.440 - 1.441 - /** 1.442 - * Print the class hierarchy tree for the given class. 1.443 - * @param type the class to print the hierarchy for. 1.444 - * @return return the amount that should be indented in 1.445 - * the next level of the tree. 1.446 - */ 1.447 - private int writeTreeForClassHelper(Type type) { 1.448 - Type sup = Util.getFirstVisibleSuperClass( 1.449 - type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(), 1.450 - configuration()); 1.451 - int indent = 0; 1.452 - if (sup != null) { 1.453 - indent = writeTreeForClassHelper(sup); 1.454 - writeStep(indent); 1.455 - } 1.456 - 1.457 - if (type.equals(classDoc)) { 1.458 - String typeParameters = getTypeParameterLinks( 1.459 - new LinkInfoImpl( 1.460 - LinkInfoImpl.CONTEXT_TREE, 1.461 - classDoc, false)); 1.462 - if (configuration.shouldExcludeQualifier( 1.463 - classDoc.containingPackage().name())) { 1.464 - strong(type.asClassDoc().name() + typeParameters); 1.465 - } else { 1.466 - strong(type.asClassDoc().qualifiedName() + typeParameters); 1.467 - } 1.468 - } else { 1.469 - print(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT, 1.470 - type instanceof ClassDoc ? (ClassDoc) type : type, 1.471 - configuration.getClassName(type.asClassDoc()), false))); 1.472 - } 1.473 - println(); 1.474 - return indent + 1; 1.475 - } 1.476 - 1.477 - /** 1.478 - * Print the class hierarchy tree for this class only. 1.479 - */ 1.480 - public void writeClassTree() { 1.481 - if (! classDoc.isClass()) { 1.482 - return; 1.483 - } 1.484 - pre(); 1.485 - writeTreeForClassHelper(classDoc); 1.486 - preEnd(); 1.487 - } 1.488 - 1.489 - /** 1.490 - * Write the type parameter information. 1.491 - */ 1.492 - public void writeTypeParamInfo() { 1.493 - if (classDoc.typeParamTags().length > 0) { 1.494 - dl(); 1.495 - dt(); 1.496 - TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc, 1.497 - getTagletWriterInstance(false)); 1.498 - print(output.toString()); 1.499 - dtEnd(); 1.500 - dlEnd(); 1.501 - } 1.502 - } 1.503 - 1.504 - /** 1.505 - * {@inheritDoc} 1.506 - */ 1.507 - public void writeSubClassInfo() { 1.508 + public void addSubClassInfo(Content classInfoTree) { 1.509 if (classDoc.isClass()) { 1.510 if (classDoc.qualifiedName().equals("java.lang.Object") || 1.511 - classDoc.qualifiedName().equals("org.omg.CORBA.Object")) { 1.512 + classDoc.qualifiedName().equals("org.omg.CORBA.Object")) { 1.513 return; // Don't generate the list, too huge 1.514 } 1.515 List<ClassDoc> subclasses = classtree.subs(classDoc, false); 1.516 if (subclasses.size() > 0) { 1.517 - dl(); 1.518 - dt(); 1.519 - strongText("doclet.Subclasses"); 1.520 - dtEnd(); 1.521 - writeClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES, 1.522 - subclasses); 1.523 - dlEnd(); 1.524 + Content label = getResource( 1.525 + "doclet.Subclasses"); 1.526 + Content dt = HtmlTree.DT(label); 1.527 + Content dl = HtmlTree.DL(dt); 1.528 + dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES, 1.529 + subclasses)); 1.530 + classInfoTree.addContent(dl); 1.531 } 1.532 } 1.533 } 1.534 @@ -369,140 +406,196 @@ 1.535 /** 1.536 * {@inheritDoc} 1.537 */ 1.538 - public void writeSubInterfacesInfo() { 1.539 + public void addSubInterfacesInfo(Content classInfoTree) { 1.540 if (classDoc.isInterface()) { 1.541 List<ClassDoc> subInterfaces = classtree.allSubs(classDoc, false); 1.542 if (subInterfaces.size() > 0) { 1.543 - dl(); 1.544 - dt(); 1.545 - strongText("doclet.Subinterfaces"); 1.546 - dtEnd(); 1.547 - writeClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES, 1.548 - subInterfaces); 1.549 - dlEnd(); 1.550 + Content label = getResource( 1.551 + "doclet.Subinterfaces"); 1.552 + Content dt = HtmlTree.DT(label); 1.553 + Content dl = HtmlTree.DL(dt); 1.554 + dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES, 1.555 + subInterfaces)); 1.556 + classInfoTree.addContent(dl); 1.557 } 1.558 } 1.559 } 1.560 1.561 /** 1.562 - * If this is the interface which are the classes, that implement this? 1.563 - */ 1.564 - public void writeInterfaceUsageInfo () { 1.565 - if (! classDoc.isInterface()) { 1.566 - return; 1.567 - } 1.568 - if (classDoc.qualifiedName().equals("java.lang.Cloneable") || 1.569 - classDoc.qualifiedName().equals("java.io.Serializable")) { 1.570 - return; // Don't generate the list, too big 1.571 - } 1.572 - List<ClassDoc> implcl = classtree.implementingclasses(classDoc); 1.573 - if (implcl.size() > 0) { 1.574 - dl(); 1.575 - dt(); 1.576 - strongText("doclet.Implementing_Classes"); 1.577 - dtEnd(); 1.578 - writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES, 1.579 - implcl); 1.580 - dlEnd(); 1.581 - } 1.582 - } 1.583 - 1.584 - /** 1.585 * {@inheritDoc} 1.586 */ 1.587 - public void writeImplementedInterfacesInfo() { 1.588 - //NOTE: we really should be using ClassDoc.interfaceTypes() here, but 1.589 - // it doesn't walk up the tree like we want it to. 1.590 - List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration); 1.591 - if (classDoc.isClass() && interfaceArray.size() > 0) { 1.592 - dl(); 1.593 - dt(); 1.594 - strongText("doclet.All_Implemented_Interfaces"); 1.595 - dtEnd(); 1.596 - writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES, 1.597 - interfaceArray); 1.598 - dlEnd(); 1.599 + public void addInterfaceUsageInfo (Content classInfoTree) { 1.600 + if (! classDoc.isInterface()) { 1.601 + return; 1.602 + } 1.603 + if (classDoc.qualifiedName().equals("java.lang.Cloneable") || 1.604 + classDoc.qualifiedName().equals("java.io.Serializable")) { 1.605 + return; // Don't generate the list, too big 1.606 + } 1.607 + List<ClassDoc> implcl = classtree.implementingclasses(classDoc); 1.608 + if (implcl.size() > 0) { 1.609 + Content label = getResource( 1.610 + "doclet.Implementing_Classes"); 1.611 + Content dt = HtmlTree.DT(label); 1.612 + Content dl = HtmlTree.DL(dt); 1.613 + dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES, 1.614 + implcl)); 1.615 + classInfoTree.addContent(dl); 1.616 } 1.617 } 1.618 1.619 /** 1.620 * {@inheritDoc} 1.621 */ 1.622 - public void writeSuperInterfacesInfo() { 1.623 + public void addImplementedInterfacesInfo(Content classInfoTree) { 1.624 + //NOTE: we really should be using ClassDoc.interfaceTypes() here, but 1.625 + // it doesn't walk up the tree like we want it to. 1.626 + List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration); 1.627 + if (classDoc.isClass() && interfaceArray.size() > 0) { 1.628 + Content label = getResource( 1.629 + "doclet.All_Implemented_Interfaces"); 1.630 + Content dt = HtmlTree.DT(label); 1.631 + Content dl = HtmlTree.DL(dt); 1.632 + dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES, 1.633 + interfaceArray)); 1.634 + classInfoTree.addContent(dl); 1.635 + } 1.636 + } 1.637 + 1.638 + /** 1.639 + * {@inheritDoc} 1.640 + */ 1.641 + public void addSuperInterfacesInfo(Content classInfoTree) { 1.642 //NOTE: we really should be using ClassDoc.interfaceTypes() here, but 1.643 // it doesn't walk up the tree like we want it to. 1.644 List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration); 1.645 if (classDoc.isInterface() && interfaceArray.size() > 0) { 1.646 - dl(); 1.647 - dt(); 1.648 - strongText("doclet.All_Superinterfaces"); 1.649 - dtEnd(); 1.650 - writeClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES, 1.651 - interfaceArray); 1.652 - dlEnd(); 1.653 + Content label = getResource( 1.654 + "doclet.All_Superinterfaces"); 1.655 + Content dt = HtmlTree.DT(label); 1.656 + Content dl = HtmlTree.DL(dt); 1.657 + dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES, 1.658 + interfaceArray)); 1.659 + classInfoTree.addContent(dl); 1.660 } 1.661 } 1.662 1.663 /** 1.664 - * Generate links to the given classes. 1.665 + * {@inheritDoc} 1.666 */ 1.667 - private void writeClassLinks(int context, List<?> list) { 1.668 + public void addNestedClassInfo(Content classInfoTree) { 1.669 + ClassDoc outerClass = classDoc.containingClass(); 1.670 + if (outerClass != null) { 1.671 + Content label; 1.672 + if (outerClass.isInterface()) { 1.673 + label = getResource( 1.674 + "doclet.Enclosing_Interface"); 1.675 + } else { 1.676 + label = getResource( 1.677 + "doclet.Enclosing_Class"); 1.678 + } 1.679 + Content dt = HtmlTree.DT(label); 1.680 + Content dl = HtmlTree.DL(dt); 1.681 + Content dd = new HtmlTree(HtmlTag.DD); 1.682 + dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass, 1.683 + false)))); 1.684 + dl.addContent(dd); 1.685 + classInfoTree.addContent(dl); 1.686 + } 1.687 + } 1.688 + 1.689 + /** 1.690 + * {@inheritDoc} 1.691 + */ 1.692 + public void addClassDeprecationInfo(Content classInfoTree) { 1.693 + Content hr = new HtmlTree(HtmlTag.HR); 1.694 + classInfoTree.addContent(hr); 1.695 + Tag[] deprs = classDoc.tags("deprecated"); 1.696 + if (Util.isDeprecated(classDoc)) { 1.697 + Content strong = HtmlTree.STRONG(deprecatedPhrase); 1.698 + Content div = HtmlTree.DIV(HtmlStyle.block, strong); 1.699 + if (deprs.length > 0) { 1.700 + Tag[] commentTags = deprs[0].inlineTags(); 1.701 + if (commentTags.length > 0) { 1.702 + div.addContent(getSpace()); 1.703 + addInlineDeprecatedComment(classDoc, deprs[0], div); 1.704 + } 1.705 + } 1.706 + classInfoTree.addContent(div); 1.707 + } 1.708 + } 1.709 + 1.710 + /** 1.711 + * Get links to the given classes. 1.712 + * 1.713 + * @param context the id of the context where the link will be printed 1.714 + * @param list the list of classes 1.715 + * @return a content tree for the class list 1.716 + */ 1.717 + private Content getClassLinks(int context, List<?> list) { 1.718 Object[] typeList = list.toArray(); 1.719 - //Sort the list to be printed. 1.720 - print(' '); 1.721 - dd(); 1.722 + Content dd = new HtmlTree(HtmlTag.DD); 1.723 for (int i = 0; i < list.size(); i++) { 1.724 if (i > 0) { 1.725 - print(", "); 1.726 + Content separator = new StringContent(", "); 1.727 + dd.addContent(separator); 1.728 } 1.729 if (typeList[i] instanceof ClassDoc) { 1.730 - printLink(new LinkInfoImpl(context, (ClassDoc)(typeList[i]))); 1.731 - 1.732 + Content link = new RawHtml(getLink( 1.733 + new LinkInfoImpl(context, (ClassDoc)(typeList[i])))); 1.734 + dd.addContent(link); 1.735 } else { 1.736 - printLink(new LinkInfoImpl(context, (Type)(typeList[i]))); 1.737 + Content link = new RawHtml(getLink( 1.738 + new LinkInfoImpl(context, (Type)(typeList[i])))); 1.739 + dd.addContent(link); 1.740 } 1.741 } 1.742 - ddEnd(); 1.743 + return dd; 1.744 } 1.745 1.746 - protected void navLinkTree() { 1.747 - navCellStart(); 1.748 - printHyperLink("package-tree.html", "", 1.749 - configuration.getText("doclet.Tree"), true, "NavBarFont1"); 1.750 - navCellEnd(); 1.751 + /** 1.752 + * {@inheritDoc} 1.753 + */ 1.754 + protected Content getNavLinkTree() { 1.755 + Content treeLinkContent = getHyperLink("package-tree.html", 1.756 + "", treeLabel, "", ""); 1.757 + Content li = HtmlTree.LI(treeLinkContent); 1.758 + return li; 1.759 } 1.760 1.761 - protected void printSummaryDetailLinks() { 1.762 + /** 1.763 + * Add summary details to the navigation bar. 1.764 + * 1.765 + * @param subDiv the content tree to which the summary detail links will be added 1.766 + */ 1.767 + protected void addSummaryDetailLinks(Content subDiv) { 1.768 try { 1.769 - tr(); 1.770 - tdVAlignClass("top", "NavBarCell3"); 1.771 - font("-2"); 1.772 - print(" "); 1.773 - navSummaryLinks(); 1.774 - fontEnd(); 1.775 - tdEnd(); 1.776 - tdVAlignClass("top", "NavBarCell3"); 1.777 - font("-2"); 1.778 - navDetailLinks(); 1.779 - fontEnd(); 1.780 - tdEnd(); 1.781 - trEnd(); 1.782 + Content div = HtmlTree.DIV(getNavSummaryLinks()); 1.783 + div.addContent(getNavDetailLinks()); 1.784 + subDiv.addContent(div); 1.785 } catch (Exception e) { 1.786 e.printStackTrace(); 1.787 throw new DocletAbortException(); 1.788 } 1.789 } 1.790 1.791 - protected void navSummaryLinks() throws Exception { 1.792 - printText("doclet.Summary"); 1.793 - space(); 1.794 + /** 1.795 + * Get summary links for navigation bar. 1.796 + * 1.797 + * @return the content tree for the navigation summary links 1.798 + */ 1.799 + protected Content getNavSummaryLinks() throws Exception { 1.800 + Content li = HtmlTree.LI(summaryLabel); 1.801 + li.addContent(getSpace()); 1.802 + Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); 1.803 MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) 1.804 - configuration.getBuilderFactory().getMemberSummaryBuilder(this); 1.805 + configuration.getBuilderFactory().getMemberSummaryBuilder(this); 1.806 String[] navLinkLabels = new String[] { 1.807 "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor", 1.808 - "doclet.navMethod" 1.809 + "doclet.navMethod" 1.810 }; 1.811 for (int i = 0; i < navLinkLabels.length; i++ ) { 1.812 + Content liNav = new HtmlTree(HtmlTag.LI); 1.813 if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) { 1.814 continue; 1.815 } 1.816 @@ -511,38 +604,41 @@ 1.817 } 1.818 AbstractMemberWriter writer = 1.819 ((AbstractMemberWriter) memberSummaryBuilder. 1.820 - getMemberSummaryWriter(i)); 1.821 + getMemberSummaryWriter(i)); 1.822 if (writer == null) { 1.823 - printText(navLinkLabels[i]); 1.824 + liNav.addContent(getResource(navLinkLabels[i])); 1.825 } else { 1.826 - writer.navSummaryLink( 1.827 - memberSummaryBuilder.members(i), 1.828 - memberSummaryBuilder.getVisibleMemberMap(i)); 1.829 + writer.addNavSummaryLink( 1.830 + memberSummaryBuilder.members(i), 1.831 + memberSummaryBuilder.getVisibleMemberMap(i), liNav); 1.832 } 1.833 if (i < navLinkLabels.length-1) { 1.834 - navGap(); 1.835 + addNavGap(liNav); 1.836 } 1.837 + ulNav.addContent(liNav); 1.838 } 1.839 + return ulNav; 1.840 } 1.841 1.842 /** 1.843 - * Method navDetailLinks 1.844 + * Get detail links for the navigation bar. 1.845 * 1.846 - * @throws Exception 1.847 - * 1.848 + * @return the content tree for the detail links 1.849 */ 1.850 - protected void navDetailLinks() throws Exception { 1.851 - printText("doclet.Detail"); 1.852 - space(); 1.853 + protected Content getNavDetailLinks() throws Exception { 1.854 + Content li = HtmlTree.LI(detailLabel); 1.855 + li.addContent(getSpace()); 1.856 + Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); 1.857 MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder) 1.858 - configuration.getBuilderFactory().getMemberSummaryBuilder(this); 1.859 + configuration.getBuilderFactory().getMemberSummaryBuilder(this); 1.860 String[] navLinkLabels = new String[] { 1.861 "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor", 1.862 - "doclet.navMethod" 1.863 + "doclet.navMethod" 1.864 }; 1.865 for (int i = 1; i < navLinkLabels.length; i++ ) { 1.866 + Content liNav = new HtmlTree(HtmlTag.LI); 1.867 AbstractMemberWriter writer = 1.868 - ((AbstractMemberWriter) memberSummaryBuilder. 1.869 + ((AbstractMemberWriter) memberSummaryBuilder. 1.870 getMemberSummaryWriter(i)); 1.871 if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) { 1.872 continue; 1.873 @@ -551,43 +647,27 @@ 1.874 continue; 1.875 } 1.876 if (writer == null) { 1.877 - printText(navLinkLabels[i]); 1.878 + liNav.addContent(getResource(navLinkLabels[i])); 1.879 } else { 1.880 - writer.navDetailLink(memberSummaryBuilder.members(i)); 1.881 + writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav); 1.882 } 1.883 if (i < navLinkLabels.length - 1) { 1.884 - navGap(); 1.885 + addNavGap(liNav); 1.886 } 1.887 + ulNav.addContent(liNav); 1.888 } 1.889 - } 1.890 - 1.891 - protected void navGap() { 1.892 - space(); 1.893 - print('|'); 1.894 - space(); 1.895 + return ulNav; 1.896 } 1.897 1.898 /** 1.899 - * If this is an inner class or interface, write the enclosing class or 1.900 - * interface. 1.901 + * Add gap between navigation bar elements. 1.902 + * 1.903 + * @param liNav the content tree to which the gap will be added 1.904 */ 1.905 - public void writeNestedClassInfo() { 1.906 - ClassDoc outerClass = classDoc.containingClass(); 1.907 - if (outerClass != null) { 1.908 - dl(); 1.909 - dt(); 1.910 - if (outerClass.isInterface()) { 1.911 - strongText("doclet.Enclosing_Interface"); 1.912 - } else { 1.913 - strongText("doclet.Enclosing_Class"); 1.914 - } 1.915 - dtEnd(); 1.916 - dd(); 1.917 - printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass, 1.918 - false)); 1.919 - ddEnd(); 1.920 - dlEnd(); 1.921 - } 1.922 + protected void addNavGap(Content liNav) { 1.923 + liNav.addContent(getSpace()); 1.924 + liNav.addContent("|"); 1.925 + liNav.addContent(getSpace()); 1.926 } 1.927 1.928 /** 1.929 @@ -598,11 +678,4 @@ 1.930 public ClassDoc getClassDoc() { 1.931 return classDoc; 1.932 } 1.933 - 1.934 - /** 1.935 - * {@inheritDoc} 1.936 - */ 1.937 - public void completeMemberSummaryBuild() { 1.938 - p(); 1.939 - } 1.940 }