langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
author jjg
Fri, 27 May 2016 13:06:58 -0700
changeset 38617 d93a7f64e231
parent 25874 83c19f00452c
permissions -rw-r--r--
8157606: deprecate com.sun.javadoc API Reviewed-by: ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
     2
 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
    28
import java.util.List;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
    29
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.javadoc.*;
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    31
import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.doclets.internal.toolkit.util.*;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9083
diff changeset
    34
import com.sun.tools.doclets.internal.toolkit.util.links.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * A factory that returns a link given the information about it.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    39
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    40
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    41
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    42
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    43
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @since 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 */
38617
d93a7f64e231 8157606: deprecate com.sun.javadoc API
jjg
parents: 25874
diff changeset
    47
@Deprecated
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
public class LinkFactoryImpl extends LinkFactory {
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    private HtmlDocletWriter m_writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    public LinkFactoryImpl(HtmlDocletWriter writer) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        m_writer = writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    59
    protected Content newContent() {
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    60
        return new ContentBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     */
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    66
    protected Content getClassLink(LinkInfo linkInfo) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    68
        boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        ClassDoc classDoc = classLinkInfo.classDoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        //Create a tool tip if we are linking to a class or interface.  Don't
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        //create one if we are linking to a member.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        String title =
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
            (classLinkInfo.where == null || classLinkInfo.where.length() == 0) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
                getClassToolTip(classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
                    classLinkInfo.type != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
                    !classDoc.qualifiedTypeName().equals(classLinkInfo.type.qualifiedTypeName())) :
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
            "";
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    78
        Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
    79
        Configuration configuration = m_writer.configuration;
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    80
        Content link = new ContentBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        if (classDoc.isIncluded()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            if (configuration.isGeneratedDoc(classDoc)) {
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
    83
                DocPath filename = getPath(classLinkInfo);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
                if (linkInfo.linkToSelf ||
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
    85
                                !(DocPath.forName(classDoc)).equals(m_writer.filename)) {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    86
                        link.addContent(m_writer.getHyperLink(
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    87
                                filename.fragment(classLinkInfo.where),
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    88
                            label,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
    89
                            classLinkInfo.isStrong, classLinkInfo.styleName,
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    90
                            title, classLinkInfo.target));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
                        if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    92
                            link.addContent(getTypeParameterLinks(linkInfo));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
                        }
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    94
                        return link;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        } else {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    98
            Content crossLink = m_writer.getCrossClassLink(
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
                classDoc.qualifiedName(), classLinkInfo.where,
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   100
                label, classLinkInfo.isStrong, classLinkInfo.styleName,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
                true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
            if (crossLink != null) {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   103
                link.addContent(crossLink);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
                if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   105
                    link.addContent(getTypeParameterLinks(linkInfo));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
                }
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   107
                return link;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        // Can't link so just write label.
19497
407ed5b28a44 8017191: Javadoc is confused by @link to imported classes outside of the set of generated packages
jjg
parents: 17570
diff changeset
   111
        link.addContent(label);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   113
            link.addContent(getTypeParameterLinks(linkInfo));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        }
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   115
        return link;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     */
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   121
    protected Content getTypeParameterLink(LinkInfo linkInfo,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        Type typeParam) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   123
        LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
17558
eee4ccf66cfd 8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents: 16969
diff changeset
   124
                ((LinkInfoImpl) linkInfo).getContext(), typeParam);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds;
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   128
        typeLinkInfo.isJava5DeclarationLocation = false;
17564
c329fe11193d 8011288: Erratic/inconsistent indentation of signatures
jjg
parents: 17560
diff changeset
   129
        return getLink(typeLinkInfo);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   132
    protected Content getTypeAnnotationLink(LinkInfo linkInfo,
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   133
            AnnotationDesc annotation) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   134
        throw new RuntimeException("Not implemented yet!");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   135
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   136
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   137
    public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   138
        ContentBuilder links = new ContentBuilder();
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   139
        AnnotationDesc[] annotations;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   140
        if (linkInfo.type instanceof AnnotatedType) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   141
            annotations = linkInfo.type.asAnnotatedType().annotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   142
        } else if (linkInfo.type instanceof TypeVariable) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   143
            annotations = linkInfo.type.asTypeVariable().annotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   144
        } else {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   145
            return links;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   146
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   147
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   148
        if (annotations.length == 0)
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   149
            return links;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   150
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
   151
        List<Content> annos = m_writer.getAnnotations(0, annotations, false, linkInfo.isJava5DeclarationLocation);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   152
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   153
        boolean isFirst = true;
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
   154
        for (Content anno : annos) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   155
            if (!isFirst) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   156
                links.addContent(" ");
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   157
            }
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
   158
            links.addContent(anno);
16969
b58d8a70d921 8009686: Generated javadoc documentation should be able to display type annotation on an array
bpatel
parents: 15385
diff changeset
   159
            isFirst = false;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   160
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   161
        if (!annos.isEmpty()) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   162
            links.addContent(" ");
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   163
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   164
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   165
        return links;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   166
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   167
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * Given a class, return the appropriate tool tip.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     * @param classDoc the class to get the tool tip for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * @return the tool tip for the appropriate class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   175
        Configuration configuration = m_writer.configuration;
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   176
        Utils utils = configuration.utils;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        if (isTypeLink) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
            return configuration.getText("doclet.Href_Type_Param_Title",
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   179
                classDoc.name());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        } else if (classDoc.isInterface()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            return configuration.getText("doclet.Href_Interface_Title",
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   182
                utils.getPackageName(classDoc.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        } else if (classDoc.isAnnotationType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
            return configuration.getText("doclet.Href_Annotation_Title",
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   185
                utils.getPackageName(classDoc.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        } else if (classDoc.isEnum()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
            return configuration.getText("doclet.Href_Enum_Title",
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   188
                utils.getPackageName(classDoc.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            return configuration.getText("doclet.Href_Class_Title",
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   191
                utils.getPackageName(classDoc.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * Return path to the given file name in the given package. So if the name
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * passed is "Object.html" and the name of the package is "java.lang", and
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * if the relative path is "../.." then returned string will be
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * "../../java/lang/Object.html"
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     * @param linkInfo the information about the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   203
    private DocPath getPath(LinkInfoImpl linkInfo) {
17558
eee4ccf66cfd 8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents: 16969
diff changeset
   204
        if (linkInfo.context == LinkInfoImpl.Kind.PACKAGE_FRAME) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
            //Not really necessary to do this but we want to be consistent
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
            //with 1.4.2 output.
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   207
            return DocPath.forName(linkInfo.classDoc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        }
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   209
        return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.classDoc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
}