001: /*
002: * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.doclets.formats.html;
027:
028: import com.sun.tools.doclets.internal.toolkit.*;
029: import com.sun.tools.doclets.internal.toolkit.taglets.*;
030: import com.sun.javadoc.*;
031:
032: import java.io.*;
033:
034: /**
035: * Writes annotation type required member documentation in HTML format.
036: *
037: * @author Jamie Ho
038: */
039: public class AnnotationTypeRequiredMemberWriterImpl extends
040: AbstractMemberWriter implements
041: AnnotationTypeRequiredMemberWriter, MemberSummaryWriter {
042:
043: /**
044: * Construct a new AnnotationTypeRequiredMemberWriterImpl.
045: *
046: * @param writer the writer that will write the output.
047: * @param annotationType the AnnotationType that holds this member.
048: */
049: public AnnotationTypeRequiredMemberWriterImpl(
050: SubWriterHolderWriter writer,
051: AnnotationTypeDoc annotationType) {
052: super (writer, annotationType);
053: }
054:
055: /**
056: * Write the annotation type member summary header for the given class.
057: *
058: * @param classDoc the class the summary belongs to.
059: */
060: public void writeMemberSummaryHeader(ClassDoc classDoc) {
061: writer
062: .println("<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->");
063: writer.println();
064: writer.printSummaryHeader(this , classDoc);
065: }
066:
067: /**
068: * Write the annotation type member summary footer for the given class.
069: *
070: * @param classDoc the class the summary belongs to.
071: */
072: public void writeMemberSummaryFooter(ClassDoc classDoc) {
073: writer.printSummaryFooter(this , classDoc);
074: }
075:
076: /**
077: * {@inheritDoc}
078: */
079: public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
080: //Not appliable.
081: }
082:
083: /**
084: * {@inheritDoc}
085: */
086: public void writeInheritedMemberSummary(ClassDoc classDoc,
087: ProgramElementDoc member, boolean isFirst, boolean isLast) {
088: //Not appliable.
089: }
090:
091: /**
092: * {@inheritDoc}
093: */
094: public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
095: //Not appliable.
096: }
097:
098: /**
099: * {@inheritDoc}
100: */
101: public void writeHeader(ClassDoc classDoc, String header) {
102: writer.println();
103: writer
104: .println("<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->");
105: writer.println();
106: writer.anchor("annotation_type_element_detail");
107: writer.printTableHeadingBackground(header);
108: writer.println();
109: }
110:
111: /**
112: * {@inheritDoc}
113: */
114: public void writeMemberHeader(MemberDoc member, boolean isFirst) {
115: if (!isFirst) {
116: writer.printMemberHeader();
117: writer.println("");
118: }
119: writer.anchor(member.name()
120: + ((ExecutableMemberDoc) member).signature());
121: writer.h3();
122: writer.print(member.name());
123: writer.h3End();
124: }
125:
126: /**
127: * {@inheritDoc}
128: */
129: public void writeSignature(MemberDoc member) {
130: writer.pre();
131: writer.writeAnnotationInfo(member);
132: printModifiers(member);
133: writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
134: getType(member)));
135: print(' ');
136: if (configuration().linksource) {
137: writer.printSrcLink(member, member.name());
138: } else {
139: bold(member.name());
140: }
141: writer.preEnd();
142: writer.dl();
143: }
144:
145: /**
146: * {@inheritDoc}
147: */
148: public void writeComments(MemberDoc member) {
149: if (member.inlineTags().length > 0) {
150: writer.dd();
151: writer.printInlineComment(member);
152: }
153: }
154:
155: /**
156: * Write the tag output for the given member.
157: *
158: * @param member the member being documented.
159: */
160: public void writeTags(MemberDoc member) {
161: writer.printTags(member);
162: }
163:
164: /**
165: * Write the annotation type member footer.
166: */
167: public void writeMemberFooter() {
168: writer.dlEnd();
169: }
170:
171: /**
172: * Write the footer for the annotation type member documentation.
173: *
174: * @param classDoc the class that the annotation type member belong to.
175: */
176: public void writeFooter(ClassDoc classDoc) {
177: //No footer to write for annotation type member documentation
178: }
179:
180: /**
181: * Close the writer.
182: */
183: public void close() throws IOException {
184: writer.close();
185: }
186:
187: /**
188: * {@inheritDoc}
189: */
190: public void printSummaryLabel(ClassDoc cd) {
191: writer
192: .boldText("doclet.Annotation_Type_Required_Member_Summary");
193: }
194:
195: /**
196: * {@inheritDoc}
197: */
198: public void printSummaryAnchor(ClassDoc cd) {
199: writer.anchor("annotation_type_required_element_summary");
200: }
201:
202: /**
203: * {@inheritDoc}
204: */
205: public void printInheritedSummaryAnchor(ClassDoc cd) {
206: } // no such
207:
208: /**
209: * {@inheritDoc}
210: */
211: public void printInheritedSummaryLabel(ClassDoc cd) {
212: // no such
213: }
214:
215: /**
216: * {@inheritDoc}
217: */
218: protected void writeSummaryLink(int context, ClassDoc cd,
219: ProgramElementDoc member) {
220: writer.bold();
221: writer.printDocLink(context, (MemberDoc) member, member.name(),
222: false);
223: writer.boldEnd();
224: }
225:
226: /**
227: * {@inheritDoc}
228: */
229: protected void writeInheritedSummaryLink(ClassDoc cd,
230: ProgramElementDoc member) {
231: //Not applicable.
232: }
233:
234: /**
235: * {@inheritDoc}
236: */
237: protected void printSummaryType(ProgramElementDoc member) {
238: MemberDoc m = (MemberDoc) member;
239: printModifierAndType(m, getType(m));
240: }
241:
242: /**
243: * {@inheritDoc}
244: */
245: protected void writeDeprecatedLink(ProgramElementDoc member) {
246: writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
247: (MemberDoc) member, ((MemberDoc) member)
248: .qualifiedName(), false);
249: }
250:
251: /**
252: * {@inheritDoc}
253: */
254: protected void printNavSummaryLink(ClassDoc cd, boolean link) {
255: if (link) {
256: writer.printHyperLink("",
257: "annotation_type_required_element_summary",
258: configuration().getText(
259: "doclet.navAnnotationTypeRequiredMember"));
260: } else {
261: writer.printText("doclet.navAnnotationTypeRequiredMember");
262: }
263: }
264:
265: /**
266: * {@inheritDoc}
267: */
268: protected void printNavDetailLink(boolean link) {
269: if (link) {
270: writer.printHyperLink("", "annotation_type_element_detail",
271: configuration().getText(
272: "doclet.navAnnotationTypeMember"));
273: } else {
274: writer.printText("doclet.navAnnotationTypeMember");
275: }
276: }
277:
278: /**
279: * {@inheritDoc}
280: */
281: public void writeDeprecated(MemberDoc member) {
282: print(((TagletOutputImpl) (new DeprecatedTaglet())
283: .getTagletOutput(member, writer
284: .getTagletWriterInstance(false))).toString());
285: }
286:
287: private Type getType(MemberDoc member) {
288: if (member instanceof FieldDoc) {
289: return ((FieldDoc) member).type();
290: } else {
291: return ((MethodDoc) member).returnType();
292: }
293: }
294: }
|