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

changeset 1
9a66ca7c79fa
child 182
47a62d8d98b4
equal deleted inserted replaced
-1:000000000000 1:9a66ca7c79fa
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 */
25
26 package com.sun.tools.doclets.formats.html;
27
28 import com.sun.tools.doclets.internal.toolkit.*;
29 import com.sun.tools.doclets.internal.toolkit.util.*;
30 import com.sun.javadoc.*;
31
32 import java.io.*;
33
34 /**
35 * Writes nested class documentation in HTML format.
36 *
37 * @author Robert Field
38 * @author Atul M Dambalkar
39 * @author Jamie Ho (rewrite)
40 */
41 public class NestedClassWriterImpl extends AbstractMemberWriter
42 implements MemberSummaryWriter {
43
44 private boolean printedSummaryHeader = false;
45
46 public NestedClassWriterImpl(SubWriterHolderWriter writer,
47 ClassDoc classdoc) {
48 super(writer, classdoc);
49 }
50
51 public NestedClassWriterImpl(SubWriterHolderWriter writer) {
52 super(writer);
53 }
54
55 /**
56 * Write the classes summary header for the given class.
57 *
58 * @param classDoc the class the summary belongs to.
59 */
60 public void writeMemberSummaryHeader(ClassDoc classDoc) {
61 printedSummaryHeader = true;
62 writer.println("<!-- ======== NESTED CLASS SUMMARY ======== -->");
63 writer.println();
64 writer.printSummaryHeader(this, classDoc);
65 }
66
67 /**
68 * Write the classes summary footer for the given class.
69 *
70 * @param classDoc the class the summary belongs to.
71 */
72 public void writeMemberSummaryFooter(ClassDoc classDoc) {
73 writer.printSummaryFooter(this, classDoc);
74 }
75
76 /**
77 * Write the inherited classes 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 }
90
91 /**
92 * {@inheritDoc}
93 */
94 public void writeInheritedMemberSummary(ClassDoc classDoc,
95 ProgramElementDoc nestedClass, boolean isFirst, boolean isLast) {
96 writer.printInheritedSummaryMember(this, classDoc, nestedClass, isFirst);
97 }
98
99 /**
100 * Write the inherited classes 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 writer.println();
107 }
108
109 /**
110 * Write the header for the nested class documentation.
111 *
112 * @param classDoc the class that the classes belong to.
113 */
114 public void writeHeader(ClassDoc classDoc, String header) {
115 writer.anchor("nested class_detail");
116 writer.printTableHeadingBackground(header);
117 }
118
119 /**
120 * Write the nested class header for the given nested class.
121 *
122 * @param nestedClass the nested class being documented.
123 * @param isFirst the flag to indicate whether or not the nested class is the
124 * first to be documented.
125 */
126 public void writeClassHeader(ClassDoc nestedClass, boolean isFirst) {
127 if (! isFirst) {
128 writer.printMemberHeader();
129 writer.println("");
130 }
131 writer.anchor(nestedClass.name());
132 writer.dl();
133 writer.h3();
134 writer.print(nestedClass.name());
135 writer.h3End();
136 }
137
138
139
140 /**
141 * Close the writer.
142 */
143 public void close() throws IOException {
144 writer.close();
145 }
146
147 public int getMemberKind() {
148 return VisibleMemberMap.INNERCLASSES;
149 }
150
151 public void printSummaryLabel(ClassDoc cd) {
152 writer.boldText("doclet.Nested_Class_Summary");
153 }
154
155 public void printSummaryAnchor(ClassDoc cd) {
156 writer.anchor("nested_class_summary");
157 }
158
159 public void printInheritedSummaryAnchor(ClassDoc cd) {
160 writer.anchor("nested_classes_inherited_from_class_" +
161 cd.qualifiedName());
162 }
163
164 public void printInheritedSummaryLabel(ClassDoc cd) {
165 String clslink = writer.getPreQualifiedClassLink(
166 LinkInfoImpl.CONTEXT_MEMBER, cd, false);
167 writer.bold();
168 writer.printText(cd.isInterface() ?
169 "doclet.Nested_Classes_Interface_Inherited_From_Interface" :
170 "doclet.Nested_Classes_Interfaces_Inherited_From_Class",
171 clslink);
172 writer.boldEnd();
173 }
174
175 protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
176 writer.bold();
177 writer.printLink(new LinkInfoImpl(context, (ClassDoc)member, false));
178 writer.boldEnd();
179 }
180
181 protected void writeInheritedSummaryLink(ClassDoc cd,
182 ProgramElementDoc member) {
183 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
184 (ClassDoc)member, false));
185 }
186
187 protected void printSummaryType(ProgramElementDoc member) {
188 ClassDoc cd = (ClassDoc)member;
189 printModifierAndType(cd, null);
190 }
191
192 protected void printHeader(ClassDoc cd) {
193 // N.A.
194 }
195
196 protected void printBodyHtmlEnd(ClassDoc cd) {
197 // N.A.
198 }
199
200 protected void printMember(ProgramElementDoc member) {
201 // N.A.
202 }
203
204 protected void writeDeprecatedLink(ProgramElementDoc member) {
205 writer.printQualifiedClassLink(LinkInfoImpl.CONTEXT_MEMBER,
206 (ClassDoc)member);
207 }
208
209 protected void printNavSummaryLink(ClassDoc cd, boolean link) {
210 if (link) {
211 writer.printHyperLink("", (cd == null) ? "nested_class_summary":
212 "nested_classes_inherited_from_class_" +
213 cd.qualifiedName(),
214 ConfigurationImpl.getInstance().getText("doclet.navNested"));
215 } else {
216 writer.printText("doclet.navNested");
217 }
218 }
219
220 protected void printNavDetailLink(boolean link) {
221 }
222
223 protected void printMemberLink(ProgramElementDoc member) {
224 }
225
226 protected void printMembersSummaryLink(ClassDoc cd, ClassDoc icd,
227 boolean link) {
228 if (link) {
229 writer.printHyperLink(cd.name() + ".html",
230 (cd == icd)?
231 "nested_class_summary":
232 "nested_classes_inherited_from_class_" +
233 icd.qualifiedName(),
234 ConfigurationImpl.getInstance().getText(
235 "doclet.Nested_Class_Summary"));
236 } else {
237 writer.printText("doclet.Nested_Class_Summary");
238 }
239 }
240 }

mercurial