提交 e904244f 编写于 作者: J jjg

8011642: Remove LinkOutput in favor of direct use of Content

Reviewed-by: bpatel, darcy
上级 cc56c8b6
......@@ -63,9 +63,9 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.MEMBER_TYPE_PARAMS, member, false);
String typeParameters = writer.getTypeParameterLinks(linkInfo);
Content typeParameters = writer.getTypeParameterLinks(linkInfo);
if (linkInfo.displayLength > 0) {
Content linkContent = new RawHtml(typeParameters);
Content linkContent = typeParameters;
htmltree.addContent(linkContent);
htmltree.addContent(writer.getSpace());
writer.displayLength += linkInfo.displayLength + 1;
......@@ -94,9 +94,9 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
Content tdSummary) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
String name = emd.name();
Content strong = HtmlTree.STRONG(new RawHtml(
Content strong = HtmlTree.STRONG(
writer.getDocLink(context, cd, (MemberDoc) emd,
name, false)));
name, false));
Content code = HtmlTree.CODE(strong);
writer.displayLength = name.length();
addParameters(emd, false, code);
......@@ -112,9 +112,9 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
*/
protected void addInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member, Content linksTree) {
linksTree.addContent(new RawHtml(
linksTree.addContent(
writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc) member,
member.name(), false)));
member.name(), false));
}
/**
......@@ -128,9 +128,9 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
protected void addParam(ExecutableMemberDoc member, Parameter param,
boolean isVarArg, Content tree) {
if (param.type() != null) {
Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
Content link = writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.EXECUTABLE_MEMBER_PARAM,
param.type(), isVarArg)));
param.type(), isVarArg));
tree.addContent(link);
}
if(param.name().length() > 0) {
......@@ -154,7 +154,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
tree.addContent(rcvrType.typeName());
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_SIGNATURE, rcvrType);
tree.addContent(new RawHtml(writer.getTypeParameterLinks(linkInfo)));
tree.addContent(writer.getTypeParameterLinks(linkInfo));
tree.addContent(writer.getSpace());
tree.addContent("this");
}
......@@ -255,15 +255,15 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
htmltree.addContent(indent);
htmltree.addContent("throws ");
indent += " ";
Content link = new RawHtml(writer.getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.MEMBER, exceptions[0])));
Content link = writer.getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.MEMBER, exceptions[0]));
htmltree.addContent(link);
for(int i = 1; i < exceptions.length; i++) {
htmltree.addContent(",");
htmltree.addContent(DocletConstants.NL);
htmltree.addContent(indent);
Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.MEMBER, exceptions[i])));
Content exceptionLink = writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.MEMBER, exceptions[i]));
htmltree.addContent(exceptionLink);
}
}
......
......@@ -139,9 +139,8 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
* @param dlTree the content tree to which the description will be added
*/
protected void addDescription(ClassDoc cd, Content dlTree) {
Content link = new RawHtml(
getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.INDEX, cd, true)));
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.INDEX, cd, true));
Content dt = HtmlTree.DT(link);
dt.addContent(" - ");
addClassInfo(cd, dt);
......@@ -162,7 +161,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
contentTree.addContent(getResource("doclet.in",
Util.getTypeName(configuration, cd, false),
getPackageLinkString(cd.containingPackage(),
Util.getPackageName(cd.containingPackage()), false)));
Util.escapeHtmlChars(Util.getPackageName(cd.containingPackage())), false)));
}
/**
......
......@@ -292,13 +292,13 @@ public abstract class AbstractMemberWriter {
if (displayLength > 10) {
code.addContent(new HtmlTree(HtmlTag.BR));
}
code.addContent(new RawHtml(
code.addContent(
writer.getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))));
LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
} else {
code.addContent(new RawHtml(
code.addContent(
writer.getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))));
LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
}
}
......
......@@ -159,11 +159,11 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
String label = italicsClassName(cd, false);
Content linkContent;
if(wantFrames){
linkContent = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.ALL_CLASSES_FRAME, cd, label, "classFrame")));
linkContent = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.ALL_CLASSES_FRAME, cd, label, "classFrame"));
} else {
linkContent = new RawHtml(getLink(new LinkInfoImpl(
configuration, cd, label)));
linkContent = getLink(new LinkInfoImpl(
configuration, cd, label));
}
Content li = HtmlTree.LI(linkContent);
content.addContent(li);
......
......@@ -105,9 +105,9 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(member, pre);
addModifiers(member, pre);
Content link = new RawHtml(
Content link =
writer.getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.MEMBER, getType(member))));
LinkInfoImpl.Kind.MEMBER, getType(member)));
pre.addContent(link);
pre.addContent(writer.getSpace());
if (configuration.linksource) {
......@@ -225,8 +225,8 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
*/
protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
Content tdSummary) {
Content strong = HtmlTree.STRONG(new RawHtml(
writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
Content strong = HtmlTree.STRONG(
writer.getDocLink(context, (MemberDoc) member, member.name(), false));
Content code = HtmlTree.CODE(strong);
tdSummary.addContent(code);
}
......
......@@ -116,9 +116,9 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
public Content getNavLinkPrevious() {
Content li;
if (prev != null) {
Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
Content prevLink = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, prev.asClassDoc(), "",
configuration.getText("doclet.Prev_Class"), true)));
configuration.getText("doclet.Prev_Class"), true));
li = HtmlTree.LI(prevLink);
}
else
......@@ -134,9 +134,9 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
public Content getNavLinkNext() {
Content li;
if (next != null) {
Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
Content nextLink = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, next.asClassDoc(), "",
configuration.getText("doclet.Next_Class"), true)));
configuration.getText("doclet.Next_Class"), true));
li = HtmlTree.LI(nextLink);
}
else
......@@ -167,7 +167,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
Content headerContent = new StringContent(header);
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
HtmlStyle.title, headerContent);
heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
heading.addContent(getTypeParameterLinks(linkInfo));
div.addContent(heading);
bodyTree.addContent(div);
return bodyTree;
......@@ -222,7 +222,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType, false);
Content annotationName = new StringContent(annotationType.name());
Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
Content parameterLinks = getTypeParameterLinks(linkInfo);
if (configuration.linksource) {
addSrcLink(annotationType, annotationName, pre);
pre.addContent(parameterLinks);
......
......@@ -259,7 +259,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
getTableCaption(configuration.getText(
"doclet.ClassUse_Packages.that.use.0",
getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc,
false)))));
false)).toString())));
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
Iterator<PackageDoc> it = pkgSet.iterator();
......@@ -294,7 +294,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
getTableCaption(configuration.getText(
"doclet.ClassUse_PackageAnnotation",
getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc, false)))));
LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc, false)).toString())));
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator();
......@@ -334,8 +334,8 @@ public class ClassUseWriter extends SubWriterHolderWriter {
Content link = new RawHtml(
configuration.getText("doclet.ClassUse_Uses.of.0.in.1",
getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
classdoc, false)),
getPackageLinkString(pkg, Util.getPackageName(pkg), false)));
classdoc, false)).toString(),
getPackageLinkString(pkg, Util.escapeHtmlChars(Util.getPackageName(pkg)), false)));
Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
li.addContent(heading);
addClassUse(pkg, li);
......@@ -369,8 +369,8 @@ public class ClassUseWriter extends SubWriterHolderWriter {
*/
protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
String classLink = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc, false));
String pkgLink = getPackageLinkString(pkg, Util.getPackageName(pkg), false);
LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc, false)).toString();
String pkgLink = getPackageLinkString(pkg, Util.escapeHtmlChars(Util.getPackageName(pkg)), false);
classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()),
configuration.getText("doclet.ClassUse_Annotation", classLink,
pkgLink), classUseTableSummary, contentTree);
......@@ -476,9 +476,9 @@ public class ClassUseWriter extends SubWriterHolderWriter {
* @return a content tree for the class page link
*/
protected Content getNavLinkClass() {
Content linkContent = new RawHtml(getLink(new LinkInfoImpl(
Content linkContent = getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc,
"", configuration.getText("doclet.Class"), false)));
"", configuration.getText("doclet.Class"), false));
Content li = HtmlTree.LI(linkContent);
return li;
}
......
......@@ -124,9 +124,9 @@ public class ClassWriterImpl extends SubWriterHolderWriter
public Content getNavLinkPrevious() {
Content li;
if (prev != null) {
Content prevLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
Content prevLink = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, prev, "",
configuration.getText("doclet.Prev_Class"), true)));
configuration.getText("doclet.Prev_Class"), true));
li = HtmlTree.LI(prevLink);
}
else
......@@ -142,9 +142,9 @@ public class ClassWriterImpl extends SubWriterHolderWriter
public Content getNavLinkNext() {
Content li;
if (next != null) {
Content nextLink = new RawHtml(getLink(new LinkInfoImpl(configuration,
Content nextLink = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, next, "",
configuration.getText("doclet.Next_Class"), true)));
configuration.getText("doclet.Next_Class"), true));
li = HtmlTree.LI(nextLink);
}
else
......@@ -191,7 +191,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
Content headerContent = new StringContent(header);
Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
HtmlStyle.title, headerContent);
heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
heading.addContent(getTypeParameterLinks(linkInfo));
div.addContent(heading);
bodyTree.addContent(div);
return bodyTree;
......@@ -249,7 +249,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
//Let's not link to ourselves in the signature.
linkInfo.linkToSelf = false;
Content className = new StringContent(classDoc.name());
Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
Content parameterLinks = getTypeParameterLinks(linkInfo);
if (configuration.linksource) {
addSrcLink(classDoc, className, pre);
pre.addContent(parameterLinks);
......@@ -264,9 +264,9 @@ public class ClassWriterImpl extends SubWriterHolderWriter
if (superclass != null) {
pre.addContent(DocletConstants.NL);
pre.addContent("extends ");
Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
superclass)));
superclass));
pre.addContent(link);
}
}
......@@ -285,9 +285,9 @@ public class ClassWriterImpl extends SubWriterHolderWriter
} else {
pre.addContent(", ");
}
Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
implIntfacs[i])));
implIntfacs[i]));
pre.addContent(link);
counter++;
}
......@@ -360,22 +360,22 @@ public class ClassWriterImpl extends SubWriterHolderWriter
private Content getTreeForClassHelper(Type type) {
Content li = new HtmlTree(HtmlTag.LI);
if (type.equals(classDoc)) {
String typeParameters = getTypeParameterLinks(
Content typeParameters = getTypeParameterLinks(
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
classDoc, false));
if (configuration.shouldExcludeQualifier(
classDoc.containingPackage().name())) {
li.addContent(type.asClassDoc().name());
li.addContent(new RawHtml(typeParameters));
li.addContent(typeParameters);
} else {
li.addContent(type.asClassDoc().qualifiedName());
li.addContent(new RawHtml(typeParameters));
li.addContent(typeParameters);
}
} else {
Content link = new RawHtml(getLink(new LinkInfoImpl(configuration,
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS_TREE_PARENT,
type instanceof ClassDoc ? (ClassDoc) type : type,
configuration.getClassName(type.asClassDoc()), false)));
configuration.getClassName(type.asClassDoc()), false));
li.addContent(link);
}
return li;
......@@ -520,8 +520,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter
Content dt = HtmlTree.DT(label);
Content dl = HtmlTree.DL(dt);
Content dd = new HtmlTree(HtmlTag.DD);
dd.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, outerClass, false))));
dd.addContent(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CLASS, outerClass, false)));
dl.addContent(dd);
classInfoTree.addContent(dl);
}
......@@ -578,12 +578,12 @@ public class ClassWriterImpl extends SubWriterHolderWriter
dd.addContent(separator);
}
if (typeList[i] instanceof ClassDoc) {
Content link = new RawHtml(getLink(
new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i]))));
Content link = getLink(
new LinkInfoImpl(configuration, context, (ClassDoc)(typeList[i])));
dd.addContent(link);
} else {
Content link = new RawHtml(getLink(
new LinkInfoImpl(configuration, context, (Type)(typeList[i]))));
Content link = getLink(
new LinkInfoImpl(configuration, context, (Type)(typeList[i])));
dd.addContent(link);
}
}
......
......@@ -186,7 +186,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
//generate links backward only to public classes.
String classlink = (cd.isPublic() || cd.isProtected()) ?
getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CONSTANT_SUMMARY, cd, false)) :
LinkInfoImpl.Kind.CONSTANT_SUMMARY, cd, false)).toString() :
cd.qualifiedName();
String name = cd.containingPackage().name();
if (name.length() > 0) {
......@@ -260,8 +260,8 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
code.addContent(modifier);
code.addContent(getSpace());
}
Content type = new RawHtml(getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.type())));
Content type = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.type()));
code.addContent(type);
tdType.addContent(code);
return tdType;
......@@ -274,8 +274,8 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
* @return the name column of the constant table row
*/
private Content getNameColumn(FieldDoc member) {
Content nameContent = new RawHtml(getDocLink(
LinkInfoImpl.Kind.CONSTANT_SUMMARY, member, member.name(), false));
Content nameContent = getDocLink(
LinkInfoImpl.Kind.CONSTANT_SUMMARY, member, member.name(), false);
Content code = HtmlTree.CODE(nameContent);
return HtmlTree.TD(code);
}
......
......@@ -101,8 +101,8 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(enumConstant, pre);
addModifiers(enumConstant, pre);
Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.type())));
Content enumConstantLink = writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.type()));
pre.addContent(enumConstantLink);
pre.addContent(" ");
if (configuration.linksource) {
......@@ -222,8 +222,8 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
*/
protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
Content tdSummary) {
Content strong = HtmlTree.STRONG(new RawHtml(
writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
Content strong = HtmlTree.STRONG(
writer.getDocLink(context, (MemberDoc) member, member.name(), false));
Content code = HtmlTree.CODE(strong);
tdSummary.addContent(code);
}
......
......@@ -102,8 +102,8 @@ public class FieldWriterImpl extends AbstractMemberWriter
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(field, pre);
addModifiers(field, pre);
Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.MEMBER, field.type())));
Content fieldlink = writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.MEMBER, field.type()));
pre.addContent(fieldlink);
pre.addContent(" ");
if (configuration.linksource) {
......@@ -132,12 +132,12 @@ public class FieldWriterImpl extends AbstractMemberWriter
(! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
writer.addInlineComment(field, fieldDocTree);
} else {
Content link = new RawHtml(
Content link =
writer.getDocLink(LinkInfoImpl.Kind.FIELD_DOC_COPY,
holder, field,
holder.isIncluded() ?
holder.typeName() : holder.qualifiedTypeName(),
false));
false);
Content codeLink = HtmlTree.CODE(link);
Content strong = HtmlTree.STRONG(holder.isClass()?
writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
......@@ -256,8 +256,8 @@ public class FieldWriterImpl extends AbstractMemberWriter
*/
protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
Content tdSummary) {
Content strong = HtmlTree.STRONG(new RawHtml(
writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false)));
Content strong = HtmlTree.STRONG(
writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false));
Content code = HtmlTree.CODE(strong);
tdSummary.addContent(code);
}
......@@ -267,9 +267,9 @@ public class FieldWriterImpl extends AbstractMemberWriter
*/
protected void addInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member, Content linksTree) {
linksTree.addContent(new RawHtml(
linksTree.addContent(
writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc)member,
member.name(), false)));
member.name(), false));
}
/**
......
......@@ -372,9 +372,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
!configuration.isGeneratedDoc(classes[i])) {
continue;
}
Content classContent = new RawHtml(getLink(new LinkInfoImpl(
Content classContent = getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.PACKAGE, classes[i],
false)));
false));
Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
HtmlTree tr = HtmlTree.TR(tdClass);
if (i%2 == 0)
......@@ -1109,9 +1109,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
*
* @return the link for the given class.
*/
public String getLink(LinkInfoImpl linkInfo) {
public Content getLink(LinkInfoImpl linkInfo) {
LinkFactoryImpl factory = new LinkFactoryImpl(this);
String link = factory.getLinkOutput(linkInfo).toString();
Content link = factory.getLink(linkInfo);
displayLength += linkInfo.displayLength;
return link;
}
......@@ -1122,9 +1122,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
* @param linkInfo the information about the link.
* @return the type for the given class.
*/
public String getTypeParameterLinks(LinkInfoImpl linkInfo) {
public Content getTypeParameterLinks(LinkInfoImpl linkInfo) {
LinkFactoryImpl factory = new LinkFactoryImpl(this);
return factory.getTypeParameterLinks(linkInfo, false).toString();
return factory.getTypeParameterLinks(linkInfo, false);
}
/*************************************************************
......@@ -1192,8 +1192,8 @@ public class HtmlDocletWriter extends HtmlDocWriter {
* @return a content tree for the link
*/
public Content getQualifiedClassLink(LinkInfoImpl.Kind context, ClassDoc cd) {
return new RawHtml(getLink(new LinkInfoImpl(configuration, context, cd,
configuration.getClassName(cd), "")));
return getLink(new LinkInfoImpl(configuration, context, cd,
configuration.getClassName(cd), ""));
}
/**
......@@ -1244,8 +1244,8 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
contentTree.addContent(getPkgName(cd));
}
contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(configuration,
context, cd, cd.name(), isStrong))));
contentTree.addContent(getLink(new LinkInfoImpl(configuration,
context, cd, cd.name(), isStrong)));
}
/**
......@@ -1281,8 +1281,8 @@ public class HtmlDocletWriter extends HtmlDocWriter {
* @param strong true if the link should be strong.
* @return the link for the given member.
*/
public String getDocLink(LinkInfoImpl.Kind context, MemberDoc doc, String label,
boolean strong) {
public Content getDocLink(LinkInfoImpl.Kind context, MemberDoc doc, String label,
boolean strong) {
return getDocLink(context, doc.containingClass(), doc, label, strong);
}
......@@ -1298,8 +1298,8 @@ public class HtmlDocletWriter extends HtmlDocWriter {
* @param strong true if the link should be strong.
* @return the link for the given member.
*/
public String getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
String label, boolean strong) {
public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
String label, boolean strong) {
return getDocLink(context, classDoc, doc, label, strong, false);
}
......@@ -1316,11 +1316,11 @@ public class HtmlDocletWriter extends HtmlDocWriter {
* @param isProperty true if the doc parameter is a JavaFX property.
* @return the link for the given member.
*/
public String getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc,
String label, boolean strong, boolean isProperty) {
if (! (doc.isIncluded() ||
Util.isLinkable(classDoc, configuration))) {
return label;
return new RawHtml(label);
} else if (doc instanceof ExecutableMemberDoc) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
return getLink(new LinkInfoImpl(configuration, context, classDoc,
......@@ -1329,7 +1329,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return getLink(new LinkInfoImpl(configuration, context, classDoc,
doc.name(), label, strong));
} else {
return label;
return new RawHtml(label);
}
}
......@@ -1351,11 +1351,11 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return new StringContent(label);
} else if (doc instanceof ExecutableMemberDoc) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
getAnchor(emd), label, false)));
return getLink(new LinkInfoImpl(configuration, context, classDoc,
getAnchor(emd), label, false));
} else if (doc instanceof MemberDoc) {
return new RawHtml(getLink(new LinkInfoImpl(configuration, context, classDoc,
doc.name(), label, false)));
return getLink(new LinkInfoImpl(configuration, context, classDoc,
doc.name(), label, false));
} else {
return new StringContent(label);
}
......@@ -1441,7 +1441,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
if (label.isEmpty()) {
label = plainOrCodeText(plain, refClass.name());
}
return getLink(new LinkInfoImpl(configuration, refClass, label));
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.
......@@ -1481,7 +1481,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
text = plainOrCodeText(plain, Util.escapeHtmlChars(refMemName));
return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
refMem, (label.isEmpty() ? text: label), false);
refMem, (label.isEmpty() ? text: label), false).toString();
}
}
......@@ -2147,7 +2147,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
linkInfo.label = (type.asClassDoc().isIncluded() ?
type.typeName() :
type.qualifiedTypeName()) + type.dimension() + ".class";
return getLink(linkInfo);
return getLink(linkInfo).toString();
} else {
return type.typeName() + type.dimension() + ".class";
}
......@@ -2163,7 +2163,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
} else if (annotationValue.value() instanceof MemberDoc) {
return getDocLink(LinkInfoImpl.Kind.ANNOTATION,
(MemberDoc) annotationValue.value(),
((MemberDoc) annotationValue.value()).name(), false);
((MemberDoc) annotationValue.value()).name(), false).toString();
} else {
return annotationValue.toString();
}
......
......@@ -129,8 +129,8 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
if (fieldType == null) {
pre.addContent(fieldTypeStr);
} else {
Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.SERIAL_MEMBER, fieldType)));
Content fieldContent = writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.SERIAL_MEMBER, fieldType));
pre.addContent(fieldContent);
}
pre.addContent(fieldDimensions + " ");
......
......@@ -28,6 +28,8 @@ package com.sun.tools.doclets.formats.html;
import java.util.List;
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.internal.toolkit.*;
import com.sun.tools.doclets.internal.toolkit.util.*;
import com.sun.tools.doclets.internal.toolkit.util.links.*;
......@@ -54,14 +56,14 @@ public class LinkFactoryImpl extends LinkFactory {
/**
* {@inheritDoc}
*/
protected LinkOutput getOutputInstance() {
return new LinkOutputImpl();
protected Content newContent() {
return new ContentBuilder();
}
/**
* {@inheritDoc}
*/
protected LinkOutput getClassLink(LinkInfo linkInfo) {
protected Content getClassLink(LinkInfo linkInfo) {
LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
boolean noLabel = linkInfo.label == null || linkInfo.label.length() == 0;
ClassDoc classDoc = classLinkInfo.classDoc;
......@@ -77,21 +79,21 @@ public class LinkFactoryImpl extends LinkFactory {
classLinkInfo.getClassLinkLabel(m_writer.configuration));
classLinkInfo.displayLength += label.length();
Configuration configuration = m_writer.configuration;
LinkOutputImpl linkOutput = new LinkOutputImpl();
Content link = new ContentBuilder();
if (classDoc.isIncluded()) {
if (configuration.isGeneratedDoc(classDoc)) {
DocPath filename = getPath(classLinkInfo);
if (linkInfo.linkToSelf ||
!(DocPath.forName(classDoc)).equals(m_writer.filename)) {
linkOutput.append(m_writer.getHyperLinkString(
link.addContent(new RawHtml(m_writer.getHyperLinkString(
filename.fragment(classLinkInfo.where),
label.toString(),
classLinkInfo.isStrong, classLinkInfo.styleName,
title, classLinkInfo.target));
title, classLinkInfo.target)));
if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
linkOutput.append(getTypeParameterLinks(linkInfo).toString());
link.addContent(getTypeParameterLinks(linkInfo));
}
return linkOutput;
return link;
}
}
} else {
......@@ -100,25 +102,25 @@ public class LinkFactoryImpl extends LinkFactory {
label.toString(), classLinkInfo.isStrong, classLinkInfo.styleName,
true);
if (crossLink != null) {
linkOutput.append(crossLink);
link.addContent(new RawHtml(crossLink));
if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
linkOutput.append(getTypeParameterLinks(linkInfo).toString());
link.addContent(getTypeParameterLinks(linkInfo));
}
return linkOutput;
return link;
}
}
// Can't link so just write label.
linkOutput.append(label.toString());
link.addContent(new RawHtml(label.toString()));
if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
linkOutput.append(getTypeParameterLinks(linkInfo).toString());
link.addContent(getTypeParameterLinks(linkInfo));
}
return linkOutput;
return link;
}
/**
* {@inheritDoc}
*/
protected LinkOutput getTypeParameterLink(LinkInfo linkInfo,
protected Content getTypeParameterLink(LinkInfo linkInfo,
Type typeParam) {
LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
((LinkInfoImpl) linkInfo).getContext(), typeParam);
......@@ -126,29 +128,29 @@ public class LinkFactoryImpl extends LinkFactory {
typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
typeLinkInfo.isJava5DeclarationLocation = false;
LinkOutput output = getLinkOutput(typeLinkInfo);
Content output = getLink(typeLinkInfo);
((LinkInfoImpl) linkInfo).displayLength += typeLinkInfo.displayLength;
return output;
}
protected LinkOutput getTypeAnnotationLink(LinkInfo linkInfo,
protected Content getTypeAnnotationLink(LinkInfo linkInfo,
AnnotationDesc annotation) {
throw new RuntimeException("Not implemented yet!");
}
public LinkOutput getTypeAnnotationLinks(LinkInfo linkInfo) {
LinkOutput output = getOutputInstance();
public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
ContentBuilder links = new ContentBuilder();
AnnotationDesc[] annotations;
if (linkInfo.type instanceof AnnotatedType) {
annotations = linkInfo.type.asAnnotatedType().annotations();
} else if (linkInfo.type instanceof TypeVariable) {
annotations = linkInfo.type.asTypeVariable().annotations();
} else {
return output;
return links;
}
if (annotations.length == 0)
return output;
return links;
List<String> annos = m_writer.getAnnotations(0, annotations, false, linkInfo.isJava5DeclarationLocation);
......@@ -156,17 +158,17 @@ public class LinkFactoryImpl extends LinkFactory {
for (String anno : annos) {
if (!isFirst) {
linkInfo.displayLength += 1;
output.append(" ");
links.addContent(" ");
}
output.append(anno);
links.addContent(new RawHtml(anno));
isFirst = false;
}
if (!annos.isEmpty()) {
linkInfo.displayLength += 1;
output.append(" ");
links.addContent(" ");
}
return output;
return links;
}
/**
......@@ -182,16 +184,16 @@ public class LinkFactoryImpl extends LinkFactory {
classDoc.name());
} else if (classDoc.isInterface()){
return configuration.getText("doclet.Href_Interface_Title",
Util.getPackageName(classDoc.containingPackage()));
Util.escapeHtmlChars(Util.getPackageName(classDoc.containingPackage())));
} else if (classDoc.isAnnotationType()) {
return configuration.getText("doclet.Href_Annotation_Title",
Util.getPackageName(classDoc.containingPackage()));
Util.escapeHtmlChars(Util.getPackageName(classDoc.containingPackage())));
} else if (classDoc.isEnum()) {
return configuration.getText("doclet.Href_Enum_Title",
Util.getPackageName(classDoc.containingPackage()));
Util.escapeHtmlChars(Util.getPackageName(classDoc.containingPackage())));
} else {
return configuration.getText("doclet.Href_Class_Title",
Util.getPackageName(classDoc.containingPackage()));
Util.escapeHtmlChars(Util.getPackageName(classDoc.containingPackage())));
}
}
......
......@@ -152,12 +152,12 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
Util.isLinkable(holderClassDoc, configuration)))) {
writer.addInlineComment(method, methodDocTree);
} else {
Content link = new RawHtml(
Content link =
writer.getDocLink(LinkInfoImpl.Kind.METHOD_DOC_COPY,
holder.asClassDoc(), method,
holder.asClassDoc().isIncluded() ?
holder.typeName() : holder.qualifiedTypeName(),
false));
false);
Content codelLink = HtmlTree.CODE(link);
Content strong = HtmlTree.STRONG(holder.asClassDoc().isClass()?
writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
......@@ -311,14 +311,14 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
}
Content dt = HtmlTree.DT(HtmlTree.STRONG(label));
dl.addContent(dt);
Content overriddenTypeLink = new RawHtml(
writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType)));
Content overriddenTypeLink =
writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType));
Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
String name = method.name();
Content methlink = new RawHtml(writer.getLink(
Content methlink = writer.getLink(
new LinkInfoImpl(writer.configuration, LinkInfoImpl.Kind.MEMBER,
overriddenType.asClassDoc(),
writer.getAnchor(method), name, false)));
writer.getAnchor(method), name, false));
Content codeMethLink = HtmlTree.CODE(methlink);
Content dd = HtmlTree.DD(codeMethLink);
dd.addContent(writer.getSpace());
......@@ -361,14 +361,14 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
for (int i = 0; i < implementedMethods.length; i++) {
MethodDoc implementedMeth = implementedMethods[i];
Type intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
Content intfaclink = new RawHtml(writer.getLink(new LinkInfoImpl(
writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac)));
Content intfaclink = writer.getLink(new LinkInfoImpl(
writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
Content codeIntfacLink = HtmlTree.CODE(intfaclink);
Content dt = HtmlTree.DT(HtmlTree.STRONG(writer.specifiedByLabel));
dl.addContent(dt);
Content methlink = new RawHtml(writer.getDocLink(
Content methlink = writer.getDocLink(
LinkInfoImpl.Kind.MEMBER, implementedMeth,
implementedMeth.name(), false));
implementedMeth.name(), false);
Content codeMethLink = HtmlTree.CODE(methlink);
Content dd = HtmlTree.DD(codeMethLink);
dd.addContent(writer.getSpace());
......@@ -388,8 +388,8 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
protected void addReturnType(MethodDoc method, Content htmltree) {
Type type = method.returnType();
if (type != null) {
Content linkContent = new RawHtml(writer.getLink(
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type)));
Content linkContent = writer.getLink(
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
htmltree.addContent(linkContent);
htmltree.addContent(writer.getSpace());
}
......
......@@ -26,7 +26,6 @@
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.*;
......@@ -165,8 +164,8 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
*/
protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
Content tdSummary) {
Content strong = HtmlTree.STRONG(new RawHtml(
writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member, false))));
Content strong = HtmlTree.STRONG(
writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member, false)));
Content code = HtmlTree.CODE(strong);
tdSummary.addContent(code);
}
......@@ -176,9 +175,9 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
*/
protected void addInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member, Content linksTree) {
linksTree.addContent(new RawHtml(
linksTree.addContent(
writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
(ClassDoc)member, false))));
(ClassDoc)member, false)));
}
/**
......
......@@ -94,7 +94,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
packgen = new PackageFrameWriter(configuration, packageDoc);
String pkgName = Util.getPackageName(packageDoc);
Content body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
Content pkgNameContent = new RawHtml(pkgName);
Content pkgNameContent = new RawHtml(Util.escapeHtmlChars(pkgName));
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
packgen.getTargetPackageLink(packageDoc, "classFrame", pkgNameContent));
body.addContent(heading);
......@@ -182,10 +182,10 @@ public class PackageFrameWriter extends HtmlDocletWriter {
contentTree.addContent(heading);
printedHeader = true;
}
Content link = new RawHtml (getLink(new LinkInfoImpl(configuration,
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i],
(arr[i].isInterface() ? italicsText(arr[i].name()) :
arr[i].name()),"classFrame")));
arr[i].name()),"classFrame"));
Content li = HtmlTree.LI(link);
ul.addContent(li);
}
......
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
......@@ -115,7 +115,7 @@ public class PackageTreeWriter extends AbstractTreeWriter {
protected void generatePackageTreeFile() throws IOException {
Content body = getPackageTreeHeader();
Content headContent = getResource("doclet.Hierarchy_For_Package",
Util.getPackageName(packagedoc));
Util.escapeHtmlChars(Util.getPackageName(packagedoc)));
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
HtmlStyle.title, headContent);
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
......
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
......@@ -154,7 +154,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
getTableCaption(configuration.getText(
"doclet.ClassUse_Packages.that.use.0",
getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false))));
getPackageLinkString(pkgdoc, Util.escapeHtmlChars(Util.getPackageName(pkgdoc)), false))));
table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
Iterator<String> it = usingPackageToUsedClasses.keySet().iterator();
......@@ -199,8 +199,8 @@ public class PackageUseWriter extends SubWriterHolderWriter {
Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
getTableCaption(configuration.getText(
"doclet.ClassUse_Classes.in.0.used.by.1",
getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false),
getPackageLinkString(usingPackage,Util.getPackageName(usingPackage), false))));
getPackageLinkString(pkgdoc, Util.escapeHtmlChars(Util.getPackageName(pkgdoc)), false),
getPackageLinkString(usingPackage, Util.escapeHtmlChars(Util.getPackageName(usingPackage)), false))));
table.addContent(getSummaryTableHeader(classTableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
Iterator<ClassDoc> itc =
......@@ -247,7 +247,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
getHyperLink(Util.getPackageName(pkg),
new RawHtml(Util.getPackageName(pkg))));
new StringContent(Util.getPackageName(pkg))));
contentTree.addContent(tdFirst);
HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
tdLast.addStyle(HtmlStyle.colLast);
......
......@@ -178,9 +178,9 @@ public class PackageWriterImpl extends HtmlDocletWriter
!configuration.isGeneratedDoc(classes[i])) {
continue;
}
Content classContent = new RawHtml(getLink(new LinkInfoImpl(
Content classContent = getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.PACKAGE, classes[i],
false)));
false));
Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
HtmlTree tr = HtmlTree.TR(tdClass);
if (i%2 == 0)
......
......@@ -173,10 +173,10 @@ public class ProfilePackageFrameWriter extends HtmlDocletWriter {
contentTree.addContent(heading);
printedHeader = true;
}
Content link = new RawHtml (getLink(new LinkInfoImpl(configuration,
Content link = getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i],
(arr[i].isInterface() ? italicsText(arr[i].name()) :
arr[i].name()),"classFrame")));
arr[i].name()),"classFrame"));
Content li = HtmlTree.LI(link);
ul.addContent(li);
}
......
......@@ -98,9 +98,9 @@ public class PropertyWriterImpl extends AbstractMemberWriter
Content pre = new HtmlTree(HtmlTag.PRE);
writer.addAnnotationInfo(property, pre);
addModifiers(property, pre);
Content propertylink = new RawHtml(writer.getLink(new LinkInfoImpl(
Content propertylink = writer.getLink(new LinkInfoImpl(
configuration, LinkInfoImpl.Kind.MEMBER,
property.returnType())));
property.returnType()));
pre.addContent(propertylink);
pre.addContent(" ");
if (configuration.linksource) {
......@@ -128,12 +128,12 @@ public class PropertyWriterImpl extends AbstractMemberWriter
(! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
writer.addInlineComment(property, propertyDocTree);
} else {
Content link = new RawHtml(
Content link =
writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_DOC_COPY,
holder, property,
holder.isIncluded() ?
holder.typeName() : holder.qualifiedTypeName(),
false));
false);
Content codeLink = HtmlTree.CODE(link);
Content strong = HtmlTree.STRONG(holder.isClass()?
writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
......@@ -252,13 +252,13 @@ public class PropertyWriterImpl extends AbstractMemberWriter
*/
protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
Content tdSummary) {
Content strong = HtmlTree.STRONG(new RawHtml(
Content strong = HtmlTree.STRONG(
writer.getDocLink(context,
cd,
(MemberDoc) member,
member.name().substring(0, member.name().lastIndexOf("Property")),
false,
true)));
true));
Content code = HtmlTree.CODE(strong);
tdSummary.addContent(code);
......@@ -269,12 +269,12 @@ public class PropertyWriterImpl extends AbstractMemberWriter
*/
protected void addInheritedSummaryLink(ClassDoc cd,
ProgramElementDoc member, Content linksTree) {
linksTree.addContent(new RawHtml(
linksTree.addContent(
writer.getDocLink(LinkInfoImpl.Kind.MEMBER, cd, (MemberDoc)member,
((member.name().lastIndexOf("Property") != -1) && configuration.javafx)
? member.name().substring(0, member.name().length() - "Property".length())
: member.name(),
false, true)));
false, true));
}
/**
......
......@@ -127,9 +127,9 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
* @return a content tree for the class header
*/
public Content getClassHeader(ClassDoc classDoc) {
String classLink = (classDoc.isPublic() || classDoc.isProtected())?
String classLink = (classDoc.isPublic() || classDoc.isProtected()) ?
getLink(new LinkInfoImpl(configuration, classDoc,
configuration.getClassName(classDoc))):
configuration.getClassName(classDoc))).toString() :
classDoc.qualifiedName();
Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
classDoc.qualifiedName()));
......@@ -137,7 +137,7 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
classDoc.superclassType() != null ?
getLink(new LinkInfoImpl(configuration,
LinkInfoImpl.Kind.SERIALIZED_FORM,
classDoc.superclassType())) :
classDoc.superclassType())).toString() :
null;
//Print the heading.
......
......@@ -248,7 +248,7 @@ public class TagletWriterImpl extends TagletWriter {
htmlWriter.codeText(throwsTag.exceptionName()) :
htmlWriter.codeText(
htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
throwsTag.exceptionType())));
throwsTag.exceptionType())).toString());
TagletOutput text = new TagletOutputImpl(
htmlWriter.commentTagsToString(throwsTag, null,
throwsTag.inlineTags(), false));
......@@ -265,7 +265,7 @@ public class TagletWriterImpl extends TagletWriter {
public TagletOutput throwsTagOutput(Type throwsType) {
return new TagletOutputImpl(DocletConstants.NL + "<dd>" +
htmlWriter.codeText(htmlWriter.getLink(
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType))) + "</dd>");
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType)).toString()) + "</dd>");
}
/**
......@@ -275,7 +275,7 @@ public class TagletWriterImpl extends TagletWriter {
boolean includeLink) {
return new TagletOutputImpl(includeLink ?
htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field,
constantVal, false) : constantVal);
constantVal, false).toString() : constantVal);
}
/**
......
/*
* Copyright (c) 2003, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.tools.doclets.formats.html.markup;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.sun.tools.doclets.internal.toolkit.Content;
/**
* A sequence of Content nodes.
*/
public class ContentBuilder extends Content {
protected List<Content> contents = Collections.<Content>emptyList();
@Override
public void addContent(Content content) {
if (content.isEmpty())
return;
ensureMutableContents();
if (content instanceof ContentBuilder) {
contents.addAll(((ContentBuilder) content).contents);
} else
contents.add(content);
}
@Override
public void addContent(String text) {
if (text.isEmpty())
return;
ensureMutableContents();
Content c = contents.isEmpty() ? null : contents.get(contents.size() - 1);
StringContent sc;
if (c != null && c instanceof StringContent) {
sc = (StringContent) c;
} else {
contents.add(sc = new StringContent());
}
sc.addContent(text);
}
@Override
public boolean write(Writer writer, boolean atNewline) throws IOException {
for (Content content: contents) {
atNewline = content.write(writer, atNewline);
}
return atNewline;
}
@Override
public boolean isEmpty() {
for (Content content: contents) {
if (!content.isEmpty())
return false;
}
return true;
}
private void ensureMutableContents() {
if (contents.isEmpty())
contents = new ArrayList<Content>();
}
}
/*
* 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
......@@ -132,7 +132,7 @@ public class HtmlTree extends Content {
*/
public static HtmlTree A(String ref, Content body) {
HtmlTree htmltree = new HtmlTree(HtmlTag.A, nullCheck(body));
htmltree.addAttr(HtmlAttr.HREF, nullCheck(ref));
htmltree.addAttr(HtmlAttr.HREF, Util.escapeHtmlChars(nullCheck(ref)));
return htmltree;
}
......
......@@ -196,7 +196,7 @@ public class HtmlWriter {
configuration.getText("doclet.Type"));
overviewLabel = getResource("doclet.Overview");
defaultPackageLabel = new RawHtml(
DocletConstants.DEFAULT_PACKAGE_NAME);
Util.escapeHtmlChars(DocletConstants.DEFAULT_PACKAGE_NAME));
packageLabel = getResource("doclet.Package");
profileLabel = getResource("doclet.Profile");
useLabel = getResource("doclet.navClassUse");
......
/*
* 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
......@@ -106,32 +106,4 @@ public abstract class Content {
t.getClass();
return t;
}
/**
* Returns true if the content ends with a newline character. Empty content
* is considered as ending with new line.
*
* @param contentBuilder content to test for newline character at the end
* @return true if the content ends with newline.
*/
protected boolean endsWithNewLine(StringBuilder contentBuilder) {
int contentLength = contentBuilder.length();
if (contentLength == 0) {
return true;
}
int nlLength = DocletConstants.NL.length();
if (contentLength < nlLength) {
return false;
}
int contentIndex = contentLength - 1;
int nlIndex = nlLength - 1;
while (nlIndex >= 0) {
if (contentBuilder.charAt(contentIndex) != DocletConstants.NL.charAt(nlIndex)) {
return false;
}
contentIndex--;
nlIndex--;
}
return true;
}
}
......@@ -121,7 +121,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
*/
public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception {
contentTree = packageWriter.getPackageHeader(
Util.getPackageName(packageDoc));
Util.escapeHtmlChars(Util.getPackageName(packageDoc)));
buildChildren(node, contentTree);
packageWriter.addPackageFooter(contentTree);
packageWriter.printDocument(contentTree);
......
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -52,7 +52,7 @@ public class DocletConstants {
/**
* The default package name.
*/
public static final String DEFAULT_PACKAGE_NAME = "&lt;Unnamed&gt;";
public static final String DEFAULT_PACKAGE_NAME = "<Unnamed>";
/**
* The default package file name.
......
......@@ -26,6 +26,7 @@
package com.sun.tools.doclets.internal.toolkit.util.links;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.Content;
/**
* A factory that constructs links from given link information.
......@@ -41,11 +42,11 @@ import com.sun.javadoc.*;
public abstract class LinkFactory {
/**
* Return an empty instance of the link output object.
* Return an empty instance of a content object.
*
* @return an empty instance of the link output object.
* @return an empty instance of a content object.
*/
protected abstract LinkOutput getOutputInstance();
protected abstract Content newContent();
/**
* Constructs a link from the given link information.
......@@ -53,41 +54,41 @@ public abstract class LinkFactory {
* @param linkInfo the information about the link.
* @return the output of the link.
*/
public LinkOutput getLinkOutput(LinkInfo linkInfo) {
public Content getLink(LinkInfo linkInfo) {
if (linkInfo.type != null) {
Type type = linkInfo.type;
LinkOutput linkOutput = getOutputInstance();
Content link = newContent();
if (type.isPrimitive()) {
//Just a primitive.
linkInfo.displayLength += type.typeName().length();
linkOutput.append(type.typeName());
link.addContent(type.typeName());
} else if (type.asAnnotatedType() != null && type.dimension().length() == 0) {
linkOutput.append(getTypeAnnotationLinks(linkInfo));
link.addContent(getTypeAnnotationLinks(linkInfo));
linkInfo.type = type.asAnnotatedType().underlyingType();
linkOutput.append(getLinkOutput(linkInfo));
return linkOutput;
link.addContent(getLink(linkInfo));
return link;
} else if (type.asWildcardType() != null) {
//Wildcard type.
linkInfo.isTypeBound = true;
linkInfo.displayLength += 1;
linkOutput.append("?");
link.addContent("?");
WildcardType wildcardType = type.asWildcardType();
Type[] extendsBounds = wildcardType.extendsBounds();
for (int i = 0; i < extendsBounds.length; i++) {
linkInfo.displayLength += i > 0 ? 2 : 9;
linkOutput.append(i > 0 ? ", " : " extends ");
link.addContent(i > 0 ? ", " : " extends ");
setBoundsLinkInfo(linkInfo, extendsBounds[i]);
linkOutput.append(getLinkOutput(linkInfo));
link.addContent(getLink(linkInfo));
}
Type[] superBounds = wildcardType.superBounds();
for (int i = 0; i < superBounds.length; i++) {
linkInfo.displayLength += i > 0 ? 2 : 7;
linkOutput.append(i > 0 ? ", " : " super ");
link.addContent(i > 0 ? ", " : " super ");
setBoundsLinkInfo(linkInfo, superBounds[i]);
linkOutput.append(getLinkOutput(linkInfo));
link.addContent(getLink(linkInfo));
}
} else if (type.asTypeVariable()!= null) {
linkOutput.append(getTypeAnnotationLinks(linkInfo));
link.addContent(getTypeAnnotationLinks(linkInfo));
linkInfo.isTypeBound = true;
//A type variable.
Doc owner = type.asTypeVariable().owner();
......@@ -95,11 +96,11 @@ public abstract class LinkFactory {
owner instanceof ClassDoc) {
linkInfo.classDoc = (ClassDoc) owner;
linkInfo.label = type.typeName();
linkOutput.append(getClassLink(linkInfo));
link.addContent(getClassLink(linkInfo));
} else {
//No need to link method type parameters.
linkInfo.displayLength += type.typeName().length();
linkOutput.append(type.typeName());
link.addContent(type.typeName());
}
Type[] bounds = type.asTypeVariable().bounds();
......@@ -107,9 +108,9 @@ public abstract class LinkFactory {
linkInfo.excludeTypeBounds = true;
for (int i = 0; i < bounds.length; i++) {
linkInfo.displayLength += i > 0 ? 2 : 9;
linkOutput.append(i > 0 ? " & " : " extends ");
link.addContent(i > 0 ? " & " : " extends ");
setBoundsLinkInfo(linkInfo, bounds[i]);
linkOutput.append(getLinkOutput(linkInfo));
link.addContent(getLink(linkInfo));
}
}
} else if (type.asClassDoc() != null) {
......@@ -119,14 +120,15 @@ public abstract class LinkFactory {
//Since we are excluding type parameter links, we should not
//be linking to the type bound.
linkInfo.displayLength += type.typeName().length();
linkOutput.append(type.typeName());
linkOutput.append(getTypeParameterLinks(linkInfo));
return linkOutput;
link.addContent(type.typeName());
link.addContent(getTypeParameterLinks(linkInfo));
return link;
} else {
linkInfo.classDoc = type.asClassDoc();
linkOutput = getClassLink(linkInfo);
link = newContent();
link.addContent(getClassLink(linkInfo));
if (linkInfo.includeTypeAsSepLink) {
linkOutput.append(getTypeParameterLinks(linkInfo, false));
link.addContent(getTypeParameterLinks(linkInfo, false));
}
}
}
......@@ -136,35 +138,39 @@ public abstract class LinkFactory {
//Javadoc returns var args as array.
//Strip out the first [] from the var arg.
linkInfo.displayLength += type.dimension().length()-2;
linkOutput.append(type.dimension().substring(2));
link.addContent(type.dimension().substring(2));
}
linkInfo.displayLength += 3;
linkOutput.append("...");
link.addContent("...");
} else {
while (type != null && type.dimension().length() > 0) {
linkInfo.displayLength += type.dimension().length();
if (type.asAnnotatedType() != null) {
linkInfo.type = type;
linkOutput.append(" ");
linkOutput.append(getTypeAnnotationLinks(linkInfo));
linkOutput.append("[]");
link.addContent(" ");
link.addContent(getTypeAnnotationLinks(linkInfo));
link.addContent("[]");
type = type.asAnnotatedType().underlyingType().getElementType();
} else {
linkOutput.append("[]");
link.addContent("[]");
type = type.getElementType();
}
}
linkInfo.type = type;
linkOutput.insert(0, getTypeAnnotationLinks(linkInfo));
Content newLink = newContent();
newLink.addContent(getTypeAnnotationLinks(linkInfo));
newLink.addContent(link);
link = newLink;
}
return linkOutput;
return link;
} else if (linkInfo.classDoc != null) {
//Just a class link
LinkOutput linkOutput = getClassLink(linkInfo);
Content link = newContent();
link.addContent(getClassLink(linkInfo));
if (linkInfo.includeTypeAsSepLink) {
linkOutput.append(getTypeParameterLinks(linkInfo, false));
link.addContent(getTypeParameterLinks(linkInfo, false));
}
return linkOutput;
return link;
} else {
return null;
}
......@@ -183,7 +189,7 @@ public abstract class LinkFactory {
*
* @return the link for the given class.
*/
protected abstract LinkOutput getClassLink(LinkInfo linkInfo);
protected abstract Content getClassLink(LinkInfo linkInfo);
/**
* Return the link to the given type parameter.
......@@ -191,10 +197,10 @@ public abstract class LinkFactory {
* @param linkInfo the information about the link to construct.
* @param typeParam the type parameter to link to.
*/
protected abstract LinkOutput getTypeParameterLink(LinkInfo linkInfo,
protected abstract Content getTypeParameterLink(LinkInfo linkInfo,
Type typeParam);
protected abstract LinkOutput getTypeAnnotationLink(LinkInfo linkInfo,
protected abstract Content getTypeAnnotationLink(LinkInfo linkInfo,
AnnotationDesc annotation);
/**
......@@ -203,7 +209,7 @@ public abstract class LinkFactory {
* @param linkInfo the information about the link to construct.
* @return the links to the type parameters.
*/
public LinkOutput getTypeParameterLinks(LinkInfo linkInfo) {
public Content getTypeParameterLinks(LinkInfo linkInfo) {
return getTypeParameterLinks(linkInfo, true);
}
......@@ -215,8 +221,8 @@ public abstract class LinkFactory {
* the type parameters portion of the link.
* @return the links to the type parameters.
*/
public LinkOutput getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) {
LinkOutput output = getOutputInstance();
public Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) {
Content links = newContent();
Type[] vars;
if (linkInfo.executableMemberDoc != null) {
vars = linkInfo.executableMemberDoc.typeParameters();
......@@ -227,62 +233,42 @@ public abstract class LinkFactory {
vars = linkInfo.classDoc.typeParameters();
} else {
//Nothing to document.
return output;
return links;
}
if (((linkInfo.includeTypeInClassLinkLabel && isClassLabel) ||
(linkInfo.includeTypeAsSepLink && ! isClassLabel)
)
&& vars.length > 0) {
linkInfo.displayLength += 1;
output.append(getLessThanString());
links.addContent("<");
for (int i = 0; i < vars.length; i++) {
if (i > 0) {
linkInfo.displayLength += 1;
output.append(",");
links.addContent(",");
}
output.append(getTypeParameterLink(linkInfo, vars[i]));
links.addContent(getTypeParameterLink(linkInfo, vars[i]));
}
linkInfo.displayLength += 1;
output.append(getGreaterThanString());
links.addContent(">");
}
return output;
return links;
}
public LinkOutput getTypeAnnotationLinks(LinkInfo linkInfo) {
LinkOutput output = getOutputInstance();
public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
Content links = newContent();
if (linkInfo.type.asAnnotatedType() == null)
return output;
return links;
AnnotationDesc[] annotations = linkInfo.type.asAnnotatedType().annotations();
for (int i = 0; i < annotations.length; i++) {
if (i > 0) {
linkInfo.displayLength += 1;
output.append(" ");
links.addContent(" ");
}
output.append(getTypeAnnotationLink(linkInfo, annotations[i]));
links.addContent(getTypeAnnotationLink(linkInfo, annotations[i]));
}
linkInfo.displayLength += 1;
output.append(" ");
return output;
}
/**
* Return &amp;lt;, which is used in type parameters. Override this
* if your doclet uses something different.
*
* @return return &amp;lt;, which is used in type parameters.
*/
protected String getLessThanString() {
return "&lt;";
}
/**
* Return &amp;gt;, which is used in type parameters. Override this
* if your doclet uses something different.
*
* @return return &amp;gt;, which is used in type parameters.
*/
protected String getGreaterThanString() {
return "&gt;";
links.addContent(" ");
return links;
}
}
......@@ -306,7 +306,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
// Handle multiple bounds.
//==============================================================
{BUG_ID + FS + "pkg" + FS + "MultiTypeParameters.html",
"public&nbsp;&lt;T extends java.lang.Number & java.lang.Runnable&gt;&nbsp;T&nbsp;foo(T&nbsp;t)"},
"public&nbsp;&lt;T extends java.lang.Number &amp; java.lang.Runnable&gt;&nbsp;T&nbsp;foo(T&nbsp;t)"},
//==============================================================
// Test Class-Use Documenation for Type Parameters.
......@@ -323,7 +323,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
"<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest1.html\" " +
"title=\"class in pkg2\">ClassUseTest1</a>&lt;T extends " +
"<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo" +
"</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
"</a> &amp; <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
"Foo2</a>&gt;</strong></code>&nbsp;</td>"
},
{BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
......@@ -375,7 +375,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
"<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest1.html\" " +
"title=\"class in pkg2\">ClassUseTest1</a>&lt;T extends " +
"<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo" +
"</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
"</a> &amp; <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
"Foo2</a>&gt;</strong></code>&nbsp;</td>"
},
{BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
......
......@@ -103,17 +103,17 @@ public class TestTypeAnnotations extends JavadocTester {
{BUG_ID + FS + "typeannos" + FS + "Complex1.html",
"class <span class=\"strong\">Complex1&lt;K extends <a href=\"../" +
"typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
"@ClassParamA</a> java.lang.String & java.lang.Runnable&gt;</span>"
"@ClassParamA</a> java.lang.String &amp; java.lang.Runnable&gt;</span>"
},
{BUG_ID + FS + "typeannos" + FS + "Complex2.html",
"class <span class=\"strong\">Complex2&lt;K extends java.lang." +
"String & <a href=\"../typeannos/ClassParamB.html\" title=\"" +
"String &amp; <a href=\"../typeannos/ClassParamB.html\" title=\"" +
"annotation in typeannos\">@ClassParamB</a> java.lang.Runnable&gt;</span>"
},
{BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html",
"class <span class=\"strong\">ComplexBoth&lt;K extends <a href=\"" +
"../typeannos/ClassParamA.html\" title=\"annotation in typeannos\"" +
">@ClassParamA</a> java.lang.String & <a href=\"../typeannos/" +
">@ClassParamA</a> java.lang.String &amp; <a href=\"../typeannos/" +
"ClassParamA.html\" title=\"annotation in typeannos\">@ClassParamA" +
"</a> java.lang.Runnable&gt;</span>"
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册