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 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 {
44 private boolean printedSummaryHeader = false;
46 public NestedClassWriterImpl(SubWriterHolderWriter writer,
47 ClassDoc classdoc) {
48 super(writer, classdoc);
49 }
51 public NestedClassWriterImpl(SubWriterHolderWriter writer) {
52 super(writer);
53 }
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 }
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 }
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 }
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 }
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 }
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 }
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.h3();
133 writer.print(nestedClass.name());
134 writer.h3End();
135 }
139 /**
140 * Close the writer.
141 */
142 public void close() throws IOException {
143 writer.close();
144 }
146 public int getMemberKind() {
147 return VisibleMemberMap.INNERCLASSES;
148 }
150 public void printSummaryLabel(ClassDoc cd) {
151 writer.strongText("doclet.Nested_Class_Summary");
152 }
154 public void printSummaryAnchor(ClassDoc cd) {
155 writer.anchor("nested_class_summary");
156 }
158 public void printInheritedSummaryAnchor(ClassDoc cd) {
159 writer.anchor("nested_classes_inherited_from_class_" +
160 cd.qualifiedName());
161 }
163 public void printInheritedSummaryLabel(ClassDoc cd) {
164 String clslink = writer.getPreQualifiedClassLink(
165 LinkInfoImpl.CONTEXT_MEMBER, cd, false);
166 writer.strong();
167 writer.printText(cd.isInterface() ?
168 "doclet.Nested_Classes_Interface_Inherited_From_Interface" :
169 "doclet.Nested_Classes_Interfaces_Inherited_From_Class",
170 clslink);
171 writer.strongEnd();
172 }
174 protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
175 writer.strong();
176 writer.printLink(new LinkInfoImpl(context, (ClassDoc)member, false));
177 writer.strongEnd();
178 }
180 protected void writeInheritedSummaryLink(ClassDoc cd,
181 ProgramElementDoc member) {
182 writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
183 (ClassDoc)member, false));
184 }
186 protected void printSummaryType(ProgramElementDoc member) {
187 ClassDoc cd = (ClassDoc)member;
188 printModifierAndType(cd, null);
189 }
191 protected void printHeader(ClassDoc cd) {
192 // N.A.
193 }
195 protected void printBodyHtmlEnd(ClassDoc cd) {
196 // N.A.
197 }
199 protected void printMember(ProgramElementDoc member) {
200 // N.A.
201 }
203 protected void writeDeprecatedLink(ProgramElementDoc member) {
204 writer.printQualifiedClassLink(LinkInfoImpl.CONTEXT_MEMBER,
205 (ClassDoc)member);
206 }
208 protected void printNavSummaryLink(ClassDoc cd, boolean link) {
209 if (link) {
210 writer.printHyperLink("", (cd == null) ? "nested_class_summary":
211 "nested_classes_inherited_from_class_" +
212 cd.qualifiedName(),
213 ConfigurationImpl.getInstance().getText("doclet.navNested"));
214 } else {
215 writer.printText("doclet.navNested");
216 }
217 }
219 protected void printNavDetailLink(boolean link) {
220 }
222 protected void printMemberLink(ProgramElementDoc member) {
223 }
225 protected void printMembersSummaryLink(ClassDoc cd, ClassDoc icd,
226 boolean link) {
227 if (link) {
228 writer.printHyperLink(cd.name() + ".html",
229 (cd == icd)?
230 "nested_class_summary":
231 "nested_classes_inherited_from_class_" +
232 icd.qualifiedName(),
233 ConfigurationImpl.getInstance().getText(
234 "doclet.Nested_Class_Summary"));
235 } else {
236 writer.printText("doclet.Nested_Class_Summary");
237 }
238 }
239 }