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

changeset 766
90af8d87741f
parent 554
9d9f26857129
child 798
4868a36f6fd8
equal deleted inserted replaced
758:bcbc86cc5b31 766:90af8d87741f
26 package com.sun.tools.doclets.formats.html; 26 package com.sun.tools.doclets.formats.html;
27 27
28 import java.io.*; 28 import java.io.*;
29 29
30 import com.sun.javadoc.*; 30 import com.sun.javadoc.*;
31 import com.sun.tools.doclets.formats.html.markup.*;
31 import com.sun.tools.doclets.internal.toolkit.*; 32 import com.sun.tools.doclets.internal.toolkit.*;
32 import com.sun.tools.doclets.internal.toolkit.util.*; 33 import com.sun.tools.doclets.internal.toolkit.util.*;
33 34
34 /** 35 /**
35 * Writes field documentation in HTML format. 36 * Writes field documentation in HTML format.
40 * @author Bhavesh Patel (Modified) 41 * @author Bhavesh Patel (Modified)
41 */ 42 */
42 public class FieldWriterImpl extends AbstractMemberWriter 43 public class FieldWriterImpl extends AbstractMemberWriter
43 implements FieldWriter, MemberSummaryWriter { 44 implements FieldWriter, MemberSummaryWriter {
44 45
45 private boolean printedSummaryHeader = false;
46
47 public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) { 46 public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
48 super(writer, classdoc); 47 super(writer, classdoc);
49 } 48 }
50 49
51 public FieldWriterImpl(SubWriterHolderWriter writer) { 50 public FieldWriterImpl(SubWriterHolderWriter writer) {
52 super(writer); 51 super(writer);
53 } 52 }
54 53
55 /** 54 /**
56 * Write the fields summary header for the given class. 55 * {@inheritDoc}
57 * 56 */
58 * @param classDoc the class the summary belongs to. 57 public Content getMemberSummaryHeader(ClassDoc classDoc,
59 */ 58 Content memberSummaryTree) {
60 public void writeMemberSummaryHeader(ClassDoc classDoc) { 59 memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY);
61 printedSummaryHeader = true; 60 Content memberTree = writer.getMemberTreeHeader();
62 writer.println("<!-- =========== FIELD SUMMARY =========== -->"); 61 writer.addSummaryHeader(this, classDoc, memberTree);
63 writer.println(); 62 return memberTree;
64 writer.printSummaryHeader(this, classDoc); 63 }
65 } 64
66 65 /**
67 /** 66 * {@inheritDoc}
68 * Write the fields summary footer for the given class. 67 */
69 * 68 public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
70 * @param classDoc the class the summary belongs to. 69 Content memberDetailsTree) {
71 */ 70 memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS);
72 public void writeMemberSummaryFooter(ClassDoc classDoc) { 71 Content fieldDetailsTree = writer.getMemberTreeHeader();
73 writer.tableEnd(); 72 fieldDetailsTree.addContent(writer.getMarkerAnchor("field_detail"));
74 writer.space(); 73 Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
75 } 74 writer.fieldDetailsLabel);
76 75 fieldDetailsTree.addContent(heading);
77 /** 76 return fieldDetailsTree;
78 * Write the inherited fields summary header for the given class. 77 }
79 * 78
80 * @param classDoc the class the summary belongs to. 79 /**
81 */ 80 * {@inheritDoc}
82 public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) { 81 */
83 if(! printedSummaryHeader){ 82 public Content getFieldDocTreeHeader(FieldDoc field,
84 //We don't want inherited summary to not be under heading. 83 Content fieldDetailsTree) {
85 writeMemberSummaryHeader(classDoc); 84 fieldDetailsTree.addContent(
86 writeMemberSummaryFooter(classDoc); 85 writer.getMarkerAnchor(field.name()));
87 printedSummaryHeader = true; 86 Content fieldDocTree = writer.getMemberTreeHeader();
87 Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
88 heading.addContent(field.name());
89 fieldDocTree.addContent(heading);
90 return fieldDocTree;
91 }
92
93 /**
94 * {@inheritDoc}
95 */
96 public Content getSignature(FieldDoc field) {
97 Content pre = new HtmlTree(HtmlTag.PRE);
98 writer.addAnnotationInfo(field, pre);
99 addModifiers(field, pre);
100 Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
101 field.type())));
102 pre.addContent(fieldlink);
103 pre.addContent(" ");
104 if (configuration().linksource) {
105 Content fieldName = new StringContent(field.name());
106 writer.addSrcLink(field, fieldName, pre);
107 } else {
108 addName(field.name(), pre);
88 } 109 }
89 writer.printInheritedSummaryHeader(this, classDoc); 110 return pre;
90 } 111 }
91 112
92 /** 113 /**
93 * {@inheritDoc} 114 * {@inheritDoc}
94 */ 115 */
95 public void writeInheritedMemberSummary(ClassDoc classDoc, 116 public void addDeprecated(FieldDoc field, Content fieldDocTree) {
96 ProgramElementDoc field, boolean isFirst, boolean isLast) { 117 addDeprecatedInfo(field, fieldDocTree);
97 writer.printInheritedSummaryMember(this, classDoc, field, isFirst); 118 }
98 } 119
99 120 /**
100 /** 121 * {@inheritDoc}
101 * Write the inherited fields summary footer for the given class. 122 */
102 * 123 public void addComments(FieldDoc field, Content fieldDocTree) {
103 * @param classDoc the class the summary belongs to.
104 */
105 public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
106 writer.printInheritedSummaryFooter(this, classDoc);
107 }
108
109 /**
110 * Write the header for the field documentation.
111 *
112 * @param classDoc the class that the fields belong to.
113 */
114 public void writeHeader(ClassDoc classDoc, String header) {
115 writer.println();
116 writer.println("<!-- ============ FIELD DETAIL =========== -->");
117 writer.println();
118 writer.anchor("field_detail");
119 writer.printTableHeadingBackground(header);
120 writer.println();
121 }
122
123 /**
124 * Write the field header for the given field.
125 *
126 * @param field the field being documented.
127 * @param isFirst the flag to indicate whether or not the field is the
128 * first to be documented.
129 */
130 public void writeFieldHeader(FieldDoc field, boolean isFirst) {
131 if (! isFirst) {
132 writer.printMemberHeader();
133 writer.println("");
134 }
135 writer.anchor(field.name());
136 writer.h3();
137 writer.print(field.name());
138 writer.h3End();
139 }
140
141 /**
142 * Write the signature for the given field.
143 *
144 * @param field the field being documented.
145 */
146 public void writeSignature(FieldDoc field) {
147 writer.pre();
148 writer.writeAnnotationInfo(field);
149 printModifiers(field);
150 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
151 field.type()));
152 print(' ');
153 if (configuration().linksource) {
154 writer.printSrcLink(field, field.name());
155 } else {
156 strong(field.name());
157 }
158 writer.preEnd();
159 assert !writer.getMemberDetailsListPrinted();
160 }
161
162 /**
163 * Write the deprecated output for the given field.
164 *
165 * @param field the field being documented.
166 */
167 public void writeDeprecated(FieldDoc field) {
168 printDeprecated(field);
169 }
170
171 /**
172 * Write the comments for the given field.
173 *
174 * @param field the field being documented.
175 */
176 public void writeComments(FieldDoc field) {
177 ClassDoc holder = field.containingClass(); 124 ClassDoc holder = field.containingClass();
178 if (field.inlineTags().length > 0) { 125 if (field.inlineTags().length > 0) {
179 writer.printMemberDetailsListStartTag();
180 if (holder.equals(classdoc) || 126 if (holder.equals(classdoc) ||
181 (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) { 127 (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
182 writer.dd(); 128 writer.addInlineComment(field, fieldDocTree);
183 writer.printInlineComment(field);
184 writer.ddEnd();
185 } else { 129 } else {
186 String classlink = writer.codeText( 130 Content link = new RawHtml(
187 writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY, 131 writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
188 holder, field, 132 holder, field,
189 holder.isIncluded() ? 133 holder.isIncluded() ?
190 holder.typeName() : holder.qualifiedTypeName(), 134 holder.typeName() : holder.qualifiedTypeName(),
191 false)); 135 false));
192 writer.dd(); 136 Content codeLink = HtmlTree.CODE(link);
193 writer.strong(configuration().getText(holder.isClass()? 137 Content strong = HtmlTree.STRONG(holder.isClass()?
194 "doclet.Description_From_Class" : 138 writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
195 "doclet.Description_From_Interface", classlink)); 139 strong.addContent(writer.getSpace());
196 writer.ddEnd(); 140 strong.addContent(codeLink);
197 writer.dd(); 141 fieldDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
198 writer.printInlineComment(field); 142 writer.addInlineComment(field, fieldDocTree);
199 writer.ddEnd();
200 } 143 }
201 } 144 }
202 } 145 }
203 146
204 /** 147 /**
205 * Write the tag output for the given field. 148 * {@inheritDoc}
206 * 149 */
207 * @param field the field being documented. 150 public void addTags(FieldDoc field, Content fieldDocTree) {
208 */ 151 writer.addTagsInfo(field, fieldDocTree);
209 public void writeTags(FieldDoc field) { 152 }
210 writer.printTags(field); 153
211 } 154 /**
212 155 * {@inheritDoc}
213 /** 156 */
214 * Write the field footer. 157 public Content getFieldDetails(Content fieldDetailsTree) {
215 */ 158 return getMemberTree(fieldDetailsTree);
216 public void writeFieldFooter() { 159 }
217 printMemberFooter(); 160
218 } 161 /**
219 162 * {@inheritDoc}
220 /** 163 */
221 * Write the footer for the field documentation. 164 public Content getFieldDoc(Content fieldDocTree,
222 * 165 boolean isLastContent) {
223 * @param classDoc the class that the fields belong to. 166 return getMemberTree(fieldDocTree, isLastContent);
224 */
225 public void writeFooter(ClassDoc classDoc) {
226 //No footer to write for field documentation
227 } 167 }
228 168
229 /** 169 /**
230 * Close the writer. 170 * Close the writer.
231 */ 171 */
235 175
236 public int getMemberKind() { 176 public int getMemberKind() {
237 return VisibleMemberMap.FIELDS; 177 return VisibleMemberMap.FIELDS;
238 } 178 }
239 179
240 public void printSummaryLabel() { 180 /**
241 writer.printText("doclet.Field_Summary"); 181 * {@inheritDoc}
242 } 182 */
243 183 public void addSummaryLabel(Content memberTree) {
244 public void printTableSummary() { 184 Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
245 writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary", 185 writer.getResource("doclet.Field_Summary"));
186 memberTree.addContent(label);
187 }
188
189 /**
190 * {@inheritDoc}
191 */
192 public String getTableSummary() {
193 return configuration().getText("doclet.Member_Table_Summary",
246 configuration().getText("doclet.Field_Summary"), 194 configuration().getText("doclet.Field_Summary"),
247 configuration().getText("doclet.fields"))); 195 configuration().getText("doclet.fields"));
248 } 196 }
249 197
250 public void printSummaryTableHeader(ProgramElementDoc member) { 198 /**
199 * {@inheritDoc}
200 */
201 public String getCaption() {
202 return configuration().getText("doclet.Fields");
203 }
204
205 /**
206 * {@inheritDoc}
207 */
208 public String[] getSummaryTableHeader(ProgramElementDoc member) {
251 String[] header = new String[] { 209 String[] header = new String[] {
252 writer.getModifierTypeHeader(), 210 writer.getModifierTypeHeader(),
253 configuration().getText("doclet.0_and_1", 211 configuration().getText("doclet.0_and_1",
254 configuration().getText("doclet.Field"), 212 configuration().getText("doclet.Field"),
255 configuration().getText("doclet.Description")) 213 configuration().getText("doclet.Description"))
256 }; 214 };
257 writer.summaryTableHeader(header, "col"); 215 return header;
258 } 216 }
259 217
260 public void printSummaryAnchor(ClassDoc cd) { 218 /**
261 writer.anchor("field_summary"); 219 * {@inheritDoc}
262 } 220 */
263 221 public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
264 public void printInheritedSummaryAnchor(ClassDoc cd) { 222 memberTree.addContent(writer.getMarkerAnchor("field_summary"));
265 writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd)); 223 }
266 } 224
267 225 /**
268 public void printInheritedSummaryLabel(ClassDoc cd) { 226 * {@inheritDoc}
269 String classlink = writer.getPreQualifiedClassLink( 227 */
270 LinkInfoImpl.CONTEXT_MEMBER, cd, false); 228 public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
271 writer.strong(); 229 inheritedTree.addContent(writer.getMarkerAnchor(
272 String key = cd.isClass()? 230 "fields_inherited_from_class_" + configuration().getClassName(cd)));
273 "doclet.Fields_Inherited_From_Class" : 231 }
274 "doclet.Fields_Inherited_From_Interface"; 232
275 writer.printText(key, classlink); 233 /**
276 writer.strongEnd(); 234 * {@inheritDoc}
277 } 235 */
278 236 public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
279 protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) { 237 Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
280 writer.strong(); 238 LinkInfoImpl.CONTEXT_MEMBER, cd, false));
281 writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false); 239 Content label = new StringContent(cd.isClass() ?
282 writer.strongEnd(); 240 configuration().getText("doclet.Fields_Inherited_From_Class") :
283 } 241 configuration().getText("doclet.Fields_Inherited_From_Interface"));
284 242 Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
285 protected void writeInheritedSummaryLink(ClassDoc cd, 243 label);
286 ProgramElementDoc member) { 244 labelHeading.addContent(writer.getSpace());
287 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member, 245 labelHeading.addContent(classLink);
288 member.name(), false); 246 inheritedTree.addContent(labelHeading);
289 } 247 }
290 248
291 protected void printSummaryType(ProgramElementDoc member) { 249 /**
250 * {@inheritDoc}
251 */
252 protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
253 Content tdSummary) {
254 Content strong = HtmlTree.STRONG(new RawHtml(
255 writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false)));
256 Content code = HtmlTree.CODE(strong);
257 tdSummary.addContent(code);
258 }
259
260 /**
261 * {@inheritDoc}
262 */
263 protected void addInheritedSummaryLink(ClassDoc cd,
264 ProgramElementDoc member, Content linksTree) {
265 linksTree.addContent(new RawHtml(
266 writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
267 member.name(), false)));
268 }
269
270 /**
271 * {@inheritDoc}
272 */
273 protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
292 FieldDoc field = (FieldDoc)member; 274 FieldDoc field = (FieldDoc)member;
293 printModifierAndType(field, field.type()); 275 addModifierAndType(field, field.type(), tdSummaryType);
294 } 276 }
295 277
296 protected void writeDeprecatedLink(ProgramElementDoc member) { 278 /**
297 writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, 279 * {@inheritDoc}
298 (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false); 280 */
299 } 281 protected Content getDeprecatedLink(ProgramElementDoc member) {
300 282 return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
301 protected void printNavSummaryLink(ClassDoc cd, boolean link) { 283 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
284 }
285
286 /**
287 * {@inheritDoc}
288 */
289 protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
302 if (link) { 290 if (link) {
303 writer.printHyperLink("", (cd == null)? 291 return writer.getHyperLink("", (cd == null)?
304 "field_summary": 292 "field_summary":
305 "fields_inherited_from_class_" + 293 "fields_inherited_from_class_" +
306 configuration().getClassName(cd), 294 configuration().getClassName(cd),
307 configuration().getText("doclet.navField")); 295 writer.getResource("doclet.navField"));
308 } else { 296 } else {
309 writer.printText("doclet.navField"); 297 return writer.getResource("doclet.navField");
310 } 298 }
311 } 299 }
312 300
313 protected void printNavDetailLink(boolean link) { 301 /**
302 * {@inheritDoc}
303 */
304 protected void addNavDetailLink(boolean link, Content liNav) {
314 if (link) { 305 if (link) {
315 writer.printHyperLink("", "field_detail", 306 liNav.addContent(writer.getHyperLink("", "field_detail",
316 configuration().getText("doclet.navField")); 307 writer.getResource("doclet.navField")));
317 } else { 308 } else {
318 writer.printText("doclet.navField"); 309 liNav.addContent(writer.getResource("doclet.navField"));
319 } 310 }
320 } 311 }
321 } 312 }

mercurial