ConstructorWriterImpl.java revision 553
0N/A/*
553N/A * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.doclets.formats.html;
0N/A
232N/Aimport java.io.*;
232N/Aimport java.util.*;
232N/A
232N/Aimport com.sun.javadoc.*;
0N/Aimport com.sun.tools.doclets.internal.toolkit.*;
0N/Aimport com.sun.tools.doclets.internal.toolkit.util.*;
0N/A
0N/A/**
0N/A * Writes constructor documentation.
0N/A *
0N/A * @author Robert Field
0N/A * @author Atul M Dambalkar
242N/A * @author Bhavesh Patel (Modified)
0N/A */
0N/Apublic class ConstructorWriterImpl extends AbstractExecutableMemberWriter
0N/A implements ConstructorWriter, MemberSummaryWriter {
0N/A
0N/A private boolean foundNonPubConstructor = false;
0N/A private boolean printedSummaryHeader = false;
0N/A
0N/A /**
0N/A * Construct a new ConstructorWriterImpl.
0N/A *
0N/A * @param writer The writer for the class that the constructors belong to.
0N/A * @param classDoc the class being documented.
0N/A */
0N/A public ConstructorWriterImpl(SubWriterHolderWriter writer,
0N/A ClassDoc classDoc) {
0N/A super(writer, classDoc);
0N/A VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc,
0N/A VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated);
73N/A List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
0N/A for (int i = 0; i < constructors.size(); i++) {
73N/A if ((constructors.get(i)).isProtected() ||
73N/A (constructors.get(i)).isPrivate()) {
0N/A setFoundNonPubConstructor(true);
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Construct a new ConstructorWriterImpl.
0N/A *
0N/A * @param writer The writer for the class that the constructors belong to.
0N/A */
0N/A public ConstructorWriterImpl(SubWriterHolderWriter writer) {
0N/A super(writer);
0N/A }
0N/A
0N/A /**
0N/A * Write the constructors summary header for the given class.
0N/A *
0N/A * @param classDoc the class the summary belongs to.
0N/A */
0N/A public void writeMemberSummaryHeader(ClassDoc classDoc) {
0N/A printedSummaryHeader = true;
0N/A writer.println();
0N/A writer.println("<!-- ======== CONSTRUCTOR SUMMARY ======== -->");
0N/A writer.println();
0N/A writer.printSummaryHeader(this, classDoc);
0N/A }
0N/A
0N/A /**
0N/A * Write the constructors summary footer for the given class.
0N/A *
0N/A * @param classDoc the class the summary belongs to.
0N/A */
0N/A public void writeMemberSummaryFooter(ClassDoc classDoc) {
0N/A writer.printSummaryFooter(this, classDoc);
0N/A }
0N/A
0N/A /**
0N/A * Write the header for the constructor documentation.
0N/A *
0N/A * @param classDoc the class that the constructors belong to.
0N/A */
0N/A public void writeHeader(ClassDoc classDoc, String header) {
0N/A writer.println();
0N/A writer.println("<!-- ========= CONSTRUCTOR DETAIL ======== -->");
0N/A writer.println();
0N/A writer.anchor("constructor_detail");
0N/A writer.printTableHeadingBackground(header);
0N/A }
0N/A
0N/A /**
0N/A * Write the constructor header for the given constructor.
0N/A *
0N/A * @param constructor the constructor being documented.
0N/A * @param isFirst the flag to indicate whether or not the constructor is the
0N/A * first to be documented.
0N/A */
0N/A public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst) {
0N/A if (! isFirst) {
0N/A writer.printMemberHeader();
0N/A }
0N/A writer.println();
0N/A String erasureAnchor;
0N/A if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
0N/A writer.anchor(erasureAnchor);
0N/A }
0N/A writer.anchor(constructor);
0N/A writer.h3();
0N/A writer.print(constructor.name());
0N/A writer.h3End();
0N/A }
0N/A
0N/A /**
0N/A * Write the signature for the given constructor.
0N/A *
0N/A * @param constructor the constructor being documented.
0N/A */
0N/A public void writeSignature(ConstructorDoc constructor) {
0N/A writer.displayLength = 0;
0N/A writer.pre();
0N/A writer.writeAnnotationInfo(constructor);
0N/A printModifiers(constructor);
0N/A //printReturnType((ConstructorDoc)constructor);
0N/A if (configuration().linksource) {
0N/A writer.printSrcLink(constructor, constructor.name());
0N/A } else {
181N/A strong(constructor.name());
0N/A }
0N/A writeParameters(constructor);
0N/A writeExceptions(constructor);
0N/A writer.preEnd();
232N/A assert !writer.getMemberDetailsListPrinted();
0N/A }
0N/A
0N/A /**
0N/A * Write the deprecated output for the given constructor.
0N/A *
0N/A * @param constructor the constructor being documented.
0N/A */
0N/A public void writeDeprecated(ConstructorDoc constructor) {
232N/A printDeprecated(constructor);
0N/A }
0N/A
0N/A /**
0N/A * Write the comments for the given constructor.
0N/A *
0N/A * @param constructor the constructor being documented.
0N/A */
0N/A public void writeComments(ConstructorDoc constructor) {
232N/A printComment(constructor);
0N/A }
0N/A
0N/A /**
0N/A * Write the tag output for the given constructor.
0N/A *
0N/A * @param constructor the constructor being documented.
0N/A */
0N/A public void writeTags(ConstructorDoc constructor) {
0N/A writer.printTags(constructor);
0N/A }
0N/A
0N/A /**
0N/A * Write the constructor footer.
0N/A */
0N/A public void writeConstructorFooter() {
232N/A printMemberFooter();
0N/A }
0N/A
0N/A /**
0N/A * Write the footer for the constructor documentation.
0N/A *
0N/A * @param classDoc the class that the constructors belong to.
0N/A */
0N/A public void writeFooter(ClassDoc classDoc) {
0N/A //No footer to write for constructor documentation
0N/A }
0N/A
0N/A /**
0N/A * Close the writer.
0N/A */
0N/A public void close() throws IOException {
0N/A writer.close();
0N/A }
0N/A
0N/A /**
0N/A * Let the writer know whether a non public constructor was found.
0N/A *
0N/A * @param foundNonPubConstructor true if we found a non public constructor.
0N/A */
0N/A public void setFoundNonPubConstructor(boolean foundNonPubConstructor) {
0N/A this.foundNonPubConstructor = foundNonPubConstructor;
0N/A }
0N/A
242N/A public void printSummaryLabel() {
242N/A writer.printText("doclet.Constructor_Summary");
242N/A }
242N/A
242N/A public void printTableSummary() {
242N/A writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
242N/A configuration().getText("doclet.Constructor_Summary"),
242N/A configuration().getText("doclet.constructors")));
242N/A }
242N/A
242N/A public void printSummaryTableHeader(ProgramElementDoc member) {
242N/A String[] header;
242N/A if (foundNonPubConstructor) {
242N/A header = new String[] {
242N/A configuration().getText("doclet.Modifier"),
242N/A configuration().getText("doclet.0_and_1",
242N/A configuration().getText("doclet.Constructor"),
242N/A configuration().getText("doclet.Description"))
242N/A };
242N/A }
242N/A else {
242N/A header = new String[] {
242N/A configuration().getText("doclet.0_and_1",
242N/A configuration().getText("doclet.Constructor"),
242N/A configuration().getText("doclet.Description"))
242N/A };
242N/A }
242N/A writer.summaryTableHeader(header, "col");
0N/A }
0N/A
0N/A public void printSummaryAnchor(ClassDoc cd) {
0N/A writer.anchor("constructor_summary");
0N/A }
0N/A
0N/A public void printInheritedSummaryAnchor(ClassDoc cd) {
0N/A } // no such
0N/A
0N/A public void printInheritedSummaryLabel(ClassDoc cd) {
0N/A // no such
0N/A }
0N/A
0N/A public int getMemberKind() {
0N/A return VisibleMemberMap.CONSTRUCTORS;
0N/A }
0N/A
183N/A protected void navSummaryLink(List<?> members) {
0N/A printNavSummaryLink(classdoc,
0N/A members.size() > 0? true: false);
0N/A }
0N/A
0N/A protected void printNavSummaryLink(ClassDoc cd, boolean link) {
0N/A if (link) {
0N/A writer.printHyperLink("", "constructor_summary",
0N/A ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
0N/A } else {
0N/A writer.printText("doclet.navConstructor");
0N/A }
0N/A }
0N/A
0N/A protected void printNavDetailLink(boolean link) {
0N/A if (link) {
0N/A writer.printHyperLink("", "constructor_detail",
0N/A ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
0N/A } else {
0N/A writer.printText("doclet.navConstructor");
0N/A }
0N/A }
0N/A
0N/A protected void printSummaryType(ProgramElementDoc member) {
0N/A if (foundNonPubConstructor) {
0N/A writer.printTypeSummaryHeader();
0N/A if (member.isProtected()) {
0N/A print("protected ");
0N/A } else if (member.isPrivate()) {
0N/A print("private ");
0N/A } else if (member.isPublic()) {
0N/A writer.space();
0N/A } else {
0N/A writer.printText("doclet.Package_private");
0N/A }
0N/A writer.printTypeSummaryFooter();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Write the inherited member summary header for the given class.
0N/A *
0N/A * @param classDoc the class the summary belongs to.
0N/A */
0N/A public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
0N/A if(! printedSummaryHeader){
0N/A //We don't want inherited summary to not be under heading.
0N/A writeMemberSummaryHeader(classDoc);
0N/A writeMemberSummaryFooter(classDoc);
0N/A printedSummaryHeader = true;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public void writeInheritedMemberSummary(ClassDoc classDoc,
0N/A ProgramElementDoc member, boolean isFirst, boolean isLast) {}
0N/A
0N/A /**
0N/A * Write the inherited member summary footer for the given class.
0N/A *
0N/A * @param classDoc the class the summary belongs to.
0N/A */
0N/A public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {}
0N/A}