duke@1: /* xdono@117: * Copyright 1997-2008 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: duke@1: import com.sun.tools.doclets.internal.toolkit.*; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: import com.sun.tools.doclets.internal.toolkit.taglets.*; duke@1: import com.sun.javadoc.*; duke@1: import java.util.*; duke@1: import java.io.*; duke@1: duke@1: /** duke@1: * Writes constructor documentation. duke@1: * duke@1: * @author Robert Field duke@1: * @author Atul M Dambalkar duke@1: */ duke@1: public class ConstructorWriterImpl extends AbstractExecutableMemberWriter duke@1: implements ConstructorWriter, MemberSummaryWriter { duke@1: duke@1: private boolean foundNonPubConstructor = false; duke@1: private boolean printedSummaryHeader = false; duke@1: duke@1: /** duke@1: * Construct a new ConstructorWriterImpl. duke@1: * duke@1: * @param writer The writer for the class that the constructors belong to. duke@1: * @param classDoc the class being documented. duke@1: */ duke@1: public ConstructorWriterImpl(SubWriterHolderWriter writer, duke@1: ClassDoc classDoc) { duke@1: super(writer, classDoc); duke@1: VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc, duke@1: VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated); jjg@74: List constructors = new ArrayList(visibleMemberMap.getMembersFor(classDoc)); duke@1: for (int i = 0; i < constructors.size(); i++) { jjg@74: if ((constructors.get(i)).isProtected() || jjg@74: (constructors.get(i)).isPrivate()) { duke@1: setFoundNonPubConstructor(true); duke@1: } duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Construct a new ConstructorWriterImpl. duke@1: * duke@1: * @param writer The writer for the class that the constructors belong to. duke@1: */ duke@1: public ConstructorWriterImpl(SubWriterHolderWriter writer) { duke@1: super(writer); duke@1: } duke@1: duke@1: /** duke@1: * Write the constructors summary header for the given class. duke@1: * duke@1: * @param classDoc the class the summary belongs to. duke@1: */ duke@1: public void writeMemberSummaryHeader(ClassDoc classDoc) { duke@1: printedSummaryHeader = true; duke@1: writer.println(); duke@1: writer.println(""); duke@1: writer.println(); duke@1: writer.printSummaryHeader(this, classDoc); duke@1: } duke@1: duke@1: /** duke@1: * Write the constructors summary footer for the given class. duke@1: * duke@1: * @param classDoc the class the summary belongs to. duke@1: */ duke@1: public void writeMemberSummaryFooter(ClassDoc classDoc) { duke@1: writer.printSummaryFooter(this, classDoc); duke@1: } duke@1: duke@1: /** duke@1: * Write the header for the constructor documentation. duke@1: * duke@1: * @param classDoc the class that the constructors belong to. duke@1: */ duke@1: public void writeHeader(ClassDoc classDoc, String header) { duke@1: writer.println(); duke@1: writer.println(""); duke@1: writer.println(); duke@1: writer.anchor("constructor_detail"); duke@1: writer.printTableHeadingBackground(header); duke@1: } duke@1: duke@1: /** duke@1: * Write the constructor header for the given constructor. duke@1: * duke@1: * @param constructor the constructor being documented. duke@1: * @param isFirst the flag to indicate whether or not the constructor is the duke@1: * first to be documented. duke@1: */ duke@1: public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst) { duke@1: if (! isFirst) { duke@1: writer.printMemberHeader(); duke@1: } duke@1: writer.println(); duke@1: String erasureAnchor; duke@1: if ((erasureAnchor = getErasureAnchor(constructor)) != null) { duke@1: writer.anchor(erasureAnchor); duke@1: } duke@1: writer.anchor(constructor); duke@1: writer.h3(); duke@1: writer.print(constructor.name()); duke@1: writer.h3End(); duke@1: } duke@1: duke@1: /** duke@1: * Write the signature for the given constructor. duke@1: * duke@1: * @param constructor the constructor being documented. duke@1: */ duke@1: public void writeSignature(ConstructorDoc constructor) { duke@1: writer.displayLength = 0; duke@1: writer.pre(); duke@1: writer.writeAnnotationInfo(constructor); duke@1: printModifiers(constructor); duke@1: //printReturnType((ConstructorDoc)constructor); duke@1: if (configuration().linksource) { duke@1: writer.printSrcLink(constructor, constructor.name()); duke@1: } else { bpatel@182: strong(constructor.name()); duke@1: } duke@1: writeParameters(constructor); duke@1: writeExceptions(constructor); duke@1: writer.preEnd(); duke@1: writer.dl(); duke@1: } duke@1: duke@1: /** duke@1: * Write the deprecated output for the given constructor. duke@1: * duke@1: * @param constructor the constructor being documented. duke@1: */ duke@1: public void writeDeprecated(ConstructorDoc constructor) { duke@1: String output = ((TagletOutputImpl) duke@1: (new DeprecatedTaglet()).getTagletOutput(constructor, duke@1: writer.getTagletWriterInstance(false))).toString(); duke@1: if (output != null && output.trim().length() > 0) { duke@1: writer.print(output); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Write the comments for the given constructor. duke@1: * duke@1: * @param constructor the constructor being documented. duke@1: */ duke@1: public void writeComments(ConstructorDoc constructor) { duke@1: if (constructor.inlineTags().length > 0) { duke@1: writer.dd(); duke@1: writer.printInlineComment(constructor); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Write the tag output for the given constructor. duke@1: * duke@1: * @param constructor the constructor being documented. duke@1: */ duke@1: public void writeTags(ConstructorDoc constructor) { duke@1: writer.printTags(constructor); duke@1: } duke@1: duke@1: /** duke@1: * Write the constructor footer. duke@1: */ duke@1: public void writeConstructorFooter() { duke@1: writer.dlEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Write the footer for the constructor documentation. duke@1: * duke@1: * @param classDoc the class that the constructors belong to. duke@1: */ duke@1: public void writeFooter(ClassDoc classDoc) { duke@1: //No footer to write for constructor documentation duke@1: } duke@1: duke@1: /** duke@1: * Close the writer. duke@1: */ duke@1: public void close() throws IOException { duke@1: writer.close(); duke@1: } duke@1: duke@1: /** duke@1: * Let the writer know whether a non public constructor was found. duke@1: * duke@1: * @param foundNonPubConstructor true if we found a non public constructor. duke@1: */ duke@1: public void setFoundNonPubConstructor(boolean foundNonPubConstructor) { duke@1: this.foundNonPubConstructor = foundNonPubConstructor; duke@1: } duke@1: duke@1: public void printSummaryLabel(ClassDoc cd) { bpatel@182: writer.strongText("doclet.Constructor_Summary"); duke@1: } duke@1: duke@1: public void printSummaryAnchor(ClassDoc cd) { duke@1: writer.anchor("constructor_summary"); duke@1: } duke@1: duke@1: public void printInheritedSummaryAnchor(ClassDoc cd) { duke@1: } // no such duke@1: duke@1: public void printInheritedSummaryLabel(ClassDoc cd) { duke@1: // no such duke@1: } duke@1: duke@1: public int getMemberKind() { duke@1: return VisibleMemberMap.CONSTRUCTORS; duke@1: } duke@1: mcimadamore@184: protected void navSummaryLink(List members) { duke@1: printNavSummaryLink(classdoc, duke@1: members.size() > 0? true: false); duke@1: } duke@1: duke@1: protected void printNavSummaryLink(ClassDoc cd, boolean link) { duke@1: if (link) { duke@1: writer.printHyperLink("", "constructor_summary", duke@1: ConfigurationImpl.getInstance().getText("doclet.navConstructor")); duke@1: } else { duke@1: writer.printText("doclet.navConstructor"); duke@1: } duke@1: } duke@1: duke@1: protected void printNavDetailLink(boolean link) { duke@1: if (link) { duke@1: writer.printHyperLink("", "constructor_detail", duke@1: ConfigurationImpl.getInstance().getText("doclet.navConstructor")); duke@1: } else { duke@1: writer.printText("doclet.navConstructor"); duke@1: } duke@1: } duke@1: duke@1: protected void printSummaryType(ProgramElementDoc member) { duke@1: if (foundNonPubConstructor) { duke@1: writer.printTypeSummaryHeader(); duke@1: if (member.isProtected()) { duke@1: print("protected "); duke@1: } else if (member.isPrivate()) { duke@1: print("private "); duke@1: } else if (member.isPublic()) { duke@1: writer.space(); duke@1: } else { duke@1: writer.printText("doclet.Package_private"); duke@1: } duke@1: writer.printTypeSummaryFooter(); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Write the inherited member summary header for the given class. duke@1: * duke@1: * @param classDoc the class the summary belongs to. duke@1: */ duke@1: public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) { duke@1: if(! printedSummaryHeader){ duke@1: //We don't want inherited summary to not be under heading. duke@1: writeMemberSummaryHeader(classDoc); duke@1: writeMemberSummaryFooter(classDoc); duke@1: printedSummaryHeader = true; duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ duke@1: public void writeInheritedMemberSummary(ClassDoc classDoc, duke@1: ProgramElementDoc member, boolean isFirst, boolean isLast) {} duke@1: duke@1: /** duke@1: * Write the inherited member summary footer for the given class. duke@1: * duke@1: * @param classDoc the class the summary belongs to. duke@1: */ duke@1: public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {} duke@1: }