src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java

changeset 1410
bfec2a1cc869
parent 1383
b980e8e6aabf
child 1417
522a1ee72340
equal deleted inserted replaced
1409:33abf479f202 1410:bfec2a1cc869
80 public int displayLength = 0; 80 public int displayLength = 0;
81 81
82 /** 82 /**
83 * The global configuration information for this run. 83 * The global configuration information for this run.
84 */ 84 */
85 public ConfigurationImpl configuration; 85 public final ConfigurationImpl configuration;
86 86
87 /** 87 /**
88 * To check whether annotation heading is printed or not. 88 * To check whether annotation heading is printed or not.
89 */ 89 */
90 protected boolean printedAnnotationHeading = false; 90 protected boolean printedAnnotationHeading = false;
300 * false for files that appear in the left-hand frames 300 * false for files that appear in the left-hand frames
301 * @param body the body htmltree to be included in the document 301 * @param body the body htmltree to be included in the document
302 */ 302 */
303 public void printHtmlDocument(String[] metakeywords, boolean includeScript, 303 public void printHtmlDocument(String[] metakeywords, boolean includeScript,
304 Content body) throws IOException { 304 Content body) throws IOException {
305 Content htmlDocType = DocType.Transitional(); 305 Content htmlDocType = DocType.TRANSITIONAL;
306 Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); 306 Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
307 Content head = new HtmlTree(HtmlTag.HEAD); 307 Content head = new HtmlTree(HtmlTag.HEAD);
308 if (!configuration.notimestamp) { 308 if (!configuration.notimestamp) {
309 Content headComment = new Comment(getGeneratedByString()); 309 Content headComment = new Comment(getGeneratedByString());
310 head.addContent(headComment); 310 head.addContent(headComment);
833 */ 833 */
834 protected void addPackageDeprecatedAPI(List<Doc> deprPkgs, String headingKey, 834 protected void addPackageDeprecatedAPI(List<Doc> deprPkgs, String headingKey,
835 String tableSummary, String[] tableHeader, Content contentTree) { 835 String tableSummary, String[] tableHeader, Content contentTree) {
836 if (deprPkgs.size() > 0) { 836 if (deprPkgs.size() > 0) {
837 Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, 837 Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
838 getTableCaption(configuration().getText(headingKey))); 838 getTableCaption(configuration.getText(headingKey)));
839 table.addContent(getSummaryTableHeader(tableHeader, "col")); 839 table.addContent(getSummaryTableHeader(tableHeader, "col"));
840 Content tbody = new HtmlTree(HtmlTag.TBODY); 840 Content tbody = new HtmlTree(HtmlTag.TBODY);
841 for (int i = 0; i < deprPkgs.size(); i++) { 841 for (int i = 0; i < deprPkgs.size(); i++) {
842 PackageDoc pkg = (PackageDoc) deprPkgs.get(i); 842 PackageDoc pkg = (PackageDoc) deprPkgs.get(i);
843 HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, 843 HtmlTree td = HtmlTree.TD(HtmlStyle.colOne,
1077 * @param context the id of the context where the link will be added 1077 * @param context the id of the context where the link will be added
1078 * @param cd the class doc to link to 1078 * @param cd the class doc to link to
1079 * @return a content tree for the link 1079 * @return a content tree for the link
1080 */ 1080 */
1081 public Content getQualifiedClassLink(int context, ClassDoc cd) { 1081 public Content getQualifiedClassLink(int context, ClassDoc cd) {
1082 return new RawHtml(getLink(new LinkInfoImpl(context, cd, 1082 return new RawHtml(getLink(new LinkInfoImpl(configuration, context, cd,
1083 configuration.getClassName(cd), ""))); 1083 configuration.getClassName(cd), "")));
1084 } 1084 }
1085 1085
1086 /** 1086 /**
1087 * Add the class link. 1087 * Add the class link.
1108 String classlink = ""; 1108 String classlink = "";
1109 PackageDoc pd = cd.containingPackage(); 1109 PackageDoc pd = cd.containingPackage();
1110 if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { 1110 if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
1111 classlink = getPkgName(cd); 1111 classlink = getPkgName(cd);
1112 } 1112 }
1113 classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isStrong)); 1113 classlink += getLink(new LinkInfoImpl(configuration,
1114 context, cd, cd.name(), isStrong));
1114 return classlink; 1115 return classlink;
1115 } 1116 }
1116 1117
1117 /** 1118 /**
1118 * Add the class link with the package portion of the label in 1119 * Add the class link with the package portion of the label in
1128 ClassDoc cd, boolean isStrong, Content contentTree) { 1129 ClassDoc cd, boolean isStrong, Content contentTree) {
1129 PackageDoc pd = cd.containingPackage(); 1130 PackageDoc pd = cd.containingPackage();
1130 if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { 1131 if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
1131 contentTree.addContent(getPkgName(cd)); 1132 contentTree.addContent(getPkgName(cd));
1132 } 1133 }
1133 contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl( 1134 contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
1134 context, cd, cd.name(), isStrong)))); 1135 context, cd, cd.name(), isStrong))));
1135 } 1136 }
1136 1137
1137 /** 1138 /**
1138 * Add the class link, with only class name as the strong link and prefixing 1139 * Add the class link, with only class name as the strong link and prefixing
1185 * @return the link for the given member. 1186 * @return the link for the given member.
1186 */ 1187 */
1187 public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc, 1188 public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
1188 String label, boolean strong) { 1189 String label, boolean strong) {
1189 if (! (doc.isIncluded() || 1190 if (! (doc.isIncluded() ||
1190 Util.isLinkable(classDoc, configuration()))) { 1191 Util.isLinkable(classDoc, configuration))) {
1191 return label; 1192 return label;
1192 } else if (doc instanceof ExecutableMemberDoc) { 1193 } else if (doc instanceof ExecutableMemberDoc) {
1193 ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; 1194 ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
1194 return getLink(new LinkInfoImpl(context, classDoc, 1195 return getLink(new LinkInfoImpl(configuration, context, classDoc,
1195 getAnchor(emd), label, strong)); 1196 getAnchor(emd), label, strong));
1196 } else if (doc instanceof MemberDoc) { 1197 } else if (doc instanceof MemberDoc) {
1197 return getLink(new LinkInfoImpl(context, classDoc, 1198 return getLink(new LinkInfoImpl(configuration, context, classDoc,
1198 doc.name(), label, strong)); 1199 doc.name(), label, strong));
1199 } else { 1200 } else {
1200 return label; 1201 return label;
1201 } 1202 }
1202 } 1203 }
1213 * @return the link for the given member 1214 * @return the link for the given member
1214 */ 1215 */
1215 public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc, 1216 public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
1216 String label) { 1217 String label) {
1217 if (! (doc.isIncluded() || 1218 if (! (doc.isIncluded() ||
1218 Util.isLinkable(classDoc, configuration()))) { 1219 Util.isLinkable(classDoc, configuration))) {
1219 return new StringContent(label); 1220 return new StringContent(label);
1220 } else if (doc instanceof ExecutableMemberDoc) { 1221 } else if (doc instanceof ExecutableMemberDoc) {
1221 ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; 1222 ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
1222 return new RawHtml(getLink(new LinkInfoImpl(context, classDoc, 1223 return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
1223 getAnchor(emd), label, false))); 1224 getAnchor(emd), label, false)));
1224 } else if (doc instanceof MemberDoc) { 1225 } else if (doc instanceof MemberDoc) {
1225 return new RawHtml(getLink(new LinkInfoImpl(context, classDoc, 1226 return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
1226 doc.name(), label, false))); 1227 doc.name(), label, false)));
1227 } else { 1228 } else {
1228 return new StringContent(label); 1229 return new StringContent(label);
1229 } 1230 }
1230 } 1231 }
1300 } else if (refMemName == null) { 1301 } else if (refMemName == null) {
1301 // Must be a class reference since refClass is not null and refMemName is null. 1302 // Must be a class reference since refClass is not null and refMemName is null.
1302 if (label.isEmpty()) { 1303 if (label.isEmpty()) {
1303 label = plainOrCodeText(plain, refClass.name()); 1304 label = plainOrCodeText(plain, refClass.name());
1304 } 1305 }
1305 return getLink(new LinkInfoImpl(refClass, label)); 1306 return getLink(new LinkInfoImpl(configuration, refClass, label));
1306 } else if (refMem == null) { 1307 } else if (refMem == null) {
1307 // Must be a member reference since refClass is not null and refMemName is not null. 1308 // Must be a member reference since refClass is not null and refMemName is not null.
1308 // However, refMem is null, so this referenced member does not exist. 1309 // However, refMem is null, so this referenced member does not exist.
1309 return (label.isEmpty() ? text: label); 1310 return (label.isEmpty() ? text: label);
1310 } else { 1311 } else {
1311 // Must be a member reference since refClass is not null and refMemName is not null. 1312 // Must be a member reference since refClass is not null and refMemName is not null.
1312 // refMem is not null, so this @see tag must be referencing a valid member. 1313 // refMem is not null, so this @see tag must be referencing a valid member.
1313 ClassDoc containing = refMem.containingClass(); 1314 ClassDoc containing = refMem.containingClass();
1314 if (see.text().trim().startsWith("#") && 1315 if (see.text().trim().startsWith("#") &&
1315 ! (containing.isPublic() || 1316 ! (containing.isPublic() ||
1316 Util.isLinkable(containing, configuration()))) { 1317 Util.isLinkable(containing, configuration))) {
1317 // Since the link is relative and the holder is not even being 1318 // Since the link is relative and the holder is not even being
1318 // documented, this must be an inherited link. Redirect it. 1319 // documented, this must be an inherited link. Redirect it.
1319 // The current class either overrides the referenced member or 1320 // The current class either overrides the referenced member or
1320 // inherits it automatically. 1321 // inherits it automatically.
1321 if (this instanceof ClassWriterImpl) { 1322 if (this instanceof ClassWriterImpl) {
1500 } 1501 }
1501 StringTokenizer lines = new StringTokenizer(text, "\r\n", true); 1502 StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
1502 StringBuilder textBuff = new StringBuilder(); 1503 StringBuilder textBuff = new StringBuilder();
1503 while (lines.hasMoreTokens()) { 1504 while (lines.hasMoreTokens()) {
1504 StringBuilder line = new StringBuilder(lines.nextToken()); 1505 StringBuilder line = new StringBuilder(lines.nextToken());
1505 Util.replaceTabs(configuration.sourcetab, line); 1506 Util.replaceTabs(configuration, line);
1506 textBuff.append(line.toString()); 1507 textBuff.append(line.toString());
1507 } 1508 }
1508 result.append(textBuff); 1509 result.append(textBuff);
1509 } 1510 }
1510 } 1511 }
1782 AnnotationTypeDoc annotationDoc = descList[i].annotationType(); 1783 AnnotationTypeDoc annotationDoc = descList[i].annotationType();
1783 if (! Util.isDocumentedAnnotation(annotationDoc)){ 1784 if (! Util.isDocumentedAnnotation(annotationDoc)){
1784 continue; 1785 continue;
1785 } 1786 }
1786 annotation = new StringBuilder(); 1787 annotation = new StringBuilder();
1787 LinkInfoImpl linkInfo = new LinkInfoImpl( 1788 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
1788 LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc); 1789 LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
1789 linkInfo.label = "@" + annotationDoc.name(); 1790 linkInfo.label = "@" + annotationDoc.name();
1790 annotation.append(getLink(linkInfo)); 1791 annotation.append(getLink(linkInfo));
1791 AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues(); 1792 AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();
1792 if (pairs.length > 0) { 1793 if (pairs.length > 0) {
1833 1834
1834 private String annotationValueToString(AnnotationValue annotationValue) { 1835 private String annotationValueToString(AnnotationValue annotationValue) {
1835 if (annotationValue.value() instanceof Type) { 1836 if (annotationValue.value() instanceof Type) {
1836 Type type = (Type) annotationValue.value(); 1837 Type type = (Type) annotationValue.value();
1837 if (type.asClassDoc() != null) { 1838 if (type.asClassDoc() != null) {
1838 LinkInfoImpl linkInfo = new LinkInfoImpl( 1839 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
1839 LinkInfoImpl.CONTEXT_ANNOTATION, type); 1840 LinkInfoImpl.CONTEXT_ANNOTATION, type);
1840 linkInfo.label = (type.asClassDoc().isIncluded() ? 1841 linkInfo.label = (type.asClassDoc().isIncluded() ?
1841 type.typeName() : 1842 type.typeName() :
1842 type.qualifiedTypeName()) + type.dimension() + ".class"; 1843 type.qualifiedTypeName()) + type.dimension() + ".class";
1843 return getLink(linkInfo); 1844 return getLink(linkInfo);

mercurial