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

changeset 1
9a66ca7c79fa
child 182
47a62d8d98b4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,259 @@
     1.4 +/*
     1.5 + * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Sun designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Sun in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 + * have any questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.doclets.formats.html;
    1.30 +
    1.31 +import com.sun.tools.doclets.internal.toolkit.*;
    1.32 +import com.sun.tools.doclets.internal.toolkit.taglets.*;
    1.33 +import com.sun.tools.doclets.internal.toolkit.util.*;
    1.34 +import com.sun.javadoc.*;
    1.35 +
    1.36 +import java.io.*;
    1.37 +
    1.38 +/**
    1.39 + * Writes enum constant documentation in HTML format.
    1.40 + *
    1.41 + * @author Jamie Ho
    1.42 + */
    1.43 +public class EnumConstantWriterImpl extends AbstractMemberWriter
    1.44 +    implements EnumConstantWriter, MemberSummaryWriter {
    1.45 +
    1.46 +    private boolean printedSummaryHeader = false;
    1.47 +
    1.48 +    public EnumConstantWriterImpl(SubWriterHolderWriter writer,
    1.49 +        ClassDoc classdoc) {
    1.50 +        super(writer, classdoc);
    1.51 +    }
    1.52 +
    1.53 +    public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
    1.54 +        super(writer);
    1.55 +    }
    1.56 +
    1.57 +    /**
    1.58 +     * Write the enum constant summary header for the given class.
    1.59 +     *
    1.60 +     * @param classDoc the class the summary belongs to.
    1.61 +     */
    1.62 +    public void writeMemberSummaryHeader(ClassDoc classDoc) {
    1.63 +        printedSummaryHeader = true;
    1.64 +        writer.println("<!-- =========== ENUM CONSTANT SUMMARY =========== -->");
    1.65 +        writer.println();
    1.66 +        writer.printSummaryHeader(this, classDoc);
    1.67 +    }
    1.68 +
    1.69 +    /**
    1.70 +     * Write the enum constant summary footer for the given class.
    1.71 +     *
    1.72 +     * @param classDoc the class the summary belongs to.
    1.73 +     */
    1.74 +    public void writeMemberSummaryFooter(ClassDoc classDoc) {
    1.75 +        writer.printSummaryFooter(this, classDoc);
    1.76 +    }
    1.77 +
    1.78 +    /**
    1.79 +     * Write the inherited enum constant summary header for the given class.
    1.80 +     *
    1.81 +     * @param classDoc the class the summary belongs to.
    1.82 +     */
    1.83 +    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
    1.84 +        if(! printedSummaryHeader){
    1.85 +            //We don't want inherited summary to not be under heading.
    1.86 +            writeMemberSummaryHeader(classDoc);
    1.87 +            writeMemberSummaryFooter(classDoc);
    1.88 +            printedSummaryHeader = true;
    1.89 +        }
    1.90 +        writer.printInheritedSummaryHeader(this, classDoc);
    1.91 +    }
    1.92 +
    1.93 +    /**
    1.94 +     * {@inheritDoc}
    1.95 +     */
    1.96 +    public void writeInheritedMemberSummary(ClassDoc classDoc,
    1.97 +        ProgramElementDoc enumConstant, boolean isFirst, boolean isLast) {
    1.98 +        writer.printInheritedSummaryMember(this, classDoc, enumConstant, isFirst);
    1.99 +    }
   1.100 +
   1.101 +    /**
   1.102 +     * Write the inherited enum constant summary footer for the given class.
   1.103 +     *
   1.104 +     * @param classDoc the class the summary belongs to.
   1.105 +     */
   1.106 +    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
   1.107 +        writer.printInheritedSummaryFooter(this, classDoc);
   1.108 +    }
   1.109 +
   1.110 +    /**
   1.111 +     * {@inheritDoc}
   1.112 +     */
   1.113 +    public void writeHeader(ClassDoc classDoc, String header) {
   1.114 +        writer.println();
   1.115 +        writer.println("<!-- ============ ENUM CONSTANT DETAIL =========== -->");
   1.116 +        writer.println();
   1.117 +        writer.anchor("enum_constant_detail");
   1.118 +        writer.printTableHeadingBackground(header);
   1.119 +        writer.println();
   1.120 +    }
   1.121 +
   1.122 +    /**
   1.123 +     * {@inheritDoc}
   1.124 +     */
   1.125 +    public void writeEnumConstantHeader(FieldDoc enumConstant, boolean isFirst) {
   1.126 +        if (! isFirst) {
   1.127 +            writer.printMemberHeader();
   1.128 +            writer.println("");
   1.129 +        }
   1.130 +        writer.anchor(enumConstant.name());
   1.131 +        writer.h3();
   1.132 +        writer.print(enumConstant.name());
   1.133 +        writer.h3End();
   1.134 +    }
   1.135 +
   1.136 +    /**
   1.137 +     * {@inheritDoc}
   1.138 +     */
   1.139 +    public void writeSignature(FieldDoc enumConstant) {
   1.140 +        writer.pre();
   1.141 +        writer.writeAnnotationInfo(enumConstant);
   1.142 +        printModifiers(enumConstant);
   1.143 +        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
   1.144 +            enumConstant.type()));
   1.145 +        print(' ');
   1.146 +        if (configuration().linksource) {
   1.147 +            writer.printSrcLink(enumConstant, enumConstant.name());
   1.148 +        } else {
   1.149 +            bold(enumConstant.name());
   1.150 +        }
   1.151 +        writer.preEnd();
   1.152 +        writer.dl();
   1.153 +    }
   1.154 +
   1.155 +    /**
   1.156 +     * {@inheritDoc}
   1.157 +     */
   1.158 +    public void writeDeprecated(FieldDoc enumConstant) {
   1.159 +        print(((TagletOutputImpl)
   1.160 +            (new DeprecatedTaglet()).getTagletOutput(enumConstant,
   1.161 +            writer.getTagletWriterInstance(false))).toString());
   1.162 +    }
   1.163 +
   1.164 +    /**
   1.165 +     * {@inheritDoc}
   1.166 +     */
   1.167 +    public void writeComments(FieldDoc enumConstant) {
   1.168 +        if (enumConstant.inlineTags().length > 0) {
   1.169 +            writer.dd();
   1.170 +            writer.printInlineComment(enumConstant);
   1.171 +        }
   1.172 +    }
   1.173 +
   1.174 +    /**
   1.175 +     * {@inheritDoc}
   1.176 +     */
   1.177 +    public void writeTags(FieldDoc enumConstant) {
   1.178 +        writer.printTags(enumConstant);
   1.179 +    }
   1.180 +
   1.181 +    /**
   1.182 +     * {@inheritDoc}
   1.183 +     */
   1.184 +    public void writeEnumConstantFooter() {
   1.185 +        writer.dlEnd();
   1.186 +    }
   1.187 +
   1.188 +    /**
   1.189 +     * {@inheritDoc}
   1.190 +     */
   1.191 +    public void writeFooter(ClassDoc classDoc) {
   1.192 +        //No footer to write for enum constant documentation
   1.193 +    }
   1.194 +
   1.195 +    /**
   1.196 +     * {@inheritDoc}
   1.197 +     */
   1.198 +    public void close() throws IOException {
   1.199 +        writer.close();
   1.200 +    }
   1.201 +
   1.202 +    public int getMemberKind() {
   1.203 +        return VisibleMemberMap.ENUM_CONSTANTS;
   1.204 +    }
   1.205 +
   1.206 +    public void printSummaryLabel(ClassDoc cd) {
   1.207 +        writer.boldText("doclet.Enum_Constant_Summary");
   1.208 +    }
   1.209 +
   1.210 +    public void printSummaryAnchor(ClassDoc cd) {
   1.211 +        writer.anchor("enum_constant_summary");
   1.212 +    }
   1.213 +
   1.214 +    public void printInheritedSummaryAnchor(ClassDoc cd) {
   1.215 +    }   // no such
   1.216 +
   1.217 +    public void printInheritedSummaryLabel(ClassDoc cd) {
   1.218 +        // no such
   1.219 +    }
   1.220 +
   1.221 +    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
   1.222 +        writer.bold();
   1.223 +        writer.printDocLink(context, (MemberDoc) member, member.name(), false);
   1.224 +        writer.boldEnd();
   1.225 +    }
   1.226 +
   1.227 +    protected void writeInheritedSummaryLink(ClassDoc cd,
   1.228 +            ProgramElementDoc member) {
   1.229 +        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc)member,
   1.230 +            member.name(), false);
   1.231 +    }
   1.232 +
   1.233 +    protected void printSummaryType(ProgramElementDoc member) {
   1.234 +        //Not applicable.
   1.235 +    }
   1.236 +
   1.237 +    protected void writeDeprecatedLink(ProgramElementDoc member) {
   1.238 +        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   1.239 +            (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
   1.240 +    }
   1.241 +
   1.242 +    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
   1.243 +        if (link) {
   1.244 +            writer.printHyperLink("", (cd == null)?
   1.245 +                        "enum_constant_summary":
   1.246 +                        "enum_constants_inherited_from_class_" +
   1.247 +                        configuration().getClassName(cd),
   1.248 +                    configuration().getText("doclet.navEnum"));
   1.249 +        } else {
   1.250 +            writer.printText("doclet.navEnum");
   1.251 +        }
   1.252 +    }
   1.253 +
   1.254 +    protected void printNavDetailLink(boolean link) {
   1.255 +        if (link) {
   1.256 +            writer.printHyperLink("", "enum_constant_detail",
   1.257 +                configuration().getText("doclet.navEnum"));
   1.258 +        } else {
   1.259 +            writer.printText("doclet.navEnum");
   1.260 +        }
   1.261 +    }
   1.262 +}

mercurial