src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.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/AnnotationTypeRequiredMemberWriterImpl.java	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,282 @@
     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.javadoc.*;
    1.34 +
    1.35 +import java.io.*;
    1.36 +
    1.37 +/**
    1.38 + * Writes annotation type required member documentation in HTML format.
    1.39 + *
    1.40 + * @author Jamie Ho
    1.41 + */
    1.42 +public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
    1.43 +    implements AnnotationTypeRequiredMemberWriter, MemberSummaryWriter {
    1.44 +
    1.45 +    /**
    1.46 +     * Construct a new AnnotationTypeRequiredMemberWriterImpl.
    1.47 +     *
    1.48 +     * @param writer         the writer that will write the output.
    1.49 +     * @param annotationType the AnnotationType that holds this member.
    1.50 +     */
    1.51 +    public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
    1.52 +        AnnotationTypeDoc annotationType) {
    1.53 +        super(writer, annotationType);
    1.54 +    }
    1.55 +
    1.56 +    /**
    1.57 +     * Write the annotation type member summary header for the given class.
    1.58 +     *
    1.59 +     * @param classDoc the class the summary belongs to.
    1.60 +     */
    1.61 +    public void writeMemberSummaryHeader(ClassDoc classDoc) {
    1.62 +        writer.println("<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->");
    1.63 +        writer.println();
    1.64 +        writer.printSummaryHeader(this, classDoc);
    1.65 +    }
    1.66 +
    1.67 +    /**
    1.68 +     * Write the annotation type member summary footer for the given class.
    1.69 +     *
    1.70 +     * @param classDoc the class the summary belongs to.
    1.71 +     */
    1.72 +    public void writeMemberSummaryFooter(ClassDoc classDoc) {
    1.73 +        writer.printSummaryFooter(this, classDoc);
    1.74 +    }
    1.75 +
    1.76 +    /**
    1.77 +     * {@inheritDoc}
    1.78 +     */
    1.79 +    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
    1.80 +        //Not appliable.
    1.81 +    }
    1.82 +
    1.83 +    /**
    1.84 +     * {@inheritDoc}
    1.85 +     */
    1.86 +    public void writeInheritedMemberSummary(ClassDoc classDoc,
    1.87 +        ProgramElementDoc member, boolean isFirst, boolean isLast) {
    1.88 +        //Not appliable.
    1.89 +    }
    1.90 +
    1.91 +    /**
    1.92 +     * {@inheritDoc}
    1.93 +     */
    1.94 +    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
    1.95 +        //Not appliable.
    1.96 +    }
    1.97 +
    1.98 +    /**
    1.99 +     * {@inheritDoc}
   1.100 +     */
   1.101 +    public void writeHeader(ClassDoc classDoc, String header) {
   1.102 +        writer.println();
   1.103 +        writer.println("<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->");
   1.104 +        writer.println();
   1.105 +        writer.anchor("annotation_type_element_detail");
   1.106 +        writer.printTableHeadingBackground(header);
   1.107 +        writer.println();
   1.108 +    }
   1.109 +
   1.110 +    /**
   1.111 +     * {@inheritDoc}
   1.112 +     */
   1.113 +    public void writeMemberHeader(MemberDoc member, boolean isFirst) {
   1.114 +        if (! isFirst) {
   1.115 +            writer.printMemberHeader();
   1.116 +            writer.println("");
   1.117 +        }
   1.118 +        writer.anchor(member.name() + ((ExecutableMemberDoc) member).signature());
   1.119 +        writer.h3();
   1.120 +        writer.print(member.name());
   1.121 +        writer.h3End();
   1.122 +    }
   1.123 +
   1.124 +    /**
   1.125 +     * {@inheritDoc}
   1.126 +     */
   1.127 +    public void writeSignature(MemberDoc member) {
   1.128 +        writer.pre();
   1.129 +        writer.writeAnnotationInfo(member);
   1.130 +        printModifiers(member);
   1.131 +        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
   1.132 +            getType(member)));
   1.133 +        print(' ');
   1.134 +        if (configuration().linksource) {
   1.135 +            writer.printSrcLink(member, member.name());
   1.136 +        } else {
   1.137 +            bold(member.name());
   1.138 +        }
   1.139 +        writer.preEnd();
   1.140 +        writer.dl();
   1.141 +    }
   1.142 +
   1.143 +    /**
   1.144 +     * {@inheritDoc}
   1.145 +     */
   1.146 +    public void writeComments(MemberDoc member) {
   1.147 +        if (member.inlineTags().length > 0) {
   1.148 +            writer.dd();
   1.149 +            writer.printInlineComment(member);
   1.150 +        }
   1.151 +    }
   1.152 +
   1.153 +    /**
   1.154 +     * Write the tag output for the given member.
   1.155 +     *
   1.156 +     * @param member the member being documented.
   1.157 +     */
   1.158 +    public void writeTags(MemberDoc member) {
   1.159 +        writer.printTags(member);
   1.160 +    }
   1.161 +
   1.162 +    /**
   1.163 +     * Write the annotation type member footer.
   1.164 +     */
   1.165 +    public void writeMemberFooter() {
   1.166 +        writer.dlEnd();
   1.167 +    }
   1.168 +
   1.169 +    /**
   1.170 +     * Write the footer for the annotation type member documentation.
   1.171 +     *
   1.172 +     * @param classDoc the class that the annotation type member belong to.
   1.173 +     */
   1.174 +    public void writeFooter(ClassDoc classDoc) {
   1.175 +        //No footer to write for annotation type member documentation
   1.176 +    }
   1.177 +
   1.178 +    /**
   1.179 +     * Close the writer.
   1.180 +     */
   1.181 +    public void close() throws IOException {
   1.182 +        writer.close();
   1.183 +    }
   1.184 +
   1.185 +    /**
   1.186 +     * {@inheritDoc}
   1.187 +     */
   1.188 +    public void printSummaryLabel(ClassDoc cd) {
   1.189 +        writer.boldText("doclet.Annotation_Type_Required_Member_Summary");
   1.190 +    }
   1.191 +
   1.192 +    /**
   1.193 +     * {@inheritDoc}
   1.194 +     */
   1.195 +    public void printSummaryAnchor(ClassDoc cd) {
   1.196 +        writer.anchor("annotation_type_required_element_summary");
   1.197 +    }
   1.198 +
   1.199 +    /**
   1.200 +     * {@inheritDoc}
   1.201 +     */
   1.202 +    public void printInheritedSummaryAnchor(ClassDoc cd) {
   1.203 +    }   // no such
   1.204 +
   1.205 +    /**
   1.206 +     * {@inheritDoc}
   1.207 +     */
   1.208 +    public void printInheritedSummaryLabel(ClassDoc cd) {
   1.209 +        // no such
   1.210 +    }
   1.211 +
   1.212 +    /**
   1.213 +     * {@inheritDoc}
   1.214 +     */
   1.215 +    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
   1.216 +        writer.bold();
   1.217 +        writer.printDocLink(context, (MemberDoc) member, member.name(), false);
   1.218 +        writer.boldEnd();
   1.219 +    }
   1.220 +
   1.221 +    /**
   1.222 +     * {@inheritDoc}
   1.223 +     */
   1.224 +    protected void writeInheritedSummaryLink(ClassDoc cd,
   1.225 +            ProgramElementDoc member) {
   1.226 +        //Not applicable.
   1.227 +    }
   1.228 +
   1.229 +    /**
   1.230 +     * {@inheritDoc}
   1.231 +     */
   1.232 +    protected void printSummaryType(ProgramElementDoc member) {
   1.233 +        MemberDoc m = (MemberDoc)member;
   1.234 +        printModifierAndType(m, getType(m));
   1.235 +    }
   1.236 +
   1.237 +    /**
   1.238 +     * {@inheritDoc}
   1.239 +     */
   1.240 +    protected void writeDeprecatedLink(ProgramElementDoc member) {
   1.241 +        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
   1.242 +            (MemberDoc) member, ((MemberDoc)member).qualifiedName(), false);
   1.243 +    }
   1.244 +
   1.245 +    /**
   1.246 +     * {@inheritDoc}
   1.247 +     */
   1.248 +    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
   1.249 +        if (link) {
   1.250 +            writer.printHyperLink("", "annotation_type_required_element_summary",
   1.251 +                    configuration().getText("doclet.navAnnotationTypeRequiredMember"));
   1.252 +        } else {
   1.253 +            writer.printText("doclet.navAnnotationTypeRequiredMember");
   1.254 +        }
   1.255 +    }
   1.256 +
   1.257 +    /**
   1.258 +     * {@inheritDoc}
   1.259 +     */
   1.260 +    protected void printNavDetailLink(boolean link) {
   1.261 +        if (link) {
   1.262 +            writer.printHyperLink("", "annotation_type_element_detail",
   1.263 +                configuration().getText("doclet.navAnnotationTypeMember"));
   1.264 +        } else {
   1.265 +            writer.printText("doclet.navAnnotationTypeMember");
   1.266 +        }
   1.267 +    }
   1.268 +
   1.269 +    /**
   1.270 +     * {@inheritDoc}
   1.271 +     */
   1.272 +    public void writeDeprecated(MemberDoc member) {
   1.273 +        print(((TagletOutputImpl)
   1.274 +            (new DeprecatedTaglet()).getTagletOutput(member,
   1.275 +            writer.getTagletWriterInstance(false))).toString());
   1.276 +    }
   1.277 +
   1.278 +    private Type getType(MemberDoc member) {
   1.279 +        if (member instanceof FieldDoc) {
   1.280 +            return ((FieldDoc) member).type();
   1.281 +        } else {
   1.282 +            return ((MethodDoc) member).returnType();
   1.283 +        }
   1.284 +    }
   1.285 +}

mercurial