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

Tue, 18 Jun 2013 20:56:04 -0700

author
mfang
date
Tue, 18 Jun 2013 20:56:04 -0700
changeset 1841
792c40d5185a
parent 1747
df4f44800923
child 1935
8c55df2442c1
permissions
-rw-r--r--

8015657: jdk8 l10n resource file translation update 3
Reviewed-by: yhuang

     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * 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.formats.html.markup.*;
    32 import com.sun.tools.doclets.internal.toolkit.*;
    33 import com.sun.tools.doclets.internal.toolkit.util.*;
    35 /**
    36  * Writes field documentation in HTML format.
    37  *
    38  *  <p><b>This is NOT part of any supported API.
    39  *  If you write code that depends on this, you do so at your own risk.
    40  *  This code and its internal interfaces are subject to change or
    41  *  deletion without notice.</b>
    42  *
    43  * @author Robert Field
    44  * @author Atul M Dambalkar
    45  * @author Jamie Ho (rewrite)
    46  * @author Bhavesh Patel (Modified)
    47  */
    48 public class FieldWriterImpl extends AbstractMemberWriter
    49     implements FieldWriter, MemberSummaryWriter {
    51     public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
    52         super(writer, classdoc);
    53     }
    55     public FieldWriterImpl(SubWriterHolderWriter writer) {
    56         super(writer);
    57     }
    59     /**
    60      * {@inheritDoc}
    61      */
    62     public Content getMemberSummaryHeader(ClassDoc classDoc,
    63             Content memberSummaryTree) {
    64         memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY);
    65         Content memberTree = writer.getMemberTreeHeader();
    66         writer.addSummaryHeader(this, classDoc, memberTree);
    67         return memberTree;
    68     }
    70     /**
    71      * {@inheritDoc}
    72      */
    73     public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
    74             Content memberDetailsTree) {
    75         memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS);
    76         Content fieldDetailsTree = writer.getMemberTreeHeader();
    77         fieldDetailsTree.addContent(writer.getMarkerAnchor("field_detail"));
    78         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
    79                 writer.fieldDetailsLabel);
    80         fieldDetailsTree.addContent(heading);
    81         return fieldDetailsTree;
    82     }
    84     /**
    85      * {@inheritDoc}
    86      */
    87     public Content getFieldDocTreeHeader(FieldDoc field,
    88             Content fieldDetailsTree) {
    89         fieldDetailsTree.addContent(
    90                 writer.getMarkerAnchor(field.name()));
    91         Content fieldDocTree = writer.getMemberTreeHeader();
    92         Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
    93         heading.addContent(field.name());
    94         fieldDocTree.addContent(heading);
    95         return fieldDocTree;
    96     }
    98     /**
    99      * {@inheritDoc}
   100      */
   101     public Content getSignature(FieldDoc field) {
   102         Content pre = new HtmlTree(HtmlTag.PRE);
   103         writer.addAnnotationInfo(field, pre);
   104         addModifiers(field, pre);
   105         Content fieldlink = writer.getLink(new LinkInfoImpl(
   106                 configuration, LinkInfoImpl.Kind.MEMBER, field.type()));
   107         pre.addContent(fieldlink);
   108         pre.addContent(" ");
   109         if (configuration.linksource) {
   110             Content fieldName = new StringContent(field.name());
   111             writer.addSrcLink(field, fieldName, pre);
   112         } else {
   113             addName(field.name(), pre);
   114         }
   115         return pre;
   116     }
   118     /**
   119      * {@inheritDoc}
   120      */
   121     public void addDeprecated(FieldDoc field, Content fieldDocTree) {
   122         addDeprecatedInfo(field, fieldDocTree);
   123     }
   125     /**
   126      * {@inheritDoc}
   127      */
   128     public void addComments(FieldDoc field, Content fieldDocTree) {
   129         ClassDoc holder = field.containingClass();
   130         if (field.inlineTags().length > 0) {
   131             if (holder.equals(classdoc) ||
   132                     (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
   133                 writer.addInlineComment(field, fieldDocTree);
   134             } else {
   135                 Content link =
   136                         writer.getDocLink(LinkInfoImpl.Kind.FIELD_DOC_COPY,
   137                         holder, field,
   138                         holder.isIncluded() ?
   139                             holder.typeName() : holder.qualifiedTypeName(),
   140                             false);
   141                 Content codeLink = HtmlTree.CODE(link);
   142                 Content strong = HtmlTree.STRONG(holder.isClass()?
   143                    writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
   144                 strong.addContent(writer.getSpace());
   145                 strong.addContent(codeLink);
   146                 fieldDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
   147                 writer.addInlineComment(field, fieldDocTree);
   148             }
   149         }
   150     }
   152     /**
   153      * {@inheritDoc}
   154      */
   155     public void addTags(FieldDoc field, Content fieldDocTree) {
   156         writer.addTagsInfo(field, fieldDocTree);
   157     }
   159     /**
   160      * {@inheritDoc}
   161      */
   162     public Content getFieldDetails(Content fieldDetailsTree) {
   163         return getMemberTree(fieldDetailsTree);
   164     }
   166     /**
   167      * {@inheritDoc}
   168      */
   169     public Content getFieldDoc(Content fieldDocTree,
   170             boolean isLastContent) {
   171         return getMemberTree(fieldDocTree, isLastContent);
   172     }
   174     /**
   175      * Close the writer.
   176      */
   177     public void close() throws IOException {
   178         writer.close();
   179     }
   181     public int getMemberKind() {
   182         return VisibleMemberMap.FIELDS;
   183     }
   185     /**
   186      * {@inheritDoc}
   187      */
   188     public void addSummaryLabel(Content memberTree) {
   189         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
   190                 writer.getResource("doclet.Field_Summary"));
   191         memberTree.addContent(label);
   192     }
   194     /**
   195      * {@inheritDoc}
   196      */
   197     public String getTableSummary() {
   198         return configuration.getText("doclet.Member_Table_Summary",
   199                 configuration.getText("doclet.Field_Summary"),
   200                 configuration.getText("doclet.fields"));
   201     }
   203     /**
   204      * {@inheritDoc}
   205      */
   206     public Content getCaption() {
   207         return configuration.getResource("doclet.Fields");
   208     }
   210     /**
   211      * {@inheritDoc}
   212      */
   213     public String[] getSummaryTableHeader(ProgramElementDoc member) {
   214         String[] header = new String[] {
   215             writer.getModifierTypeHeader(),
   216             configuration.getText("doclet.0_and_1",
   217                     configuration.getText("doclet.Field"),
   218                     configuration.getText("doclet.Description"))
   219         };
   220         return header;
   221     }
   223     /**
   224      * {@inheritDoc}
   225      */
   226     public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
   227         memberTree.addContent(writer.getMarkerAnchor("field_summary"));
   228     }
   230     /**
   231      * {@inheritDoc}
   232      */
   233     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
   234         inheritedTree.addContent(writer.getMarkerAnchor(
   235                 "fields_inherited_from_class_" + configuration.getClassName(cd)));
   236     }
   238     /**
   239      * {@inheritDoc}
   240      */
   241     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
   242         Content classLink = writer.getPreQualifiedClassLink(
   243                 LinkInfoImpl.Kind.MEMBER, cd, false);
   244         Content label = new StringContent(cd.isClass() ?
   245             configuration.getText("doclet.Fields_Inherited_From_Class") :
   246             configuration.getText("doclet.Fields_Inherited_From_Interface"));
   247         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
   248                 label);
   249         labelHeading.addContent(writer.getSpace());
   250         labelHeading.addContent(classLink);
   251         inheritedTree.addContent(labelHeading);
   252     }
   254     /**
   255      * {@inheritDoc}
   256      */
   257     protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
   258             Content tdSummary) {
   259         Content strong = HtmlTree.STRONG(
   260                 writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false));
   261         Content code = HtmlTree.CODE(strong);
   262         tdSummary.addContent(code);
   263     }
   265     /**
   266      * {@inheritDoc}
   267      */
   268     protected void addInheritedSummaryLink(ClassDoc cd,
   269             ProgramElementDoc member, Content linksTree) {
   270         linksTree.addContent(
   271                 writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc)member,
   272                 member.name(), false));
   273     }
   275     /**
   276      * {@inheritDoc}
   277      */
   278     protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
   279         FieldDoc field = (FieldDoc)member;
   280         addModifierAndType(field, field.type(), tdSummaryType);
   281     }
   283     /**
   284      * {@inheritDoc}
   285      */
   286     protected Content getDeprecatedLink(ProgramElementDoc member) {
   287         return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
   288                 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
   289     }
   291     /**
   292      * {@inheritDoc}
   293      */
   294     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
   295         if (link) {
   296             return writer.getHyperLink((cd == null)?
   297                 "field_summary":
   298                 "fields_inherited_from_class_" +
   299                 configuration.getClassName(cd),
   300                 writer.getResource("doclet.navField"));
   301         } else {
   302             return writer.getResource("doclet.navField");
   303         }
   304     }
   306     /**
   307      * {@inheritDoc}
   308      */
   309     protected void addNavDetailLink(boolean link, Content liNav) {
   310         if (link) {
   311             liNav.addContent(writer.getHyperLink("field_detail",
   312                     writer.getResource("doclet.navField")));
   313         } else {
   314             liNav.addContent(writer.getResource("doclet.navField"));
   315         }
   316     }
   317 }

mercurial