001 /*
002 * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package com.sun.tools.doclets.formats.html;
027
028 import com.sun.tools.doclets.internal.toolkit.*;
029 import com.sun.tools.doclets.internal.toolkit.util.*;
030 import com.sun.javadoc.*;
031
032 import java.io.*;
033
034 /**
035 * Writes nested class documentation in HTML format.
036 *
037 * @author Robert Field
038 * @author Atul M Dambalkar
039 * @author Jamie Ho (rewrite)
040 */
041 public class NestedClassWriterImpl extends AbstractMemberWriter
042 implements MemberSummaryWriter {
043
044 private boolean printedSummaryHeader = false;
045
046 public NestedClassWriterImpl(SubWriterHolderWriter writer,
047 ClassDoc classdoc) {
048 super(writer, classdoc);
049 }
050
051 public NestedClassWriterImpl(SubWriterHolderWriter writer) {
052 super(writer);
053 }
054
055 /**
056 * Write the classes summary header for the given class.
057 *
058 * @param classDoc the class the summary belongs to.
059 */
060 public void writeMemberSummaryHeader(ClassDoc classDoc) {
061 printedSummaryHeader = true;
062 writer.println("<!-- ======== NESTED CLASS SUMMARY ======== -->");
063 writer.println();
064 writer.printSummaryHeader(this, classDoc);
065 }
066
067 /**
068 * Write the classes summary footer for the given class.
069 *
070 * @param classDoc the class the summary belongs to.
071 */
072 public void writeMemberSummaryFooter(ClassDoc classDoc) {
073 writer.printSummaryFooter(this, classDoc);
074 }
075
076 /**
077 * Write the inherited classes summary header for the given class.
078 *
079 * @param classDoc the class the summary belongs to.
080 */
081 public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
082 if(! printedSummaryHeader){
083 //We don't want inherited summary to not be under heading.
084 writeMemberSummaryHeader(classDoc);
085 writeMemberSummaryFooter(classDoc);
086 printedSummaryHeader = true;
087 }
088 writer.printInheritedSummaryHeader(this, classDoc);
089 }
090
091 /**
092 * {@inheritDoc}
093 */
094 public void writeInheritedMemberSummary(ClassDoc classDoc,
095 ProgramElementDoc nestedClass, boolean isFirst, boolean isLast) {
096 writer.printInheritedSummaryMember(this, classDoc, nestedClass, isFirst);
097 }
098
099 /**
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.strongText("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.strong();
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.strongEnd();
173 }
174
175 protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
176 writer.strong();
177 writer.printLink(new LinkInfoImpl(context, (ClassDoc)member, false));
178 writer.strongEnd();
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 }