Fri, 03 Dec 2010 20:31:57 -0800
6522789: [zh_CN] translation of "enclosing class" in doclet is incorrect
Reviewed-by: yhuang
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 1997, 2008, Oracle and/or its affiliates. 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 |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle 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 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.doclets.formats.html; |
duke@1 | 27 | |
bpatel@233 | 28 | import java.io.*; |
bpatel@233 | 29 | import java.util.*; |
bpatel@233 | 30 | |
bpatel@233 | 31 | import com.sun.javadoc.*; |
duke@1 | 32 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 33 | import com.sun.tools.doclets.internal.toolkit.util.*; |
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 |
bpatel@243 | 40 | * @author Bhavesh Patel (Modified) |
duke@1 | 41 | */ |
duke@1 | 42 | public class ConstructorWriterImpl extends AbstractExecutableMemberWriter |
duke@1 | 43 | implements ConstructorWriter, MemberSummaryWriter { |
duke@1 | 44 | |
duke@1 | 45 | private boolean foundNonPubConstructor = false; |
duke@1 | 46 | private boolean printedSummaryHeader = false; |
duke@1 | 47 | |
duke@1 | 48 | /** |
duke@1 | 49 | * Construct a new ConstructorWriterImpl. |
duke@1 | 50 | * |
duke@1 | 51 | * @param writer The writer for the class that the constructors belong to. |
duke@1 | 52 | * @param classDoc the class being documented. |
duke@1 | 53 | */ |
duke@1 | 54 | public ConstructorWriterImpl(SubWriterHolderWriter writer, |
duke@1 | 55 | ClassDoc classDoc) { |
duke@1 | 56 | super(writer, classDoc); |
duke@1 | 57 | VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc, |
duke@1 | 58 | VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated); |
jjg@74 | 59 | List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc)); |
duke@1 | 60 | for (int i = 0; i < constructors.size(); i++) { |
jjg@74 | 61 | if ((constructors.get(i)).isProtected() || |
jjg@74 | 62 | (constructors.get(i)).isPrivate()) { |
duke@1 | 63 | setFoundNonPubConstructor(true); |
duke@1 | 64 | } |
duke@1 | 65 | } |
duke@1 | 66 | } |
duke@1 | 67 | |
duke@1 | 68 | /** |
duke@1 | 69 | * Construct a new ConstructorWriterImpl. |
duke@1 | 70 | * |
duke@1 | 71 | * @param writer The writer for the class that the constructors belong to. |
duke@1 | 72 | */ |
duke@1 | 73 | public ConstructorWriterImpl(SubWriterHolderWriter writer) { |
duke@1 | 74 | super(writer); |
duke@1 | 75 | } |
duke@1 | 76 | |
duke@1 | 77 | /** |
duke@1 | 78 | * Write the constructors summary header for the given class. |
duke@1 | 79 | * |
duke@1 | 80 | * @param classDoc the class the summary belongs to. |
duke@1 | 81 | */ |
duke@1 | 82 | public void writeMemberSummaryHeader(ClassDoc classDoc) { |
duke@1 | 83 | printedSummaryHeader = true; |
duke@1 | 84 | writer.println(); |
duke@1 | 85 | writer.println("<!-- ======== CONSTRUCTOR SUMMARY ======== -->"); |
duke@1 | 86 | writer.println(); |
duke@1 | 87 | writer.printSummaryHeader(this, classDoc); |
duke@1 | 88 | } |
duke@1 | 89 | |
duke@1 | 90 | /** |
duke@1 | 91 | * Write the constructors summary footer for the given class. |
duke@1 | 92 | * |
duke@1 | 93 | * @param classDoc the class the summary belongs to. |
duke@1 | 94 | */ |
duke@1 | 95 | public void writeMemberSummaryFooter(ClassDoc classDoc) { |
duke@1 | 96 | writer.printSummaryFooter(this, classDoc); |
duke@1 | 97 | } |
duke@1 | 98 | |
duke@1 | 99 | /** |
duke@1 | 100 | * Write the header for the constructor documentation. |
duke@1 | 101 | * |
duke@1 | 102 | * @param classDoc the class that the constructors belong to. |
duke@1 | 103 | */ |
duke@1 | 104 | public void writeHeader(ClassDoc classDoc, String header) { |
duke@1 | 105 | writer.println(); |
duke@1 | 106 | writer.println("<!-- ========= CONSTRUCTOR DETAIL ======== -->"); |
duke@1 | 107 | writer.println(); |
duke@1 | 108 | writer.anchor("constructor_detail"); |
duke@1 | 109 | writer.printTableHeadingBackground(header); |
duke@1 | 110 | } |
duke@1 | 111 | |
duke@1 | 112 | /** |
duke@1 | 113 | * Write the constructor header for the given constructor. |
duke@1 | 114 | * |
duke@1 | 115 | * @param constructor the constructor being documented. |
duke@1 | 116 | * @param isFirst the flag to indicate whether or not the constructor is the |
duke@1 | 117 | * first to be documented. |
duke@1 | 118 | */ |
duke@1 | 119 | public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst) { |
duke@1 | 120 | if (! isFirst) { |
duke@1 | 121 | writer.printMemberHeader(); |
duke@1 | 122 | } |
duke@1 | 123 | writer.println(); |
duke@1 | 124 | String erasureAnchor; |
duke@1 | 125 | if ((erasureAnchor = getErasureAnchor(constructor)) != null) { |
duke@1 | 126 | writer.anchor(erasureAnchor); |
duke@1 | 127 | } |
duke@1 | 128 | writer.anchor(constructor); |
duke@1 | 129 | writer.h3(); |
duke@1 | 130 | writer.print(constructor.name()); |
duke@1 | 131 | writer.h3End(); |
duke@1 | 132 | } |
duke@1 | 133 | |
duke@1 | 134 | /** |
duke@1 | 135 | * Write the signature for the given constructor. |
duke@1 | 136 | * |
duke@1 | 137 | * @param constructor the constructor being documented. |
duke@1 | 138 | */ |
duke@1 | 139 | public void writeSignature(ConstructorDoc constructor) { |
duke@1 | 140 | writer.displayLength = 0; |
duke@1 | 141 | writer.pre(); |
duke@1 | 142 | writer.writeAnnotationInfo(constructor); |
duke@1 | 143 | printModifiers(constructor); |
duke@1 | 144 | //printReturnType((ConstructorDoc)constructor); |
duke@1 | 145 | if (configuration().linksource) { |
duke@1 | 146 | writer.printSrcLink(constructor, constructor.name()); |
duke@1 | 147 | } else { |
bpatel@182 | 148 | strong(constructor.name()); |
duke@1 | 149 | } |
duke@1 | 150 | writeParameters(constructor); |
duke@1 | 151 | writeExceptions(constructor); |
duke@1 | 152 | writer.preEnd(); |
bpatel@233 | 153 | assert !writer.getMemberDetailsListPrinted(); |
duke@1 | 154 | } |
duke@1 | 155 | |
duke@1 | 156 | /** |
duke@1 | 157 | * Write the deprecated output for the given constructor. |
duke@1 | 158 | * |
duke@1 | 159 | * @param constructor the constructor being documented. |
duke@1 | 160 | */ |
duke@1 | 161 | public void writeDeprecated(ConstructorDoc constructor) { |
bpatel@233 | 162 | printDeprecated(constructor); |
duke@1 | 163 | } |
duke@1 | 164 | |
duke@1 | 165 | /** |
duke@1 | 166 | * Write the comments for the given constructor. |
duke@1 | 167 | * |
duke@1 | 168 | * @param constructor the constructor being documented. |
duke@1 | 169 | */ |
duke@1 | 170 | public void writeComments(ConstructorDoc constructor) { |
bpatel@233 | 171 | printComment(constructor); |
duke@1 | 172 | } |
duke@1 | 173 | |
duke@1 | 174 | /** |
duke@1 | 175 | * Write the tag output for the given constructor. |
duke@1 | 176 | * |
duke@1 | 177 | * @param constructor the constructor being documented. |
duke@1 | 178 | */ |
duke@1 | 179 | public void writeTags(ConstructorDoc constructor) { |
duke@1 | 180 | writer.printTags(constructor); |
duke@1 | 181 | } |
duke@1 | 182 | |
duke@1 | 183 | /** |
duke@1 | 184 | * Write the constructor footer. |
duke@1 | 185 | */ |
duke@1 | 186 | public void writeConstructorFooter() { |
bpatel@233 | 187 | printMemberFooter(); |
duke@1 | 188 | } |
duke@1 | 189 | |
duke@1 | 190 | /** |
duke@1 | 191 | * Write the footer for the constructor documentation. |
duke@1 | 192 | * |
duke@1 | 193 | * @param classDoc the class that the constructors belong to. |
duke@1 | 194 | */ |
duke@1 | 195 | public void writeFooter(ClassDoc classDoc) { |
duke@1 | 196 | //No footer to write for constructor documentation |
duke@1 | 197 | } |
duke@1 | 198 | |
duke@1 | 199 | /** |
duke@1 | 200 | * Close the writer. |
duke@1 | 201 | */ |
duke@1 | 202 | public void close() throws IOException { |
duke@1 | 203 | writer.close(); |
duke@1 | 204 | } |
duke@1 | 205 | |
duke@1 | 206 | /** |
duke@1 | 207 | * Let the writer know whether a non public constructor was found. |
duke@1 | 208 | * |
duke@1 | 209 | * @param foundNonPubConstructor true if we found a non public constructor. |
duke@1 | 210 | */ |
duke@1 | 211 | public void setFoundNonPubConstructor(boolean foundNonPubConstructor) { |
duke@1 | 212 | this.foundNonPubConstructor = foundNonPubConstructor; |
duke@1 | 213 | } |
duke@1 | 214 | |
bpatel@243 | 215 | public void printSummaryLabel() { |
bpatel@243 | 216 | writer.printText("doclet.Constructor_Summary"); |
bpatel@243 | 217 | } |
bpatel@243 | 218 | |
bpatel@243 | 219 | public void printTableSummary() { |
bpatel@243 | 220 | writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary", |
bpatel@243 | 221 | configuration().getText("doclet.Constructor_Summary"), |
bpatel@243 | 222 | configuration().getText("doclet.constructors"))); |
bpatel@243 | 223 | } |
bpatel@243 | 224 | |
bpatel@243 | 225 | public void printSummaryTableHeader(ProgramElementDoc member) { |
bpatel@243 | 226 | String[] header; |
bpatel@243 | 227 | if (foundNonPubConstructor) { |
bpatel@243 | 228 | header = new String[] { |
bpatel@243 | 229 | configuration().getText("doclet.Modifier"), |
bpatel@243 | 230 | configuration().getText("doclet.0_and_1", |
bpatel@243 | 231 | configuration().getText("doclet.Constructor"), |
bpatel@243 | 232 | configuration().getText("doclet.Description")) |
bpatel@243 | 233 | }; |
bpatel@243 | 234 | } |
bpatel@243 | 235 | else { |
bpatel@243 | 236 | header = new String[] { |
bpatel@243 | 237 | configuration().getText("doclet.0_and_1", |
bpatel@243 | 238 | configuration().getText("doclet.Constructor"), |
bpatel@243 | 239 | configuration().getText("doclet.Description")) |
bpatel@243 | 240 | }; |
bpatel@243 | 241 | } |
bpatel@243 | 242 | writer.summaryTableHeader(header, "col"); |
duke@1 | 243 | } |
duke@1 | 244 | |
duke@1 | 245 | public void printSummaryAnchor(ClassDoc cd) { |
duke@1 | 246 | writer.anchor("constructor_summary"); |
duke@1 | 247 | } |
duke@1 | 248 | |
duke@1 | 249 | public void printInheritedSummaryAnchor(ClassDoc cd) { |
duke@1 | 250 | } // no such |
duke@1 | 251 | |
duke@1 | 252 | public void printInheritedSummaryLabel(ClassDoc cd) { |
duke@1 | 253 | // no such |
duke@1 | 254 | } |
duke@1 | 255 | |
duke@1 | 256 | public int getMemberKind() { |
duke@1 | 257 | return VisibleMemberMap.CONSTRUCTORS; |
duke@1 | 258 | } |
duke@1 | 259 | |
mcimadamore@184 | 260 | protected void navSummaryLink(List<?> members) { |
duke@1 | 261 | printNavSummaryLink(classdoc, |
duke@1 | 262 | members.size() > 0? true: false); |
duke@1 | 263 | } |
duke@1 | 264 | |
duke@1 | 265 | protected void printNavSummaryLink(ClassDoc cd, boolean link) { |
duke@1 | 266 | if (link) { |
duke@1 | 267 | writer.printHyperLink("", "constructor_summary", |
duke@1 | 268 | ConfigurationImpl.getInstance().getText("doclet.navConstructor")); |
duke@1 | 269 | } else { |
duke@1 | 270 | writer.printText("doclet.navConstructor"); |
duke@1 | 271 | } |
duke@1 | 272 | } |
duke@1 | 273 | |
duke@1 | 274 | protected void printNavDetailLink(boolean link) { |
duke@1 | 275 | if (link) { |
duke@1 | 276 | writer.printHyperLink("", "constructor_detail", |
duke@1 | 277 | ConfigurationImpl.getInstance().getText("doclet.navConstructor")); |
duke@1 | 278 | } else { |
duke@1 | 279 | writer.printText("doclet.navConstructor"); |
duke@1 | 280 | } |
duke@1 | 281 | } |
duke@1 | 282 | |
duke@1 | 283 | protected void printSummaryType(ProgramElementDoc member) { |
duke@1 | 284 | if (foundNonPubConstructor) { |
duke@1 | 285 | writer.printTypeSummaryHeader(); |
duke@1 | 286 | if (member.isProtected()) { |
duke@1 | 287 | print("protected "); |
duke@1 | 288 | } else if (member.isPrivate()) { |
duke@1 | 289 | print("private "); |
duke@1 | 290 | } else if (member.isPublic()) { |
duke@1 | 291 | writer.space(); |
duke@1 | 292 | } else { |
duke@1 | 293 | writer.printText("doclet.Package_private"); |
duke@1 | 294 | } |
duke@1 | 295 | writer.printTypeSummaryFooter(); |
duke@1 | 296 | } |
duke@1 | 297 | } |
duke@1 | 298 | |
duke@1 | 299 | /** |
duke@1 | 300 | * Write the inherited member summary header for the given class. |
duke@1 | 301 | * |
duke@1 | 302 | * @param classDoc the class the summary belongs to. |
duke@1 | 303 | */ |
duke@1 | 304 | public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) { |
duke@1 | 305 | if(! printedSummaryHeader){ |
duke@1 | 306 | //We don't want inherited summary to not be under heading. |
duke@1 | 307 | writeMemberSummaryHeader(classDoc); |
duke@1 | 308 | writeMemberSummaryFooter(classDoc); |
duke@1 | 309 | printedSummaryHeader = true; |
duke@1 | 310 | } |
duke@1 | 311 | } |
duke@1 | 312 | |
duke@1 | 313 | /** |
duke@1 | 314 | * {@inheritDoc} |
duke@1 | 315 | */ |
duke@1 | 316 | public void writeInheritedMemberSummary(ClassDoc classDoc, |
duke@1 | 317 | ProgramElementDoc member, boolean isFirst, boolean isLast) {} |
duke@1 | 318 | |
duke@1 | 319 | /** |
duke@1 | 320 | * Write the inherited member summary footer for the given class. |
duke@1 | 321 | * |
duke@1 | 322 | * @param classDoc the class the summary belongs to. |
duke@1 | 323 | */ |
duke@1 | 324 | public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {} |
duke@1 | 325 | } |