Thu, 02 Oct 2008 19:58:40 -0700
6754988: Update copyright year
Summary: Update for files that have been modified starting July 2008
Reviewed-by: ohair, tbell
1 /*
2 * Copyright 1997-2008 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 com.sun.tools.doclets.internal.toolkit.*;
29 import com.sun.tools.doclets.internal.toolkit.util.*;
30 import com.sun.tools.doclets.internal.toolkit.taglets.*;
31 import com.sun.javadoc.*;
32 import java.util.*;
33 import java.io.*;
35 /**
36 * Writes constructor documentation.
37 *
38 * @author Robert Field
39 * @author Atul M Dambalkar
40 */
41 public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
42 implements ConstructorWriter, MemberSummaryWriter {
44 private boolean foundNonPubConstructor = false;
45 private boolean printedSummaryHeader = false;
47 /**
48 * Construct a new ConstructorWriterImpl.
49 *
50 * @param writer The writer for the class that the constructors belong to.
51 * @param classDoc the class being documented.
52 */
53 public ConstructorWriterImpl(SubWriterHolderWriter writer,
54 ClassDoc classDoc) {
55 super(writer, classDoc);
56 VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc,
57 VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated);
58 List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
59 for (int i = 0; i < constructors.size(); i++) {
60 if ((constructors.get(i)).isProtected() ||
61 (constructors.get(i)).isPrivate()) {
62 setFoundNonPubConstructor(true);
63 }
64 }
65 }
67 /**
68 * Construct a new ConstructorWriterImpl.
69 *
70 * @param writer The writer for the class that the constructors belong to.
71 */
72 public ConstructorWriterImpl(SubWriterHolderWriter writer) {
73 super(writer);
74 }
76 /**
77 * Write the constructors summary header for the given class.
78 *
79 * @param classDoc the class the summary belongs to.
80 */
81 public void writeMemberSummaryHeader(ClassDoc classDoc) {
82 printedSummaryHeader = true;
83 writer.println();
84 writer.println("<!-- ======== CONSTRUCTOR SUMMARY ======== -->");
85 writer.println();
86 writer.printSummaryHeader(this, classDoc);
87 }
89 /**
90 * Write the constructors summary footer for the given class.
91 *
92 * @param classDoc the class the summary belongs to.
93 */
94 public void writeMemberSummaryFooter(ClassDoc classDoc) {
95 writer.printSummaryFooter(this, classDoc);
96 }
98 /**
99 * Write the header for the constructor documentation.
100 *
101 * @param classDoc the class that the constructors belong to.
102 */
103 public void writeHeader(ClassDoc classDoc, String header) {
104 writer.println();
105 writer.println("<!-- ========= CONSTRUCTOR DETAIL ======== -->");
106 writer.println();
107 writer.anchor("constructor_detail");
108 writer.printTableHeadingBackground(header);
109 }
111 /**
112 * Write the constructor header for the given constructor.
113 *
114 * @param constructor the constructor being documented.
115 * @param isFirst the flag to indicate whether or not the constructor is the
116 * first to be documented.
117 */
118 public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst) {
119 if (! isFirst) {
120 writer.printMemberHeader();
121 }
122 writer.println();
123 String erasureAnchor;
124 if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
125 writer.anchor(erasureAnchor);
126 }
127 writer.anchor(constructor);
128 writer.h3();
129 writer.print(constructor.name());
130 writer.h3End();
131 }
133 /**
134 * Write the signature for the given constructor.
135 *
136 * @param constructor the constructor being documented.
137 */
138 public void writeSignature(ConstructorDoc constructor) {
139 writer.displayLength = 0;
140 writer.pre();
141 writer.writeAnnotationInfo(constructor);
142 printModifiers(constructor);
143 //printReturnType((ConstructorDoc)constructor);
144 if (configuration().linksource) {
145 writer.printSrcLink(constructor, constructor.name());
146 } else {
147 bold(constructor.name());
148 }
149 writeParameters(constructor);
150 writeExceptions(constructor);
151 writer.preEnd();
152 writer.dl();
153 }
155 /**
156 * Write the deprecated output for the given constructor.
157 *
158 * @param constructor the constructor being documented.
159 */
160 public void writeDeprecated(ConstructorDoc constructor) {
161 String output = ((TagletOutputImpl)
162 (new DeprecatedTaglet()).getTagletOutput(constructor,
163 writer.getTagletWriterInstance(false))).toString();
164 if (output != null && output.trim().length() > 0) {
165 writer.print(output);
166 }
167 }
169 /**
170 * Write the comments for the given constructor.
171 *
172 * @param constructor the constructor being documented.
173 */
174 public void writeComments(ConstructorDoc constructor) {
175 if (constructor.inlineTags().length > 0) {
176 writer.dd();
177 writer.printInlineComment(constructor);
178 }
179 }
181 /**
182 * Write the tag output for the given constructor.
183 *
184 * @param constructor the constructor being documented.
185 */
186 public void writeTags(ConstructorDoc constructor) {
187 writer.printTags(constructor);
188 }
190 /**
191 * Write the constructor footer.
192 */
193 public void writeConstructorFooter() {
194 writer.dlEnd();
195 }
197 /**
198 * Write the footer for the constructor documentation.
199 *
200 * @param classDoc the class that the constructors belong to.
201 */
202 public void writeFooter(ClassDoc classDoc) {
203 //No footer to write for constructor documentation
204 }
206 /**
207 * Close the writer.
208 */
209 public void close() throws IOException {
210 writer.close();
211 }
213 /**
214 * Let the writer know whether a non public constructor was found.
215 *
216 * @param foundNonPubConstructor true if we found a non public constructor.
217 */
218 public void setFoundNonPubConstructor(boolean foundNonPubConstructor) {
219 this.foundNonPubConstructor = foundNonPubConstructor;
220 }
222 public void printSummaryLabel(ClassDoc cd) {
223 writer.boldText("doclet.Constructor_Summary");
224 }
226 public void printSummaryAnchor(ClassDoc cd) {
227 writer.anchor("constructor_summary");
228 }
230 public void printInheritedSummaryAnchor(ClassDoc cd) {
231 } // no such
233 public void printInheritedSummaryLabel(ClassDoc cd) {
234 // no such
235 }
237 public int getMemberKind() {
238 return VisibleMemberMap.CONSTRUCTORS;
239 }
241 protected void navSummaryLink(List members) {
242 printNavSummaryLink(classdoc,
243 members.size() > 0? true: false);
244 }
246 protected void printNavSummaryLink(ClassDoc cd, boolean link) {
247 if (link) {
248 writer.printHyperLink("", "constructor_summary",
249 ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
250 } else {
251 writer.printText("doclet.navConstructor");
252 }
253 }
255 protected void printNavDetailLink(boolean link) {
256 if (link) {
257 writer.printHyperLink("", "constructor_detail",
258 ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
259 } else {
260 writer.printText("doclet.navConstructor");
261 }
262 }
264 protected void printSummaryType(ProgramElementDoc member) {
265 if (foundNonPubConstructor) {
266 writer.printTypeSummaryHeader();
267 if (member.isProtected()) {
268 print("protected ");
269 } else if (member.isPrivate()) {
270 print("private ");
271 } else if (member.isPublic()) {
272 writer.space();
273 } else {
274 writer.printText("doclet.Package_private");
275 }
276 writer.printTypeSummaryFooter();
277 }
278 }
280 /**
281 * Write the inherited member summary header for the given class.
282 *
283 * @param classDoc the class the summary belongs to.
284 */
285 public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
286 if(! printedSummaryHeader){
287 //We don't want inherited summary to not be under heading.
288 writeMemberSummaryHeader(classDoc);
289 writeMemberSummaryFooter(classDoc);
290 printedSummaryHeader = true;
291 }
292 }
294 /**
295 * {@inheritDoc}
296 */
297 public void writeInheritedMemberSummary(ClassDoc classDoc,
298 ProgramElementDoc member, boolean isFirst, boolean isLast) {}
300 /**
301 * Write the inherited member summary footer for the given class.
302 *
303 * @param classDoc the class the summary belongs to.
304 */
305 public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {}
306 }