0N/A/*
797N/A * Copyright (c) 1997, 2010, 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/A
232N/Aimport com.sun.javadoc.*;
765N/Aimport com.sun.tools.doclets.formats.html.markup.*;
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 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 /**
765N/A * {@inheritDoc}
0N/A */
765N/A public Content getMemberSummaryHeader(ClassDoc classDoc,
765N/A Content memberSummaryTree) {
765N/A memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY);
765N/A Content memberTree = writer.getMemberTreeHeader();
765N/A writer.addSummaryHeader(this, classDoc, memberTree);
765N/A return memberTree;
0N/A }
0N/A
0N/A /**
765N/A * {@inheritDoc}
0N/A */
765N/A public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
765N/A Content memberDetailsTree) {
765N/A memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS);
765N/A Content fieldDetailsTree = writer.getMemberTreeHeader();
765N/A fieldDetailsTree.addContent(writer.getMarkerAnchor("field_detail"));
765N/A Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
765N/A writer.fieldDetailsLabel);
765N/A fieldDetailsTree.addContent(heading);
765N/A return fieldDetailsTree;
0N/A }
0N/A
0N/A /**
765N/A * {@inheritDoc}
0N/A */
765N/A public Content getFieldDocTreeHeader(FieldDoc field,
765N/A Content fieldDetailsTree) {
765N/A fieldDetailsTree.addContent(
765N/A writer.getMarkerAnchor(field.name()));
765N/A Content fieldDocTree = writer.getMemberTreeHeader();
765N/A Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
765N/A heading.addContent(field.name());
765N/A fieldDocTree.addContent(heading);
765N/A return fieldDocTree;
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A */
765N/A public Content getSignature(FieldDoc field) {
765N/A Content pre = new HtmlTree(HtmlTag.PRE);
765N/A writer.addAnnotationInfo(field, pre);
765N/A addModifiers(field, pre);
765N/A Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
765N/A field.type())));
765N/A pre.addContent(fieldlink);
765N/A pre.addContent(" ");
765N/A if (configuration().linksource) {
765N/A Content fieldName = new StringContent(field.name());
765N/A writer.addSrcLink(field, fieldName, pre);
765N/A } else {
765N/A addName(field.name(), pre);
0N/A }
765N/A return pre;
0N/A }
0N/A
0N/A /**
765N/A * {@inheritDoc}
0N/A */
765N/A public void addDeprecated(FieldDoc field, Content fieldDocTree) {
765N/A addDeprecatedInfo(field, fieldDocTree);
0N/A }
0N/A
0N/A /**
765N/A * {@inheritDoc}
0N/A */
765N/A public void addComments(FieldDoc field, Content fieldDocTree) {
0N/A ClassDoc holder = field.containingClass();
0N/A if (field.inlineTags().length > 0) {
0N/A if (holder.equals(classdoc) ||
765N/A (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
765N/A writer.addInlineComment(field, fieldDocTree);
0N/A } else {
765N/A Content link = new RawHtml(
765N/A writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
0N/A holder, field,
0N/A holder.isIncluded() ?
0N/A holder.typeName() : holder.qualifiedTypeName(),
765N/A false));
765N/A Content codeLink = HtmlTree.CODE(link);
765N/A Content strong = HtmlTree.STRONG(holder.isClass()?
765N/A writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
765N/A strong.addContent(writer.getSpace());
765N/A strong.addContent(codeLink);
765N/A fieldDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
765N/A writer.addInlineComment(field, fieldDocTree);
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
765N/A * {@inheritDoc}
0N/A */
765N/A public void addTags(FieldDoc field, Content fieldDocTree) {
765N/A writer.addTagsInfo(field, fieldDocTree);
0N/A }
0N/A
0N/A /**
765N/A * {@inheritDoc}
0N/A */
765N/A public Content getFieldDetails(Content fieldDetailsTree) {
765N/A return getMemberTree(fieldDetailsTree);
0N/A }
0N/A
0N/A /**
765N/A * {@inheritDoc}
0N/A */
765N/A public Content getFieldDoc(Content fieldDocTree,
765N/A boolean isLastContent) {
765N/A return getMemberTree(fieldDocTree, isLastContent);
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
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public void addSummaryLabel(Content memberTree) {
765N/A Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
765N/A writer.getResource("doclet.Field_Summary"));
765N/A memberTree.addContent(label);
242N/A }
242N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public String getTableSummary() {
765N/A return configuration().getText("doclet.Member_Table_Summary",
242N/A configuration().getText("doclet.Field_Summary"),
765N/A configuration().getText("doclet.fields"));
242N/A }
242N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public String getCaption() {
765N/A return configuration().getText("doclet.Fields");
765N/A }
765N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public String[] getSummaryTableHeader(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 };
765N/A return header;
0N/A }
0N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
765N/A memberTree.addContent(writer.getMarkerAnchor("field_summary"));
0N/A }
0N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
765N/A inheritedTree.addContent(writer.getMarkerAnchor(
765N/A "fields_inherited_from_class_" + configuration().getClassName(cd)));
0N/A }
0N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
765N/A Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
765N/A LinkInfoImpl.CONTEXT_MEMBER, cd, false));
765N/A Content label = new StringContent(cd.isClass() ?
765N/A configuration().getText("doclet.Fields_Inherited_From_Class") :
765N/A configuration().getText("doclet.Fields_Inherited_From_Interface"));
765N/A Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
765N/A label);
765N/A labelHeading.addContent(writer.getSpace());
765N/A labelHeading.addContent(classLink);
765N/A inheritedTree.addContent(labelHeading);
0N/A }
0N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
765N/A Content tdSummary) {
765N/A Content strong = HtmlTree.STRONG(new RawHtml(
765N/A writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false)));
765N/A Content code = HtmlTree.CODE(strong);
765N/A tdSummary.addContent(code);
0N/A }
0N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A protected void addInheritedSummaryLink(ClassDoc cd,
765N/A ProgramElementDoc member, Content linksTree) {
765N/A linksTree.addContent(new RawHtml(
765N/A writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
765N/A member.name(), false)));
0N/A }
0N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
0N/A FieldDoc field = (FieldDoc)member;
765N/A addModifierAndType(field, field.type(), tdSummaryType);
0N/A }
0N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A protected Content getDeprecatedLink(ProgramElementDoc member) {
765N/A return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
765N/A (MemberDoc) member, ((FieldDoc)member).qualifiedName());
765N/A }
765N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
0N/A if (link) {
765N/A return writer.getHyperLink("", (cd == null)?
765N/A "field_summary":
765N/A "fields_inherited_from_class_" +
765N/A configuration().getClassName(cd),
765N/A writer.getResource("doclet.navField"));
0N/A } else {
765N/A return writer.getResource("doclet.navField");
0N/A }
0N/A }
0N/A
765N/A /**
765N/A * {@inheritDoc}
765N/A */
765N/A protected void addNavDetailLink(boolean link, Content liNav) {
0N/A if (link) {
765N/A liNav.addContent(writer.getHyperLink("", "field_detail",
765N/A writer.getResource("doclet.navField")));
0N/A } else {
765N/A liNav.addContent(writer.getResource("doclet.navField"));
0N/A }
0N/A }
0N/A}