package com.sun.tools.doclets.formats.html;
import java.io.*;
import java.util.*;
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.*;
@Deprecated
public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
implements ConstantsSummaryWriter {
ConfigurationImpl configuration;
private ClassDoc currentClassDoc;
private final String constantsTableSummary;
private final String[] ;
private HtmlTree mainTree = HtmlTree.MAIN();
private HtmlTree summaryTree;
public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
throws IOException {
super(configuration, DocPaths.CONSTANT_VALUES);
this.configuration = configuration;
constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
configuration.getText("doclet.Constants_Summary"));
constantsTableHeader = new String[] {
getModifierTypeHeader(),
configuration.getText("doclet.ConstantField"),
configuration.getText("doclet.Value")
};
}
public Content () {
String label = configuration.getText("doclet.Constants_Summary");
HtmlTree bodyTree = getBody(true, getWindowTitle(label));
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
? HtmlTree.HEADER()
: bodyTree;
addTop(htmlTree);
addNavLinks(true, htmlTree);
if (configuration.allowTag(HtmlTag.HEADER)) {
bodyTree.addContent(htmlTree);
}
return bodyTree;
}
public Content () {
return new HtmlTree(HtmlTag.UL);
}
public void addLinkToPackageContent(PackageDoc pkg, String parsedPackageName,
Set<String> printedPackageHeaders, Content contentListTree) {
String packageName = pkg.name();
Content link;
if (packageName.length() == 0) {
link = getHyperLink(getDocLink(
SectionName.UNNAMED_PACKAGE_ANCHOR),
defaultPackageLabel, "", "");
} else {
Content packageNameContent = getPackageLabel(parsedPackageName);
packageNameContent.addContent(".*");
link = getHyperLink(DocLink.fragment(parsedPackageName),
packageNameContent, "", "");
printedPackageHeaders.add(parsedPackageName);
}
contentListTree.addContent(HtmlTree.LI(link));
}
public void addContentsList(Content contentTree, Content contentListTree) {
Content titleContent = getResource(
"doclet.Constants_Summary");
Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
HtmlStyle.title, titleContent);
Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
Content headingContent = getResource(
"doclet.Contents");
Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
headingContent);
if (configuration.allowTag(HtmlTag.SECTION)) {
HtmlTree section = HtmlTree.SECTION(heading);
section.addContent(contentListTree);
div.addContent(section);
mainTree.addContent(div);
} else {
div.addContent(heading);
div.addContent(contentListTree);
contentTree.addContent(div);
}
}
public Content getConstantSummaries() {
HtmlTree summariesDiv = new HtmlTree(HtmlTag.DIV);
summariesDiv.addStyle(HtmlStyle.constantValuesContainer);
return summariesDiv;
}
public void addPackageName(String parsedPackageName, Content summariesTree, boolean first) {
Content pkgNameContent;
if (!first && configuration.allowTag(HtmlTag.SECTION)) {
summariesTree.addContent(summaryTree);
}
if (parsedPackageName.length() == 0) {
summariesTree.addContent(getMarkerAnchor(
SectionName.UNNAMED_PACKAGE_ANCHOR));
pkgNameContent = defaultPackageLabel;
} else {
summariesTree.addContent(getMarkerAnchor(
parsedPackageName));
pkgNameContent = getPackageLabel(parsedPackageName);
}
Content headingContent = new StringContent(".*");
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
pkgNameContent);
heading.addContent(headingContent);
if (configuration.allowTag(HtmlTag.SECTION)) {
summaryTree = HtmlTree.SECTION(heading);
} else {
summariesTree.addContent(heading);
}
}
public Content () {
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.addStyle(HtmlStyle.blockList);
return ul;
}
public void addClassConstant(Content summariesTree, Content classConstantTree) {
if (configuration.allowTag(HtmlTag.SECTION)) {
summaryTree.addContent(classConstantTree);
} else {
summariesTree.addContent(classConstantTree);
}
}
public Content (ClassDoc cd) {
Content classlink = (cd.isPublic() || cd.isProtected()) ?
getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CONSTANT_SUMMARY, cd)) :
new StringContent(cd.qualifiedName());
String name = cd.containingPackage().name();
if (name.length() > 0) {
Content cb = new ContentBuilder();
cb.addContent(name);
cb.addContent(".");
cb.addContent(classlink);
return getClassName(cb);
} else {
return getClassName(classlink);
}
}
protected Content getClassName(Content classStr) {
Content caption = getTableCaption(classStr);
Content table = (configuration.isOutputHtml5())
? HtmlTree.TABLE(HtmlStyle.constantsSummary, caption)
: HtmlTree.TABLE(HtmlStyle.constantsSummary, constantsTableSummary, caption);
table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
return table;
}
public void addConstantMembers(ClassDoc cd, List<FieldDoc> fields,
Content classConstantTree) {
currentClassDoc = cd;
Content tbody = new HtmlTree(HtmlTag.TBODY);
for (int i = 0; i < fields.size(); ++i) {
HtmlTree tr = new HtmlTree(HtmlTag.TR);
if (i%2 == 0)
tr.addStyle(HtmlStyle.altColor);
else
tr.addStyle(HtmlStyle.rowColor);
addConstantMember(fields.get(i), tr);
tbody.addContent(tr);
}
Content table = getConstantMembersHeader(cd);
table.addContent(tbody);
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
classConstantTree.addContent(li);
}
private void addConstantMember(FieldDoc member, HtmlTree trTree) {
trTree.addContent(getTypeColumn(member));
trTree.addContent(getNameColumn(member));
trTree.addContent(getValue(member));
}
private Content getTypeColumn(FieldDoc member) {
Content anchor = getMarkerAnchor(currentClassDoc.qualifiedName() +
"." + member.name());
Content tdType = HtmlTree.TD(HtmlStyle.colFirst, anchor);
Content code = new HtmlTree(HtmlTag.CODE);
StringTokenizer mods = new StringTokenizer(member.modifiers());
while(mods.hasMoreTokens()) {
Content modifier = new StringContent(mods.nextToken());
code.addContent(modifier);
code.addContent(getSpace());
}
Content type = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.type()));
code.addContent(type);
tdType.addContent(code);
return tdType;
}
private Content getNameColumn(FieldDoc member) {
Content nameContent = getDocLink(
LinkInfoImpl.Kind.CONSTANT_SUMMARY, member, member.name(), false);
Content code = HtmlTree.CODE(nameContent);
return HtmlTree.TD(code);
}
private Content getValue(FieldDoc member) {
Content valueContent = new StringContent(member.constantValueExpression());
Content code = HtmlTree.CODE(valueContent);
return HtmlTree.TD(HtmlStyle.colLast, code);
}
public void addConstantSummaries(Content contentTree, Content summariesTree) {
if (configuration.allowTag(HtmlTag.SECTION) && summaryTree != null) {
summariesTree.addContent(summaryTree);
}
if (configuration.allowTag(HtmlTag.MAIN)) {
mainTree.addContent(summariesTree);
contentTree.addContent(mainTree);
} else {
contentTree.addContent(summariesTree);
}
}
public void (Content contentTree) {
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
? HtmlTree.FOOTER()
: contentTree;
addNavLinks(false, htmlTree);
addBottom(htmlTree);
if (configuration.allowTag(HtmlTag.FOOTER)) {
contentTree.addContent(htmlTree);
}
}
public void printDocument(Content contentTree) throws IOException {
printHtmlDocument(null, true, contentTree);
}
}