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

changeset 766
90af8d87741f
parent 554
9d9f26857129
child 798
4868a36f6fd8
equal deleted inserted replaced
758:bcbc86cc5b31 766:90af8d87741f
29 29
30 import com.sun.javadoc.*; 30 import com.sun.javadoc.*;
31 import com.sun.tools.doclets.internal.toolkit.*; 31 import com.sun.tools.doclets.internal.toolkit.*;
32 import com.sun.tools.doclets.internal.toolkit.taglets.*; 32 import com.sun.tools.doclets.internal.toolkit.taglets.*;
33 import com.sun.tools.doclets.internal.toolkit.util.*; 33 import com.sun.tools.doclets.internal.toolkit.util.*;
34 import com.sun.tools.doclets.formats.html.markup.*;
34 35
35 /** 36 /**
36 * Generate serialized form for serializable fields. 37 * Generate serialized form for serializable fields.
37 * Documentation denoted by the tags <code>serial</code> and 38 * Documentation denoted by the tags <code>serial</code> and
38 * <code>serialField</code> is processed. 39 * <code>serialField</code> is processed.
43 public class HtmlSerialFieldWriter extends FieldWriterImpl 44 public class HtmlSerialFieldWriter extends FieldWriterImpl
44 implements SerializedFormWriter.SerialFieldWriter { 45 implements SerializedFormWriter.SerialFieldWriter {
45 ProgramElementDoc[] members = null; 46 ProgramElementDoc[] members = null;
46 47
47 private boolean printedOverallAnchor = false; 48 private boolean printedOverallAnchor = false;
48
49 private boolean printedFirstMember = false;
50 49
51 public HtmlSerialFieldWriter(SubWriterHolderWriter writer, 50 public HtmlSerialFieldWriter(SubWriterHolderWriter writer,
52 ClassDoc classdoc) { 51 ClassDoc classdoc) {
53 super(writer, classdoc); 52 super(writer, classdoc);
54 } 53 }
67 writer.printLink(new LinkInfoImpl( 66 writer.printLink(new LinkInfoImpl(
68 LinkInfoImpl.CONTEXT_SERIAL_MEMBER, type)); 67 LinkInfoImpl.CONTEXT_SERIAL_MEMBER, type));
69 } 68 }
70 } 69 }
71 70
72 public void writeHeader(String heading) { 71 /**
73 if (! printedOverallAnchor) { 72 * Return the header for serializable fields section.
74 writer.anchor("serializedForm"); 73 *
75 printedOverallAnchor = true; 74 * @return a content tree for the header
76 writer.printTableHeadingBackground(heading); 75 */
77 writer.println(); 76 public Content getSerializableFieldsHeader() {
78 if (heading.equals( 77 HtmlTree ul = new HtmlTree(HtmlTag.UL);
79 configuration().getText("doclet.Serialized_Form_class"))) { 78 ul.addStyle(HtmlStyle.blockList);
80 assert !writer.getMemberDetailsListPrinted(); 79 return ul;
80 }
81
82 /**
83 * Return the header for serializable fields content section.
84 *
85 * @param isLastContent true if the cotent being documented is the last content.
86 * @return a content tree for the header
87 */
88 public Content getFieldsContentHeader(boolean isLastContent) {
89 HtmlTree li = new HtmlTree(HtmlTag.LI);
90 if (isLastContent)
91 li.addStyle(HtmlStyle.blockListLast);
92 else
93 li.addStyle(HtmlStyle.blockList);
94 return li;
95 }
96
97 /**
98 * Add serializable fields.
99 *
100 * @param heading the heading for the section
101 * @param serializableFieldsTree the tree to be added to the serializable fileds
102 * content tree
103 * @return a content tree for the serializable fields content
104 */
105 public Content getSerializableFields(String heading, Content serializableFieldsTree) {
106 HtmlTree li = new HtmlTree(HtmlTag.LI);
107 li.addStyle(HtmlStyle.blockList);
108 if (serializableFieldsTree.isValid()) {
109 if (!printedOverallAnchor) {
110 li.addContent(writer.getMarkerAnchor("serializedForm"));
111 printedOverallAnchor = true;
81 } 112 }
113 Content headingContent = new StringContent(heading);
114 Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
115 headingContent);
116 li.addContent(serialHeading);
117 li.addContent(serializableFieldsTree);
118 }
119 return li;
120 }
121
122 /**
123 * Add the member header.
124 *
125 * @param fieldsType the class document to be listed
126 * @param fieldTypeStr the string for the filed type to be documented
127 * @param fieldDimensions the dimensions of the field string to be added
128 * @param firldName name of the field to be added
129 * @param contentTree the content tree to which the member header will be added
130 */
131 public void addMemberHeader(ClassDoc fieldType, String fieldTypeStr,
132 String fieldDimensions, String fieldName, Content contentTree) {
133 Content nameContent = new RawHtml(fieldName);
134 Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent);
135 contentTree.addContent(heading);
136 Content pre = new HtmlTree(HtmlTag.PRE);
137 if (fieldType == null) {
138 pre.addContent(fieldTypeStr);
82 } else { 139 } else {
83 writer.printTableHeadingBackground(heading); 140 Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl(
84 writer.println(); 141 LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
85 } 142 pre.addContent(fieldContent);
86 } 143 }
87 144 pre.addContent(fieldDimensions + " ");
88 public void writeMemberHeader(ClassDoc fieldType, String fieldTypeStr, 145 pre.addContent(fieldName);
89 String fieldDimensions, String fieldName) { 146 contentTree.addContent(pre);
90 if (printedFirstMember) { 147 }
91 writer.printMemberHeader(); 148
92 } 149 /**
93 printedFirstMember = true; 150 * Add the deprecated information for this member.
94 writer.h3();
95 writer.print(fieldName);
96 writer.h3End();
97 writer.pre();
98 if (fieldType == null) {
99 writer.print(fieldTypeStr);
100 } else {
101 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIAL_MEMBER,
102 fieldType));
103 }
104 print(fieldDimensions + ' ');
105 strong(fieldName);
106 writer.preEnd();
107 assert !writer.getMemberDetailsListPrinted();
108 }
109
110 /**
111 * Write the deprecated information for this member.
112 * 151 *
113 * @param field the field to document. 152 * @param field the field to document.
114 */ 153 * @param contentTree the tree to which the deprecated info will be added
115 public void writeMemberDeprecatedInfo(FieldDoc field) { 154 */
116 printDeprecated(field); 155 public void addMemberDeprecatedInfo(FieldDoc field, Content contentTree) {
117 } 156 addDeprecatedInfo(field, contentTree);
118 157 }
119 /** 158
120 * Write the description text for this member. 159 /**
160 * Add the description text for this member.
121 * 161 *
122 * @param field the field to document. 162 * @param field the field to document.
123 */ 163 * @param contentTree the tree to which the deprecated info will be added
124 public void writeMemberDescription(FieldDoc field) { 164 */
165 public void addMemberDescription(FieldDoc field, Content contentTree) {
125 if (field.inlineTags().length > 0) { 166 if (field.inlineTags().length > 0) {
126 writer.printMemberDetailsListStartTag(); 167 writer.addInlineComment(field, contentTree);
127 writer.dd();
128 writer.printInlineComment(field);
129 writer.ddEnd();
130 } 168 }
131 Tag[] tags = field.tags("serial"); 169 Tag[] tags = field.tags("serial");
132 if (tags.length > 0) { 170 if (tags.length > 0) {
133 writer.printMemberDetailsListStartTag(); 171 writer.addInlineComment(field, tags[0], contentTree);
134 writer.dd(); 172 }
135 writer.printInlineComment(field, tags[0]); 173 }
136 writer.ddEnd(); 174
137 } 175 /**
138 } 176 * Add the description text for this member represented by the tag.
139 177 *
140 /** 178 * @param serialFieldTag the field to document (represented by tag)
141 * Write the description text for this member represented by the tag. 179 * @param contentTree the tree to which the deprecated info will be added
142 * 180 */
143 * @param serialFieldTag the field to document (represented by tag). 181 public void addMemberDescription(SerialFieldTag serialFieldTag, Content contentTree) {
144 */
145 public void writeMemberDescription(SerialFieldTag serialFieldTag) {
146 String serialFieldTagDesc = serialFieldTag.description().trim(); 182 String serialFieldTagDesc = serialFieldTag.description().trim();
147 if (!serialFieldTagDesc.isEmpty()) { 183 if (!serialFieldTagDesc.isEmpty()) {
148 writer.dl(); 184 Content serialFieldContent = new RawHtml(serialFieldTagDesc);
149 writer.dd(); 185 Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);
150 writer.print(serialFieldTagDesc); 186 contentTree.addContent(div);
151 writer.ddEnd(); 187 }
152 writer.dlEnd(); 188 }
153 } 189
154 } 190 /**
155 191 * Add the tag information for this member.
156 /**
157 * Write the tag information for this member.
158 * 192 *
159 * @param field the field to document. 193 * @param field the field to document.
160 */ 194 * @param contentTree the tree to which the member tags info will be added
161 public void writeMemberTags(FieldDoc field) { 195 */
196 public void addMemberTags(FieldDoc field, Content contentTree) {
162 TagletOutputImpl output = new TagletOutputImpl(""); 197 TagletOutputImpl output = new TagletOutputImpl("");
163 TagletWriter.genTagOuput(configuration().tagletManager, field, 198 TagletWriter.genTagOuput(configuration().tagletManager, field,
164 configuration().tagletManager.getCustomTags(field), 199 configuration().tagletManager.getCustomTags(field),
165 writer.getTagletWriterInstance(false), output); 200 writer.getTagletWriterInstance(false), output);
166 String outputString = output.toString().trim(); 201 String outputString = output.toString().trim();
202 Content dlTags = new HtmlTree(HtmlTag.DL);
167 if (!outputString.isEmpty()) { 203 if (!outputString.isEmpty()) {
168 writer.printMemberDetailsListStartTag(); 204 Content tagContent = new RawHtml(outputString);
169 writer.dd(); 205 dlTags.addContent(tagContent);
170 writer.dl(); 206 }
171 print(outputString); 207 contentTree.addContent(dlTags);
172 writer.dlEnd();
173 writer.ddEnd();
174 }
175 } 208 }
176 209
177 /** 210 /**
178 * Check to see if overview details should be printed. If 211 * Check to see if overview details should be printed. If
179 * nocomment option set or if there is no text to be printed 212 * nocomment option set or if there is no text to be printed
190 } 223 }
191 if (field.tags("deprecated").length > 0) 224 if (field.tags("deprecated").length > 0)
192 return true; 225 return true;
193 return false; 226 return false;
194 } 227 }
195
196 public void writeMemberFooter() {
197 printMemberFooter();
198 }
199
200 /**
201 * Write the footer information. If the serilization overview section was
202 * printed, check for definition list and close list tag.
203 *
204 * @param heading the heading that was written.
205 */
206 public void writeFooter(String heading) {
207 if (printedOverallAnchor) {
208 if (heading.equals(
209 configuration().getText("doclet.Serialized_Form_class"))) {
210 writer.printMemberDetailsListEndTag();
211 assert !writer.getMemberDetailsListPrinted();
212 }
213 }
214 }
215 } 228 }

mercurial