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

Thu, 02 Oct 2008 19:58:40 -0700

author
xdono
date
Thu, 02 Oct 2008 19:58:40 -0700
changeset 117
24a47c3062fe
parent 74
5a9172b251dd
child 182
47a62d8d98b4
permissions
-rw-r--r--

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

     1 /*
     2  * Copyright 2001-2008 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.util.*;
    30 import com.sun.javadoc.*;
    31 import java.io.*;
    32 import java.util.*;
    34 /**
    35  * Write the Constants Summary Page in HTML format.
    36  *
    37  * @author Jamie Ho
    38  * @since 1.4
    39  */
    40 public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
    41         implements ConstantsSummaryWriter {
    43     /**
    44      * The configuration used in this run of the standard doclet.
    45      */
    46     ConfigurationImpl configuration;
    48     /**
    49      * The current class being documented.
    50      */
    51     private ClassDoc currentClassDoc;
    53     /**
    54      * Construct a ConstantsSummaryWriter.
    55      * @param configuration the configuration used in this run
    56      *        of the standard doclet.
    57      */
    58     public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
    59             throws IOException {
    60         super(configuration, ConfigurationImpl.CONSTANTS_FILE_NAME);
    61         this.configuration = configuration;
    62     }
    64     /**
    65      * {@inheritDoc}
    66      */
    67     public void writeHeader() {
    68         printHtmlHeader(configuration.getText("doclet.Constants_Summary"),
    69             null, true);
    70         printTop();
    71         navLinks(true);
    72         hr();
    74         center();
    75         h1(); printText("doclet.Constants_Summary"); h1End();
    76         centerEnd();
    78         hr(4, "noshade");
    79     }
    81     /**
    82      * {@inheritDoc}
    83      */
    84     public void writeFooter() {
    85         hr();
    86         navLinks(false);
    87         printBottom();
    88         printBodyHtmlEnd();
    89     }
    91     /**
    92      * {@inheritDoc}
    93      */
    94     public void writeContentsHeader() {
    95         bold(configuration.getText("doclet.Contents"));
    96         ul();
    97     }
    99     /**
   100      * {@inheritDoc}
   101      */
   102     public void writeContentsFooter() {
   103         ulEnd();
   104         println();
   105     }
   107     /**
   108      * {@inheritDoc}
   109      */
   110     public void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set<String> printedPackageHeaders) {
   111         String packageName = pkg.name();
   112         //add link to summary
   113         li();
   114         if (packageName.length() == 0) {
   115             printHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
   116                            DocletConstants.DEFAULT_PACKAGE_NAME);
   117         } else {
   118             printHyperLink("#" + parsedPackageName, parsedPackageName + ".*");
   119             printedPackageHeaders.add(parsedPackageName);
   120         }
   121         println();
   122     }
   124     /**
   125      * {@inheritDoc}
   126      */
   127     public void writeConstantMembersHeader(ClassDoc cd) {
   128         //generate links backward only to public classes.
   129         String classlink = (cd.isPublic() || cd.isProtected())?
   130             getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
   131                 false)) :
   132             cd.qualifiedName();
   133         String name = cd.containingPackage().name();
   134         if (name.length() > 0) {
   135             writeClassName(name + "." + classlink);
   136         } else {
   137             writeClassName(classlink);
   138         }
   139     }
   141     /**
   142      * {@inheritDoc}
   143      */
   144     public void writeConstantMembersFooter(ClassDoc cd) {
   145         tableFooter(false);
   146         p();
   147     }
   149     /**
   150      * Print the class name in the table heading.
   151      * @param classStr the heading to print.
   152      */
   153     protected void writeClassName(String classStr) {
   154         table(1, 3, 0);
   155         trBgcolorStyle("#EEEEFF", "TableSubHeadingColor");
   156         thAlignColspan("left", 3);
   157         write(classStr);
   158         thEnd();
   159         trEnd();
   160     }
   162     private void tableFooter(boolean isHeader) {
   163         fontEnd();
   164         if (isHeader) {
   165             thEnd();
   166         } else {
   167             tdEnd();
   168         }
   169         trEnd();
   170         tableEnd();
   171         p();
   172     }
   174     /**
   175      * {@inheritDoc}
   176      */
   177     public void writePackageName(PackageDoc pkg, String parsedPackageName) {
   178         String pkgname;
   179         if (parsedPackageName.length() == 0) {
   180             anchor(DocletConstants.UNNAMED_PACKAGE_ANCHOR);
   181             pkgname = DocletConstants.DEFAULT_PACKAGE_NAME;
   182         } else {
   183             anchor(parsedPackageName);
   184             pkgname = parsedPackageName;
   185         }
   186         table(1, "100%", 3, 0);
   187         trBgcolorStyle("#CCCCFF", "TableHeadingColor");
   188         thAlign("left");
   189         font("+2");
   190         write(pkgname + ".*");
   191         tableFooter(true);
   192     }
   194     /**
   195      * {@inheritDoc}
   196      */
   197     public void writeConstantMembers(ClassDoc cd, List fields) {
   198         currentClassDoc = cd;
   199         for (int i = 0; i < fields.size(); ++i) {
   200             writeConstantMember((FieldDoc)(fields.get(i)));
   201         }
   202     }
   204     private void writeConstantMember(FieldDoc member) {
   205         trBgcolorStyle("white", "TableRowColor");
   206         anchor(currentClassDoc.qualifiedName() + "." + member.name());
   207         writeTypeColumn(member);
   208         writeNameColumn(member);
   209         writeValue(member);
   210         trEnd();
   211     }
   213     private void writeTypeColumn(FieldDoc member) {
   214         tdAlign("right");
   215         font("-1");
   216         code();
   217         StringTokenizer mods = new StringTokenizer(member.modifiers());
   218         while(mods.hasMoreTokens()) {
   219             print(mods.nextToken() + "&nbsp;");
   220         }
   221         printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY,
   222             member.type()));
   223         codeEnd();
   224         fontEnd();
   225         tdEnd();
   226     }
   228     private void writeNameColumn(FieldDoc member) {
   229         tdAlign("left");
   230         code();
   231         printDocLink(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member,
   232             member.name(), false);
   233         codeEnd();
   234         tdEnd();
   235     }
   237     private void writeValue(FieldDoc member) {
   238         tdAlign("right");
   239         code();
   240         print(Util.escapeHtmlChars(member.constantValueExpression()));
   241         codeEnd();
   242         tdEnd();
   243     }
   244 }

mercurial