langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java
changeset 40587 1c355ea550ed
parent 40303 96a1226aca18
child 45599 8bc3a019f948
equal deleted inserted replaced
40519:e17429a7e843 40587:1c355ea550ed
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.javadoc.internal.doclets.toolkit.builders;
    26 package jdk.javadoc.internal.doclets.toolkit.builders;
    27 
    27 
    28 import java.io.*;
       
    29 
       
    30 import javax.lang.model.element.PackageElement;
    28 import javax.lang.model.element.PackageElement;
    31 import javax.lang.model.element.TypeElement;
    29 import javax.lang.model.element.TypeElement;
    32 
    30 
    33 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
    31 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
    34 import jdk.javadoc.internal.doclets.toolkit.Content;
    32 import jdk.javadoc.internal.doclets.toolkit.Content;
       
    33 import jdk.javadoc.internal.doclets.toolkit.DocletException;
    35 
    34 
    36 
    35 
    37 /**
    36 /**
    38  * Builds the summary for a given annotation type.
    37  * Builds the summary for a given annotation type.
    39  *
    38  *
    81         this.annotationType = annotationTypeElement;
    80         this.annotationType = annotationTypeElement;
    82         this.writer = writer;
    81         this.writer = writer;
    83     }
    82     }
    84 
    83 
    85     /**
    84     /**
    86      * Construct a new ClassBuilder.
    85      * Construct a new AnnotationTypeBuilder.
    87      *
    86      *
    88      * @param context           the build context.
    87      * @param context           the build context.
    89      * @param annotationTypeDoc the class being documented.
    88      * @param annotationTypeDoc the class being documented.
    90      * @param writer            the doclet specific writer.
    89      * @param writer            the doclet specific writer.
       
    90      * @return                  an AnnotationTypeBuilder
    91      */
    91      */
    92     public static AnnotationTypeBuilder getInstance(Context context,
    92     public static AnnotationTypeBuilder getInstance(Context context,
    93             TypeElement annotationTypeDoc,
    93             TypeElement annotationTypeDoc,
    94             AnnotationTypeWriter writer)
    94             AnnotationTypeWriter writer) {
    95             throws Exception {
       
    96         return new AnnotationTypeBuilder(context, annotationTypeDoc, writer);
    95         return new AnnotationTypeBuilder(context, annotationTypeDoc, writer);
    97     }
    96     }
    98 
    97 
    99     /**
    98     /**
   100      * {@inheritDoc}
    99      * {@inheritDoc}
   101      */
   100      */
   102     public void build() throws IOException {
   101     @Override
       
   102     public void build() throws DocletException {
   103         build(layoutParser.parseXML(ROOT), contentTree);
   103         build(layoutParser.parseXML(ROOT), contentTree);
   104     }
   104     }
   105 
   105 
   106     /**
   106     /**
   107      * {@inheritDoc}
   107      * {@inheritDoc}
   108      */
   108      */
       
   109     @Override
   109     public String getName() {
   110     public String getName() {
   110         return ROOT;
   111         return ROOT;
   111     }
   112     }
   112 
   113 
   113     /**
   114     /**
   114       * Build the annotation type documentation.
   115      * Build the annotation type documentation.
   115       *
   116      *
   116       * @param node the XML element that specifies which components to document
   117      * @param node the XML element that specifies which components to document
   117       * @param contentTree the content tree to which the documentation will be added
   118      * @param contentTree the content tree to which the documentation will be added
   118       */
   119      * @throws DocletException if there is a problem building the documentation
   119      public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception {
   120      */
   120          contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") +
   121     public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws DocletException {
   121                 " " + utils.getSimpleName(annotationType));
   122         contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") +
   122          Content annotationContentTree = writer.getAnnotationContentHeader();
   123                " " + utils.getSimpleName(annotationType));
   123          buildChildren(node, annotationContentTree);
   124         Content annotationContentTree = writer.getAnnotationContentHeader();
   124          writer.addAnnotationContentTree(contentTree, annotationContentTree);
   125         buildChildren(node, annotationContentTree);
   125          writer.addFooter(contentTree);
   126         writer.addAnnotationContentTree(contentTree, annotationContentTree);
   126          writer.printDocument(contentTree);
   127         writer.addFooter(contentTree);
   127          copyDocFiles();
   128         writer.printDocument(contentTree);
   128      }
   129         copyDocFiles();
   129 
   130     }
   130      /**
   131 
   131       * Copy the doc files for the current TypeElement if necessary.
   132     /**
   132       */
   133      * Copy the doc files for the current TypeElement if necessary.
   133      private void copyDocFiles() {
   134      *
       
   135      * @throws DocletException if there is a problem building the documentation
       
   136      */
       
   137     private void copyDocFiles() throws DocletException {
   134         PackageElement containingPackage = utils.containingPackage(annotationType);
   138         PackageElement containingPackage = utils.containingPackage(annotationType);
   135         if((configuration.packages == null ||
   139         if((configuration.packages == null ||
   136             !configuration.packages.contains(containingPackage) &&
   140             !configuration.packages.contains(containingPackage) &&
   137             !containingPackagesSeen.contains(containingPackage))){
   141             !containingPackagesSeen.contains(containingPackage))){
   138             //Only copy doc files dir if the containing package is not
   142             //Only copy doc files dir if the containing package is not
   139             //documented AND if we have not documented a class from the same
   143             //documented AND if we have not documented a class from the same
   140             //package already. Otherwise, we are making duplicate copies.
   144             //package already. Otherwise, we are making duplicate copies.
   141             utils.copyDocFiles(containingPackage);
   145             utils.copyDocFiles(containingPackage);
   142             containingPackagesSeen.add(containingPackage);
   146             containingPackagesSeen.add(containingPackage);
   143         }
   147         }
   144      }
   148     }
   145 
   149 
   146     /**
   150     /**
   147      * Build the annotation information tree documentation.
   151      * Build the annotation information tree documentation.
   148      *
   152      *
   149      * @param node the XML element that specifies which components to document
   153      * @param node the XML element that specifies which components to document
   150      * @param annotationContentTree the content tree to which the documentation will be added
   154      * @param annotationContentTree the content tree to which the documentation will be added
   151      */
   155      * @throws DocletException if there is a problem building the documentation
   152     public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree) {
   156      */
       
   157     public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree)
       
   158             throws DocletException {
   153         Content annotationInfoTree = writer.getAnnotationInfoTreeHeader();
   159         Content annotationInfoTree = writer.getAnnotationInfoTreeHeader();
   154         buildChildren(node, annotationInfoTree);
   160         buildChildren(node, annotationInfoTree);
   155         annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree));
   161         annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree));
   156     }
   162     }
   157 
   163 
   199     /**
   205     /**
   200      * Build the member summary contents of the page.
   206      * Build the member summary contents of the page.
   201      *
   207      *
   202      * @param node the XML element that specifies which components to document
   208      * @param node the XML element that specifies which components to document
   203      * @param annotationContentTree the content tree to which the documentation will be added
   209      * @param annotationContentTree the content tree to which the documentation will be added
   204      */
   210      * @throws DocletException if there is a problem building the documentation
   205     public void buildMemberSummary(XMLNode node, Content annotationContentTree)
   211      */
   206             throws Exception {
   212     public void buildMemberSummary(XMLNode node, Content annotationContentTree) throws DocletException {
   207         Content memberSummaryTree = writer.getMemberTreeHeader();
   213         Content memberSummaryTree = writer.getMemberTreeHeader();
   208         configuration.getBuilderFactory().
   214         configuration.getBuilderFactory().
   209                 getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree);
   215                 getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree);
   210         annotationContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree));
   216         annotationContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree));
   211     }
   217     }
   213     /**
   219     /**
   214      * Build the member details contents of the page.
   220      * Build the member details contents of the page.
   215      *
   221      *
   216      * @param node the XML element that specifies which components to document
   222      * @param node the XML element that specifies which components to document
   217      * @param annotationContentTree the content tree to which the documentation will be added
   223      * @param annotationContentTree the content tree to which the documentation will be added
   218      */
   224      * @throws DocletException if there is a problem building the documentation
   219     public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree) {
   225      */
       
   226     public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree)
       
   227             throws DocletException {
   220         Content memberDetailsTree = writer.getMemberTreeHeader();
   228         Content memberDetailsTree = writer.getMemberTreeHeader();
   221         buildChildren(node, memberDetailsTree);
   229         buildChildren(node, memberDetailsTree);
   222         if (memberDetailsTree.isValid()) {
   230         if (memberDetailsTree.isValid()) {
   223             annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree));
   231             annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree));
   224         }
   232         }
   227     /**
   235     /**
   228      * Build the annotation type field documentation.
   236      * Build the annotation type field documentation.
   229      *
   237      *
   230      * @param node the XML element that specifies which components to document
   238      * @param node the XML element that specifies which components to document
   231      * @param memberDetailsTree the content tree to which the documentation will be added
   239      * @param memberDetailsTree the content tree to which the documentation will be added
       
   240      * @throws DocletException if there is a problem building the documentation
   232      */
   241      */
   233     public void buildAnnotationTypeFieldDetails(XMLNode node, Content memberDetailsTree)
   242     public void buildAnnotationTypeFieldDetails(XMLNode node, Content memberDetailsTree)
   234             throws Exception {
   243             throws DocletException {
   235         configuration.getBuilderFactory().
   244         configuration.getBuilderFactory().
   236                 getAnnotationTypeFieldsBuilder(writer).buildChildren(node, memberDetailsTree);
   245                 getAnnotationTypeFieldsBuilder(writer).buildChildren(node, memberDetailsTree);
   237     }
   246     }
   238 
   247 
   239     /**
   248     /**
   240      * Build the annotation type optional member documentation.
   249      * Build the annotation type optional member documentation.
   241      *
   250      *
   242      * @param node the XML element that specifies which components to document
   251      * @param node the XML element that specifies which components to document
   243      * @param memberDetailsTree the content tree to which the documentation will be added
   252      * @param memberDetailsTree the content tree to which the documentation will be added
       
   253      * @throws DocletException if there is a problem building the documentation
   244      */
   254      */
   245     public void buildAnnotationTypeOptionalMemberDetails(XMLNode node, Content memberDetailsTree)
   255     public void buildAnnotationTypeOptionalMemberDetails(XMLNode node, Content memberDetailsTree)
   246             throws Exception {
   256             throws DocletException {
   247         configuration.getBuilderFactory().
   257         configuration.getBuilderFactory().
   248                 getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node, memberDetailsTree);
   258                 getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node, memberDetailsTree);
   249     }
   259     }
   250 
   260 
   251     /**
   261     /**
   252      * Build the annotation type required member documentation.
   262      * Build the annotation type required member documentation.
   253      *
   263      *
   254      * @param node the XML element that specifies which components to document
   264      * @param node the XML element that specifies which components to document
   255      * @param memberDetailsTree the content tree to which the documentation will be added
   265      * @param memberDetailsTree the content tree to which the documentation will be added
       
   266      * @throws DocletException if there is a problem building the documentation
   256      */
   267      */
   257     public void buildAnnotationTypeRequiredMemberDetails(XMLNode node, Content memberDetailsTree)
   268     public void buildAnnotationTypeRequiredMemberDetails(XMLNode node, Content memberDetailsTree)
   258             throws Exception {
   269             throws DocletException {
   259         configuration.getBuilderFactory().
   270         configuration.getBuilderFactory().
   260                 getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node, memberDetailsTree);
   271                 getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node, memberDetailsTree);
   261     }
   272     }
   262 }
   273 }