16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.javadoc.internal.doclets.formats.html;
27
28 import java.util.List;
29
30 import javax.lang.model.element.AnnotationMirror;
31 import javax.lang.model.element.Element;
32 import javax.lang.model.element.TypeElement;
33 import javax.lang.model.type.TypeMirror;
34
35 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
36 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
37 import jdk.javadoc.internal.doclets.toolkit.Content;
38 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
39 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
40 import jdk.javadoc.internal.doclets.toolkit.util.links.LinkFactory;
41 import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
42
43 /**
44 * A factory that returns a link given the information about it.
45 *
46 * <p><b>This is NOT part of any supported API.
47 * If you write code that depends on this, you do so at your own risk.
48 * This code and its internal interfaces are subject to change or
49 * deletion without notice.</b>
50 *
51 * @author Jamie Ho
52 */
53 public class LinkFactoryImpl extends LinkFactory {
54
55 private final HtmlDocletWriter m_writer;
75 Utils utils = configuration.utils;
76 LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
77 boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
78 TypeElement typeElement = classLinkInfo.typeElement;
79 // Create a tool tip if we are linking to a class or interface. Don't
80 // create one if we are linking to a member.
81 String title = "";
82 if (classLinkInfo.where == null || classLinkInfo.where.length() == 0) {
83 boolean isTypeLink = classLinkInfo.type != null &&
84 utils.isTypeVariable(utils.getComponentType(classLinkInfo.type));
85 title = getClassToolTip(typeElement, isTypeLink);
86 }
87 Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
88
89 Content link = new ContentBuilder();
90 if (utils.isIncluded(typeElement)) {
91 if (configuration.isGeneratedDoc(typeElement)) {
92 DocPath filename = getPath(classLinkInfo);
93 if (linkInfo.linkToSelf ||
94 !(DocPath.forName(utils, typeElement)).equals(m_writer.filename)) {
95 link.addContent(m_writer.getHyperLink(
96 filename.fragment(classLinkInfo.where),
97 label,
98 classLinkInfo.isStrong, classLinkInfo.styleName,
99 title, classLinkInfo.target));
100 if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
101 link.addContent(getTypeParameterLinks(linkInfo));
102 }
103 return link;
104 }
105 }
106 } else {
107 Content crossLink = m_writer.getCrossClassLink(
108 typeElement.getQualifiedName().toString(), classLinkInfo.where,
109 label, classLinkInfo.isStrong, classLinkInfo.styleName,
110 true);
111 if (crossLink != null) {
112 link.addContent(crossLink);
113 if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
114 link.addContent(getTypeParameterLinks(linkInfo));
115 }
116 return link;
117 }
118 }
119 // Can't link so just write label.
|
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.javadoc.internal.doclets.formats.html;
27
28 import java.util.List;
29
30 import javax.lang.model.element.AnnotationMirror;
31 import javax.lang.model.element.Element;
32 import javax.lang.model.element.TypeElement;
33 import javax.lang.model.type.TypeMirror;
34
35 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
36 import jdk.javadoc.internal.doclets.formats.html.markup.Links;
37 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
38 import jdk.javadoc.internal.doclets.toolkit.Content;
39 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
40 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
41 import jdk.javadoc.internal.doclets.toolkit.util.links.LinkFactory;
42 import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
43
44 /**
45 * A factory that returns a link given the information about it.
46 *
47 * <p><b>This is NOT part of any supported API.
48 * If you write code that depends on this, you do so at your own risk.
49 * This code and its internal interfaces are subject to change or
50 * deletion without notice.</b>
51 *
52 * @author Jamie Ho
53 */
54 public class LinkFactoryImpl extends LinkFactory {
55
56 private final HtmlDocletWriter m_writer;
76 Utils utils = configuration.utils;
77 LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
78 boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
79 TypeElement typeElement = classLinkInfo.typeElement;
80 // Create a tool tip if we are linking to a class or interface. Don't
81 // create one if we are linking to a member.
82 String title = "";
83 if (classLinkInfo.where == null || classLinkInfo.where.length() == 0) {
84 boolean isTypeLink = classLinkInfo.type != null &&
85 utils.isTypeVariable(utils.getComponentType(classLinkInfo.type));
86 title = getClassToolTip(typeElement, isTypeLink);
87 }
88 Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
89
90 Content link = new ContentBuilder();
91 if (utils.isIncluded(typeElement)) {
92 if (configuration.isGeneratedDoc(typeElement)) {
93 DocPath filename = getPath(classLinkInfo);
94 if (linkInfo.linkToSelf ||
95 !(DocPath.forName(utils, typeElement)).equals(m_writer.filename)) {
96 link.addContent(Links.createLink(
97 filename.fragment(classLinkInfo.where),
98 label,
99 classLinkInfo.isStrong,
100 classLinkInfo.styleName,
101 title,
102 classLinkInfo.target));
103 if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
104 link.addContent(getTypeParameterLinks(linkInfo));
105 }
106 return link;
107 }
108 }
109 } else {
110 Content crossLink = m_writer.getCrossClassLink(
111 typeElement.getQualifiedName().toString(), classLinkInfo.where,
112 label, classLinkInfo.isStrong, classLinkInfo.styleName,
113 true);
114 if (crossLink != null) {
115 link.addContent(crossLink);
116 if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
117 link.addContent(getTypeParameterLinks(linkInfo));
118 }
119 return link;
120 }
121 }
122 // Can't link so just write label.
|