langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
author ksrini
Sun, 15 Jun 2014 08:41:57 -0700
changeset 25454 376a52c9540c
parent 19497 407ed5b28a44
permissions -rw-r--r--
8039028: [javadoc] refactor the usage of Util.java Reviewed-by: jjg
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
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
public class LinkFactoryImpl extends LinkFactory {
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    private HtmlDocletWriter m_writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    public LinkFactoryImpl(HtmlDocletWriter writer) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
        m_writer = writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     */
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    58
    protected Content newContent() {
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    59
        return new ContentBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     */
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    65
    protected Content getClassLink(LinkInfo linkInfo) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    67
        boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        ClassDoc classDoc = classLinkInfo.classDoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        //Create a tool tip if we are linking to a class or interface.  Don't
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        //create one if we are linking to a member.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        String title =
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
            (classLinkInfo.where == null || classLinkInfo.where.length() == 0) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
                getClassToolTip(classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
                    classLinkInfo.type != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
                    !classDoc.qualifiedTypeName().equals(classLinkInfo.type.qualifiedTypeName())) :
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
            "";
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    77
        Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
    78
        Configuration configuration = m_writer.configuration;
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    79
        Content link = new ContentBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
        if (classDoc.isIncluded()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
            if (configuration.isGeneratedDoc(classDoc)) {
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
    82
                DocPath filename = getPath(classLinkInfo);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
                if (linkInfo.linkToSelf ||
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
    84
                                !(DocPath.forName(classDoc)).equals(m_writer.filename)) {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    85
                        link.addContent(m_writer.getHyperLink(
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    86
                                filename.fragment(classLinkInfo.where),
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    87
                            label,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
    88
                            classLinkInfo.isStrong, classLinkInfo.styleName,
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    89
                            title, classLinkInfo.target));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
                        if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    91
                            link.addContent(getTypeParameterLinks(linkInfo));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
                        }
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
    93
                        return link;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        } else {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    97
            Content crossLink = m_writer.getCrossClassLink(
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
                classDoc.qualifiedName(), classLinkInfo.where,
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
    99
                label, classLinkInfo.isStrong, classLinkInfo.styleName,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
                true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
            if (crossLink != null) {
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 17559
diff changeset
   102
                link.addContent(crossLink);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
                if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   104
                    link.addContent(getTypeParameterLinks(linkInfo));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                }
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   106
                return link;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        // 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
   110
        link.addContent(label);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   112
            link.addContent(getTypeParameterLinks(linkInfo));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        }
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   114
        return link;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     */
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   120
    protected Content getTypeParameterLink(LinkInfo linkInfo,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        Type typeParam) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   122
        LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
17558
eee4ccf66cfd 8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents: 16969
diff changeset
   123
                ((LinkInfoImpl) linkInfo).getContext(), typeParam);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds;
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   127
        typeLinkInfo.isJava5DeclarationLocation = false;
17564
c329fe11193d 8011288: Erratic/inconsistent indentation of signatures
jjg
parents: 17560
diff changeset
   128
        return getLink(typeLinkInfo);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   131
    protected Content getTypeAnnotationLink(LinkInfo linkInfo,
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   132
            AnnotationDesc annotation) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   133
        throw new RuntimeException("Not implemented yet!");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   134
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   135
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   136
    public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   137
        ContentBuilder links = new ContentBuilder();
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   138
        AnnotationDesc[] annotations;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   139
        if (linkInfo.type instanceof AnnotatedType) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   140
            annotations = linkInfo.type.asAnnotatedType().annotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   141
        } else if (linkInfo.type instanceof TypeVariable) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   142
            annotations = linkInfo.type.asTypeVariable().annotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   143
        } else {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   144
            return links;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   145
        }
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
        if (annotations.length == 0)
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   148
            return links;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   149
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
   150
        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
   151
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   152
        boolean isFirst = true;
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
   153
        for (Content anno : annos) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   154
            if (!isFirst) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   155
                links.addContent(" ");
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   156
            }
17570
78512b2899db 8012183: replace some uses of Configuration.getText with Configuration.getResource
jjg
parents: 17569
diff changeset
   157
            links.addContent(anno);
16969
b58d8a70d921 8009686: Generated javadoc documentation should be able to display type annotation on an array
bpatel
parents: 15385
diff changeset
   158
            isFirst = false;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   159
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   160
        if (!annos.isEmpty()) {
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   161
            links.addContent(" ");
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   162
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   163
17559
87c28ee29329 8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents: 17558
diff changeset
   164
        return links;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   165
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   166
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     * Given a class, return the appropriate tool tip.
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     * @param classDoc the class to get the tool tip for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     * @return the tool tip for the appropriate class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   174
        Configuration configuration = m_writer.configuration;
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   175
        Utils utils = configuration.utils;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        if (isTypeLink) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
            return configuration.getText("doclet.Href_Type_Param_Title",
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   178
                classDoc.name());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        } else if (classDoc.isInterface()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
            return configuration.getText("doclet.Href_Interface_Title",
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   181
                utils.getPackageName(classDoc.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        } else if (classDoc.isAnnotationType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
            return configuration.getText("doclet.Href_Annotation_Title",
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   184
                utils.getPackageName(classDoc.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        } else if (classDoc.isEnum()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
            return configuration.getText("doclet.Href_Enum_Title",
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   187
                utils.getPackageName(classDoc.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
            return configuration.getText("doclet.Href_Class_Title",
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 19497
diff changeset
   190
                utils.getPackageName(classDoc.containingPackage()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        }
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
     * Return path to the given file name in the given package. So if the name
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * passed is "Object.html" and the name of the package is "java.lang", and
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     * if the relative path is "../.." then returned string will be
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * "../../java/lang/Object.html"
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * @param linkInfo the information about the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   202
    private DocPath getPath(LinkInfoImpl linkInfo) {
17558
eee4ccf66cfd 8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents: 16969
diff changeset
   203
        if (linkInfo.context == LinkInfoImpl.Kind.PACKAGE_FRAME) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
            //Not really necessary to do this but we want to be consistent
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
            //with 1.4.2 output.
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   206
            return DocPath.forName(linkInfo.classDoc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        }
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   208
        return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.classDoc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
}