< prev index next >
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java
Print this page
@@ -33,12 +33,13 @@
import javax.lang.model.type.TypeMirror;
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
import jdk.javadoc.internal.doclets.toolkit.util.links.LinkFactory;
import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
/**
* A factory that returns a link given the information about it.
@@ -51,13 +52,16 @@
* @author Jamie Ho
*/
public class LinkFactoryImpl extends LinkFactory {
private final HtmlDocletWriter m_writer;
+ private final DocPaths docPaths;
public LinkFactoryImpl(HtmlDocletWriter writer) {
+ super(writer.configuration.utils);
m_writer = writer;
+ docPaths = writer.configuration.docPaths;
}
/**
* {@inheritDoc}
*/
@@ -70,11 +74,10 @@
* {@inheritDoc}
*/
@Override
protected Content getClassLink(LinkInfo linkInfo) {
BaseConfiguration configuration = m_writer.configuration;
- Utils utils = configuration.utils;
LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
TypeElement typeElement = classLinkInfo.typeElement;
// Create a tool tip if we are linking to a class or interface. Don't
// create one if we are linking to a member.
@@ -82,18 +85,18 @@
if (classLinkInfo.where == null || classLinkInfo.where.length() == 0) {
boolean isTypeLink = classLinkInfo.type != null &&
utils.isTypeVariable(utils.getComponentType(classLinkInfo.type));
title = getClassToolTip(typeElement, isTypeLink);
}
- Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
+ Content label = classLinkInfo.getClassLinkLabel(configuration);
Content link = new ContentBuilder();
if (utils.isIncluded(typeElement)) {
if (configuration.isGeneratedDoc(typeElement)) {
DocPath filename = getPath(classLinkInfo);
if (linkInfo.linkToSelf ||
- !(DocPath.forName(utils, typeElement)).equals(m_writer.filename)) {
+ !(docPaths.forName(typeElement)).equals(m_writer.filename)) {
link.addContent(m_writer.links.createLink(
filename.fragment(classLinkInfo.where),
label,
classLinkInfo.isStrong,
title,
@@ -138,11 +141,10 @@
return getLink(typeLinkInfo);
}
@Override
public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
- Utils utils = ((LinkInfoImpl)linkInfo).utils;
ContentBuilder links = new ContentBuilder();
List<? extends AnnotationMirror> annotations;
if (utils.isAnnotated(linkInfo.type)) {
annotations = linkInfo.type.getAnnotationMirrors();
} else if (utils.isTypeVariable(linkInfo.type)) {
@@ -189,26 +191,25 @@
*
* @param typeElement the class to get the tool tip for.
* @return the tool tip for the appropriate class.
*/
private String getClassToolTip(TypeElement typeElement, boolean isTypeLink) {
- BaseConfiguration configuration = m_writer.configuration;
- Utils utils = configuration.utils;
+ Resources resources = m_writer.configuration.getResources();
if (isTypeLink) {
- return configuration.getText("doclet.Href_Type_Param_Title",
+ return resources.getText("doclet.Href_Type_Param_Title",
utils.getSimpleName(typeElement));
} else if (utils.isInterface(typeElement)){
- return configuration.getText("doclet.Href_Interface_Title",
+ return resources.getText("doclet.Href_Interface_Title",
utils.getPackageName(utils.containingPackage(typeElement)));
} else if (utils.isAnnotationType(typeElement)) {
- return configuration.getText("doclet.Href_Annotation_Title",
+ return resources.getText("doclet.Href_Annotation_Title",
utils.getPackageName(utils.containingPackage(typeElement)));
} else if (utils.isEnum(typeElement)) {
- return configuration.getText("doclet.Href_Enum_Title",
+ return resources.getText("doclet.Href_Enum_Title",
utils.getPackageName(utils.containingPackage(typeElement)));
} else {
- return configuration.getText("doclet.Href_Class_Title",
+ return resources.getText("doclet.Href_Class_Title",
utils.getPackageName(utils.containingPackage(typeElement)));
}
}
/**
@@ -221,10 +222,10 @@
*/
private DocPath getPath(LinkInfoImpl linkInfo) {
if (linkInfo.context == LinkInfoImpl.Kind.PACKAGE_FRAME) {
//Not really necessary to do this but we want to be consistent
//with 1.4.2 output.
- return DocPath.forName(linkInfo.utils, linkInfo.typeElement);
+ return docPaths.forName(linkInfo.typeElement);
}
- return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.utils, linkInfo.typeElement));
+ return m_writer.pathToRoot.resolve(docPaths.forClass(linkInfo.typeElement));
}
}
< prev index next >