src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.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 field 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 FieldWriterImpl extends AbstractMemberWriter
    43     implements FieldWriter, MemberSummaryWriter {
    45     private boolean printedSummaryHeader = false;
    47     public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
    48         super(writer, classdoc);
    49     }
    51     public FieldWriterImpl(SubWriterHolderWriter writer) {
    52         super(writer);
    53     }
    55     /**
    56      * Write the fields summary header for the given class.
    57      *
    58      * @param classDoc the class the summary belongs to.
    59      */
    60     public void writeMemberSummaryHeader(ClassDoc classDoc) {
    61         printedSummaryHeader = true;
    62         writer.println("<!-- =========== FIELD SUMMARY =========== -->");
    63         writer.println();
    64         writer.printSummaryHeader(this, classDoc);
    65     }
    67     /**
    68      * Write the fields summary footer for the given class.
    69      *
    70      * @param classDoc the class the summary belongs to.
    71      */
    72     public void writeMemberSummaryFooter(ClassDoc classDoc) {
    73         writer.tableEnd();
    74         writer.space();
    75     }
    77     /**
    78      * Write the inherited fields 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 field, boolean isFirst, boolean isLast) {
    97         writer.printInheritedSummaryMember(this, classDoc, field, isFirst);
    98     }
   100     /**
   101      * Write the inherited fields 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     }
   109     /**
   110      * Write the header for the field documentation.
   111      *
   112      * @param classDoc the class that the fields belong to.
   113      */
   114     public void writeHeader(ClassDoc classDoc, String header) {
   115         writer.println();
   116         writer.println("<!-- ============ FIELD DETAIL =========== -->");
   117         writer.println();
   118         writer.anchor("field_detail");
   119         writer.printTableHeadingBackground(header);
   120         writer.println();
   121     }
   123     /**
   124      * Write the field header for the given field.
   125      *
   126      * @param field the field being documented.
   127      * @param isFirst the flag to indicate whether or not the field is the
   128      *        first to be documented.
   129      */
   130     public void writeFieldHeader(FieldDoc field, boolean isFirst) {
   131         if (! isFirst) {
   132             writer.printMemberHeader();
   133             writer.println("");
   134         }
   135         writer.anchor(field.name());
   136         writer.h3();
   137         writer.print(field.name());
   138         writer.h3End();
   139     }
   141     /**
   142      * Write the signature for the given field.
   143      *
   144      * @param field the field being documented.
   145      */
   146     public void writeSignature(FieldDoc field) {
   147         writer.pre();
   148         writer.writeAnnotationInfo(field);
   149         printModifiers(field);
   150         writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
   151             field.type()));
   152         print(' ');
   153         if (configuration().linksource) {
   154             writer.printSrcLink(field, field.name());
   155         } else {
   156             strong(field.name());
   157         }
   158         writer.preEnd();
   159         assert !writer.getMemberDetailsListPrinted();
   160     }
   162     /**
   163      * Write the deprecated output for the given field.
   164      *
   165      * @param field the field being documented.
   166      */
   167     public void writeDeprecated(FieldDoc field) {
   168         printDeprecated(field);
   169     }
   171     /**
   172      * Write the comments for the given field.
   173      *
   174      * @param field the field being documented.
   175      */
   176     public void writeComments(FieldDoc field) {
   177         ClassDoc holder = field.containingClass();
   178         if (field.inlineTags().length > 0) {
   179             writer.printMemberDetailsListStartTag();
   180             if (holder.equals(classdoc) ||
   181                 (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
   182                 writer.dd();
   183                 writer.printInlineComment(field);
   184                 writer.ddEnd();
   185             } else {
   186                 String classlink = writer.codeText(
   187                     writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
   188                         holder, field,
   189                         holder.isIncluded() ?
   190                             holder.typeName() : holder.qualifiedTypeName(),
   191                         false));
   192                 writer.dd();
   193                 writer.strong(configuration().getText(holder.isClass()?
   194                    "doclet.Description_From_Class" :
   195                     "doclet.Description_From_Interface", classlink));
   196                 writer.ddEnd();
   197                 writer.dd();
   198                 writer.printInlineComment(field);
   199                 writer.ddEnd();
   200             }
   201         }
   202     }
   204     /**
   205      * Write the tag output for the given field.
   206      *
   207      * @param field the field being documented.
   208      */
   209     public void writeTags(FieldDoc field) {
   210         writer.printTags(field);
   211     }
   213     /**
   214      * Write the field footer.
   215      */
   216     public void writeFieldFooter() {
   217         printMemberFooter();
   218     }
   220     /**
   221      * Write the footer for the field documentation.
   222      *
   223      * @param classDoc the class that the fields belong to.
   224      */
   225     public void writeFooter(ClassDoc classDoc) {
   226         //No footer to write for field documentation
   227     }
   229     /**
   230      * Close the writer.
   231      */
   232     public void close() throws IOException {
   233         writer.close();
   234     }
   236     public int getMemberKind() {
   237         return VisibleMemberMap.FIELDS;
   238     }
   240     public void printSummaryLabel() {
   241         writer.printText("doclet.Field_Summary");
   242     }
   244     public void printTableSummary() {
   245         writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
   246                 configuration().getText("doclet.Field_Summary"),
   247                 configuration().getText("doclet.fields")));
   248     }
   250     public void printSummaryTableHeader(ProgramElementDoc member) {
   251         String[] header = new String[] {
   252             writer.getModifierTypeHeader(),
   253             configuration().getText("doclet.0_and_1",
   254                     configuration().getText("doclet.Field"),
   255                     configuration().getText("doclet.Description"))
   256         };
   257         writer.summaryTableHeader(header, "col");
   258     }
   260     public void printSummaryAnchor(ClassDoc cd) {
   261         writer.anchor("field_summary");
   262     }
   264     public void printInheritedSummaryAnchor(ClassDoc cd) {
   265         writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd));
   266     }
   268     public void printInheritedSummaryLabel(ClassDoc cd) {
   269         String classlink = writer.getPreQualifiedClassLink(
   270             LinkInfoImpl.CONTEXT_MEMBER, cd, false);
   271         writer.strong();
   272         String key = cd.isClass()?
   273             "doclet.Fields_Inherited_From_Class" :
   274             "doclet.Fields_Inherited_From_Interface";
   275         writer.printText(key, classlink);
   276         writer.strongEnd();
   277     }
   279     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
   280         writer.strong();
   281         writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false);
   282         writer.strongEnd();
   283     }
   285     protected void writeInheritedSummaryLink(ClassDoc cd,
   286             ProgramElementDoc member) {
   287         writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
   288             member.name(), false);
   289     }
   291     protected void printSummaryType(ProgramElementDoc member) {
   292         FieldDoc field = (FieldDoc)member;
   293         printModifierAndType(field, field.type());
   294     }
   296     protected void writeDeprecatedLink(ProgramElementDoc member) {
   297         writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   298             (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
   299     }
   301     protected void printNavSummaryLink(ClassDoc cd, boolean link) {
   302         if (link) {
   303             writer.printHyperLink("", (cd == null)?
   304                         "field_summary":
   305                         "fields_inherited_from_class_" +
   306                         configuration().getClassName(cd),
   307                     configuration().getText("doclet.navField"));
   308         } else {
   309             writer.printText("doclet.navField");
   310         }
   311     }
   313     protected void printNavDetailLink(boolean link) {
   314         if (link) {
   315             writer.printHyperLink("", "field_detail",
   316                 configuration().getText("doclet.navField"));
   317         } else {
   318             writer.printText("doclet.navField");
   319         }
   320     }
   321 }

mercurial