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

Mon, 15 Dec 2008 16:55:33 -0800

author
xdono
date
Mon, 15 Dec 2008 16:55:33 -0800
changeset 174
fdfed22db054
parent 1
9a66ca7c79fa
child 182
47a62d8d98b4
permissions
-rw-r--r--

6785258: Update copyright year
Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008
Reviewed-by: katleman, ohair, tbell

     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 com.sun.tools.doclets.internal.toolkit.*;
    29 import com.sun.tools.doclets.internal.toolkit.taglets.*;
    30 import com.sun.tools.doclets.internal.toolkit.util.*;
    31 import com.sun.javadoc.*;
    33 import java.io.*;
    35 /**
    36  * Writes field documentation in HTML format.
    37  *
    38  * @author Robert Field
    39  * @author Atul M Dambalkar
    40  * @author Jamie Ho (rewrite)
    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             bold(field.name());
   157         }
   158         writer.preEnd();
   159         writer.dl();
   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         print(((TagletOutputImpl)
   169             (new DeprecatedTaglet()).getTagletOutput(field,
   170             writer.getTagletWriterInstance(false))).toString());
   171     }
   173     /**
   174      * Write the comments for the given field.
   175      *
   176      * @param field the field being documented.
   177      */
   178     public void writeComments(FieldDoc field) {
   179         ClassDoc holder = field.containingClass();
   180         if (field.inlineTags().length > 0) {
   181             if (holder.equals(classdoc) ||
   182                 (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
   183                 writer.dd();
   184                 writer.printInlineComment(field);
   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.bold(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             }
   200         }
   201     }
   203     /**
   204      * Write the tag output for the given field.
   205      *
   206      * @param field the field being documented.
   207      */
   208     public void writeTags(FieldDoc field) {
   209         writer.printTags(field);
   210     }
   212     /**
   213      * Write the field footer.
   214      */
   215     public void writeFieldFooter() {
   216         writer.dlEnd();
   217     }
   219     /**
   220      * Write the footer for the field documentation.
   221      *
   222      * @param classDoc the class that the fields belong to.
   223      */
   224     public void writeFooter(ClassDoc classDoc) {
   225         //No footer to write for field documentation
   226     }
   228     /**
   229      * Close the writer.
   230      */
   231     public void close() throws IOException {
   232         writer.close();
   233     }
   235     public int getMemberKind() {
   236         return VisibleMemberMap.FIELDS;
   237     }
   239     public void printSummaryLabel(ClassDoc cd) {
   240         writer.boldText("doclet.Field_Summary");
   241     }
   243     public void printSummaryAnchor(ClassDoc cd) {
   244         writer.anchor("field_summary");
   245     }
   247     public void printInheritedSummaryAnchor(ClassDoc cd) {
   248         writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd));
   249     }
   251     public void printInheritedSummaryLabel(ClassDoc cd) {
   252         String classlink = writer.getPreQualifiedClassLink(
   253             LinkInfoImpl.CONTEXT_MEMBER, cd, false);
   254         writer.bold();
   255         String key = cd.isClass()?
   256             "doclet.Fields_Inherited_From_Class" :
   257             "doclet.Fields_Inherited_From_Interface";
   258         writer.printText(key, classlink);
   259         writer.boldEnd();
   260     }
   262     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
   263         writer.bold();
   264         writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false);
   265         writer.boldEnd();
   266     }
   268     protected void writeInheritedSummaryLink(ClassDoc cd,
   269             ProgramElementDoc member) {
   270         writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
   271             member.name(), false);
   272     }
   274     protected void printSummaryType(ProgramElementDoc member) {
   275         FieldDoc field = (FieldDoc)member;
   276         printModifierAndType(field, field.type());
   277     }
   279     protected void writeDeprecatedLink(ProgramElementDoc member) {
   280         writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   281             (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
   282     }
   284     protected void printNavSummaryLink(ClassDoc cd, boolean link) {
   285         if (link) {
   286             writer.printHyperLink("", (cd == null)?
   287                         "field_summary":
   288                         "fields_inherited_from_class_" +
   289                         configuration().getClassName(cd),
   290                     configuration().getText("doclet.navField"));
   291         } else {
   292             writer.printText("doclet.navField");
   293         }
   294     }
   296     protected void printNavDetailLink(boolean link) {
   297         if (link) {
   298             writer.printHyperLink("", "field_detail",
   299                 configuration().getText("doclet.navField"));
   300         } else {
   301             writer.printText("doclet.navField");
   302         }
   303     }
   304 }

mercurial