src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.doclets.formats.html;
  27 
  28 import java.io.IOException;

  29 
  30 import com.sun.javadoc.*;
  31 import com.sun.tools.doclets.formats.html.markup.*;
  32 import com.sun.tools.doclets.internal.toolkit.*;
  33 import com.sun.tools.doclets.internal.toolkit.builders.*;
  34 import com.sun.tools.doclets.internal.toolkit.util.*;
  35 















  36 /**
  37  * Generate the Class Information Page.
  38  *
  39  *  <p><b>This is NOT part of any supported API.
  40  *  If you write code that depends on this, you do so at your own risk.
  41  *  This code and its internal interfaces are subject to change or
  42  *  deletion without notice.</b>
  43  *
  44  * @see com.sun.javadoc.ClassDoc
  45  * @see java.util.Collections
  46  * @see java.util.List
  47  * @see java.util.ArrayList
  48  * @see java.util.HashMap
  49  *
  50  * @author Atul M Dambalkar
  51  * @author Robert Field
  52  * @author Bhavesh Patel (Modified)
  53  */
  54 public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
  55         implements AnnotationTypeWriter {
  56 
  57     protected AnnotationTypeDoc annotationType;
  58 
  59     protected Type prev;
  60 
  61     protected Type next;
  62 
  63     /**

  64      * @param annotationType the annotation type being documented.
  65      * @param prevType the previous class that was documented.
  66      * @param nextType the next class being documented.

  67      */
  68     public AnnotationTypeWriterImpl(ConfigurationImpl configuration,
  69             AnnotationTypeDoc annotationType, Type prevType, Type nextType)
  70             throws Exception {
  71         super(configuration, DocPath.forClass(annotationType));
  72         this.annotationType = annotationType;
  73         configuration.currentcd = annotationType.asClassDoc();
  74         this.prev = prevType;
  75         this.next = nextType;
  76     }
  77 
  78     /**
  79      * Get this package link.
  80      *
  81      * @return a content tree for the package link
  82      */

  83     protected Content getNavLinkPackage() {
  84         Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
  85                 packageLabel);
  86         Content li = HtmlTree.LI(linkContent);
  87         return li;
  88     }
  89 
  90     /**
  91      * Get the class link.
  92      *
  93      * @return a content tree for the class link
  94      */

  95     protected Content getNavLinkClass() {
  96         Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
  97         return li;
  98     }
  99 
 100     /**
 101      * Get the class use link.
 102      *
 103      * @return a content tree for the class use link
 104      */

 105     protected Content getNavLinkClassUse() {
 106         Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
 107         Content li = HtmlTree.LI(linkContent);
 108         return li;
 109     }
 110 
 111     /**
 112      * Get link to previous class.
 113      *
 114      * @return a content tree for the previous class link
 115      */

 116     public Content getNavLinkPrevious() {
 117         Content li;
 118         if (prev != null) {
 119             Content prevLink = getLink(new LinkInfoImpl(configuration,
 120                     LinkInfoImpl.Kind.CLASS, prev.asClassDoc())
 121                     .label(prevclassLabel).strong(true));
 122             li = HtmlTree.LI(prevLink);
 123         }
 124         else
 125             li = HtmlTree.LI(prevclassLabel);
 126         return li;
 127     }
 128 
 129     /**
 130      * Get link to next class.
 131      *
 132      * @return a content tree for the next class link
 133      */

 134     public Content getNavLinkNext() {
 135         Content li;
 136         if (next != null) {
 137             Content nextLink = getLink(new LinkInfoImpl(configuration,
 138                     LinkInfoImpl.Kind.CLASS, next.asClassDoc())
 139                     .label(nextclassLabel).strong(true));
 140             li = HtmlTree.LI(nextLink);
 141         }
 142         else
 143             li = HtmlTree.LI(nextclassLabel);
 144         return li;
 145     }
 146 
 147     /**
 148      * {@inheritDoc}
 149      */

 150     public Content getHeader(String header) {
 151         String pkgname = (annotationType.containingPackage() != null)?
 152             annotationType.containingPackage().name(): "";
 153         String clname = annotationType.name();
 154         HtmlTree bodyTree = getBody(true, getWindowTitle(clname));
 155         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
 156                 ? HtmlTree.HEADER()
 157                 : bodyTree;
 158         addTop(htmlTree);
 159         addNavLinks(true, htmlTree);
 160         if (configuration.allowTag(HtmlTag.HEADER)) {
 161             bodyTree.addContent(htmlTree);
 162         }
 163         bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
 164         HtmlTree div = new HtmlTree(HtmlTag.DIV);
 165         div.addStyle(HtmlStyle.header);
 166         if (pkgname.length() > 0) {
 167             Content pkgNameContent = new StringContent(pkgname);

 168             Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
 169             div.addContent(pkgNameDiv);
 170         }
 171         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
 172                 LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
 173         Content headerContent = new StringContent(header);
 174         Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
 175                 HtmlStyle.title, headerContent);
 176         heading.addContent(getTypeParameterLinks(linkInfo));
 177         div.addContent(heading);
 178         if (configuration.allowTag(HtmlTag.MAIN)) {
 179             mainTree.addContent(div);
 180         } else {
 181             bodyTree.addContent(div);
 182         }
 183         return bodyTree;
 184     }
 185 
 186     /**
 187      * {@inheritDoc}
 188      */

 189     public Content getAnnotationContentHeader() {
 190         return getContentHeader();
 191     }
 192 
 193     /**
 194      * {@inheritDoc}
 195      */

 196     public void addFooter(Content contentTree) {
 197         contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
 198         Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
 199                 ? HtmlTree.FOOTER()
 200                 : contentTree;
 201         addNavLinks(false, htmlTree);
 202         addBottom(htmlTree);
 203         if (configuration.allowTag(HtmlTag.FOOTER)) {
 204             contentTree.addContent(htmlTree);
 205         }
 206     }
 207 
 208     /**
 209      * {@inheritDoc}
 210      */

 211     public void printDocument(Content contentTree) throws IOException {
 212         printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
 213                 true, contentTree);
 214     }
 215 
 216     /**
 217      * {@inheritDoc}
 218      */

 219     public Content getAnnotationInfoTreeHeader() {
 220         return getMemberTreeHeader();
 221     }
 222 
 223     /**
 224      * {@inheritDoc}
 225      */

 226     public Content getAnnotationInfo(Content annotationInfoTree) {
 227         return getMemberTree(HtmlStyle.description, annotationInfoTree);
 228     }
 229 
 230     /**
 231      * {@inheritDoc}
 232      */

 233     public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) {
 234         annotationInfoTree.addContent(new HtmlTree(HtmlTag.BR));
 235         Content pre = new HtmlTree(HtmlTag.PRE);
 236         addAnnotationInfo(annotationType, pre);
 237         pre.addContent(modifiers);
 238         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
 239                 LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
 240         Content annotationName = new StringContent(annotationType.name());
 241         Content parameterLinks = getTypeParameterLinks(linkInfo);
 242         if (configuration.linksource) {
 243             addSrcLink(annotationType, annotationName, pre);
 244             pre.addContent(parameterLinks);
 245         } else {
 246             Content span = HtmlTree.SPAN(HtmlStyle.memberNameLabel, annotationName);
 247             span.addContent(parameterLinks);
 248             pre.addContent(span);
 249         }
 250         annotationInfoTree.addContent(pre);
 251     }
 252 
 253     /**
 254      * {@inheritDoc}
 255      */

 256     public void addAnnotationTypeDescription(Content annotationInfoTree) {
 257         if(!configuration.nocomment) {
 258             if (annotationType.inlineTags().length > 0) {
 259                 addInlineComment(annotationType, annotationInfoTree);
 260             }
 261         }
 262     }
 263 
 264     /**
 265      * {@inheritDoc}
 266      */

 267     public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
 268         if(!configuration.nocomment) {
 269             addTagsInfo(annotationType, annotationInfoTree);
 270         }
 271     }
 272 
 273     /**
 274      * {@inheritDoc}
 275      */

 276     public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) {
 277         Content hr = new HtmlTree(HtmlTag.HR);
 278         annotationInfoTree.addContent(hr);
 279         Tag[] deprs = annotationType.tags("deprecated");
 280         if (utils.isDeprecated(annotationType)) {

 281             Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
 282             Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
 283             if (deprs.length > 0) {
 284                 Tag[] commentTags = deprs[0].inlineTags();
 285                 if (commentTags.length > 0) {

 286                     div.addContent(getSpace());
 287                     addInlineDeprecatedComment(annotationType, deprs[0], div);
 288                 }
 289             }
 290             annotationInfoTree.addContent(div);
 291         }
 292     }
 293 
 294     /**
 295      * {@inheritDoc}
 296      */

 297     protected Content getNavLinkTree() {
 298         Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
 299                 treeLabel, "", "");
 300         Content li = HtmlTree.LI(treeLinkContent);
 301         return li;
 302     }
 303 
 304     /**
 305      * Add summary details to the navigation bar.
 306      *
 307      * @param subDiv the content tree to which the summary detail links will be added
 308      */

 309     protected void addSummaryDetailLinks(Content subDiv) {
 310         try {
 311             Content div = HtmlTree.DIV(getNavSummaryLinks());
 312             div.addContent(getNavDetailLinks());
 313             subDiv.addContent(div);
 314         } catch (Exception e) {
 315             e.printStackTrace();
 316             throw new DocletAbortException(e);
 317         }
 318     }
 319 
 320     /**
 321      * Get summary links for navigation bar.
 322      *
 323      * @return the content tree for the navigation summary links

 324      */
 325     protected Content getNavSummaryLinks() throws Exception {
 326         Content li = HtmlTree.LI(summaryLabel);
 327         li.addContent(getSpace());
 328         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
 329         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
 330                 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
 331         Content liNavField = new HtmlTree(HtmlTag.LI);
 332         addNavSummaryLink(memberSummaryBuilder,
 333                 "doclet.navField",
 334                 VisibleMemberMap.ANNOTATION_TYPE_FIELDS, liNavField);
 335         addNavGap(liNavField);
 336         ulNav.addContent(liNavField);
 337         Content liNavReq = new HtmlTree(HtmlTag.LI);
 338         addNavSummaryLink(memberSummaryBuilder,
 339                 "doclet.navAnnotationTypeRequiredMember",
 340                 VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, liNavReq);
 341         addNavGap(liNavReq);
 342         ulNav.addContent(liNavReq);
 343         Content liNavOpt = new HtmlTree(HtmlTag.LI);
 344         addNavSummaryLink(memberSummaryBuilder,
 345                 "doclet.navAnnotationTypeOptionalMember",
 346                 VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, liNavOpt);
 347         ulNav.addContent(liNavOpt);
 348         return ulNav;
 349     }
 350 
 351     /**
 352      * Add the navigation summary link.
 353      *
 354      * @param builder builder for the member to be documented
 355      * @param label the label for the navigation
 356      * @param type type to be documented
 357      * @param liNav the content tree to which the navigation summary link will be added
 358      */
 359     protected void addNavSummaryLink(MemberSummaryBuilder builder,
 360             String label, int type, Content liNav) {
 361         AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
 362                 getMemberSummaryWriter(type));
 363         if (writer == null) {
 364             liNav.addContent(getResource(label));
 365         } else {
 366             liNav.addContent(writer.getNavSummaryLink(null,
 367                     ! builder.getVisibleMemberMap(type).noVisibleMembers()));
 368         }
 369     }
 370 
 371     /**
 372      * Get detail links for the navigation bar.
 373      *
 374      * @return the content tree for the detail links

 375      */
 376     protected Content getNavDetailLinks() throws Exception {
 377         Content li = HtmlTree.LI(detailLabel);
 378         li.addContent(getSpace());
 379         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
 380         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
 381                 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
 382         AbstractMemberWriter writerField =
 383                 ((AbstractMemberWriter) memberSummaryBuilder.
 384                 getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_FIELDS));
 385         AbstractMemberWriter writerOptional =
 386                 ((AbstractMemberWriter) memberSummaryBuilder.
 387                 getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL));
 388         AbstractMemberWriter writerRequired =
 389                 ((AbstractMemberWriter) memberSummaryBuilder.
 390                 getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED));
 391         Content liNavField = new HtmlTree(HtmlTag.LI);
 392         if (writerField != null){
 393             writerField.addNavDetailLink(annotationType.fields().length > 0, liNavField);
 394         } else {
 395             liNavField.addContent(getResource("doclet.navField"));
 396         }
 397         addNavGap(liNavField);
 398         ulNav.addContent(liNavField);
 399         if (writerOptional != null){
 400             Content liNavOpt = new HtmlTree(HtmlTag.LI);
 401             writerOptional.addNavDetailLink(annotationType.elements().length > 0, liNavOpt);
 402             ulNav.addContent(liNavOpt);
 403         } else if (writerRequired != null){
 404             Content liNavReq = new HtmlTree(HtmlTag.LI);
 405             writerRequired.addNavDetailLink(annotationType.elements().length > 0, liNavReq);
 406             ulNav.addContent(liNavReq);
 407         } else {
 408             Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
 409             ulNav.addContent(liNav);
 410         }
 411         return ulNav;
 412     }
 413 
 414     /**
 415      * Add gap between navigation bar elements.
 416      *
 417      * @param liNav the content tree to which the gap will be added
 418      */
 419     protected void addNavGap(Content liNav) {
 420         liNav.addContent(getSpace());
 421         liNav.addContent("|");
 422         liNav.addContent(getSpace());
 423     }
 424 
 425     /**
 426      * {@inheritDoc}
 427      */
 428     public AnnotationTypeDoc getAnnotationTypeDoc() {

 429         return annotationType;
 430     }
 431 }
   1 /*
   2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.javadoc.internal.doclets.formats.html;
  27 
  28 import java.io.IOException;
  29 import java.util.List;
  30 
  31 import javax.lang.model.element.PackageElement;
  32 import javax.lang.model.element.TypeElement;
  33 import javax.lang.model.type.TypeMirror;


  34 
  35 import com.sun.source.doctree.DocTree;
  36 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
  37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  39 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  40 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  41 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
  42 import jdk.javadoc.internal.doclets.toolkit.Content;
  43 import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
  44 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
  45 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  46 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  47 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
  48 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
  49 
  50 /**
  51  * Generate the Class Information Page.
  52  *
  53  *  <p><b>This is NOT part of any supported API.
  54  *  If you write code that depends on this, you do so at your own risk.
  55  *  This code and its internal interfaces are subject to change or
  56  *  deletion without notice.</b>
  57  *

  58  * @see java.util.Collections
  59  * @see java.util.List
  60  * @see java.util.ArrayList
  61  * @see java.util.HashMap
  62  *
  63  * @author Atul M Dambalkar
  64  * @author Robert Field
  65  * @author Bhavesh Patel (Modified)
  66  */
  67 public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
  68         implements AnnotationTypeWriter {
  69 
  70     protected TypeElement annotationType;
  71 
  72     protected TypeMirror prev;
  73 
  74     protected TypeMirror next;
  75 
  76     /**
  77      * @param configuration the configuration
  78      * @param annotationType the annotation type being documented.
  79      * @param prevType the previous class that was documented.
  80      * @param nextType the next class being documented.
  81      * @throws java.lang.Exception
  82      */
  83     public AnnotationTypeWriterImpl(ConfigurationImpl configuration,
  84             TypeElement annotationType, TypeMirror prevType, TypeMirror nextType)
  85             throws Exception {
  86         super(configuration, DocPath.forClass(configuration.utils, annotationType));
  87         this.annotationType = annotationType;
  88         configuration.currentTypeElement = annotationType;
  89         this.prev = prevType;
  90         this.next = nextType;
  91     }
  92 
  93     /**
  94      * Get this package link.
  95      *
  96      * @return a content tree for the package link
  97      */
  98     @Override
  99     protected Content getNavLinkPackage() {
 100         Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
 101                 packageLabel);
 102         Content li = HtmlTree.LI(linkContent);
 103         return li;
 104     }
 105 
 106     /**
 107      * Get the class link.
 108      *
 109      * @return a content tree for the class link
 110      */
 111     @Override
 112     protected Content getNavLinkClass() {
 113         Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
 114         return li;
 115     }
 116 
 117     /**
 118      * Get the class use link.
 119      *
 120      * @return a content tree for the class use link
 121      */
 122     @Override
 123     protected Content getNavLinkClassUse() {
 124         Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
 125         Content li = HtmlTree.LI(linkContent);
 126         return li;
 127     }
 128 
 129     /**
 130      * Get link to previous class.
 131      *
 132      * @return a content tree for the previous class link
 133      */
 134     @Override
 135     public Content getNavLinkPrevious() {
 136         Content li;
 137         if (prev != null) {
 138             Content prevLink = getLink(new LinkInfoImpl(configuration,
 139                     LinkInfoImpl.Kind.CLASS, utils.asTypeElement(prev))
 140                     .label(prevclassLabel).strong(true));
 141             li = HtmlTree.LI(prevLink);
 142         }
 143         else
 144             li = HtmlTree.LI(prevclassLabel);
 145         return li;
 146     }
 147 
 148     /**
 149      * Get link to next class.
 150      *
 151      * @return a content tree for the next class link
 152      */
 153     @Override
 154     public Content getNavLinkNext() {
 155         Content li;
 156         if (next != null) {
 157             Content nextLink = getLink(new LinkInfoImpl(configuration,
 158                     LinkInfoImpl.Kind.CLASS, utils.asTypeElement(next))
 159                     .label(nextclassLabel).strong(true));
 160             li = HtmlTree.LI(nextLink);
 161         }
 162         else
 163             li = HtmlTree.LI(nextclassLabel);
 164         return li;
 165     }
 166 
 167     /**
 168      * {@inheritDoc}
 169      */
 170     @Override
 171     public Content getHeader(String header) {
 172         HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getSimpleName(annotationType)));



 173         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
 174                 ? HtmlTree.HEADER()
 175                 : bodyTree;
 176         addTop(htmlTree);
 177         addNavLinks(true, htmlTree);
 178         if (configuration.allowTag(HtmlTag.HEADER)) {
 179             bodyTree.addContent(htmlTree);
 180         }
 181         bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
 182         HtmlTree div = new HtmlTree(HtmlTag.DIV);
 183         div.addStyle(HtmlStyle.header);
 184         PackageElement pkg = utils.containingPackage(annotationType);
 185         if (!pkg.isUnnamed()) {
 186             Content pkgNameContent = new StringContent(utils.getPackageName(pkg));
 187             Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
 188             div.addContent(pkgNameDiv);
 189         }
 190         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
 191                 LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
 192         Content headerContent = new StringContent(header);
 193         Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
 194                 HtmlStyle.title, headerContent);
 195         heading.addContent(getTypeParameterLinks(linkInfo));
 196         div.addContent(heading);
 197         if (configuration.allowTag(HtmlTag.MAIN)) {
 198             mainTree.addContent(div);
 199         } else {
 200             bodyTree.addContent(div);
 201         }
 202         return bodyTree;
 203     }
 204 
 205     /**
 206      * {@inheritDoc}
 207      */
 208     @Override
 209     public Content getAnnotationContentHeader() {
 210         return getContentHeader();
 211     }
 212 
 213     /**
 214      * {@inheritDoc}
 215      */
 216     @Override
 217     public void addFooter(Content contentTree) {
 218         contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
 219         Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
 220                 ? HtmlTree.FOOTER()
 221                 : contentTree;
 222         addNavLinks(false, htmlTree);
 223         addBottom(htmlTree);
 224         if (configuration.allowTag(HtmlTag.FOOTER)) {
 225             contentTree.addContent(htmlTree);
 226         }
 227     }
 228 
 229     /**
 230      * {@inheritDoc}
 231      */
 232     @Override
 233     public void printDocument(Content contentTree) throws IOException {
 234         printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
 235                 true, contentTree);
 236     }
 237 
 238     /**
 239      * {@inheritDoc}
 240      */
 241     @Override
 242     public Content getAnnotationInfoTreeHeader() {
 243         return getMemberTreeHeader();
 244     }
 245 
 246     /**
 247      * {@inheritDoc}
 248      */
 249     @Override
 250     public Content getAnnotationInfo(Content annotationInfoTree) {
 251         return getMemberTree(HtmlStyle.description, annotationInfoTree);
 252     }
 253 
 254     /**
 255      * {@inheritDoc}
 256      */
 257     @Override
 258     public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) {
 259         annotationInfoTree.addContent(new HtmlTree(HtmlTag.BR));
 260         Content pre = new HtmlTree(HtmlTag.PRE);
 261         addAnnotationInfo(annotationType, pre);
 262         pre.addContent(modifiers);
 263         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
 264                 LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
 265         Content annotationName = new StringContent(utils.getSimpleName(annotationType));
 266         Content parameterLinks = getTypeParameterLinks(linkInfo);
 267         if (configuration.linksource) {
 268             addSrcLink(annotationType, annotationName, pre);
 269             pre.addContent(parameterLinks);
 270         } else {
 271             Content span = HtmlTree.SPAN(HtmlStyle.memberNameLabel, annotationName);
 272             span.addContent(parameterLinks);
 273             pre.addContent(span);
 274         }
 275         annotationInfoTree.addContent(pre);
 276     }
 277 
 278     /**
 279      * {@inheritDoc}
 280      */
 281     @Override
 282     public void addAnnotationTypeDescription(Content annotationInfoTree) {
 283         if(!configuration.nocomment) {
 284             if (!utils.getBody(annotationType).isEmpty()) {
 285                 addInlineComment(annotationType, annotationInfoTree);
 286             }
 287         }
 288     }
 289 
 290     /**
 291      * {@inheritDoc}
 292      */
 293     @Override
 294     public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
 295         if(!configuration.nocomment) {
 296             addTagsInfo(annotationType, annotationInfoTree);
 297         }
 298     }
 299 
 300     /**
 301      * {@inheritDoc}
 302      */
 303     @Override
 304     public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) {
 305         Content hr = new HtmlTree(HtmlTag.HR);
 306         annotationInfoTree.addContent(hr);
 307         List<? extends DocTree> deprs = utils.getBlockTags(annotationType, DocTree.Kind.DEPRECATED);
 308         if (utils.isDeprecated(annotationType)) {
 309             CommentHelper ch = utils.getCommentHelper(annotationType);
 310             Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
 311             Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
 312             if (!deprs.isEmpty()) {
 313 
 314                 List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
 315                 if (!commentTags.isEmpty()) {
 316                     div.addContent(getSpace());
 317                     addInlineDeprecatedComment(annotationType, deprs.get(0), div);
 318                 }
 319             }
 320             annotationInfoTree.addContent(div);
 321         }
 322     }
 323 
 324     /**
 325      * {@inheritDoc}
 326      */
 327     @Override
 328     protected Content getNavLinkTree() {
 329         Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
 330                 treeLabel, "", "");
 331         Content li = HtmlTree.LI(treeLinkContent);
 332         return li;
 333     }
 334 
 335     /**
 336      * Add summary details to the navigation bar.
 337      *
 338      * @param subDiv the content tree to which the summary detail links will be added
 339      */
 340     @Override
 341     protected void addSummaryDetailLinks(Content subDiv) {
 342         try {
 343             Content div = HtmlTree.DIV(getNavSummaryLinks());
 344             div.addContent(getNavDetailLinks());
 345             subDiv.addContent(div);
 346         } catch (Exception e) {

 347             throw new DocletAbortException(e);
 348         }
 349     }
 350 
 351     /**
 352      * Get summary links for navigation bar.
 353      *
 354      * @return the content tree for the navigation summary links
 355      * @throws java.lang.Exception
 356      */
 357     protected Content getNavSummaryLinks() throws Exception {
 358         Content li = HtmlTree.LI(summaryLabel);
 359         li.addContent(getSpace());
 360         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
 361         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
 362                 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
 363         Content liNavField = new HtmlTree(HtmlTag.LI);
 364         addNavSummaryLink(memberSummaryBuilder,
 365                 "doclet.navField",
 366                 VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS, liNavField);
 367         addNavGap(liNavField);
 368         ulNav.addContent(liNavField);
 369         Content liNavReq = new HtmlTree(HtmlTag.LI);
 370         addNavSummaryLink(memberSummaryBuilder,
 371                 "doclet.navAnnotationTypeRequiredMember",
 372                 VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED, liNavReq);
 373         addNavGap(liNavReq);
 374         ulNav.addContent(liNavReq);
 375         Content liNavOpt = new HtmlTree(HtmlTag.LI);
 376         addNavSummaryLink(memberSummaryBuilder,
 377                 "doclet.navAnnotationTypeOptionalMember",
 378                 VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL, liNavOpt);
 379         ulNav.addContent(liNavOpt);
 380         return ulNav;
 381     }
 382 
 383     /**
 384      * Add the navigation summary link.
 385      *
 386      * @param builder builder for the member to be documented
 387      * @param label the label for the navigation
 388      * @param type type to be documented
 389      * @param liNav the content tree to which the navigation summary link will be added
 390      */
 391     protected void addNavSummaryLink(MemberSummaryBuilder builder,
 392             String label, VisibleMemberMap.Kind type, Content liNav) {
 393         AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
 394                 getMemberSummaryWriter(type));
 395         if (writer == null) {
 396             liNav.addContent(getResource(label));
 397         } else {
 398             liNav.addContent(writer.getNavSummaryLink(null,
 399                     ! builder.getVisibleMemberMap(type).noVisibleMembers()));
 400         }
 401     }
 402 
 403     /**
 404      * Get detail links for the navigation bar.
 405      *
 406      * @return the content tree for the detail links
 407      * @throws java.lang.Exception
 408      */
 409     protected Content getNavDetailLinks() throws Exception {
 410         Content li = HtmlTree.LI(detailLabel);
 411         li.addContent(getSpace());
 412         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
 413         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
 414                 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
 415         AbstractMemberWriter writerField =
 416                 ((AbstractMemberWriter) memberSummaryBuilder.
 417                 getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS));
 418         AbstractMemberWriter writerOptional =
 419                 ((AbstractMemberWriter) memberSummaryBuilder.
 420                 getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL));
 421         AbstractMemberWriter writerRequired =
 422                 ((AbstractMemberWriter) memberSummaryBuilder.
 423                 getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED));
 424         Content liNavField = new HtmlTree(HtmlTag.LI);
 425         if (writerField != null) {
 426             writerField.addNavDetailLink(!utils.getAnnotationFields(annotationType).isEmpty(), liNavField);
 427         } else {
 428             liNavField.addContent(getResource("doclet.navField"));
 429         }
 430         addNavGap(liNavField);
 431         ulNav.addContent(liNavField);
 432         if (writerOptional != null){
 433             Content liNavOpt = new HtmlTree(HtmlTag.LI);
 434             writerOptional.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavOpt);
 435             ulNav.addContent(liNavOpt);
 436         } else if (writerRequired != null){
 437             Content liNavReq = new HtmlTree(HtmlTag.LI);
 438             writerRequired.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavReq);
 439             ulNav.addContent(liNavReq);
 440         } else {
 441             Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
 442             ulNav.addContent(liNav);
 443         }
 444         return ulNav;
 445     }
 446 
 447     /**
 448      * Add gap between navigation bar elements.
 449      *
 450      * @param liNav the content tree to which the gap will be added
 451      */
 452     protected void addNavGap(Content liNav) {
 453         liNav.addContent(getSpace());
 454         liNav.addContent("|");
 455         liNav.addContent(getSpace());
 456     }
 457 
 458     /**
 459      * {@inheritDoc}
 460      */
 461     @Override
 462     public TypeElement getAnnotationTypeElement() {
 463         return annotationType;
 464     }
 465 }