/* * @(#)AbstractIndexWriter.java 1.7 98/04/17 * * Copyright 1998 by Sun Microsystems, Inc., * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of Sun Microsystems, Inc. ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Sun. */ package com.sun.tools.doclets.standard; import com.sun.tools.doclets.*; import com.sun.javadoc.*; import java.io.*; import java.lang.*; import java.util.*; /** * Generate Files for all the Member Names with Indexing in * Alphabetical Order. * * @author Atul M Dambalkar */ public class AbstractIndexWriter extends HtmlStandardWriter { /** * The index of all the members with unicode character. */ protected IndexBuilder indexbuilder; /** * Constructor. */ protected AbstractIndexWriter(String filename, IndexBuilder indexbuilder) throws IOException { super(filename); this.indexbuilder = indexbuilder; } /** * Print index link - it's me: bold */ protected void navLinkIndex() { boldText("doclet.Index"); } /** * Generate the member information for the unicode character along with the * list of the members. * * @param unicode Unicode for which member list information to be generated. * @param memberlist List of members for the unicode character. */ protected void generateContents(Character unicode, List memberlist) { anchor("_" + unicode + "_"); h2(); bold(unicode.toString()); h2End(); dl(); for (int i = 0; i < memberlist.size(); i++) { Doc element = (Doc)memberlist.get(i); if (element instanceof MemberDoc) { printDescription((MemberDoc)element); } else if (element instanceof ClassDoc) { printDescription((ClassDoc)element); } else if (element instanceof PackageDoc) { printDescription((PackageDoc)element); } } dlEnd(); hr(); } /** * Print the description for the package passed. */ protected void printDescription(PackageDoc pd) { dt(); printPackageLink(pd); print(" - "); print("package " + pd.name()); dd(); printCommentTags(pd.firstSentenceTags()); } /** * Print the description for the class passed. */ protected void printDescription(ClassDoc cd) { dt(); printClassLink(cd, true); print(" - "); printClassInfo(cd); dd(); printCommentTags(cd.firstSentenceTags()); } /** * What is the classkind? */ protected void printClassInfo(ClassDoc cd) { if (cd.isOrdinaryClass()) { printText("doclet.class"); } else if (cd.isInterface()) { printText("doclet.interface"); } else if (cd.isException()) { printText("doclet.exception"); } else { // error printText("doclet.error"); } print(' '); printPreQualifiedClassLink(cd); print('.'); } /** * Generate Description for Class, Field, Method or Constructor. * for Java.* Packages Class Members * * @param member MemberDoc for the member of the Class Kind. * @see com.sun.javadoc.ClassDoc#classKind * @see com.sun.javadoc.MemberDoc */ protected void printDescription(MemberDoc element) { String name = (element instanceof ExecutableMemberDoc)? element.name() + ((ExecutableMemberDoc)element).flatSignature(): element.name(); ClassDoc containing = element.containingClass(); String qualname = containing.qualifiedName(); String baseClassName = containing.name(); dt(); printDocLink(element, name, true); println(" - "); printMemberDesc(element); print(' '); printText(containing.isInterface()? "doclet.interface" : "doclet.class"); print(" "); printPreQualifiedClassLink(containing); println(); dd(); printComment(element); println(); } protected void printComment(MemberDoc element) { Tag[] tags; if ((tags = element.tags("deprecated")).length > 0) { printCommentTags(tags[0].inlineTags()); } else { printCommentTags(element.firstSentenceTags()); } } /** * Print description about the Static/Method/Constructor for a member. * * @param member MemberDoc for the member within the Class Kind. * @see com.sun.javadoc.MemberDoc */ protected void printMemberDesc(MemberDoc member) { if (member.isField()) { if (member.isStatic()) { printText("doclet.Static_variable_in"); } else { printText("doclet.Variable_in"); } } else if (member.isConstructor()) { printText("doclet.Constructor_for"); } else if (member.isMethod()) { if (member.isStatic()) { printText("doclet.Static_method_in"); } else { printText("doclet.Method_in"); } } } }