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.tools.doclets.internal.toolkit.util.*;
031: import com.sun.javadoc.*;
032:
033: import java.io.*;
034:
035: /**
036: * Writes enum constant documentation in HTML format.
037: *
038: * @author Jamie Ho
039: */
040: public class EnumConstantWriterImpl extends AbstractMemberWriter
041: implements EnumConstantWriter, MemberSummaryWriter {
042:
043: private boolean printedSummaryHeader = false;
044:
045: public EnumConstantWriterImpl(SubWriterHolderWriter writer,
046: ClassDoc classdoc) {
047: super (writer, classdoc);
048: }
049:
050: public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
051: super (writer);
052: }
053:
054: /**
055: * Write the enum constant summary header for the given class.
056: *
057: * @param classDoc the class the summary belongs to.
058: */
059: public void writeMemberSummaryHeader(ClassDoc classDoc) {
060: printedSummaryHeader = true;
061: writer
062: .println("<!-- =========== ENUM CONSTANT SUMMARY =========== -->");
063: writer.println();
064: writer.printSummaryHeader(this , classDoc);
065: }
066:
067: /**
068: * Write the enum constant 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: * Write the inherited enum constant summary header for the given class.
078: *
079: * @param classDoc the class the summary belongs to.
080: */
081: public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
082: if (!printedSummaryHeader) {
083: //We don't want inherited summary to not be under heading.
084: writeMemberSummaryHeader(classDoc);
085: writeMemberSummaryFooter(classDoc);
086: printedSummaryHeader = true;
087: }
088: writer.printInheritedSummaryHeader(this , classDoc);
089: }
090:
091: /**
092: * {@inheritDoc}
093: */
094: public void writeInheritedMemberSummary(ClassDoc classDoc,
095: ProgramElementDoc enumConstant, boolean isFirst,
096: boolean isLast) {
097: writer.printInheritedSummaryMember(this , classDoc,
098: enumConstant, isFirst);
099: }
100:
101: /**
102: * Write the inherited enum constant summary footer for the given class.
103: *
104: * @param classDoc the class the summary belongs to.
105: */
106: public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
107: writer.printInheritedSummaryFooter(this , classDoc);
108: }
109:
110: /**
111: * {@inheritDoc}
112: */
113: public void writeHeader(ClassDoc classDoc, String header) {
114: writer.println();
115: writer
116: .println("<!-- ============ ENUM CONSTANT DETAIL =========== -->");
117: writer.println();
118: writer.anchor("enum_constant_detail");
119: writer.printTableHeadingBackground(header);
120: writer.println();
121: }
122:
123: /**
124: * {@inheritDoc}
125: */
126: public void writeEnumConstantHeader(FieldDoc enumConstant,
127: boolean isFirst) {
128: if (!isFirst) {
129: writer.printMemberHeader();
130: writer.println("");
131: }
132: writer.anchor(enumConstant.name());
133: writer.h3();
134: writer.print(enumConstant.name());
135: writer.h3End();
136: }
137:
138: /**
139: * {@inheritDoc}
140: */
141: public void writeSignature(FieldDoc enumConstant) {
142: writer.pre();
143: writer.writeAnnotationInfo(enumConstant);
144: printModifiers(enumConstant);
145: writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
146: enumConstant.type()));
147: print(' ');
148: if (configuration().linksource) {
149: writer.printSrcLink(enumConstant, enumConstant.name());
150: } else {
151: bold(enumConstant.name());
152: }
153: writer.preEnd();
154: writer.dl();
155: }
156:
157: /**
158: * {@inheritDoc}
159: */
160: public void writeDeprecated(FieldDoc enumConstant) {
161: print(((TagletOutputImpl) (new DeprecatedTaglet())
162: .getTagletOutput(enumConstant, writer
163: .getTagletWriterInstance(false))).toString());
164: }
165:
166: /**
167: * {@inheritDoc}
168: */
169: public void writeComments(FieldDoc enumConstant) {
170: if (enumConstant.inlineTags().length > 0) {
171: writer.dd();
172: writer.printInlineComment(enumConstant);
173: }
174: }
175:
176: /**
177: * {@inheritDoc}
178: */
179: public void writeTags(FieldDoc enumConstant) {
180: writer.printTags(enumConstant);
181: }
182:
183: /**
184: * {@inheritDoc}
185: */
186: public void writeEnumConstantFooter() {
187: writer.dlEnd();
188: }
189:
190: /**
191: * {@inheritDoc}
192: */
193: public void writeFooter(ClassDoc classDoc) {
194: //No footer to write for enum constant documentation
195: }
196:
197: /**
198: * {@inheritDoc}
199: */
200: public void close() throws IOException {
201: writer.close();
202: }
203:
204: public int getMemberKind() {
205: return VisibleMemberMap.ENUM_CONSTANTS;
206: }
207:
208: public void printSummaryLabel(ClassDoc cd) {
209: writer.boldText("doclet.Enum_Constant_Summary");
210: }
211:
212: public void printSummaryAnchor(ClassDoc cd) {
213: writer.anchor("enum_constant_summary");
214: }
215:
216: public void printInheritedSummaryAnchor(ClassDoc cd) {
217: } // no such
218:
219: public void printInheritedSummaryLabel(ClassDoc cd) {
220: // no such
221: }
222:
223: protected void writeSummaryLink(int context, ClassDoc cd,
224: ProgramElementDoc member) {
225: writer.bold();
226: writer.printDocLink(context, (MemberDoc) member, member.name(),
227: false);
228: writer.boldEnd();
229: }
230:
231: protected void writeInheritedSummaryLink(ClassDoc cd,
232: ProgramElementDoc member) {
233: writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
234: (MemberDoc) member, member.name(), false);
235: }
236:
237: protected void printSummaryType(ProgramElementDoc member) {
238: //Not applicable.
239: }
240:
241: protected void writeDeprecatedLink(ProgramElementDoc member) {
242: writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
243: (MemberDoc) member,
244: ((FieldDoc) member).qualifiedName(), false);
245: }
246:
247: protected void printNavSummaryLink(ClassDoc cd, boolean link) {
248: if (link) {
249: writer.printHyperLink("",
250: (cd == null) ? "enum_constant_summary"
251: : "enum_constants_inherited_from_class_"
252: + configuration().getClassName(cd),
253: configuration().getText("doclet.navEnum"));
254: } else {
255: writer.printText("doclet.navEnum");
256: }
257: }
258:
259: protected void printNavDetailLink(boolean link) {
260: if (link) {
261: writer.printHyperLink("", "enum_constant_detail",
262: configuration().getText("doclet.navEnum"));
263: } else {
264: writer.printText("doclet.navEnum");
265: }
266: }
267: }
|