Tue, 25 May 2010 15:54:51 -0700
6943119: Rebrand source copyright notices
Reviewed-by: darcy
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 1997, 2004, 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 | |
bpatel@233 | 30 | import com.sun.javadoc.*; |
duke@1 | 31 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 32 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 33 | |
duke@1 | 34 | /** |
duke@1 | 35 | * Writes field documentation in HTML format. |
duke@1 | 36 | * |
duke@1 | 37 | * @author Robert Field |
duke@1 | 38 | * @author Atul M Dambalkar |
duke@1 | 39 | * @author Jamie Ho (rewrite) |
bpatel@243 | 40 | * @author Bhavesh Patel (Modified) |
duke@1 | 41 | */ |
duke@1 | 42 | public class FieldWriterImpl extends AbstractMemberWriter |
duke@1 | 43 | implements FieldWriter, MemberSummaryWriter { |
duke@1 | 44 | |
duke@1 | 45 | private boolean printedSummaryHeader = false; |
duke@1 | 46 | |
duke@1 | 47 | public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) { |
duke@1 | 48 | super(writer, classdoc); |
duke@1 | 49 | } |
duke@1 | 50 | |
duke@1 | 51 | public FieldWriterImpl(SubWriterHolderWriter writer) { |
duke@1 | 52 | super(writer); |
duke@1 | 53 | } |
duke@1 | 54 | |
duke@1 | 55 | /** |
duke@1 | 56 | * Write the fields summary header for the given class. |
duke@1 | 57 | * |
duke@1 | 58 | * @param classDoc the class the summary belongs to. |
duke@1 | 59 | */ |
duke@1 | 60 | public void writeMemberSummaryHeader(ClassDoc classDoc) { |
duke@1 | 61 | printedSummaryHeader = true; |
duke@1 | 62 | writer.println("<!-- =========== FIELD SUMMARY =========== -->"); |
duke@1 | 63 | writer.println(); |
duke@1 | 64 | writer.printSummaryHeader(this, classDoc); |
duke@1 | 65 | } |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * Write the fields summary footer for the given class. |
duke@1 | 69 | * |
duke@1 | 70 | * @param classDoc the class the summary belongs to. |
duke@1 | 71 | */ |
duke@1 | 72 | public void writeMemberSummaryFooter(ClassDoc classDoc) { |
duke@1 | 73 | writer.tableEnd(); |
duke@1 | 74 | writer.space(); |
duke@1 | 75 | } |
duke@1 | 76 | |
duke@1 | 77 | /** |
duke@1 | 78 | * Write the inherited fields 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 writeInheritedMemberSummaryHeader(ClassDoc classDoc) { |
duke@1 | 83 | if(! printedSummaryHeader){ |
duke@1 | 84 | //We don't want inherited summary to not be under heading. |
duke@1 | 85 | writeMemberSummaryHeader(classDoc); |
duke@1 | 86 | writeMemberSummaryFooter(classDoc); |
duke@1 | 87 | printedSummaryHeader = true; |
duke@1 | 88 | } |
duke@1 | 89 | writer.printInheritedSummaryHeader(this, classDoc); |
duke@1 | 90 | } |
duke@1 | 91 | |
duke@1 | 92 | /** |
duke@1 | 93 | * {@inheritDoc} |
duke@1 | 94 | */ |
duke@1 | 95 | public void writeInheritedMemberSummary(ClassDoc classDoc, |
duke@1 | 96 | ProgramElementDoc field, boolean isFirst, boolean isLast) { |
duke@1 | 97 | writer.printInheritedSummaryMember(this, classDoc, field, isFirst); |
duke@1 | 98 | } |
duke@1 | 99 | |
duke@1 | 100 | /** |
duke@1 | 101 | * Write the inherited fields summary footer for the given class. |
duke@1 | 102 | * |
duke@1 | 103 | * @param classDoc the class the summary belongs to. |
duke@1 | 104 | */ |
duke@1 | 105 | public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) { |
duke@1 | 106 | writer.printInheritedSummaryFooter(this, classDoc); |
duke@1 | 107 | } |
duke@1 | 108 | |
duke@1 | 109 | /** |
duke@1 | 110 | * Write the header for the field documentation. |
duke@1 | 111 | * |
duke@1 | 112 | * @param classDoc the class that the fields belong to. |
duke@1 | 113 | */ |
duke@1 | 114 | public void writeHeader(ClassDoc classDoc, String header) { |
duke@1 | 115 | writer.println(); |
duke@1 | 116 | writer.println("<!-- ============ FIELD DETAIL =========== -->"); |
duke@1 | 117 | writer.println(); |
duke@1 | 118 | writer.anchor("field_detail"); |
duke@1 | 119 | writer.printTableHeadingBackground(header); |
duke@1 | 120 | writer.println(); |
duke@1 | 121 | } |
duke@1 | 122 | |
duke@1 | 123 | /** |
duke@1 | 124 | * Write the field header for the given field. |
duke@1 | 125 | * |
duke@1 | 126 | * @param field the field being documented. |
duke@1 | 127 | * @param isFirst the flag to indicate whether or not the field is the |
duke@1 | 128 | * first to be documented. |
duke@1 | 129 | */ |
duke@1 | 130 | public void writeFieldHeader(FieldDoc field, boolean isFirst) { |
duke@1 | 131 | if (! isFirst) { |
duke@1 | 132 | writer.printMemberHeader(); |
duke@1 | 133 | writer.println(""); |
duke@1 | 134 | } |
duke@1 | 135 | writer.anchor(field.name()); |
duke@1 | 136 | writer.h3(); |
duke@1 | 137 | writer.print(field.name()); |
duke@1 | 138 | writer.h3End(); |
duke@1 | 139 | } |
duke@1 | 140 | |
duke@1 | 141 | /** |
duke@1 | 142 | * Write the signature for the given field. |
duke@1 | 143 | * |
duke@1 | 144 | * @param field the field being documented. |
duke@1 | 145 | */ |
duke@1 | 146 | public void writeSignature(FieldDoc field) { |
duke@1 | 147 | writer.pre(); |
duke@1 | 148 | writer.writeAnnotationInfo(field); |
duke@1 | 149 | printModifiers(field); |
duke@1 | 150 | writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, |
duke@1 | 151 | field.type())); |
duke@1 | 152 | print(' '); |
duke@1 | 153 | if (configuration().linksource) { |
duke@1 | 154 | writer.printSrcLink(field, field.name()); |
duke@1 | 155 | } else { |
bpatel@182 | 156 | strong(field.name()); |
duke@1 | 157 | } |
duke@1 | 158 | writer.preEnd(); |
bpatel@233 | 159 | assert !writer.getMemberDetailsListPrinted(); |
duke@1 | 160 | } |
duke@1 | 161 | |
duke@1 | 162 | /** |
duke@1 | 163 | * Write the deprecated output for the given field. |
duke@1 | 164 | * |
duke@1 | 165 | * @param field the field being documented. |
duke@1 | 166 | */ |
duke@1 | 167 | public void writeDeprecated(FieldDoc field) { |
bpatel@233 | 168 | printDeprecated(field); |
duke@1 | 169 | } |
duke@1 | 170 | |
duke@1 | 171 | /** |
duke@1 | 172 | * Write the comments for the given field. |
duke@1 | 173 | * |
duke@1 | 174 | * @param field the field being documented. |
duke@1 | 175 | */ |
duke@1 | 176 | public void writeComments(FieldDoc field) { |
duke@1 | 177 | ClassDoc holder = field.containingClass(); |
duke@1 | 178 | if (field.inlineTags().length > 0) { |
bpatel@233 | 179 | writer.printMemberDetailsListStartTag(); |
duke@1 | 180 | if (holder.equals(classdoc) || |
duke@1 | 181 | (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) { |
duke@1 | 182 | writer.dd(); |
duke@1 | 183 | writer.printInlineComment(field); |
bpatel@233 | 184 | writer.ddEnd(); |
duke@1 | 185 | } else { |
duke@1 | 186 | String classlink = writer.codeText( |
duke@1 | 187 | writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY, |
duke@1 | 188 | holder, field, |
duke@1 | 189 | holder.isIncluded() ? |
duke@1 | 190 | holder.typeName() : holder.qualifiedTypeName(), |
duke@1 | 191 | false)); |
duke@1 | 192 | writer.dd(); |
bpatel@182 | 193 | writer.strong(configuration().getText(holder.isClass()? |
duke@1 | 194 | "doclet.Description_From_Class" : |
duke@1 | 195 | "doclet.Description_From_Interface", classlink)); |
duke@1 | 196 | writer.ddEnd(); |
duke@1 | 197 | writer.dd(); |
duke@1 | 198 | writer.printInlineComment(field); |
bpatel@233 | 199 | writer.ddEnd(); |
duke@1 | 200 | } |
duke@1 | 201 | } |
duke@1 | 202 | } |
duke@1 | 203 | |
duke@1 | 204 | /** |
duke@1 | 205 | * Write the tag output for the given field. |
duke@1 | 206 | * |
duke@1 | 207 | * @param field the field being documented. |
duke@1 | 208 | */ |
duke@1 | 209 | public void writeTags(FieldDoc field) { |
duke@1 | 210 | writer.printTags(field); |
duke@1 | 211 | } |
duke@1 | 212 | |
duke@1 | 213 | /** |
duke@1 | 214 | * Write the field footer. |
duke@1 | 215 | */ |
duke@1 | 216 | public void writeFieldFooter() { |
bpatel@233 | 217 | printMemberFooter(); |
duke@1 | 218 | } |
duke@1 | 219 | |
duke@1 | 220 | /** |
duke@1 | 221 | * Write the footer for the field documentation. |
duke@1 | 222 | * |
duke@1 | 223 | * @param classDoc the class that the fields belong to. |
duke@1 | 224 | */ |
duke@1 | 225 | public void writeFooter(ClassDoc classDoc) { |
duke@1 | 226 | //No footer to write for field documentation |
duke@1 | 227 | } |
duke@1 | 228 | |
duke@1 | 229 | /** |
duke@1 | 230 | * Close the writer. |
duke@1 | 231 | */ |
duke@1 | 232 | public void close() throws IOException { |
duke@1 | 233 | writer.close(); |
duke@1 | 234 | } |
duke@1 | 235 | |
duke@1 | 236 | public int getMemberKind() { |
duke@1 | 237 | return VisibleMemberMap.FIELDS; |
duke@1 | 238 | } |
duke@1 | 239 | |
bpatel@243 | 240 | public void printSummaryLabel() { |
bpatel@243 | 241 | writer.printText("doclet.Field_Summary"); |
bpatel@243 | 242 | } |
bpatel@243 | 243 | |
bpatel@243 | 244 | public void printTableSummary() { |
bpatel@243 | 245 | writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary", |
bpatel@243 | 246 | configuration().getText("doclet.Field_Summary"), |
bpatel@243 | 247 | configuration().getText("doclet.fields"))); |
bpatel@243 | 248 | } |
bpatel@243 | 249 | |
bpatel@243 | 250 | public void printSummaryTableHeader(ProgramElementDoc member) { |
bpatel@243 | 251 | String[] header = new String[] { |
bpatel@243 | 252 | writer.getModifierTypeHeader(), |
bpatel@243 | 253 | configuration().getText("doclet.0_and_1", |
bpatel@243 | 254 | configuration().getText("doclet.Field"), |
bpatel@243 | 255 | configuration().getText("doclet.Description")) |
bpatel@243 | 256 | }; |
bpatel@243 | 257 | writer.summaryTableHeader(header, "col"); |
duke@1 | 258 | } |
duke@1 | 259 | |
duke@1 | 260 | public void printSummaryAnchor(ClassDoc cd) { |
duke@1 | 261 | writer.anchor("field_summary"); |
duke@1 | 262 | } |
duke@1 | 263 | |
duke@1 | 264 | public void printInheritedSummaryAnchor(ClassDoc cd) { |
duke@1 | 265 | writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd)); |
duke@1 | 266 | } |
duke@1 | 267 | |
duke@1 | 268 | public void printInheritedSummaryLabel(ClassDoc cd) { |
duke@1 | 269 | String classlink = writer.getPreQualifiedClassLink( |
duke@1 | 270 | LinkInfoImpl.CONTEXT_MEMBER, cd, false); |
bpatel@182 | 271 | writer.strong(); |
duke@1 | 272 | String key = cd.isClass()? |
duke@1 | 273 | "doclet.Fields_Inherited_From_Class" : |
duke@1 | 274 | "doclet.Fields_Inherited_From_Interface"; |
duke@1 | 275 | writer.printText(key, classlink); |
bpatel@182 | 276 | writer.strongEnd(); |
duke@1 | 277 | } |
duke@1 | 278 | |
duke@1 | 279 | protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) { |
bpatel@182 | 280 | writer.strong(); |
duke@1 | 281 | writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false); |
bpatel@182 | 282 | writer.strongEnd(); |
duke@1 | 283 | } |
duke@1 | 284 | |
duke@1 | 285 | protected void writeInheritedSummaryLink(ClassDoc cd, |
duke@1 | 286 | ProgramElementDoc member) { |
duke@1 | 287 | writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member, |
duke@1 | 288 | member.name(), false); |
duke@1 | 289 | } |
duke@1 | 290 | |
duke@1 | 291 | protected void printSummaryType(ProgramElementDoc member) { |
duke@1 | 292 | FieldDoc field = (FieldDoc)member; |
duke@1 | 293 | printModifierAndType(field, field.type()); |
duke@1 | 294 | } |
duke@1 | 295 | |
duke@1 | 296 | protected void writeDeprecatedLink(ProgramElementDoc member) { |
duke@1 | 297 | writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, |
duke@1 | 298 | (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false); |
duke@1 | 299 | } |
duke@1 | 300 | |
duke@1 | 301 | protected void printNavSummaryLink(ClassDoc cd, boolean link) { |
duke@1 | 302 | if (link) { |
duke@1 | 303 | writer.printHyperLink("", (cd == null)? |
duke@1 | 304 | "field_summary": |
duke@1 | 305 | "fields_inherited_from_class_" + |
duke@1 | 306 | configuration().getClassName(cd), |
duke@1 | 307 | configuration().getText("doclet.navField")); |
duke@1 | 308 | } else { |
duke@1 | 309 | writer.printText("doclet.navField"); |
duke@1 | 310 | } |
duke@1 | 311 | } |
duke@1 | 312 | |
duke@1 | 313 | protected void printNavDetailLink(boolean link) { |
duke@1 | 314 | if (link) { |
duke@1 | 315 | writer.printHyperLink("", "field_detail", |
duke@1 | 316 | configuration().getText("doclet.navField")); |
duke@1 | 317 | } else { |
duke@1 | 318 | writer.printText("doclet.navField"); |
duke@1 | 319 | } |
duke@1 | 320 | } |
duke@1 | 321 | } |