FieldWriterImpl.java revision 242
0N/A/*
0N/A * Copyright 1997-2004 Sun Microsystems, Inc. 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
0N/A * published by the Free Software Foundation. Sun designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Sun 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 *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.doclets.formats.html;
0N/A
232N/Aimport java.io.*;
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 field documentation in HTML format.
0N/A *
0N/A * @author Robert Field
0N/A * @author Atul M Dambalkar
0N/A * @author Jamie Ho (rewrite)
242N/A * @author Bhavesh Patel (Modified)
0N/A */
0N/Apublic class FieldWriterImpl extends AbstractMemberWriter
0N/A implements FieldWriter, MemberSummaryWriter {
0N/A
0N/A private boolean printedSummaryHeader = false;
0N/A
0N/A public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
0N/A super(writer, classdoc);
0N/A }
0N/A
0N/A public FieldWriterImpl(SubWriterHolderWriter writer) {
0N/A super(writer);
0N/A }
0N/A
0N/A /**
0N/A * Write the fields 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("<!-- =========== FIELD SUMMARY =========== -->");
0N/A writer.println();
0N/A writer.printSummaryHeader(this, classDoc);
0N/A }
0N/A
0N/A /**
0N/A * Write the fields 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.tableEnd();
0N/A writer.space();
0N/A }
0N/A
0N/A /**
0N/A * Write the inherited fields 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 writer.printInheritedSummaryHeader(this, classDoc);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
0N/A public void writeInheritedMemberSummary(ClassDoc classDoc,
0N/A ProgramElementDoc field, boolean isFirst, boolean isLast) {
0N/A writer.printInheritedSummaryMember(this, classDoc, field, isFirst);
0N/A }
0N/A
0N/A /**
0N/A * Write the inherited fields 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 writer.printInheritedSummaryFooter(this, classDoc);
0N/A }
0N/A
0N/A /**
0N/A * Write the header for the field documentation.
0N/A *
0N/A * @param classDoc the class that the fields belong to.
0N/A */
0N/A public void writeHeader(ClassDoc classDoc, String header) {
0N/A writer.println();
0N/A writer.println("<!-- ============ FIELD DETAIL =========== -->");
0N/A writer.println();
0N/A writer.anchor("field_detail");
0N/A writer.printTableHeadingBackground(header);
0N/A writer.println();
0N/A }
0N/A
0N/A /**
0N/A * Write the field header for the given field.
0N/A *
0N/A * @param field the field being documented.
0N/A * @param isFirst the flag to indicate whether or not the field is the
0N/A * first to be documented.
0N/A */
0N/A public void writeFieldHeader(FieldDoc field, boolean isFirst) {
0N/A if (! isFirst) {
0N/A writer.printMemberHeader();
0N/A writer.println("");
0N/A }
0N/A writer.anchor(field.name());
0N/A writer.h3();
0N/A writer.print(field.name());
0N/A writer.h3End();
0N/A }
0N/A
0N/A /**
0N/A * Write the signature for the given field.
0N/A *
0N/A * @param field the field being documented.
0N/A */
0N/A public void writeSignature(FieldDoc field) {
0N/A writer.pre();
0N/A writer.writeAnnotationInfo(field);
0N/A printModifiers(field);
0N/A writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
0N/A field.type()));
0N/A print(' ');
0N/A if (configuration().linksource) {
0N/A writer.printSrcLink(field, field.name());
0N/A } else {
181N/A strong(field.name());
0N/A }
0N/A writer.preEnd();
232N/A assert !writer.getMemberDetailsListPrinted();
0N/A }
0N/A
0N/A /**
0N/A * Write the deprecated output for the given field.
0N/A *
0N/A * @param field the field being documented.
0N/A */
0N/A public void writeDeprecated(FieldDoc field) {
232N/A printDeprecated(field);
0N/A }
0N/A
0N/A /**
0N/A * Write the comments for the given field.
0N/A *
0N/A * @param field the field being documented.
0N/A */
0N/A public void writeComments(FieldDoc field) {
0N/A ClassDoc holder = field.containingClass();
0N/A if (field.inlineTags().length > 0) {
232N/A writer.printMemberDetailsListStartTag();
0N/A if (holder.equals(classdoc) ||
0N/A (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
0N/A writer.dd();
0N/A writer.printInlineComment(field);
232N/A writer.ddEnd();
0N/A } else {
0N/A String classlink = writer.codeText(
0N/A writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
0N/A holder, field,
0N/A holder.isIncluded() ?
0N/A holder.typeName() : holder.qualifiedTypeName(),
0N/A false));
0N/A writer.dd();
181N/A writer.strong(configuration().getText(holder.isClass()?
0N/A "doclet.Description_From_Class" :
0N/A "doclet.Description_From_Interface", classlink));
0N/A writer.ddEnd();
0N/A writer.dd();
0N/A writer.printInlineComment(field);
232N/A writer.ddEnd();
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Write the tag output for the given field.
0N/A *
0N/A * @param field the field being documented.
0N/A */
0N/A public void writeTags(FieldDoc field) {
0N/A writer.printTags(field);
0N/A }
0N/A
0N/A /**
0N/A * Write the field footer.
0N/A */
0N/A public void writeFieldFooter() {
232N/A printMemberFooter();
0N/A }
0N/A
0N/A /**
0N/A * Write the footer for the field documentation.
0N/A *
0N/A * @param classDoc the class that the fields belong to.
0N/A */
0N/A public void writeFooter(ClassDoc classDoc) {
0N/A //No footer to write for field 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 public int getMemberKind() {
0N/A return VisibleMemberMap.FIELDS;
0N/A }
0N/A
242N/A public void printSummaryLabel() {
242N/A writer.printText("doclet.Field_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.Field_Summary"),
242N/A configuration().getText("doclet.fields")));
242N/A }
242N/A
242N/A public void printSummaryTableHeader(ProgramElementDoc member) {
242N/A String[] header = new String[] {
242N/A writer.getModifierTypeHeader(),
242N/A configuration().getText("doclet.0_and_1",
242N/A configuration().getText("doclet.Field"),
242N/A configuration().getText("doclet.Description"))
242N/A };
242N/A writer.summaryTableHeader(header, "col");
0N/A }
0N/A
0N/A public void printSummaryAnchor(ClassDoc cd) {
0N/A writer.anchor("field_summary");
0N/A }
0N/A
0N/A public void printInheritedSummaryAnchor(ClassDoc cd) {
0N/A writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd));
0N/A }
0N/A
0N/A public void printInheritedSummaryLabel(ClassDoc cd) {
0N/A String classlink = writer.getPreQualifiedClassLink(
0N/A LinkInfoImpl.CONTEXT_MEMBER, cd, false);
181N/A writer.strong();
0N/A String key = cd.isClass()?
0N/A "doclet.Fields_Inherited_From_Class" :
0N/A "doclet.Fields_Inherited_From_Interface";
0N/A writer.printText(key, classlink);
181N/A writer.strongEnd();
0N/A }
0N/A
0N/A protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
181N/A writer.strong();
0N/A writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false);
181N/A writer.strongEnd();
0N/A }
0N/A
0N/A protected void writeInheritedSummaryLink(ClassDoc cd,
0N/A ProgramElementDoc member) {
0N/A writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
0N/A member.name(), false);
0N/A }
0N/A
0N/A protected void printSummaryType(ProgramElementDoc member) {
0N/A FieldDoc field = (FieldDoc)member;
0N/A printModifierAndType(field, field.type());
0N/A }
0N/A
0N/A protected void writeDeprecatedLink(ProgramElementDoc member) {
0N/A writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
0N/A (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
0N/A }
0N/A
0N/A protected void printNavSummaryLink(ClassDoc cd, boolean link) {
0N/A if (link) {
0N/A writer.printHyperLink("", (cd == null)?
0N/A "field_summary":
0N/A "fields_inherited_from_class_" +
0N/A configuration().getClassName(cd),
0N/A configuration().getText("doclet.navField"));
0N/A } else {
0N/A writer.printText("doclet.navField");
0N/A }
0N/A }
0N/A
0N/A protected void printNavDetailLink(boolean link) {
0N/A if (link) {
0N/A writer.printHyperLink("", "field_detail",
0N/A configuration().getText("doclet.navField"));
0N/A } else {
0N/A writer.printText("doclet.navField");
0N/A }
0N/A }
0N/A}