changeset 1736:7a9ef837e57f

8011650: reduce use of RawHtml nodes in doclet Reviewed-by: darcy
author jjg
date Tue, 14 May 2013 10:14:52 -0700
parents 74cd21f2c2fe
children 6ea964c78845
files src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java src/share/classes/com/sun/tools/doclets/formats/html/markup/ContentBuilder.java src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java
diffstat 27 files changed, 302 insertions(+), 147 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -126,7 +126,7 @@
      * @param tree the content tree to which the parameter information will be added.
      */
     protected void addParam(ExecutableMemberDoc member, Parameter param,
-        boolean isVarArg, Content tree) {
+            boolean isVarArg, Content tree) {
         if (param.type() != null) {
             Content link = writer.getLink(new LinkInfoImpl(
                     configuration, LinkInfoImpl.Kind.EXECUTABLE_MEMBER_PARAM,
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -174,9 +174,6 @@
         String name = (member instanceof ExecutableMemberDoc)?
             member.name() + ((ExecutableMemberDoc)member).flatSignature() :
             member.name();
-        if (name.indexOf("<") != -1 || name.indexOf(">") != -1) {
-                name = Util.escapeHtmlChars(name);
-        }
         Content span = HtmlTree.SPAN(HtmlStyle.strong,
                 getDocLink(LinkInfoImpl.Kind.INDEX, member, name));
         Content dt = HtmlTree.DT(span);
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -378,7 +378,7 @@
      * @return a header content for the section.
      */
     protected Content getHead(MemberDoc member) {
-        Content memberContent = new RawHtml(member.name());
+        Content memberContent = new StringContent(member.name());
         Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
         return heading;
     }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -156,14 +156,13 @@
             if (!Util.isCoreClass(cd)) {
                 continue;
             }
-            String label = italicsClassName(cd, false);
+            Content label = italicsClassName(cd, false);
             Content linkContent;
-            if(wantFrames){
+            if (wantFrames) {
                 linkContent = getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.Kind.ALL_CLASSES_FRAME, cd, label, "classFrame"));
             } else {
-                linkContent = getLink(new LinkInfoImpl(
-                        configuration, cd, label));
+                linkContent = getLink(new LinkInfoImpl(configuration, cd, label));
             }
             Content li = HtmlTree.LI(linkContent);
             content.addContent(li);
--- a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java	Tue May 14 10:14:52 2013 -0700
@@ -239,8 +239,8 @@
      * {@inheritDoc}
      */
     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
-        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
-                LinkInfoImpl.Kind.MEMBER, cd, false));
+        Content classLink = writer.getPreQualifiedClassLink(
+                LinkInfoImpl.Kind.MEMBER, cd, false);
         Content label = new StringContent(cd.isClass() ?
             configuration.getText("doclet.Fields_Inherited_From_Class") :
             configuration.getText("doclet.Fields_Inherited_From_Interface"));
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -1074,9 +1074,9 @@
         }
     }
 
-    public String italicsClassName(ClassDoc cd, boolean qual) {
-        String name = (qual)? cd.qualifiedName(): cd.name();
-        return (cd.isInterface())?  italicsText(name): name;
+    public Content italicsClassName(ClassDoc cd, boolean qual) {
+        Content name = new StringContent((qual)? cd.qualifiedName(): cd.name());
+        return (cd.isInterface())?  HtmlTree.I(name): name;
     }
 
     /**
@@ -1141,8 +1141,8 @@
      * @param style the style of the link.
      * @param code true if the label should be code font.
      */
-    public String getCrossClassLink(String qualifiedClassName, String refMemName,
-                                    String label, boolean strong, String style,
+    public Content getCrossClassLink(String qualifiedClassName, String refMemName,
+                                    Content label, boolean strong, String style,
                                     boolean code) {
         String className = "";
         String packageName = qualifiedClassName == null ? "" : qualifiedClassName;
@@ -1150,7 +1150,9 @@
         while ((periodIndex = packageName.lastIndexOf('.')) != -1) {
             className = packageName.substring(periodIndex + 1, packageName.length()) +
                 (className.length() > 0 ? "." + className : "");
-            String defaultLabel = code ? codeText(className) : className;
+            Content defaultLabel = new StringContent(className);
+            if (code)
+                defaultLabel = HtmlTree.CODE(defaultLabel);
             packageName = packageName.substring(0, periodIndex);
             if (getCrossPackageLink(packageName) != null) {
                 //The package exists in external documentation, so link to the external
@@ -1160,10 +1162,8 @@
                 //have to assume that it does.
                 DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot,
                                 className + ".html", refMemName);
-                return getHyperLinkString(link,
-                    (label == null) || label.length() == 0 ? defaultLabel : label,
-
-
+                return getHyperLink(link,
+                    (label == null) || label.isEmpty() ? defaultLabel : label,
                     strong, style,
                     configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName),
                     "");
@@ -1193,7 +1193,7 @@
      */
     public Content getQualifiedClassLink(LinkInfoImpl.Kind context, ClassDoc cd) {
         return getLink(new LinkInfoImpl(configuration, context, cd,
-                configuration.getClassName(cd), ""));
+                new StringContent(configuration.getClassName(cd)), ""));
     }
 
     /**
@@ -1216,15 +1216,15 @@
      * @param isStrong true if the link should be strong.
      * @return the link with the package portion of the label in plain text.
      */
-    public String getPreQualifiedClassLink(LinkInfoImpl.Kind context,
+    public Content getPreQualifiedClassLink(LinkInfoImpl.Kind context,
             ClassDoc cd, boolean isStrong) {
-        String classlink = "";
+        ContentBuilder classlink = new ContentBuilder();
         PackageDoc pd = cd.containingPackage();
-        if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
-            classlink = getPkgName(cd);
+        if (pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
+            classlink.addContent(getPkgName(cd));
         }
-        classlink += getLink(new LinkInfoImpl(configuration,
-                context, cd, cd.name(), isStrong));
+        classlink.addContent(getLink(new LinkInfoImpl(configuration,
+                context, cd, cd.name(), isStrong)));
         return classlink;
     }
 
@@ -1269,7 +1269,8 @@
      * @return a content tree for the doc link
      */
     public Content getDocLink(LinkInfoImpl.Kind context, MemberDoc doc, String label) {
-        return getDocLink(context, doc.containingClass(), doc, label);
+        return getDocLink(context, doc.containingClass(), doc,
+                new StringContent(label));
     }
 
     /**
@@ -1317,10 +1318,15 @@
      * @return the link for the given member.
      */
     public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
-        String label, boolean strong, boolean isProperty) {
+            String label, boolean strong, boolean isProperty) {
+        return getDocLink(context, classDoc, doc, new RawHtml(label), strong, isProperty);
+    }
+
+    public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
+            Content label, boolean strong, boolean isProperty) {
         if (! (doc.isIncluded() ||
             Util.isLinkable(classDoc, configuration))) {
-            return new RawHtml(label);
+            return label;
         } else if (doc instanceof ExecutableMemberDoc) {
             ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
             return getLink(new LinkInfoImpl(configuration, context, classDoc,
@@ -1329,7 +1335,7 @@
             return getLink(new LinkInfoImpl(configuration, context, classDoc,
                 doc.name(), label, strong));
         } else {
-            return new RawHtml(label);
+            return label;
         }
     }
 
@@ -1345,10 +1351,10 @@
      * @return the link for the given member
      */
     public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
-        String label) {
+            Content label) {
         if (! (doc.isIncluded() ||
             Util.isLinkable(classDoc, configuration))) {
-            return new StringContent(label);
+            return label;
         } else if (doc instanceof ExecutableMemberDoc) {
             ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
             return getLink(new LinkInfoImpl(configuration, context, classDoc,
@@ -1357,7 +1363,7 @@
             return getLink(new LinkInfoImpl(configuration, context, classDoc,
                 doc.name(), label, false));
         } else {
-            return new StringContent(label);
+            return label;
         }
     }
 
@@ -1399,10 +1405,10 @@
         }
 
         boolean plain = tagName.equalsIgnoreCase("@linkplain");
-        String label = plainOrCodeText(plain, see.label());
+        Content label = plainOrCode(plain, new RawHtml(see.label()));
 
         //The text from the @see tag.  We will output this text when a label is not specified.
-        String text = plainOrCodeText(plain, seetext);
+        Content text = plainOrCode(plain, new RawHtml(seetext));
 
         ClassDoc refClass = see.referencedClass();
         String refClassName = see.referencedClassName();
@@ -1415,37 +1421,37 @@
             if (refPackage != null && refPackage.isIncluded()) {
                 //@see is referencing an included package
                 if (label.isEmpty())
-                    label = plainOrCodeText(plain, refPackage.name());
-                return getPackageLinkString(refPackage, label, false);
+                    label = plainOrCode(plain, new StringContent(refPackage.name()));
+                return getPackageLink(refPackage, label).toString();
             } else {
                 //@see is not referencing an included class or package.  Check for cross links.
-                String classCrossLink;
+                Content classCrossLink;
                 DocLink packageCrossLink = getCrossPackageLink(refClassName);
                 if (packageCrossLink != null) {
                     //Package cross link found
-                    return getHyperLinkString(packageCrossLink,
-                        (label.isEmpty() ? text : label), false);
+                    return getHyperLink(packageCrossLink,
+                        (label.isEmpty() ? text : label)).toString();
                 } else if ((classCrossLink = getCrossClassLink(refClassName,
                         refMemName, label, false, "", !plain)) != null) {
                     //Class cross link found (possibly to a member in the class)
-                    return classCrossLink;
+                    return classCrossLink.toString();
                 } else {
                     //No cross link found so print warning
                     configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found",
                             tagName, seetext);
-                    return (label.isEmpty() ? text: label);
+                    return (label.isEmpty() ? text: label).toString();
                 }
             }
         } else if (refMemName == null) {
             // Must be a class reference since refClass is not null and refMemName is null.
             if (label.isEmpty()) {
-                label = plainOrCodeText(plain, refClass.name());
+                label = plainOrCode(plain, new StringContent(refClass.name()));
             }
             return getLink(new LinkInfoImpl(configuration, refClass, label)).toString();
         } else if (refMem == null) {
             // Must be a member reference since refClass is not null and refMemName is not null.
             // However, refMem is null, so this referenced member does not exist.
-            return (label.isEmpty() ? text: label);
+            return (label.isEmpty() ? text: label).toString();
         } else {
             // Must be a member reference since refClass is not null and refMemName is not null.
             // refMem is not null, so this @see tag must be referencing a valid member.
@@ -1478,10 +1484,10 @@
                 }
             }
 
-            text = plainOrCodeText(plain, Util.escapeHtmlChars(refMemName));
+            text = plainOrCode(plain, new StringContent(refMemName));
 
             return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
-                refMem, (label.isEmpty() ? text: label), false).toString();
+                refMem, (label.isEmpty() ? text: label).toString(), false).toString();
         }
     }
 
@@ -1489,6 +1495,10 @@
         return (plain || text.isEmpty()) ? text : codeText(text);
     }
 
+    private Content plainOrCode(boolean plain, Content body) {
+        return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);
+    }
+
     /**
      * Add the inline comment.
      *
@@ -2066,7 +2076,7 @@
     private void addAnnotations(AnnotationTypeDoc annotationDoc, LinkInfoImpl linkInfo,
             StringBuilder annotation, AnnotationDesc.ElementValuePair[] pairs,
             int indent, boolean linkBreak) {
-        linkInfo.label = "@" + annotationDoc.name();
+        linkInfo.label = new StringContent("@" + annotationDoc.name());
         annotation.append(getLink(linkInfo));
         if (pairs.length > 0) {
             annotation.append('(');
@@ -2144,9 +2154,9 @@
             if (type.asClassDoc() != null) {
                 LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
                     LinkInfoImpl.Kind.ANNOTATION, type);
-                    linkInfo.label = (type.asClassDoc().isIncluded() ?
-                        type.typeName() :
-                        type.qualifiedTypeName()) + type.dimension() + ".class";
+                linkInfo.label = new StringContent((type.asClassDoc().isIncluded() ?
+                    type.typeName() :
+                    type.qualifiedTypeName()) + type.dimension() + ".class");
                 return getLink(linkInfo).toString();
             } else {
                 return type.typeName() + type.dimension() + ".class";
--- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java	Tue May 14 10:14:52 2013 -0700
@@ -30,6 +30,7 @@
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
 import com.sun.tools.doclets.formats.html.markup.RawHtml;
+import com.sun.tools.doclets.formats.html.markup.StringContent;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.util.links.*;
@@ -65,7 +66,7 @@
      */
     protected Content getClassLink(LinkInfo linkInfo) {
         LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
-        boolean noLabel = linkInfo.label == null || linkInfo.label.length() == 0;
+        boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
         ClassDoc classDoc = classLinkInfo.classDoc;
         //Create a tool tip if we are linking to a class or interface.  Don't
         //create one if we are linking to a member.
@@ -75,9 +76,8 @@
                     classLinkInfo.type != null &&
                     !classDoc.qualifiedTypeName().equals(classLinkInfo.type.qualifiedTypeName())) :
             "";
-        StringBuilder label = new StringBuilder(
-            classLinkInfo.getClassLinkLabel(m_writer.configuration));
-        classLinkInfo.displayLength += label.length();
+        Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
+        classLinkInfo.displayLength += label.charCount();
         Configuration configuration = m_writer.configuration;
         Content link = new ContentBuilder();
         if (classDoc.isIncluded()) {
@@ -85,11 +85,11 @@
                 DocPath filename = getPath(classLinkInfo);
                 if (linkInfo.linkToSelf ||
                                 !(DocPath.forName(classDoc)).equals(m_writer.filename)) {
-                        link.addContent(new RawHtml(m_writer.getHyperLinkString(
+                        link.addContent(m_writer.getHyperLink(
                                 filename.fragment(classLinkInfo.where),
-                            label.toString(),
+                            label,
                             classLinkInfo.isStrong, classLinkInfo.styleName,
-                            title, classLinkInfo.target)));
+                            title, classLinkInfo.target));
                         if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
                             link.addContent(getTypeParameterLinks(linkInfo));
                         }
@@ -97,12 +97,12 @@
                 }
             }
         } else {
-            String crossLink = m_writer.getCrossClassLink(
+            Content crossLink = m_writer.getCrossClassLink(
                 classDoc.qualifiedName(), classLinkInfo.where,
-                label.toString(), classLinkInfo.isStrong, classLinkInfo.styleName,
+                label, classLinkInfo.isStrong, classLinkInfo.styleName,
                 true);
             if (crossLink != null) {
-                link.addContent(new RawHtml(crossLink));
+                link.addContent(crossLink);
                 if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
                     link.addContent(getTypeParameterLinks(linkInfo));
                 }
@@ -110,7 +110,7 @@
             }
         }
         // Can't link so just write label.
-        link.addContent(new RawHtml(label.toString()));
+        link.addContent(label.toString());
         if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
             link.addContent(getTypeParameterLinks(linkInfo));
         }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java	Tue May 14 10:14:52 2013 -0700
@@ -27,6 +27,9 @@
 package com.sun.tools.doclets.formats.html;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
+import com.sun.tools.doclets.formats.html.markup.StringContent;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.util.links.*;
 
@@ -222,7 +225,7 @@
     /**
      * String style of text defined in style sheet.
      */
-    public String styleName ="";
+    public String styleName = "";
 
     /**
      * The value of the target.
@@ -239,7 +242,7 @@
      * @param target     the value of the target attribute.
      */
     public LinkInfoImpl(ConfigurationImpl configuration,
-            Kind context, ClassDoc classDoc, String label, String target) {
+            Kind context, ClassDoc classDoc, Content label, String target) {
         this.configuration = configuration;
         this.classDoc = classDoc;
         this.label = label;
@@ -248,6 +251,13 @@
     }
 
     /**
+     * {@inherotDoc}
+     */
+    protected Content newContent() {
+        return new ContentBuilder();
+    }
+
+    /**
      * Construct a LinkInfo object.
      *
      * @param configuration the configuration data for the doclet
@@ -259,7 +269,7 @@
      * @param styleName  String style of text defined in style sheet.
      */
     public LinkInfoImpl(ConfigurationImpl configuration,
-            Kind context, ClassDoc classDoc, String where, String label,
+            Kind context, ClassDoc classDoc, String where, Content label,
             boolean isStrong, String styleName) {
         this.configuration = configuration;
         this.classDoc = classDoc;
@@ -277,17 +287,45 @@
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
      * @param where      the value of the marker #.
-     * @param label      the label for the link.
+     * @param label      the plain-text label for the link.
      * @param isStrong       true if the link should be strong.
      */
     public LinkInfoImpl(ConfigurationImpl configuration,
             Kind context, ClassDoc classDoc, String where, String label,
             boolean isStrong) {
+        this(configuration, context, classDoc, where, new StringContent(label),
+                isStrong, "");
+    }
+
+    /**
+     * Construct a LinkInfo object.
+     *
+     * @param configuration the configuration data for the doclet
+     * @param context    the context of the link.
+     * @param classDoc   the class to link to.
+     * @param where      the value of the marker #.
+     * @param label      the label for the link.
+     * @param isStrong       true if the link should be strong.
+     */
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            Kind context, ClassDoc classDoc, String where, Content label,
+            boolean isStrong) {
+        this(configuration, context, classDoc, where, label,
+                isStrong, "");
+    }
+
+    /**
+     * Construct a LinkInfo object.
+     *
+     * @param configuration the configuration data for the doclet
+     * @param classDoc   the class to link to.
+     * @param label      the label for the link.
+     */
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            ClassDoc classDoc, Content label) {
         this.configuration = configuration;
         this.classDoc = classDoc;
-        this.where = where;
         this.label = label;
-        this.isStrong = isStrong;
         setContext(context);
     }
 
@@ -302,7 +340,7 @@
             ClassDoc classDoc, String label) {
         this.configuration = configuration;
         this.classDoc = classDoc;
-        this.label = label;
+        this.label = new StringContent(label);
         setContext(context);
     }
 
@@ -375,11 +413,26 @@
      * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param type       the class to link to.
+     * @param label      plain-text label for the link.
+     * @param isStrong     true if the link should be strong.
+     */
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            Kind context, Type type, String label,
+            boolean isStrong) {
+        this(configuration, context, type, new StringContent(label), isStrong);
+    }
+
+    /**
+     * Construct a LinkInfo object.
+     *
+     * @param configuration the configuration data for the doclet
+     * @param context    the context of the link.
+     * @param type       the class to link to.
      * @param label      the label for the link.
      * @param isStrong     true if the link should be strong.
      */
     public LinkInfoImpl(ConfigurationImpl configuration,
-            Kind context, Type type, String label,
+            Kind context, Type type, Content label,
             boolean isStrong) {
         this.configuration = configuration;
         this.type = type;
@@ -394,11 +447,26 @@
      * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
+     * @param label      plain-text label for the link.
+     * @param isStrong       true if the link should be strong.
+     */
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            Kind context, ClassDoc classDoc, String label,
+            boolean isStrong) {
+        this(configuration, context, classDoc, new StringContent(label), isStrong);
+    }
+
+    /**
+     * Construct a LinkInfo object.
+     *
+     * @param configuration the configuration data for the doclet
+     * @param context    the context of the link.
+     * @param classDoc   the class to link to.
      * @param label      the label for the link.
      * @param isStrong       true if the link should be strong.
      */
     public LinkInfoImpl(ConfigurationImpl configuration,
-            Kind context, ClassDoc classDoc, String label,
+            Kind context, ClassDoc classDoc, Content label,
             boolean isStrong) {
         this.configuration = configuration;
         this.classDoc = classDoc;
--- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Tue May 14 10:14:52 2013 -0700
@@ -260,8 +260,8 @@
      * {@inheritDoc}
      */
     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
-        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
-                LinkInfoImpl.Kind.MEMBER, cd, false));
+        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"));
--- a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java	Tue May 14 10:14:52 2013 -0700
@@ -147,8 +147,8 @@
      * {@inheritDoc}
      */
     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
-        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
-                LinkInfoImpl.Kind.MEMBER, cd, false));
+        Content classLink = writer.getPreQualifiedClassLink(
+                LinkInfoImpl.Kind.MEMBER, cd, false);
         Content label = new StringContent(cd.isInterface() ?
             configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") :
             configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -94,7 +94,7 @@
             packgen = new PackageFrameWriter(configuration, packageDoc);
             String pkgName = Util.getPackageName(packageDoc);
             Content body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
-            Content pkgNameContent = new RawHtml(Util.escapeHtmlChars(pkgName));
+            Content pkgNameContent = new StringContent(pkgName);
             Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
                     packgen.getTargetPackageLink(packageDoc, "classFrame", pkgNameContent));
             body.addContent(heading);
@@ -182,10 +182,10 @@
                     contentTree.addContent(heading);
                     printedHeader = true;
                 }
+                Content arr_i_name = new StringContent(arr[i].name());
+                if (arr[i].isInterface()) arr_i_name = HtmlTree.I(arr_i_name);
                 Content link = getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i],
-                        (arr[i].isInterface() ? italicsText(arr[i].name()) :
-                            arr[i].name()),"classFrame"));
+                        LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i], arr_i_name, "classFrame"));
                 Content li = HtmlTree.LI(link);
                 ul.addContent(li);
             }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -112,7 +112,7 @@
                      DocPaths.PACKAGE_FRAME), packageLabel, "",
                     "packageFrame");
         } else {
-            packageLabel = new RawHtml("&lt;unnamed package&gt;");
+            packageLabel = new StringContent("<unnamed package>");
             packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
                     packageLabel, "", "packageFrame");
         }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -173,10 +173,10 @@
                     contentTree.addContent(heading);
                     printedHeader = true;
                 }
+                Content arr_i_name = new StringContent(arr[i].name());
+                if (arr[i].isInterface()) arr_i_name = HtmlTree.I(arr_i_name);
                 Content link = getLink(new LinkInfoImpl(configuration,
-                        LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i],
-                        (arr[i].isInterface() ? italicsText(arr[i].name()) :
-                            arr[i].name()),"classFrame"));
+                        LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i], arr_i_name, "classFrame"));
                 Content li = HtmlTree.LI(link);
                 ul.addContent(li);
             }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -118,7 +118,7 @@
                      DocPaths.profilePackageFrame(profileName)), pkgLabel, "",
                     "packageFrame");
         } else {
-            pkgLabel = new RawHtml("&lt;unnamed package&gt;");
+            pkgLabel = new StringContent("<unnamed package>");
             packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
                     pkgLabel, "", "packageFrame");
         }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java	Tue May 14 10:14:52 2013 -0700
@@ -235,8 +235,8 @@
      * {@inheritDoc}
      */
     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
-        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
-                LinkInfoImpl.Kind.MEMBER, cd, false));
+        Content classLink = writer.getPreQualifiedClassLink(
+                LinkInfoImpl.Kind.MEMBER, cd, false);
         Content label = new StringContent(cd.isClass() ?
             configuration.getText("doclet.Properties_Inherited_From_Class") :
             configuration.getText("doclet.Properties_Inherited_From_Interface"));
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java	Tue May 14 10:14:52 2013 -0700
@@ -127,10 +127,10 @@
      * @return a content tree for the class header
      */
     public Content getClassHeader(ClassDoc classDoc) {
-        String classLink = (classDoc.isPublic() || classDoc.isProtected()) ?
+        Content classLink = (classDoc.isPublic() || classDoc.isProtected()) ?
             getLink(new LinkInfoImpl(configuration, classDoc,
-            configuration.getClassName(classDoc))).toString() :
-            classDoc.qualifiedName();
+            configuration.getClassName(classDoc))) :
+            new StringContent(classDoc.qualifiedName());
         Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
                 classDoc.qualifiedName()));
         String superClassLink =
@@ -143,9 +143,9 @@
         //Print the heading.
         String className = superClassLink == null ?
             configuration.getText(
-            "doclet.Class_0_implements_serializable", classLink) :
+            "doclet.Class_0_implements_serializable", classLink.toString()) :
             configuration.getText(
-            "doclet.Class_0_extends_implements_serializable", classLink,
+            "doclet.Class_0_extends_implements_serializable", classLink.toString(),
             superClassLink);
         Content classNameContent = new RawHtml(className);
         li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Tue May 14 10:14:52 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@
     /**
      * New line to be added to the documentation.
      */
-    private static final Content NEW_LINE = new RawHtml(DocletConstants.NL);
+    private static final String NEW_LINE = DocletConstants.NL;
 
     private final ConfigurationImpl configuration;
 
@@ -271,8 +271,7 @@
         if (line != null) {
             StringBuilder lineBuffer = new StringBuilder(line);
             Util.replaceTabs(configuration, lineBuffer);
-            Util.escapeHtmlChars(lineBuffer);
-            pre.addContent(new RawHtml(lineBuffer.toString()));
+            pre.addContent(lineBuffer.toString());
             Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
             pre.addContent(anchor);
             pre.addContent(NEW_LINE);
--- a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java	Tue May 14 10:14:52 2013 -0700
@@ -180,8 +180,7 @@
                     ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name();
             DocLink link = constantsPath.fragment(whichConstant);
             result += htmlWriter.getHyperLinkString(link,
-                    configuration.getText("doclet.Constants_Summary"),
-                    false);
+                    configuration.getText("doclet.Constants_Summary"));
         }
         if (holder.isClass() && ((ClassDoc)holder).isSerializable()) {
             //Automatically add link to serialized form page for serializable classes.
@@ -191,7 +190,7 @@
                 DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
                 DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName());
                 result += htmlWriter.getHyperLinkString(link,
-                        configuration.getText("doclet.Serialized_Form"), false);
+                        configuration.getText("doclet.Serialized_Form"));
             }
         }
         return result.equals("") ? null : new TagletOutputImpl(result + "</dd>");
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/ContentBuilder.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/ContentBuilder.java	Tue May 14 10:14:52 2013 -0700
@@ -81,6 +81,13 @@
         return true;
     }
 
+    public int charCount() {
+        int n = 0;
+        for (Content c : contents)
+            n += c.charCount();
+        return n;
+    }
+
     private void ensureMutableContents() {
         if (contents.isEmpty())
             contents = new ArrayList<Content>();
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
 import com.sun.tools.doclets.internal.toolkit.util.DocFile;
 import com.sun.tools.doclets.internal.toolkit.util.DocLink;
 import com.sun.tools.doclets.internal.toolkit.util.DocPath;
-import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
 
 
 /**
@@ -73,21 +72,18 @@
     public abstract Configuration configuration();
 
     /**
-     * Return Html Hyper Link string.
+     * Return Html hyperlink string.
      *
      * @param link       String name of the file.
      * @param label      Tag for the link.
-     * @param strong       Boolean that sets label to strong.
      * @return String    Hyper Link.
      */
-    public String getHyperLinkString(DocPath link,
-                               String label, boolean strong) {
-        return getHyperLinkString(link, label, strong, "", "", "");
+    public String getHyperLinkString(DocPath link, String label) {
+        return getHyperLinkString(link, label, false, "", "", "");
     }
 
-    public String getHyperLinkString(DocLink link,
-                               String label, boolean strong) {
-        return getHyperLinkString(link, label, strong, "", "", "");
+    public String getHyperLinkString(DocLink link, String label) {
+        return getHyperLinkString(link, label, false, "", "", "");
     }
 
     /**
@@ -125,19 +121,17 @@
     }
 
     /**
-     * Get Html Hyper Link string.
+     * Get Html hyperlink.
      *
-     * @param link       String name of the file.
+     * @param link       path of the file.
      * @param label      Tag for the link.
      * @return a content tree for the hyper link
      */
-    public Content getHyperLink(DocPath link,
-                               Content label) {
+    public Content getHyperLink(DocPath link, Content label) {
         return getHyperLink(link, label, "", "");
     }
 
-    public Content getHyperLink(DocLink link,
-                               Content label) {
+    public Content getHyperLink(DocLink link, Content label) {
         return getHyperLink(link, label, "", "");
     }
 
@@ -190,6 +184,28 @@
         return retlink.toString();
     }
 
+    public Content getHyperLink(DocLink link,
+                               Content label, boolean strong,
+                               String stylename, String title, String target) {
+        Content body = label;
+        if (strong) {
+            body = HtmlTree.SPAN(HtmlStyle.strong, body);
+        }
+        if (stylename != null && stylename.length() != 0) {
+            HtmlTree t = new HtmlTree(HtmlTag.FONT, body);
+            t.addAttr(HtmlAttr.CLASS, stylename);
+            body = t;
+        }
+        HtmlTree l = HtmlTree.A(link.toString(), body);
+        if (title != null && title.length() != 0) {
+            l.addAttr(HtmlAttr.TITLE, title);
+        }
+        if (target != null && target.length() != 0) {
+            l.addAttr(HtmlAttr.TARGET, target);
+        }
+        return l;
+    }
+
     /**
      * Get Html Hyper Link.
      *
@@ -217,17 +233,6 @@
     }
 
     /**
-     * Get link string without positioning in the file.
-     *
-     * @param link       String name of the file.
-     * @param label      Tag for the link.
-     * @return Strign    Hyper link.
-     */
-    public String getHyperLinkString(DocPath link, String label) {
-        return getHyperLinkString(link, label, false);
-    }
-
-    /**
      * Get the name of the package, this class is in.
      *
      * @param cd    ClassDoc.
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java	Tue May 14 10:14:52 2013 -0700
@@ -123,6 +123,13 @@
             addContent(new StringContent(stringContent));
     }
 
+    public int charCount() {
+        int n = 0;
+        for (Content c : content)
+            n += c.charCount();
+        return n;
+    }
+
     /**
      * Generates an HTML anchor tag.
      *
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Tue May 14 10:14:52 2013 -0700
@@ -303,10 +303,11 @@
      *
      * @return a content for the SCRIPT tag
      */
-    protected Content getFramesetJavaScript(){
+    protected Content getFramesetJavaScript() {
         HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
         script.addAttr(HtmlAttr.TYPE, "text/javascript");
-        String scriptCode = DocletConstants.NL + "    targetPage = \"\" + window.location.search;" + DocletConstants.NL +
+        String scriptCode = DocletConstants.NL +
+                "    targetPage = \"\" + window.location.search;" + DocletConstants.NL +
                 "    if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
                 "        targetPage = targetPage.substring(1);" + DocletConstants.NL +
                 "    if (targetPage.indexOf(\":\") != -1)" + DocletConstants.NL +
@@ -400,16 +401,6 @@
         return title;
     }
 
-    /**
-     * Return, text passed, with Italics &lt;i&gt; and &lt;/i&gt; tags, surrounding it.
-     * So if the text passed is "Hi", then string returned will be "&lt;i&gt;Hi&lt;/i&gt;".
-     *
-     * @param text String to be printed in between &lt;I&gt; and &lt;/I&gt; tags.
-     */
-    public String italicsText(String text) {
-        return "<i>" + text + "</i>";
-    }
-
     public String codeText(String text) {
         return "<code>" + text + "</code>";
     }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java	Tue May 14 10:14:52 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
  *
  * @author Bhavesh Patel
  */
-public class RawHtml extends Content{
+public class RawHtml extends Content {
 
     private String rawHtmlContent;
 
@@ -90,10 +90,61 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public String toString() {
         return rawHtmlContent;
     }
 
+    private enum State { TEXT, ENTITY, TAG, STRING };
+
+    @Override
+    public int charCount() {
+        State state = State.TEXT;
+        int count = 0;
+        for (int i = 0; i < rawHtmlContent.length(); i++) {
+            char c = rawHtmlContent.charAt(i);
+            switch (state) {
+                case TEXT:
+                    switch (c) {
+                        case '<':
+                            state = State.TAG;
+                            break;
+                        case '&':
+                            state = State.ENTITY;
+                            count++;
+                            break;
+                        default:
+                            count++;
+                    }
+                    break;
+
+                case ENTITY:
+                    if (!Character.isLetterOrDigit(c))
+                        state = State.TEXT;
+                    break;
+
+                case TAG:
+                    switch (c) {
+                        case '"':
+                            state = State.STRING;
+                            break;
+                        case '>':
+                            state = State.TEXT;
+                            break;
+                    }
+                    break;
+
+                case STRING:
+                    switch (c) {
+                        case '"':
+                            state = State.TAG;
+                            break;
+                    }
+            }
+        }
+        return count;
+    }
+
     /**
      * {@inheritDoc}
      */
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java	Tue May 14 10:14:52 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,6 +91,10 @@
         return (stringContent.length() == 0);
     }
 
+    public int charCount() {
+        return stringContent.length();
+    }
+
     /**
      * {@inheritDoc}
      */
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java	Tue May 14 10:14:52 2013 -0700
@@ -96,6 +96,10 @@
         return !isEmpty();
     }
 
+    public int charCount() {
+        throw new UnsupportedOperationException();
+    }
+
     /**
      * Checks for null values.
      *
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java	Tue May 14 10:14:52 2013 -0700
@@ -95,7 +95,9 @@
                 if ((! linkInfo.excludeTypeParameterLinks) &&
                         owner instanceof ClassDoc) {
                     linkInfo.classDoc = (ClassDoc) owner;
-                    linkInfo.label = type.typeName();
+                    Content label = newContent();
+                    label.addContent(type.typeName());
+                    linkInfo.label = label;
                     link.addContent(getClassLink(linkInfo));
                 } else {
                     //No need to link method type parameters.
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java	Tue May 14 10:14:52 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java	Tue May 14 10:14:52 2013 -0700
@@ -27,6 +27,7 @@
 
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * Encapsulates information about a link.
@@ -77,7 +78,7 @@
     /**
      * The label for the link.
      */
-    public String label;
+    public Content label;
 
     /**
      * True if the link should be strong.
@@ -121,6 +122,13 @@
     public int displayLength = 0;
 
     /**
+     * Return an empty instance of a content object.
+     *
+     * @return an empty instance of a content object.
+     */
+    protected abstract Content newContent();
+
+    /**
      * Return true if this link is linkable and false if we can't link to the
      * desired place.
      *
@@ -135,13 +143,17 @@
      * @param configuration the current configuration of the doclet.
      * @return the label for this class link.
      */
-    public String getClassLinkLabel(Configuration configuration) {
-        if (label != null && label.length() > 0) {
+    public Content getClassLinkLabel(Configuration configuration) {
+        if (label != null && !label.isEmpty()) {
             return label;
         } else if (isLinkable()) {
-            return classDoc.name();
+            Content label = newContent();
+            label.addContent(classDoc.name());
+            return label;
         } else {
-            return configuration.getClassName(classDoc);
+            Content label = newContent();
+            label.addContent(configuration.getClassName(classDoc));
+            return label;
         }
     }
 }