src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java

Sun, 11 Apr 2010 23:24:24 -0700

author
yhuang
date
Sun, 11 Apr 2010 23:24:24 -0700
changeset 539
06e06ec0d6f2
parent 243
edd944553131
child 554
9d9f26857129
permissions
-rw-r--r--

6875904: Java 7 message synchronization 1
Reviewed-by: ogino, faryad

     1 /*
     2  * Copyright 1997-2004 Sun Microsystems, Inc.  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.  Sun designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
    23  * have any questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import java.io.*;
    30 import com.sun.javadoc.*;
    31 import com.sun.tools.doclets.internal.toolkit.*;
    32 import com.sun.tools.doclets.internal.toolkit.util.*;
    34 /**
    35  * Writes nested class documentation in HTML format.
    36  *
    37  * @author Robert Field
    38  * @author Atul M Dambalkar
    39  * @author Jamie Ho (rewrite)
    40  * @author Bhavesh Patel (Modified)
    41  */
    42 public class NestedClassWriterImpl extends AbstractMemberWriter
    43     implements MemberSummaryWriter {
    45     private boolean printedSummaryHeader = false;
    47     public NestedClassWriterImpl(SubWriterHolderWriter writer,
    48             ClassDoc classdoc) {
    49         super(writer, classdoc);
    50     }
    52     public NestedClassWriterImpl(SubWriterHolderWriter writer) {
    53         super(writer);
    54     }
    56     /**
    57      * Write the classes summary header for the given class.
    58      *
    59      * @param classDoc the class the summary belongs to.
    60      */
    61     public void writeMemberSummaryHeader(ClassDoc classDoc) {
    62         printedSummaryHeader = true;
    63         writer.println("<!-- ======== NESTED CLASS SUMMARY ======== -->");
    64         writer.println();
    65         writer.printSummaryHeader(this, classDoc);
    66     }
    68     /**
    69      * Write the classes summary footer for the given class.
    70      *
    71      * @param classDoc the class the summary belongs to.
    72      */
    73     public void writeMemberSummaryFooter(ClassDoc classDoc) {
    74         writer.printSummaryFooter(this, classDoc);
    75     }
    77     /**
    78      * Write the inherited classes summary header for the given class.
    79      *
    80      * @param classDoc the class the summary belongs to.
    81      */
    82     public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
    83         if(! printedSummaryHeader){
    84             //We don't want inherited summary to not be under heading.
    85             writeMemberSummaryHeader(classDoc);
    86             writeMemberSummaryFooter(classDoc);
    87             printedSummaryHeader = true;
    88         }
    89         writer.printInheritedSummaryHeader(this, classDoc);
    90     }
    92     /**
    93      * {@inheritDoc}
    94      */
    95     public void writeInheritedMemberSummary(ClassDoc classDoc,
    96             ProgramElementDoc nestedClass, boolean isFirst, boolean isLast) {
    97         writer.printInheritedSummaryMember(this, classDoc, nestedClass, isFirst);
    98     }
   100     /**
   101      * Write the inherited classes summary footer for the given class.
   102      *
   103      * @param classDoc the class the summary belongs to.
   104      */
   105     public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
   106         writer.printInheritedSummaryFooter(this, classDoc);
   107         writer.println();
   108     }
   110     /**
   111      * Write the header for the nested class documentation.
   112      *
   113      * @param classDoc the class that the classes belong to.
   114      */
   115     public void writeHeader(ClassDoc classDoc, String header) {
   116         writer.anchor("nested class_detail");
   117         writer.printTableHeadingBackground(header);
   118     }
   120     /**
   121      * Write the nested class header for the given nested class.
   122      *
   123      * @param nestedClass the nested class being documented.
   124      * @param isFirst the flag to indicate whether or not the nested class is the
   125      *        first to be documented.
   126      */
   127     public void writeClassHeader(ClassDoc nestedClass, boolean isFirst) {
   128         if (! isFirst) {
   129             writer.printMemberHeader();
   130             writer.println("");
   131         }
   132         writer.anchor(nestedClass.name());
   133         writer.h3();
   134         writer.print(nestedClass.name());
   135         writer.h3End();
   136     }
   140     /**
   141      * Close the writer.
   142      */
   143     public void close() throws IOException {
   144         writer.close();
   145     }
   147     public int getMemberKind() {
   148         return VisibleMemberMap.INNERCLASSES;
   149     }
   151     public void printSummaryLabel() {
   152         writer.printText("doclet.Nested_Class_Summary");
   153     }
   155     public void printTableSummary() {
   156         writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
   157                 configuration().getText("doclet.Nested_Class_Summary"),
   158                 configuration().getText("doclet.nested_classes")));
   159     }
   161     public void printSummaryTableHeader(ProgramElementDoc member) {
   162         String[] header;
   163         if (member.isInterface()) {
   164             header = new String[] {
   165                 writer.getModifierTypeHeader(),
   166                 configuration().getText("doclet.0_and_1",
   167                         configuration().getText("doclet.Interface"),
   168                         configuration().getText("doclet.Description"))
   169             };
   170         }
   171         else {
   172             header = new String[] {
   173                 writer.getModifierTypeHeader(),
   174                 configuration().getText("doclet.0_and_1",
   175                         configuration().getText("doclet.Class"),
   176                         configuration().getText("doclet.Description"))
   177             };
   178         }
   179         writer.summaryTableHeader(header, "col");
   180     }
   182     public void printSummaryAnchor(ClassDoc cd) {
   183         writer.anchor("nested_class_summary");
   184     }
   186     public void printInheritedSummaryAnchor(ClassDoc cd) {
   187         writer.anchor("nested_classes_inherited_from_class_" +
   188                        cd.qualifiedName());
   189     }
   191     public void printInheritedSummaryLabel(ClassDoc cd) {
   192         String clslink = writer.getPreQualifiedClassLink(
   193             LinkInfoImpl.CONTEXT_MEMBER, cd, false);
   194         writer.strong();
   195         writer.printText(cd.isInterface() ?
   196             "doclet.Nested_Classes_Interface_Inherited_From_Interface" :
   197             "doclet.Nested_Classes_Interfaces_Inherited_From_Class",
   198             clslink);
   199         writer.strongEnd();
   200     }
   202     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
   203         writer.strong();
   204         writer.printLink(new LinkInfoImpl(context, (ClassDoc)member, false));
   205         writer.strongEnd();
   206     }
   208     protected void writeInheritedSummaryLink(ClassDoc cd,
   209             ProgramElementDoc member) {
   210         writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
   211             (ClassDoc)member, false));
   212     }
   214     protected void printSummaryType(ProgramElementDoc member) {
   215         ClassDoc cd = (ClassDoc)member;
   216         printModifierAndType(cd, null);
   217     }
   219     protected void printHeader(ClassDoc cd) {
   220         // N.A.
   221     }
   223     protected void printBodyHtmlEnd(ClassDoc cd) {
   224         // N.A.
   225     }
   227     protected void printMember(ProgramElementDoc member) {
   228         // N.A.
   229     }
   231     protected void writeDeprecatedLink(ProgramElementDoc member) {
   232         writer.printQualifiedClassLink(LinkInfoImpl.CONTEXT_MEMBER,
   233             (ClassDoc)member);
   234     }
   236     protected void printNavSummaryLink(ClassDoc cd, boolean link) {
   237         if (link) {
   238             writer.printHyperLink("", (cd == null) ? "nested_class_summary":
   239                     "nested_classes_inherited_from_class_" +
   240                 cd.qualifiedName(),
   241                 ConfigurationImpl.getInstance().getText("doclet.navNested"));
   242         } else {
   243             writer.printText("doclet.navNested");
   244         }
   245     }
   247     protected void printNavDetailLink(boolean link) {
   248     }
   250     protected void printMemberLink(ProgramElementDoc member) {
   251     }
   253     protected void printMembersSummaryLink(ClassDoc cd, ClassDoc icd,
   254                                            boolean link) {
   255         if (link) {
   256             writer.printHyperLink(cd.name() + ".html",
   257                 (cd == icd)?
   258                     "nested_class_summary":
   259                     "nested_classes_inherited_from_class_" +
   260                     icd.qualifiedName(),
   261                     ConfigurationImpl.getInstance().getText(
   262                         "doclet.Nested_Class_Summary"));
   263         } else {
   264             writer.printText("doclet.Nested_Class_Summary");
   265         }
   266     }
   267 }

mercurial