< prev index next >

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

Print this page
rev 52865 : [mq]: 8210031


  54 /**
  55  * Generate the Class Information Page.
  56  *
  57  *  <p><b>This is NOT part of any supported API.
  58  *  If you write code that depends on this, you do so at your own risk.
  59  *  This code and its internal interfaces are subject to change or
  60  *  deletion without notice.</b>
  61  *
  62  * @see javax.lang.model.element.TypeElement
  63  * @see java.util.Collections
  64  * @see java.util.List
  65  * @see java.util.ArrayList
  66  * @see java.util.HashMap
  67  *
  68  * @author Atul M Dambalkar
  69  * @author Robert Field
  70  * @author Bhavesh Patel (Modified)
  71  */
  72 public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWriter {
  73 










  74     protected final TypeElement typeElement;
  75 
  76     protected final ClassTree classtree;
  77 
  78     private final Navigation navBar;
  79 
  80     /**
  81      * @param configuration the configuration data for the doclet
  82      * @param typeElement the class being documented.
  83      * @param classTree the class tree for the given class.
  84      */
  85     public ClassWriterImpl(HtmlConfiguration configuration, TypeElement typeElement,
  86                            ClassTree classTree) {
  87         super(configuration, configuration.docPaths.forClass(typeElement));
  88         this.typeElement = typeElement;
  89         configuration.currentTypeElement = typeElement;
  90         this.classtree = classTree;
  91         this.navBar = new Navigation(typeElement, configuration, fixedNavDiv, PageMode.CLASS, path);
  92     }
  93 


 353 
 354     /**
 355      * {@inheritDoc}
 356      */
 357     @Override
 358     public void addTypeParamInfo(Content classInfoTree) {
 359         if (!utils.getTypeParamTrees(typeElement).isEmpty()) {
 360             Content typeParam = (new ParamTaglet()).getTagletOutput(typeElement,
 361                     getTagletWriterInstance(false));
 362             Content dl = HtmlTree.DL(typeParam);
 363             classInfoTree.addContent(dl);
 364         }
 365     }
 366 
 367     /**
 368      * {@inheritDoc}
 369      */
 370     @Override
 371     public void addSubClassInfo(Content classInfoTree) {
 372         if (utils.isClass(typeElement)) {
 373             if (typeElement.getQualifiedName().contentEquals("java.lang.Object") ||
 374                     typeElement.getQualifiedName().contentEquals("org.omg.CORBA.Object")) {
 375                 return;    // Don't generate the list, too huge
 376             }

 377             Set<TypeElement> subclasses = classtree.directSubClasses(typeElement, false);
 378             if (!subclasses.isEmpty()) {
 379                 Content label = contents.subclassesLabel;
 380                 Content dt = HtmlTree.DT(label);
 381                 Content dl = HtmlTree.DL(dt);
 382                 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES,
 383                         subclasses));
 384                 classInfoTree.addContent(dl);
 385             }
 386         }
 387     }
 388 
 389     /**
 390      * {@inheritDoc}
 391      */
 392     @Override
 393     public void addSubInterfacesInfo(Content classInfoTree) {
 394         if (utils.isInterface(typeElement)) {
 395             Set<TypeElement> subInterfaces = classtree.allSubClasses(typeElement, false);
 396             if (!subInterfaces.isEmpty()) {
 397                 Content label = contents.subinterfacesLabel;
 398                 Content dt = HtmlTree.DT(label);
 399                 Content dl = HtmlTree.DL(dt);
 400                 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES,
 401                         subInterfaces));
 402                 classInfoTree.addContent(dl);
 403             }
 404         }
 405     }
 406 
 407     /**
 408      * {@inheritDoc}
 409      */
 410     @Override
 411     public void addInterfaceUsageInfo (Content classInfoTree) {
 412         if (!utils.isInterface(typeElement)) {
 413             return;
 414         }
 415         if (typeElement.getQualifiedName().contentEquals("java.lang.Cloneable") ||
 416                 typeElement.getQualifiedName().contentEquals("java.io.Serializable")) {
 417             return;   // Don't generate the list, too big

 418         }
 419         Set<TypeElement> implcl = classtree.implementingClasses(typeElement);
 420         if (!implcl.isEmpty()) {
 421             Content label = contents.implementingClassesLabel;
 422             Content dt = HtmlTree.DT(label);
 423             Content dl = HtmlTree.DL(dt);
 424             dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES,
 425                     implcl));
 426             classInfoTree.addContent(dl);
 427         }
 428     }
 429 
 430     /**
 431      * {@inheritDoc}
 432      */
 433     @Override
 434     public void addImplementedInterfacesInfo(Content classInfoTree) {
 435         SortedSet<TypeMirror> interfaces = new TreeSet<>(utils.makeTypeMirrorClassUseComparator());
 436         interfaces.addAll(utils.getAllInterfaces(typeElement));
 437         if (utils.isClass(typeElement) && !interfaces.isEmpty()) {




  54 /**
  55  * Generate the Class Information Page.
  56  *
  57  *  <p><b>This is NOT part of any supported API.
  58  *  If you write code that depends on this, you do so at your own risk.
  59  *  This code and its internal interfaces are subject to change or
  60  *  deletion without notice.</b>
  61  *
  62  * @see javax.lang.model.element.TypeElement
  63  * @see java.util.Collections
  64  * @see java.util.List
  65  * @see java.util.ArrayList
  66  * @see java.util.HashMap
  67  *
  68  * @author Atul M Dambalkar
  69  * @author Robert Field
  70  * @author Bhavesh Patel (Modified)
  71  */
  72 public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWriter {
  73 
  74     private static final Set<String> suppressSubtypesSet
  75             = Set.of("java.lang.Object",
  76                      "org.omg.CORBA.Object");
  77 
  78     private static final Set<String> suppressImplementingSet
  79             = Set.of( "java.lang.Cloneable",
  80                     "java.lang.constant.Constable",
  81                     "java.lang.constant.ConstantDesc",
  82                     "java.io.Serializable");
  83 
  84     protected final TypeElement typeElement;
  85 
  86     protected final ClassTree classtree;
  87 
  88     private final Navigation navBar;
  89 
  90     /**
  91      * @param configuration the configuration data for the doclet
  92      * @param typeElement the class being documented.
  93      * @param classTree the class tree for the given class.
  94      */
  95     public ClassWriterImpl(HtmlConfiguration configuration, TypeElement typeElement,
  96                            ClassTree classTree) {
  97         super(configuration, configuration.docPaths.forClass(typeElement));
  98         this.typeElement = typeElement;
  99         configuration.currentTypeElement = typeElement;
 100         this.classtree = classTree;
 101         this.navBar = new Navigation(typeElement, configuration, fixedNavDiv, PageMode.CLASS, path);
 102     }
 103 


 363 
 364     /**
 365      * {@inheritDoc}
 366      */
 367     @Override
 368     public void addTypeParamInfo(Content classInfoTree) {
 369         if (!utils.getTypeParamTrees(typeElement).isEmpty()) {
 370             Content typeParam = (new ParamTaglet()).getTagletOutput(typeElement,
 371                     getTagletWriterInstance(false));
 372             Content dl = HtmlTree.DL(typeParam);
 373             classInfoTree.addContent(dl);
 374         }
 375     }
 376 
 377     /**
 378      * {@inheritDoc}
 379      */
 380     @Override
 381     public void addSubClassInfo(Content classInfoTree) {
 382         if (utils.isClass(typeElement)) {
 383             for (String s : suppressSubtypesSet) {
 384                 if (typeElement.getQualifiedName().contentEquals(s)) {
 385                     return;    // Don't generate the list, too huge
 386                 }
 387             }
 388             Set<TypeElement> subclasses = classtree.directSubClasses(typeElement, false);
 389             if (!subclasses.isEmpty()) {
 390                 Content label = contents.subclassesLabel;
 391                 Content dt = HtmlTree.DT(label);
 392                 Content dl = HtmlTree.DL(dt);
 393                 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES,
 394                         subclasses));
 395                 classInfoTree.addContent(dl);
 396             }
 397         }
 398     }
 399 
 400     /**
 401      * {@inheritDoc}
 402      */
 403     @Override
 404     public void addSubInterfacesInfo(Content classInfoTree) {
 405         if (utils.isInterface(typeElement)) {
 406             Set<TypeElement> subInterfaces = classtree.allSubClasses(typeElement, false);
 407             if (!subInterfaces.isEmpty()) {
 408                 Content label = contents.subinterfacesLabel;
 409                 Content dt = HtmlTree.DT(label);
 410                 Content dl = HtmlTree.DL(dt);
 411                 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES,
 412                         subInterfaces));
 413                 classInfoTree.addContent(dl);
 414             }
 415         }
 416     }
 417 
 418     /**
 419      * {@inheritDoc}
 420      */
 421     @Override
 422     public void addInterfaceUsageInfo (Content classInfoTree) {
 423         if (!utils.isInterface(typeElement)) {
 424             return;
 425         }
 426         for (String s : suppressImplementingSet) {
 427             if (typeElement.getQualifiedName().contentEquals(s)) {
 428                 return;    // Don't generate the list, too huge
 429             }
 430         }
 431         Set<TypeElement> implcl = classtree.implementingClasses(typeElement);
 432         if (!implcl.isEmpty()) {
 433             Content label = contents.implementingClassesLabel;
 434             Content dt = HtmlTree.DT(label);
 435             Content dl = HtmlTree.DL(dt);
 436             dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES,
 437                     implcl));
 438             classInfoTree.addContent(dl);
 439         }
 440     }
 441 
 442     /**
 443      * {@inheritDoc}
 444      */
 445     @Override
 446     public void addImplementedInterfacesInfo(Content classInfoTree) {
 447         SortedSet<TypeMirror> interfaces = new TreeSet<>(utils.makeTypeMirrorClassUseComparator());
 448         interfaces.addAll(utils.getAllInterfaces(typeElement));
 449         if (utils.isClass(typeElement) && !interfaces.isEmpty()) {


< prev index next >