src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java

Thu, 02 Oct 2008 19:58:40 -0700

author
xdono
date
Thu, 02 Oct 2008 19:58:40 -0700
changeset 117
24a47c3062fe
parent 74
5a9172b251dd
child 182
47a62d8d98b4
permissions
-rw-r--r--

6754988: Update copyright year
Summary: Update for files that have been modified starting July 2008
Reviewed-by: ohair, tbell

duke@1 1 /*
xdono@117 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation. Sun designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
duke@1 9 * by Sun in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
duke@1 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@1 22 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@1 23 * have any questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.doclets.formats.html;
duke@1 27
duke@1 28 import com.sun.tools.doclets.internal.toolkit.*;
duke@1 29 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 30 import com.sun.tools.doclets.internal.toolkit.taglets.*;
duke@1 31 import com.sun.javadoc.*;
duke@1 32 import java.util.*;
duke@1 33 import java.io.*;
duke@1 34
duke@1 35 /**
duke@1 36 * Writes constructor documentation.
duke@1 37 *
duke@1 38 * @author Robert Field
duke@1 39 * @author Atul M Dambalkar
duke@1 40 */
duke@1 41 public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
duke@1 42 implements ConstructorWriter, MemberSummaryWriter {
duke@1 43
duke@1 44 private boolean foundNonPubConstructor = false;
duke@1 45 private boolean printedSummaryHeader = false;
duke@1 46
duke@1 47 /**
duke@1 48 * Construct a new ConstructorWriterImpl.
duke@1 49 *
duke@1 50 * @param writer The writer for the class that the constructors belong to.
duke@1 51 * @param classDoc the class being documented.
duke@1 52 */
duke@1 53 public ConstructorWriterImpl(SubWriterHolderWriter writer,
duke@1 54 ClassDoc classDoc) {
duke@1 55 super(writer, classDoc);
duke@1 56 VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc,
duke@1 57 VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated);
jjg@74 58 List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
duke@1 59 for (int i = 0; i < constructors.size(); i++) {
jjg@74 60 if ((constructors.get(i)).isProtected() ||
jjg@74 61 (constructors.get(i)).isPrivate()) {
duke@1 62 setFoundNonPubConstructor(true);
duke@1 63 }
duke@1 64 }
duke@1 65 }
duke@1 66
duke@1 67 /**
duke@1 68 * Construct a new ConstructorWriterImpl.
duke@1 69 *
duke@1 70 * @param writer The writer for the class that the constructors belong to.
duke@1 71 */
duke@1 72 public ConstructorWriterImpl(SubWriterHolderWriter writer) {
duke@1 73 super(writer);
duke@1 74 }
duke@1 75
duke@1 76 /**
duke@1 77 * Write the constructors summary header for the given class.
duke@1 78 *
duke@1 79 * @param classDoc the class the summary belongs to.
duke@1 80 */
duke@1 81 public void writeMemberSummaryHeader(ClassDoc classDoc) {
duke@1 82 printedSummaryHeader = true;
duke@1 83 writer.println();
duke@1 84 writer.println("<!-- ======== CONSTRUCTOR SUMMARY ======== -->");
duke@1 85 writer.println();
duke@1 86 writer.printSummaryHeader(this, classDoc);
duke@1 87 }
duke@1 88
duke@1 89 /**
duke@1 90 * Write the constructors summary footer for the given class.
duke@1 91 *
duke@1 92 * @param classDoc the class the summary belongs to.
duke@1 93 */
duke@1 94 public void writeMemberSummaryFooter(ClassDoc classDoc) {
duke@1 95 writer.printSummaryFooter(this, classDoc);
duke@1 96 }
duke@1 97
duke@1 98 /**
duke@1 99 * Write the header for the constructor documentation.
duke@1 100 *
duke@1 101 * @param classDoc the class that the constructors belong to.
duke@1 102 */
duke@1 103 public void writeHeader(ClassDoc classDoc, String header) {
duke@1 104 writer.println();
duke@1 105 writer.println("<!-- ========= CONSTRUCTOR DETAIL ======== -->");
duke@1 106 writer.println();
duke@1 107 writer.anchor("constructor_detail");
duke@1 108 writer.printTableHeadingBackground(header);
duke@1 109 }
duke@1 110
duke@1 111 /**
duke@1 112 * Write the constructor header for the given constructor.
duke@1 113 *
duke@1 114 * @param constructor the constructor being documented.
duke@1 115 * @param isFirst the flag to indicate whether or not the constructor is the
duke@1 116 * first to be documented.
duke@1 117 */
duke@1 118 public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst) {
duke@1 119 if (! isFirst) {
duke@1 120 writer.printMemberHeader();
duke@1 121 }
duke@1 122 writer.println();
duke@1 123 String erasureAnchor;
duke@1 124 if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
duke@1 125 writer.anchor(erasureAnchor);
duke@1 126 }
duke@1 127 writer.anchor(constructor);
duke@1 128 writer.h3();
duke@1 129 writer.print(constructor.name());
duke@1 130 writer.h3End();
duke@1 131 }
duke@1 132
duke@1 133 /**
duke@1 134 * Write the signature for the given constructor.
duke@1 135 *
duke@1 136 * @param constructor the constructor being documented.
duke@1 137 */
duke@1 138 public void writeSignature(ConstructorDoc constructor) {
duke@1 139 writer.displayLength = 0;
duke@1 140 writer.pre();
duke@1 141 writer.writeAnnotationInfo(constructor);
duke@1 142 printModifiers(constructor);
duke@1 143 //printReturnType((ConstructorDoc)constructor);
duke@1 144 if (configuration().linksource) {
duke@1 145 writer.printSrcLink(constructor, constructor.name());
duke@1 146 } else {
duke@1 147 bold(constructor.name());
duke@1 148 }
duke@1 149 writeParameters(constructor);
duke@1 150 writeExceptions(constructor);
duke@1 151 writer.preEnd();
duke@1 152 writer.dl();
duke@1 153 }
duke@1 154
duke@1 155 /**
duke@1 156 * Write the deprecated output for the given constructor.
duke@1 157 *
duke@1 158 * @param constructor the constructor being documented.
duke@1 159 */
duke@1 160 public void writeDeprecated(ConstructorDoc constructor) {
duke@1 161 String output = ((TagletOutputImpl)
duke@1 162 (new DeprecatedTaglet()).getTagletOutput(constructor,
duke@1 163 writer.getTagletWriterInstance(false))).toString();
duke@1 164 if (output != null && output.trim().length() > 0) {
duke@1 165 writer.print(output);
duke@1 166 }
duke@1 167 }
duke@1 168
duke@1 169 /**
duke@1 170 * Write the comments for the given constructor.
duke@1 171 *
duke@1 172 * @param constructor the constructor being documented.
duke@1 173 */
duke@1 174 public void writeComments(ConstructorDoc constructor) {
duke@1 175 if (constructor.inlineTags().length > 0) {
duke@1 176 writer.dd();
duke@1 177 writer.printInlineComment(constructor);
duke@1 178 }
duke@1 179 }
duke@1 180
duke@1 181 /**
duke@1 182 * Write the tag output for the given constructor.
duke@1 183 *
duke@1 184 * @param constructor the constructor being documented.
duke@1 185 */
duke@1 186 public void writeTags(ConstructorDoc constructor) {
duke@1 187 writer.printTags(constructor);
duke@1 188 }
duke@1 189
duke@1 190 /**
duke@1 191 * Write the constructor footer.
duke@1 192 */
duke@1 193 public void writeConstructorFooter() {
duke@1 194 writer.dlEnd();
duke@1 195 }
duke@1 196
duke@1 197 /**
duke@1 198 * Write the footer for the constructor documentation.
duke@1 199 *
duke@1 200 * @param classDoc the class that the constructors belong to.
duke@1 201 */
duke@1 202 public void writeFooter(ClassDoc classDoc) {
duke@1 203 //No footer to write for constructor documentation
duke@1 204 }
duke@1 205
duke@1 206 /**
duke@1 207 * Close the writer.
duke@1 208 */
duke@1 209 public void close() throws IOException {
duke@1 210 writer.close();
duke@1 211 }
duke@1 212
duke@1 213 /**
duke@1 214 * Let the writer know whether a non public constructor was found.
duke@1 215 *
duke@1 216 * @param foundNonPubConstructor true if we found a non public constructor.
duke@1 217 */
duke@1 218 public void setFoundNonPubConstructor(boolean foundNonPubConstructor) {
duke@1 219 this.foundNonPubConstructor = foundNonPubConstructor;
duke@1 220 }
duke@1 221
duke@1 222 public void printSummaryLabel(ClassDoc cd) {
duke@1 223 writer.boldText("doclet.Constructor_Summary");
duke@1 224 }
duke@1 225
duke@1 226 public void printSummaryAnchor(ClassDoc cd) {
duke@1 227 writer.anchor("constructor_summary");
duke@1 228 }
duke@1 229
duke@1 230 public void printInheritedSummaryAnchor(ClassDoc cd) {
duke@1 231 } // no such
duke@1 232
duke@1 233 public void printInheritedSummaryLabel(ClassDoc cd) {
duke@1 234 // no such
duke@1 235 }
duke@1 236
duke@1 237 public int getMemberKind() {
duke@1 238 return VisibleMemberMap.CONSTRUCTORS;
duke@1 239 }
duke@1 240
duke@1 241 protected void navSummaryLink(List members) {
duke@1 242 printNavSummaryLink(classdoc,
duke@1 243 members.size() > 0? true: false);
duke@1 244 }
duke@1 245
duke@1 246 protected void printNavSummaryLink(ClassDoc cd, boolean link) {
duke@1 247 if (link) {
duke@1 248 writer.printHyperLink("", "constructor_summary",
duke@1 249 ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
duke@1 250 } else {
duke@1 251 writer.printText("doclet.navConstructor");
duke@1 252 }
duke@1 253 }
duke@1 254
duke@1 255 protected void printNavDetailLink(boolean link) {
duke@1 256 if (link) {
duke@1 257 writer.printHyperLink("", "constructor_detail",
duke@1 258 ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
duke@1 259 } else {
duke@1 260 writer.printText("doclet.navConstructor");
duke@1 261 }
duke@1 262 }
duke@1 263
duke@1 264 protected void printSummaryType(ProgramElementDoc member) {
duke@1 265 if (foundNonPubConstructor) {
duke@1 266 writer.printTypeSummaryHeader();
duke@1 267 if (member.isProtected()) {
duke@1 268 print("protected ");
duke@1 269 } else if (member.isPrivate()) {
duke@1 270 print("private ");
duke@1 271 } else if (member.isPublic()) {
duke@1 272 writer.space();
duke@1 273 } else {
duke@1 274 writer.printText("doclet.Package_private");
duke@1 275 }
duke@1 276 writer.printTypeSummaryFooter();
duke@1 277 }
duke@1 278 }
duke@1 279
duke@1 280 /**
duke@1 281 * Write the inherited member summary header for the given class.
duke@1 282 *
duke@1 283 * @param classDoc the class the summary belongs to.
duke@1 284 */
duke@1 285 public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
duke@1 286 if(! printedSummaryHeader){
duke@1 287 //We don't want inherited summary to not be under heading.
duke@1 288 writeMemberSummaryHeader(classDoc);
duke@1 289 writeMemberSummaryFooter(classDoc);
duke@1 290 printedSummaryHeader = true;
duke@1 291 }
duke@1 292 }
duke@1 293
duke@1 294 /**
duke@1 295 * {@inheritDoc}
duke@1 296 */
duke@1 297 public void writeInheritedMemberSummary(ClassDoc classDoc,
duke@1 298 ProgramElementDoc member, boolean isFirst, boolean isLast) {}
duke@1 299
duke@1 300 /**
duke@1 301 * Write the inherited member summary footer for the given class.
duke@1 302 *
duke@1 303 * @param classDoc the class the summary belongs to.
duke@1 304 */
duke@1 305 public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {}
duke@1 306 }

mercurial