1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Tue May 14 10:14:52 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Tue May 14 10:14:52 2013 -0700 1.3 @@ -1074,9 +1074,9 @@ 1.4 } 1.5 } 1.6 1.7 - public String italicsClassName(ClassDoc cd, boolean qual) { 1.8 - String name = (qual)? cd.qualifiedName(): cd.name(); 1.9 - return (cd.isInterface())? italicsText(name): name; 1.10 + public Content italicsClassName(ClassDoc cd, boolean qual) { 1.11 + Content name = new StringContent((qual)? cd.qualifiedName(): cd.name()); 1.12 + return (cd.isInterface())? HtmlTree.I(name): name; 1.13 } 1.14 1.15 /** 1.16 @@ -1141,8 +1141,8 @@ 1.17 * @param style the style of the link. 1.18 * @param code true if the label should be code font. 1.19 */ 1.20 - public String getCrossClassLink(String qualifiedClassName, String refMemName, 1.21 - String label, boolean strong, String style, 1.22 + public Content getCrossClassLink(String qualifiedClassName, String refMemName, 1.23 + Content label, boolean strong, String style, 1.24 boolean code) { 1.25 String className = ""; 1.26 String packageName = qualifiedClassName == null ? "" : qualifiedClassName; 1.27 @@ -1150,7 +1150,9 @@ 1.28 while ((periodIndex = packageName.lastIndexOf('.')) != -1) { 1.29 className = packageName.substring(periodIndex + 1, packageName.length()) + 1.30 (className.length() > 0 ? "." + className : ""); 1.31 - String defaultLabel = code ? codeText(className) : className; 1.32 + Content defaultLabel = new StringContent(className); 1.33 + if (code) 1.34 + defaultLabel = HtmlTree.CODE(defaultLabel); 1.35 packageName = packageName.substring(0, periodIndex); 1.36 if (getCrossPackageLink(packageName) != null) { 1.37 //The package exists in external documentation, so link to the external 1.38 @@ -1160,10 +1162,8 @@ 1.39 //have to assume that it does. 1.40 DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot, 1.41 className + ".html", refMemName); 1.42 - return getHyperLinkString(link, 1.43 - (label == null) || label.length() == 0 ? defaultLabel : label, 1.44 - 1.45 - 1.46 + return getHyperLink(link, 1.47 + (label == null) || label.isEmpty() ? defaultLabel : label, 1.48 strong, style, 1.49 configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName), 1.50 ""); 1.51 @@ -1193,7 +1193,7 @@ 1.52 */ 1.53 public Content getQualifiedClassLink(LinkInfoImpl.Kind context, ClassDoc cd) { 1.54 return getLink(new LinkInfoImpl(configuration, context, cd, 1.55 - configuration.getClassName(cd), "")); 1.56 + new StringContent(configuration.getClassName(cd)), "")); 1.57 } 1.58 1.59 /** 1.60 @@ -1216,15 +1216,15 @@ 1.61 * @param isStrong true if the link should be strong. 1.62 * @return the link with the package portion of the label in plain text. 1.63 */ 1.64 - public String getPreQualifiedClassLink(LinkInfoImpl.Kind context, 1.65 + public Content getPreQualifiedClassLink(LinkInfoImpl.Kind context, 1.66 ClassDoc cd, boolean isStrong) { 1.67 - String classlink = ""; 1.68 + ContentBuilder classlink = new ContentBuilder(); 1.69 PackageDoc pd = cd.containingPackage(); 1.70 - if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { 1.71 - classlink = getPkgName(cd); 1.72 + if (pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { 1.73 + classlink.addContent(getPkgName(cd)); 1.74 } 1.75 - classlink += getLink(new LinkInfoImpl(configuration, 1.76 - context, cd, cd.name(), isStrong)); 1.77 + classlink.addContent(getLink(new LinkInfoImpl(configuration, 1.78 + context, cd, cd.name(), isStrong))); 1.79 return classlink; 1.80 } 1.81 1.82 @@ -1269,7 +1269,8 @@ 1.83 * @return a content tree for the doc link 1.84 */ 1.85 public Content getDocLink(LinkInfoImpl.Kind context, MemberDoc doc, String label) { 1.86 - return getDocLink(context, doc.containingClass(), doc, label); 1.87 + return getDocLink(context, doc.containingClass(), doc, 1.88 + new StringContent(label)); 1.89 } 1.90 1.91 /** 1.92 @@ -1317,10 +1318,15 @@ 1.93 * @return the link for the given member. 1.94 */ 1.95 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc, 1.96 - String label, boolean strong, boolean isProperty) { 1.97 + String label, boolean strong, boolean isProperty) { 1.98 + return getDocLink(context, classDoc, doc, new RawHtml(label), strong, isProperty); 1.99 + } 1.100 + 1.101 + public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc, 1.102 + Content label, boolean strong, boolean isProperty) { 1.103 if (! (doc.isIncluded() || 1.104 Util.isLinkable(classDoc, configuration))) { 1.105 - return new RawHtml(label); 1.106 + return label; 1.107 } else if (doc instanceof ExecutableMemberDoc) { 1.108 ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; 1.109 return getLink(new LinkInfoImpl(configuration, context, classDoc, 1.110 @@ -1329,7 +1335,7 @@ 1.111 return getLink(new LinkInfoImpl(configuration, context, classDoc, 1.112 doc.name(), label, strong)); 1.113 } else { 1.114 - return new RawHtml(label); 1.115 + return label; 1.116 } 1.117 } 1.118 1.119 @@ -1345,10 +1351,10 @@ 1.120 * @return the link for the given member 1.121 */ 1.122 public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc, 1.123 - String label) { 1.124 + Content label) { 1.125 if (! (doc.isIncluded() || 1.126 Util.isLinkable(classDoc, configuration))) { 1.127 - return new StringContent(label); 1.128 + return label; 1.129 } else if (doc instanceof ExecutableMemberDoc) { 1.130 ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; 1.131 return getLink(new LinkInfoImpl(configuration, context, classDoc, 1.132 @@ -1357,7 +1363,7 @@ 1.133 return getLink(new LinkInfoImpl(configuration, context, classDoc, 1.134 doc.name(), label, false)); 1.135 } else { 1.136 - return new StringContent(label); 1.137 + return label; 1.138 } 1.139 } 1.140 1.141 @@ -1399,10 +1405,10 @@ 1.142 } 1.143 1.144 boolean plain = tagName.equalsIgnoreCase("@linkplain"); 1.145 - String label = plainOrCodeText(plain, see.label()); 1.146 + Content label = plainOrCode(plain, new RawHtml(see.label())); 1.147 1.148 //The text from the @see tag. We will output this text when a label is not specified. 1.149 - String text = plainOrCodeText(plain, seetext); 1.150 + Content text = plainOrCode(plain, new RawHtml(seetext)); 1.151 1.152 ClassDoc refClass = see.referencedClass(); 1.153 String refClassName = see.referencedClassName(); 1.154 @@ -1415,37 +1421,37 @@ 1.155 if (refPackage != null && refPackage.isIncluded()) { 1.156 //@see is referencing an included package 1.157 if (label.isEmpty()) 1.158 - label = plainOrCodeText(plain, refPackage.name()); 1.159 - return getPackageLinkString(refPackage, label, false); 1.160 + label = plainOrCode(plain, new StringContent(refPackage.name())); 1.161 + return getPackageLink(refPackage, label).toString(); 1.162 } else { 1.163 //@see is not referencing an included class or package. Check for cross links. 1.164 - String classCrossLink; 1.165 + Content classCrossLink; 1.166 DocLink packageCrossLink = getCrossPackageLink(refClassName); 1.167 if (packageCrossLink != null) { 1.168 //Package cross link found 1.169 - return getHyperLinkString(packageCrossLink, 1.170 - (label.isEmpty() ? text : label), false); 1.171 + return getHyperLink(packageCrossLink, 1.172 + (label.isEmpty() ? text : label)).toString(); 1.173 } else if ((classCrossLink = getCrossClassLink(refClassName, 1.174 refMemName, label, false, "", !plain)) != null) { 1.175 //Class cross link found (possibly to a member in the class) 1.176 - return classCrossLink; 1.177 + return classCrossLink.toString(); 1.178 } else { 1.179 //No cross link found so print warning 1.180 configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found", 1.181 tagName, seetext); 1.182 - return (label.isEmpty() ? text: label); 1.183 + return (label.isEmpty() ? text: label).toString(); 1.184 } 1.185 } 1.186 } else if (refMemName == null) { 1.187 // Must be a class reference since refClass is not null and refMemName is null. 1.188 if (label.isEmpty()) { 1.189 - label = plainOrCodeText(plain, refClass.name()); 1.190 + label = plainOrCode(plain, new StringContent(refClass.name())); 1.191 } 1.192 return getLink(new LinkInfoImpl(configuration, refClass, label)).toString(); 1.193 } else if (refMem == null) { 1.194 // Must be a member reference since refClass is not null and refMemName is not null. 1.195 // However, refMem is null, so this referenced member does not exist. 1.196 - return (label.isEmpty() ? text: label); 1.197 + return (label.isEmpty() ? text: label).toString(); 1.198 } else { 1.199 // Must be a member reference since refClass is not null and refMemName is not null. 1.200 // refMem is not null, so this @see tag must be referencing a valid member. 1.201 @@ -1478,10 +1484,10 @@ 1.202 } 1.203 } 1.204 1.205 - text = plainOrCodeText(plain, Util.escapeHtmlChars(refMemName)); 1.206 + text = plainOrCode(plain, new StringContent(refMemName)); 1.207 1.208 return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing, 1.209 - refMem, (label.isEmpty() ? text: label), false).toString(); 1.210 + refMem, (label.isEmpty() ? text: label).toString(), false).toString(); 1.211 } 1.212 } 1.213 1.214 @@ -1489,6 +1495,10 @@ 1.215 return (plain || text.isEmpty()) ? text : codeText(text); 1.216 } 1.217 1.218 + private Content plainOrCode(boolean plain, Content body) { 1.219 + return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body); 1.220 + } 1.221 + 1.222 /** 1.223 * Add the inline comment. 1.224 * 1.225 @@ -2066,7 +2076,7 @@ 1.226 private void addAnnotations(AnnotationTypeDoc annotationDoc, LinkInfoImpl linkInfo, 1.227 StringBuilder annotation, AnnotationDesc.ElementValuePair[] pairs, 1.228 int indent, boolean linkBreak) { 1.229 - linkInfo.label = "@" + annotationDoc.name(); 1.230 + linkInfo.label = new StringContent("@" + annotationDoc.name()); 1.231 annotation.append(getLink(linkInfo)); 1.232 if (pairs.length > 0) { 1.233 annotation.append('('); 1.234 @@ -2144,9 +2154,9 @@ 1.235 if (type.asClassDoc() != null) { 1.236 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, 1.237 LinkInfoImpl.Kind.ANNOTATION, type); 1.238 - linkInfo.label = (type.asClassDoc().isIncluded() ? 1.239 - type.typeName() : 1.240 - type.qualifiedTypeName()) + type.dimension() + ".class"; 1.241 + linkInfo.label = new StringContent((type.asClassDoc().isIncluded() ? 1.242 + type.typeName() : 1.243 + type.qualifiedTypeName()) + type.dimension() + ".class"); 1.244 return getLink(linkInfo).toString(); 1.245 } else { 1.246 return type.typeName() + type.dimension() + ".class";