Mon, 09 Mar 2009 23:53:41 -0700
Merge
1 /*
2 * Copyright 1997-2004 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 java.io.*;
30 import com.sun.javadoc.*;
31 import com.sun.tools.doclets.internal.toolkit.*;
32 import com.sun.tools.doclets.internal.toolkit.util.*;
34 /**
35 * Writes field documentation in HTML format.
36 *
37 * @author Robert Field
38 * @author Atul M Dambalkar
39 * @author Jamie Ho (rewrite)
40 */
41 public class FieldWriterImpl extends AbstractMemberWriter
42 implements FieldWriter, MemberSummaryWriter {
44 private boolean printedSummaryHeader = false;
46 public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
47 super(writer, classdoc);
48 }
50 public FieldWriterImpl(SubWriterHolderWriter writer) {
51 super(writer);
52 }
54 /**
55 * Write the fields summary header for the given class.
56 *
57 * @param classDoc the class the summary belongs to.
58 */
59 public void writeMemberSummaryHeader(ClassDoc classDoc) {
60 printedSummaryHeader = true;
61 writer.println("<!-- =========== FIELD SUMMARY =========== -->");
62 writer.println();
63 writer.printSummaryHeader(this, classDoc);
64 }
66 /**
67 * Write the fields summary footer for the given class.
68 *
69 * @param classDoc the class the summary belongs to.
70 */
71 public void writeMemberSummaryFooter(ClassDoc classDoc) {
72 writer.tableEnd();
73 writer.space();
74 }
76 /**
77 * Write the inherited fields summary header for the given class.
78 *
79 * @param classDoc the class the summary belongs to.
80 */
81 public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
82 if(! printedSummaryHeader){
83 //We don't want inherited summary to not be under heading.
84 writeMemberSummaryHeader(classDoc);
85 writeMemberSummaryFooter(classDoc);
86 printedSummaryHeader = true;
87 }
88 writer.printInheritedSummaryHeader(this, classDoc);
89 }
91 /**
92 * {@inheritDoc}
93 */
94 public void writeInheritedMemberSummary(ClassDoc classDoc,
95 ProgramElementDoc field, boolean isFirst, boolean isLast) {
96 writer.printInheritedSummaryMember(this, classDoc, field, isFirst);
97 }
99 /**
100 * Write the inherited fields summary footer for the given class.
101 *
102 * @param classDoc the class the summary belongs to.
103 */
104 public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
105 writer.printInheritedSummaryFooter(this, classDoc);
106 }
108 /**
109 * Write the header for the field documentation.
110 *
111 * @param classDoc the class that the fields belong to.
112 */
113 public void writeHeader(ClassDoc classDoc, String header) {
114 writer.println();
115 writer.println("<!-- ============ FIELD DETAIL =========== -->");
116 writer.println();
117 writer.anchor("field_detail");
118 writer.printTableHeadingBackground(header);
119 writer.println();
120 }
122 /**
123 * Write the field header for the given field.
124 *
125 * @param field the field being documented.
126 * @param isFirst the flag to indicate whether or not the field is the
127 * first to be documented.
128 */
129 public void writeFieldHeader(FieldDoc field, boolean isFirst) {
130 if (! isFirst) {
131 writer.printMemberHeader();
132 writer.println("");
133 }
134 writer.anchor(field.name());
135 writer.h3();
136 writer.print(field.name());
137 writer.h3End();
138 }
140 /**
141 * Write the signature for the given field.
142 *
143 * @param field the field being documented.
144 */
145 public void writeSignature(FieldDoc field) {
146 writer.pre();
147 writer.writeAnnotationInfo(field);
148 printModifiers(field);
149 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
150 field.type()));
151 print(' ');
152 if (configuration().linksource) {
153 writer.printSrcLink(field, field.name());
154 } else {
155 strong(field.name());
156 }
157 writer.preEnd();
158 assert !writer.getMemberDetailsListPrinted();
159 }
161 /**
162 * Write the deprecated output for the given field.
163 *
164 * @param field the field being documented.
165 */
166 public void writeDeprecated(FieldDoc field) {
167 printDeprecated(field);
168 }
170 /**
171 * Write the comments for the given field.
172 *
173 * @param field the field being documented.
174 */
175 public void writeComments(FieldDoc field) {
176 ClassDoc holder = field.containingClass();
177 if (field.inlineTags().length > 0) {
178 writer.printMemberDetailsListStartTag();
179 if (holder.equals(classdoc) ||
180 (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
181 writer.dd();
182 writer.printInlineComment(field);
183 writer.ddEnd();
184 } else {
185 String classlink = writer.codeText(
186 writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
187 holder, field,
188 holder.isIncluded() ?
189 holder.typeName() : holder.qualifiedTypeName(),
190 false));
191 writer.dd();
192 writer.strong(configuration().getText(holder.isClass()?
193 "doclet.Description_From_Class" :
194 "doclet.Description_From_Interface", classlink));
195 writer.ddEnd();
196 writer.dd();
197 writer.printInlineComment(field);
198 writer.ddEnd();
199 }
200 }
201 }
203 /**
204 * Write the tag output for the given field.
205 *
206 * @param field the field being documented.
207 */
208 public void writeTags(FieldDoc field) {
209 writer.printTags(field);
210 }
212 /**
213 * Write the field footer.
214 */
215 public void writeFieldFooter() {
216 printMemberFooter();
217 }
219 /**
220 * Write the footer for the field documentation.
221 *
222 * @param classDoc the class that the fields belong to.
223 */
224 public void writeFooter(ClassDoc classDoc) {
225 //No footer to write for field documentation
226 }
228 /**
229 * Close the writer.
230 */
231 public void close() throws IOException {
232 writer.close();
233 }
235 public int getMemberKind() {
236 return VisibleMemberMap.FIELDS;
237 }
239 public void printSummaryLabel(ClassDoc cd) {
240 writer.strongText("doclet.Field_Summary");
241 }
243 public void printSummaryAnchor(ClassDoc cd) {
244 writer.anchor("field_summary");
245 }
247 public void printInheritedSummaryAnchor(ClassDoc cd) {
248 writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd));
249 }
251 public void printInheritedSummaryLabel(ClassDoc cd) {
252 String classlink = writer.getPreQualifiedClassLink(
253 LinkInfoImpl.CONTEXT_MEMBER, cd, false);
254 writer.strong();
255 String key = cd.isClass()?
256 "doclet.Fields_Inherited_From_Class" :
257 "doclet.Fields_Inherited_From_Interface";
258 writer.printText(key, classlink);
259 writer.strongEnd();
260 }
262 protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
263 writer.strong();
264 writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false);
265 writer.strongEnd();
266 }
268 protected void writeInheritedSummaryLink(ClassDoc cd,
269 ProgramElementDoc member) {
270 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
271 member.name(), false);
272 }
274 protected void printSummaryType(ProgramElementDoc member) {
275 FieldDoc field = (FieldDoc)member;
276 printModifierAndType(field, field.type());
277 }
279 protected void writeDeprecatedLink(ProgramElementDoc member) {
280 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
281 (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
282 }
284 protected void printNavSummaryLink(ClassDoc cd, boolean link) {
285 if (link) {
286 writer.printHyperLink("", (cd == null)?
287 "field_summary":
288 "fields_inherited_from_class_" +
289 configuration().getClassName(cd),
290 configuration().getText("doclet.navField"));
291 } else {
292 writer.printText("doclet.navField");
293 }
294 }
296 protected void printNavDetailLink(boolean link) {
297 if (link) {
298 writer.printHyperLink("", "field_detail",
299 configuration().getText("doclet.navField"));
300 } else {
301 writer.printText("doclet.navField");
302 }
303 }
304 }