package com.sun.tools.doclets.formats.html;
import java.io.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.formats.html.markup.*;
import com.sun.tools.doclets.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.javac.util.StringUtils;
@Deprecated
public class MethodWriterImpl extends AbstractExecutableMemberWriter
implements MethodWriter, MemberSummaryWriter {
public MethodWriterImpl(SubWriterHolderWriter writer, ClassDoc classDoc) {
super(writer, classDoc);
}
public MethodWriterImpl(SubWriterHolderWriter writer) {
super(writer);
}
public Content (ClassDoc classDoc,
Content memberSummaryTree) {
memberSummaryTree.addContent(HtmlConstants.START_OF_METHOD_SUMMARY);
Content memberTree = writer.getMemberTreeHeader();
writer.addSummaryHeader(this, classDoc, memberTree);
return memberTree;
}
public void addMemberTree(Content memberSummaryTree, Content memberTree) {
writer.addMemberTree(memberSummaryTree, memberTree);
}
public Content (ClassDoc classDoc,
Content memberDetailsTree) {
memberDetailsTree.addContent(HtmlConstants.START_OF_METHOD_DETAILS);
Content methodDetailsTree = writer.getMemberTreeHeader();
methodDetailsTree.addContent(writer.getMarkerAnchor(
SectionName.METHOD_DETAIL));
Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
writer.methodDetailsLabel);
methodDetailsTree.addContent(heading);
return methodDetailsTree;
}
public Content (MethodDoc method,
Content methodDetailsTree) {
String erasureAnchor;
if ((erasureAnchor = getErasureAnchor(method)) != null) {
methodDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
}
methodDetailsTree.addContent(
writer.getMarkerAnchor(writer.getAnchor(method)));
Content methodDocTree = writer.getMemberTreeHeader();
Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
heading.addContent(method.name());
methodDocTree.addContent(heading);
return methodDocTree;
}
public Content getSignature(MethodDoc method) {
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(method, pre);
int annotationLength = pre.charCount();
addModifiers(method, pre);
addTypeParameters(method, pre);
addReturnType(method, pre);
if (configuration.linksource) {
Content methodName = new StringContent(method.name());
writer.addSrcLink(method, methodName, pre);
} else {
addName(method.name(), pre);
}
int indent = pre.charCount() - annotationLength;
addParameters(method, pre, indent);
addExceptions(method, pre, indent);
return pre;
}
public void addDeprecated(MethodDoc method, Content methodDocTree) {
addDeprecatedInfo(method, methodDocTree);
}
public void (Type holder, MethodDoc method, Content methodDocTree) {
ClassDoc holderClassDoc = holder.asClassDoc();
if (method.inlineTags().length > 0) {
if (holder.asClassDoc().equals(classdoc) ||
(! (holderClassDoc.isPublic() ||
utils.isLinkable(holderClassDoc, configuration)))) {
writer.addInlineComment(method, methodDocTree);
} else {
Content link =
writer.getDocLink(LinkInfoImpl.Kind.METHOD_DOC_COPY,
holder.asClassDoc(), method,
holder.asClassDoc().isIncluded() ?
holder.typeName() : holder.qualifiedTypeName(),
false);
Content codelLink = HtmlTree.CODE(link);
Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel, holder.asClassDoc().isClass()?
writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
descfrmLabel.addContent(writer.getSpace());
descfrmLabel.addContent(codelLink);
methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
writer.addInlineComment(method, methodDocTree);
}
}
}
public void addTags(MethodDoc method, Content methodDocTree) {
writer.addTagsInfo(method, methodDocTree);
}
public Content getMethodDetails(Content methodDetailsTree) {
if (configuration.allowTag(HtmlTag.SECTION)) {
HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(methodDetailsTree));
return htmlTree;
}
return getMemberTree(methodDetailsTree);
}
public Content getMethodDoc(Content methodDocTree,
boolean isLastContent) {
return getMemberTree(methodDocTree, isLastContent);
}
public void close() throws IOException {
writer.close();
}
public int getMemberKind() {
return VisibleMemberMap.METHODS;
}
public void addSummaryLabel(Content memberTree) {
Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
writer.getResource("doclet.Method_Summary"));
memberTree.addContent(label);
}
public String getTableSummary() {
return configuration.getText("doclet.Member_Table_Summary",
configuration.getText("doclet.Method_Summary"),
configuration.getText("doclet.methods"));
}
public Content getCaption() {
return configuration.getResource("doclet.Methods");
}
public String[] (ProgramElementDoc member) {
String[] header = new String[] {
writer.getModifierTypeHeader(),
configuration.getText("doclet.0_and_1",
configuration.getText("doclet.Method"),
configuration.getText("doclet.Description"))
};
return header;
}
public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
memberTree.addContent(writer.getMarkerAnchor(
SectionName.METHOD_SUMMARY));
}
public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
inheritedTree.addContent(writer.getMarkerAnchor(
SectionName.METHODS_INHERITANCE, configuration.getClassName(cd)));
}
public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
Content classLink = writer.getPreQualifiedClassLink(
LinkInfoImpl.Kind.MEMBER, cd, false);
Content label = new StringContent(cd.isClass() ?
configuration.getText("doclet.Methods_Inherited_From_Class") :
configuration.getText("doclet.Methods_Inherited_From_Interface"));
Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
label);
labelHeading.addContent(writer.getSpace());
labelHeading.addContent(classLink);
inheritedTree.addContent(labelHeading);
}
protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
MethodDoc meth = (MethodDoc)member;
addModifierAndType(meth, meth.returnType(), tdSummaryType);
}
protected static void addOverridden(HtmlDocletWriter writer,
Type overriddenType, MethodDoc method, Content dl) {
if (writer.configuration.nocomment) {
return;
}
ClassDoc holderClassDoc = overriddenType.asClassDoc();
if (! (holderClassDoc.isPublic() ||
writer.configuration.utils.isLinkable(holderClassDoc, writer.configuration))) {
return;
}
if (overriddenType.asClassDoc().isIncluded() && ! method.isIncluded()) {
return;
}
Content label = writer.overridesLabel;
LinkInfoImpl.Kind context = LinkInfoImpl.Kind.METHOD_OVERRIDES;
if (method != null) {
if (overriddenType.asClassDoc().isAbstract() && method.isAbstract()){
label = writer.specifiedByLabel;
context = LinkInfoImpl.Kind.METHOD_SPECIFIED_BY;
}
Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, label));
dl.addContent(dt);
Content overriddenTypeLink =
writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType));
Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
String name = method.name();
Content methlink = writer.getLink(
new LinkInfoImpl(writer.configuration, LinkInfoImpl.Kind.MEMBER,
overriddenType.asClassDoc())
.where(writer.getName(writer.getAnchor(method))).label(name));
Content codeMethLink = HtmlTree.CODE(methlink);
Content dd = HtmlTree.DD(codeMethLink);
dd.addContent(writer.getSpace());
dd.addContent(writer.getResource("doclet.in_class"));
dd.addContent(writer.getSpace());
dd.addContent(codeOverridenTypeLink);
dl.addContent(dd);
}
}
protected static void addImplementsInfo(HtmlDocletWriter writer,
MethodDoc method, Content dl) {
if(writer.configuration.nocomment){
return;
}
ImplementedMethods implementedMethodsFinder =
new ImplementedMethods(method, writer.configuration);
MethodDoc[] implementedMethods = implementedMethodsFinder.build();
for (MethodDoc implementedMeth : implementedMethods) {
Type intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
Content intfaclink = writer.getLink(new LinkInfoImpl(
writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
Content codeIntfacLink = HtmlTree.CODE(intfaclink);
Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, writer.specifiedByLabel));
dl.addContent(dt);
Content methlink = writer.getDocLink(
LinkInfoImpl.Kind.MEMBER, implementedMeth,
implementedMeth.name(), false);
Content codeMethLink = HtmlTree.CODE(methlink);
Content dd = HtmlTree.DD(codeMethLink);
dd.addContent(writer.getSpace());
dd.addContent(writer.getResource("doclet.in_interface"));
dd.addContent(writer.getSpace());
dd.addContent(codeIntfacLink);
dl.addContent(dd);
}
}
protected void addReturnType(MethodDoc method, Content htmltree) {
Type type = method.returnType();
if (type != null) {
Content linkContent = writer.getLink(
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
htmltree.addContent(linkContent);
htmltree.addContent(writer.getSpace());
}
}
protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
if (link) {
if (cd == null) {
return writer.getHyperLink(
SectionName.METHOD_SUMMARY,
writer.getResource("doclet.navMethod"));
} else {
return writer.getHyperLink(
SectionName.METHODS_INHERITANCE,
configuration.getClassName(cd), writer.getResource("doclet.navMethod"));
}
} else {
return writer.getResource("doclet.navMethod");
}
}
protected void addNavDetailLink(boolean link, Content liNav) {
if (link) {
liNav.addContent(writer.getHyperLink(
SectionName.METHOD_DETAIL, writer.getResource("doclet.navMethod")));
} else {
liNav.addContent(writer.getResource("doclet.navMethod"));
}
}
}