duke@1: /* duke@1: * Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as duke@1: * published by the Free Software Foundation. Sun designates this duke@1: * particular file as subject to the "Classpath" exception as provided duke@1: * by Sun in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * duke@1: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: * CA 95054 USA or visit www.sun.com if you need additional information or duke@1: * have any questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: bpatel@233: import java.io.*; bpatel@233: import java.util.*; duke@1: duke@1: import com.sun.javadoc.*; bpatel@233: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: duke@1: /** duke@1: * Generate Index for all the Member Names with Indexing in duke@1: * Unicode Order. This class is a base class for {@link SingleIndexWriter} and duke@1: * {@link SplitIndexWriter}. It uses the functionality from duke@1: * {@link HtmlDocletWriter} to generate the Index Contents. duke@1: * duke@1: * @see IndexBuilder duke@1: * @author Atul M Dambalkar duke@1: */ duke@1: public class AbstractIndexWriter extends HtmlDocletWriter { duke@1: duke@1: /** duke@1: * The index of all the members with unicode character. duke@1: */ duke@1: protected IndexBuilder indexbuilder; duke@1: duke@1: /** duke@1: * This constructor will be used by {@link SplitIndexWriter}. Initialises duke@1: * path to this file and relative path from this file. duke@1: * duke@1: * @param path Path to the file which is getting generated. duke@1: * @param filename Name of the file which is getting genrated. duke@1: * @param relpath Relative path from this file to the current directory. duke@1: * @param indexbuilder Unicode based Index from {@link IndexBuilder} duke@1: */ duke@1: protected AbstractIndexWriter(ConfigurationImpl configuration, duke@1: String path, String filename, duke@1: String relpath, IndexBuilder indexbuilder) duke@1: throws IOException { duke@1: super(configuration, path, filename, relpath); duke@1: this.indexbuilder = indexbuilder; duke@1: } duke@1: duke@1: /** duke@1: * This Constructor will be used by {@link SingleIndexWriter}. duke@1: * duke@1: * @param filename Name of the file which is getting genrated. duke@1: * @param indexbuilder Unicode based Index form {@link IndexBuilder} duke@1: */ duke@1: protected AbstractIndexWriter(ConfigurationImpl configuration, duke@1: String filename, IndexBuilder indexbuilder) duke@1: throws IOException { duke@1: super(configuration, filename); duke@1: this.indexbuilder = indexbuilder; duke@1: } duke@1: duke@1: /** bpatel@182: * Print the text "Index" in strong format in the navigation bar. duke@1: */ duke@1: protected void navLinkIndex() { duke@1: navCellRevStart(); duke@1: fontStyle("NavBarFont1Rev"); bpatel@182: strongText("doclet.Index"); duke@1: fontEnd(); duke@1: navCellEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Generate the member information for the unicode character along with the duke@1: * list of the members. duke@1: * duke@1: * @param unicode Unicode for which member list information to be generated. duke@1: * @param memberlist List of members for the unicode character. duke@1: */ mcimadamore@184: protected void generateContents(Character unicode, List memberlist) { duke@1: anchor("_" + unicode + "_"); duke@1: h2(); bpatel@182: strong(unicode.toString()); duke@1: h2End(); bpatel@233: int memberListSize = memberlist.size(); bpatel@233: // Display the list only if there are elements to be displayed. bpatel@233: if (memberListSize > 0) { bpatel@233: dl(); bpatel@233: for (int i = 0; i < memberListSize; i++) { bpatel@233: Doc element = memberlist.get(i); bpatel@233: if (element instanceof MemberDoc) { bpatel@233: printDescription((MemberDoc)element); bpatel@233: } else if (element instanceof ClassDoc) { bpatel@233: printDescription((ClassDoc)element); bpatel@233: } else if (element instanceof PackageDoc) { bpatel@233: printDescription((PackageDoc)element); bpatel@233: } duke@1: } bpatel@233: dlEnd(); duke@1: } duke@1: hr(); duke@1: } duke@1: duke@1: duke@1: /** duke@1: * Print one line summary comment for the package. duke@1: * duke@1: * @param pkg PackageDoc passed. duke@1: */ duke@1: protected void printDescription(PackageDoc pkg) { duke@1: dt(); duke@1: printPackageLink(pkg, Util.getPackageName(pkg), true); duke@1: print(" - "); duke@1: print(configuration.getText("doclet.package") + " " + pkg.name()); bpatel@233: dtEnd(); duke@1: dd(); duke@1: printSummaryComment(pkg); bpatel@233: ddEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Print one line summary comment for the class. duke@1: * duke@1: * @param cd ClassDoc passed. duke@1: */ duke@1: protected void printDescription(ClassDoc cd) { duke@1: dt(); duke@1: printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)); duke@1: print(" - "); duke@1: printClassInfo(cd); bpatel@233: dtEnd(); duke@1: dd(); duke@1: printComment(cd); bpatel@233: ddEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Print the classkind(class, interface, exception, error of the class duke@1: * passed. duke@1: * duke@1: * @param cd ClassDoc. duke@1: */ duke@1: protected void printClassInfo(ClassDoc cd) { duke@1: print(configuration.getText("doclet.in", duke@1: Util.getTypeName(configuration, cd, false), duke@1: getPackageLink(cd.containingPackage(), duke@1: Util.getPackageName(cd.containingPackage()), false))); duke@1: } duke@1: duke@1: duke@1: /** duke@1: * Generate Description for Class, Field, Method or Constructor. duke@1: * for Java.* Packages Class Members. duke@1: * duke@1: * @param member MemberDoc for the member of the Class Kind. duke@1: * @see com.sun.javadoc.MemberDoc duke@1: */ duke@1: protected void printDescription(MemberDoc member) { duke@1: String name = (member instanceof ExecutableMemberDoc)? duke@1: member.name() + ((ExecutableMemberDoc)member).flatSignature() : duke@1: member.name(); duke@1: if (name.indexOf("<") != -1 || name.indexOf(">") != -1) { duke@1: name = Util.escapeHtmlChars(name); duke@1: } duke@1: ClassDoc containing = member.containingClass(); duke@1: dt(); duke@1: printDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name, true); duke@1: println(" - "); duke@1: printMemberDesc(member); duke@1: println(); bpatel@233: dtEnd(); duke@1: dd(); duke@1: printComment(member); bpatel@233: ddEnd(); duke@1: println(); duke@1: } duke@1: duke@1: duke@1: /** duke@1: * Print comment for each element in the index. If the element is deprecated duke@1: * and it has a @deprecated tag, use that comment. Else if the containing duke@1: * class for this element is deprecated, then add the word "Deprecated." at duke@1: * the start and then print the normal comment. duke@1: * duke@1: * @param element Index element. duke@1: */ duke@1: protected void printComment(ProgramElementDoc element) { duke@1: Tag[] tags; duke@1: if (Util.isDeprecated(element)) { bpatel@182: strongText("doclet.Deprecated"); space(); duke@1: if ((tags = element.tags("deprecated")).length > 0) duke@1: printInlineDeprecatedComment(element, tags[0]); duke@1: } else { duke@1: ClassDoc cont = element.containingClass(); duke@1: while (cont != null) { duke@1: if (Util.isDeprecated(cont)) { bpatel@182: strongText("doclet.Deprecated"); space(); duke@1: break; duke@1: } duke@1: cont = cont.containingClass(); duke@1: } duke@1: printSummaryComment(element); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Print description about the Static Varible/Method/Constructor for a duke@1: * member. duke@1: * duke@1: * @param member MemberDoc for the member within the Class Kind. duke@1: * @see com.sun.javadoc.MemberDoc duke@1: */ duke@1: protected void printMemberDesc(MemberDoc member) { duke@1: ClassDoc containing = member.containingClass(); duke@1: String classdesc = Util.getTypeName(configuration, containing, true) + " " + duke@1: getPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing, duke@1: false); duke@1: if (member.isField()) { duke@1: if (member.isStatic()) { duke@1: printText("doclet.Static_variable_in", classdesc); duke@1: } else { duke@1: printText("doclet.Variable_in", classdesc); duke@1: } duke@1: } else if (member.isConstructor()) { duke@1: printText("doclet.Constructor_for", classdesc); duke@1: } else if (member.isMethod()) { duke@1: if (member.isStatic()) { duke@1: printText("doclet.Static_method_in", classdesc); duke@1: } else { duke@1: printText("doclet.Method_in", classdesc); duke@1: } duke@1: } duke@1: } duke@1: }