langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.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.ClassWriter;
    31 import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
    34 import jdk.javadoc.internal.doclets.toolkit.Content;
    32 import jdk.javadoc.internal.doclets.toolkit.Content;
       
    33 import jdk.javadoc.internal.doclets.toolkit.DocletException;
       
    34 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
    35 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
    35 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
    36 
    36 
    37 /**
    37 /**
    38  * Builds the summary for a given class.
    38  * Builds the summary for a given class.
    39  *
    39  *
   103             isEnum = false;
   103             isEnum = false;
   104         }
   104         }
   105     }
   105     }
   106 
   106 
   107     /**
   107     /**
   108      * Construct a new ClassBuilder.
   108      * Constructs a new ClassBuilder.
   109      *
   109      *
   110      * @param context  the build context
   110      * @param context  the build context
   111      * @param typeElement the class being documented.
   111      * @param typeElement the class being documented.
   112      * @param writer the doclet specific writer.
   112      * @param writer the doclet specific writer.
       
   113      * @return the new ClassBuilder
   113      */
   114      */
   114     public static ClassBuilder getInstance(Context context,
   115     public static ClassBuilder getInstance(Context context,
   115             TypeElement typeElement, ClassWriter writer) {
   116             TypeElement typeElement, ClassWriter writer) {
   116         return new ClassBuilder(context, typeElement, writer);
   117         return new ClassBuilder(context, typeElement, writer);
   117     }
   118     }
   118 
   119 
   119     /**
   120     /**
   120      * {@inheritDoc}
   121      * {@inheritDoc}
   121      */
   122      */
   122     public void build() throws IOException {
   123     @Override
       
   124     public void build() throws DocletException {
   123         build(layoutParser.parseXML(ROOT), contentTree);
   125         build(layoutParser.parseXML(ROOT), contentTree);
   124     }
   126     }
   125 
   127 
   126     /**
   128     /**
   127      * {@inheritDoc}
   129      * {@inheritDoc}
   128      */
   130      */
       
   131     @Override
   129     public String getName() {
   132     public String getName() {
   130         return ROOT;
   133         return ROOT;
   131     }
   134     }
   132 
   135 
   133      /**
   136      /**
   134       * Handles the {@literal <TypeElement>} tag.
   137       * Handles the {@literal <TypeElement>} tag.
   135       *
   138       *
   136       * @param node the XML element that specifies which components to document
   139       * @param node the XML element that specifies which components to document
   137       * @param contentTree the content tree to which the documentation will be added
   140       * @param contentTree the content tree to which the documentation will be added
       
   141      * @throws DocletException if there is a problem while building the documentation
   138       */
   142       */
   139      public void buildClassDoc(XMLNode node, Content contentTree) throws Exception {
   143      public void buildClassDoc(XMLNode node, Content contentTree) throws DocletException {
   140          String key;
   144          String key;
   141          if (isInterface) {
   145          if (isInterface) {
   142              key =  "doclet.Interface";
   146              key =  "doclet.Interface";
   143          } else if (isEnum) {
   147          } else if (isEnum) {
   144              key = "doclet.Enum";
   148              key = "doclet.Enum";
   168     /**
   172     /**
   169      * Build the class information tree documentation.
   173      * Build the class information tree documentation.
   170      *
   174      *
   171      * @param node the XML element that specifies which components to document
   175      * @param node the XML element that specifies which components to document
   172      * @param classContentTree the content tree to which the documentation will be added
   176      * @param classContentTree the content tree to which the documentation will be added
   173      */
   177      * @throws DocletException if there is a problem while building the documentation
   174     public void buildClassInfo(XMLNode node, Content classContentTree) {
   178      */
       
   179     public void buildClassInfo(XMLNode node, Content classContentTree) throws DocletException {
   175         Content classInfoTree = writer.getClassInfoTreeHeader();
   180         Content classInfoTree = writer.getClassInfoTreeHeader();
   176         buildChildren(node, classInfoTree);
   181         buildChildren(node, classInfoTree);
   177         classContentTree.addContent(writer.getClassInfo(classInfoTree));
   182         classContentTree.addContent(writer.getClassInfo(classInfoTree));
   178     }
   183     }
   179 
   184 
   180     /**
   185     /**
   181      * Build the typeparameters of this class.
   186      * Build the type parameters of this class.
   182      *
   187      *
   183      * @param node the XML element that specifies which components to document
   188      * @param node the XML element that specifies which components to document
   184      * @param classInfoTree the content tree to which the documentation will be added
   189      * @param classInfoTree the content tree to which the documentation will be added
   185      */
   190      */
   186     public void buildTypeParamInfo(XMLNode node, Content classInfoTree) {
   191     public void buildTypeParamInfo(XMLNode node, Content classInfoTree) {
   267         writer.addNestedClassInfo(classInfoTree);
   272         writer.addNestedClassInfo(classInfoTree);
   268     }
   273     }
   269 
   274 
   270     /**
   275     /**
   271      * Copy the doc files.
   276      * Copy the doc files.
   272      */
   277      *
   273      private void copyDocFiles() {
   278      * @throws DocFileIOException if there is a problem while copying the files
       
   279      */
       
   280      private void copyDocFiles() throws DocFileIOException {
   274         PackageElement containingPackage = utils.containingPackage(typeElement);
   281         PackageElement containingPackage = utils.containingPackage(typeElement);
   275         if((configuration.packages == null ||
   282         if((configuration.packages == null ||
   276             !configuration.packages.contains(containingPackage)) &&
   283             !configuration.packages.contains(containingPackage)) &&
   277             !containingPackagesSeen.contains(containingPackage)) {
   284             !containingPackagesSeen.contains(containingPackage)) {
   278             //Only copy doc files dir if the containing package is not
   285             //Only copy doc files dir if the containing package is not
   316     /**
   323     /**
   317      * Build the member summary contents of the page.
   324      * Build the member summary contents of the page.
   318      *
   325      *
   319      * @param node the XML element that specifies which components to document
   326      * @param node the XML element that specifies which components to document
   320      * @param classContentTree the content tree to which the documentation will be added
   327      * @param classContentTree the content tree to which the documentation will be added
   321      */
   328      * @throws DocletException if there is a problem while building the documentation
   322     public void buildMemberSummary(XMLNode node, Content classContentTree) throws Exception {
   329      */
       
   330     public void buildMemberSummary(XMLNode node, Content classContentTree) throws DocletException {
   323         Content memberSummaryTree = writer.getMemberTreeHeader();
   331         Content memberSummaryTree = writer.getMemberTreeHeader();
   324         configuration.getBuilderFactory().
   332         configuration.getBuilderFactory().
   325                 getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree);
   333                 getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree);
   326         classContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree));
   334         classContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree));
   327     }
   335     }
   329     /**
   337     /**
   330      * Build the member details contents of the page.
   338      * Build the member details contents of the page.
   331      *
   339      *
   332      * @param node the XML element that specifies which components to document
   340      * @param node the XML element that specifies which components to document
   333      * @param classContentTree the content tree to which the documentation will be added
   341      * @param classContentTree the content tree to which the documentation will be added
   334      */
   342      * @throws DocletException if there is a problem while building the documentation
   335     public void buildMemberDetails(XMLNode node, Content classContentTree) {
   343      */
       
   344     public void buildMemberDetails(XMLNode node, Content classContentTree) throws DocletException {
   336         Content memberDetailsTree = writer.getMemberTreeHeader();
   345         Content memberDetailsTree = writer.getMemberTreeHeader();
   337         buildChildren(node, memberDetailsTree);
   346         buildChildren(node, memberDetailsTree);
   338         classContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree));
   347         classContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree));
   339     }
   348     }
   340 
   349 
   341     /**
   350     /**
   342      * Build the enum constants documentation.
   351      * Build the enum constants documentation.
   343      *
   352      *
   344      * @param node the XML element that specifies which components to document
   353      * @param node the XML element that specifies which components to document
   345      * @param memberDetailsTree the content tree to which the documentation will be added
   354      * @param memberDetailsTree the content tree to which the documentation will be added
       
   355      * @throws DocletException if there is a problem while building the documentation
   346      */
   356      */
   347     public void buildEnumConstantsDetails(XMLNode node,
   357     public void buildEnumConstantsDetails(XMLNode node,
   348             Content memberDetailsTree) throws Exception {
   358             Content memberDetailsTree) throws DocletException {
   349         configuration.getBuilderFactory().
   359         configuration.getBuilderFactory().
   350                 getEnumConstantsBuilder(writer).buildChildren(node, memberDetailsTree);
   360                 getEnumConstantsBuilder(writer).buildChildren(node, memberDetailsTree);
   351     }
   361     }
   352 
   362 
   353     /**
   363     /**
   354      * Build the field documentation.
   364      * Build the field documentation.
   355      *
   365      *
   356      * @param node the XML element that specifies which components to document
   366      * @param node the XML element that specifies which components to document
   357      * @param memberDetailsTree the content tree to which the documentation will be added
   367      * @param memberDetailsTree the content tree to which the documentation will be added
       
   368      * @throws DocletException if there is a problem while building the documentation
   358      */
   369      */
   359     public void buildFieldDetails(XMLNode node,
   370     public void buildFieldDetails(XMLNode node,
   360             Content memberDetailsTree) throws Exception {
   371             Content memberDetailsTree) throws DocletException {
   361         configuration.getBuilderFactory().
   372         configuration.getBuilderFactory().
   362                 getFieldBuilder(writer).buildChildren(node, memberDetailsTree);
   373                 getFieldBuilder(writer).buildChildren(node, memberDetailsTree);
   363     }
   374     }
   364 
   375 
   365     /**
   376     /**
   366      * Build the property documentation.
   377      * Build the property documentation.
   367      *
   378      *
   368      * @param elements the XML elements that specify how a field is documented.
   379      * @param node the XML element that specifies which components to document
       
   380      * @param memberDetailsTree the content tree to which the documentation will be added
       
   381      * @throws DocletException if there is a problem while building the documentation
   369      */
   382      */
   370     public void buildPropertyDetails(XMLNode node,
   383     public void buildPropertyDetails(XMLNode node,
   371             Content memberDetailsTree) throws Exception {
   384             Content memberDetailsTree) throws DocletException {
   372         configuration.getBuilderFactory().
   385         configuration.getBuilderFactory().
   373                 getPropertyBuilder(writer).buildChildren(node, memberDetailsTree);
   386                 getPropertyBuilder(writer).buildChildren(node, memberDetailsTree);
   374     }
   387     }
   375 
   388 
   376     /**
   389     /**
   377      * Build the constructor documentation.
   390      * Build the constructor documentation.
   378      *
   391      *
   379      * @param node the XML element that specifies which components to document
   392      * @param node the XML element that specifies which components to document
   380      * @param memberDetailsTree the content tree to which the documentation will be added
   393      * @param memberDetailsTree the content tree to which the documentation will be added
       
   394      * @throws DocletException if there is a problem while building the documentation
   381      */
   395      */
   382     public void buildConstructorDetails(XMLNode node,
   396     public void buildConstructorDetails(XMLNode node,
   383             Content memberDetailsTree) throws Exception {
   397             Content memberDetailsTree) throws DocletException {
   384         configuration.getBuilderFactory().
   398         configuration.getBuilderFactory().
   385                 getConstructorBuilder(writer).buildChildren(node, memberDetailsTree);
   399                 getConstructorBuilder(writer).buildChildren(node, memberDetailsTree);
   386     }
   400     }
   387 
   401 
   388     /**
   402     /**
   389      * Build the method documentation.
   403      * Build the method documentation.
   390      *
   404      *
   391      * @param node the XML element that specifies which components to document
   405      * @param node the XML element that specifies which components to document
   392      * @param memberDetailsTree the content tree to which the documentation will be added
   406      * @param memberDetailsTree the content tree to which the documentation will be added
       
   407      * @throws DocletException if there is a problem while building the documentation
   393      */
   408      */
   394     public void buildMethodDetails(XMLNode node,
   409     public void buildMethodDetails(XMLNode node,
   395             Content memberDetailsTree) throws Exception {
   410             Content memberDetailsTree) throws DocletException {
   396         configuration.getBuilderFactory().
   411         configuration.getBuilderFactory().
   397                 getMethodBuilder(writer).buildChildren(node, memberDetailsTree);
   412                 getMethodBuilder(writer).buildChildren(node, memberDetailsTree);
   398     }
   413     }
   399 }
   414 }