langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
author jjg
Wed, 23 Jan 2013 13:27:24 -0800
changeset 15385 ee1eebe7e210
parent 14542 7062120649c2
child 16969 b58d8a70d921
permissions -rw-r--r--
8006775: JSR 308: Compiler changes in JDK8 Reviewed-by: jjg Contributed-by: mernst@cs.washington.edu, wmdietl@cs.washington.edu, mpapi@csail.mit.edu, mahmood@notnoop.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
     2
 * Copyright (c) 2003, 2013, 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.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.doclets.internal.toolkit.util.*;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9083
diff changeset
    33
import com.sun.tools.doclets.internal.toolkit.util.links.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * A factory that returns a link given the information about it.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    38
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    39
 *  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
    40
 *  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
    41
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    42
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @since 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
public class LinkFactoryImpl extends LinkFactory {
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    private HtmlDocletWriter m_writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    public LinkFactoryImpl(HtmlDocletWriter writer) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        m_writer = writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    protected LinkOutput getOutputInstance() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        return new LinkOutputImpl();
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    protected LinkOutput getClassLink(LinkInfo linkInfo) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
        LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        boolean noLabel = linkInfo.label == null || linkInfo.label.length() == 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        ClassDoc classDoc = classLinkInfo.classDoc;
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        //Create a tool tip if we are linking to a class or interface.  Don't
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        //create one if we are linking to a member.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        String title =
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
            (classLinkInfo.where == null || classLinkInfo.where.length() == 0) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
                getClassToolTip(classDoc,
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
                    classLinkInfo.type != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
                    !classDoc.qualifiedTypeName().equals(classLinkInfo.type.qualifiedTypeName())) :
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
            "";
14263
473b1eaede64 8000310: Clean up use of StringBuffer in langtools
jjg
parents: 14260
diff changeset
    76
        StringBuilder label = new StringBuilder(
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
            classLinkInfo.getClassLinkLabel(m_writer.configuration));
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
        classLinkInfo.displayLength += label.length();
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
    79
        Configuration configuration = m_writer.configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
        LinkOutputImpl linkOutput = new LinkOutputImpl();
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)) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    86
                        linkOutput.append(m_writer.getHyperLinkString(
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    87
                                filename.fragment(classLinkInfo.where),
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
    88
                            label.toString(),
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,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
                            title, classLinkInfo.target));
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
                        if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
                            linkOutput.append(getTypeParameterLinks(linkInfo).toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
                        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
                        return linkOutput;
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 {
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            String crossLink = m_writer.getCrossClassLink(
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
                classDoc.qualifiedName(), classLinkInfo.where,
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   100
                label.toString(), 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) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
                linkOutput.append(crossLink);
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
                if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                    linkOutput.append(getTypeParameterLinks(linkInfo).toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
                return linkOutput;
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.
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        linkOutput.append(label.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
            linkOutput.append(getTypeParameterLinks(linkInfo).toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        return linkOutput;
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
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    protected LinkOutput getTypeParameterLink(LinkInfo linkInfo,
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,
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   124
                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;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        LinkOutput output = getLinkOutput(typeLinkInfo);
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        ((LinkInfoImpl) linkInfo).displayLength += typeLinkInfo.displayLength;
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        return output;
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   134
    protected LinkOutput getTypeAnnotationLink(LinkInfo linkInfo,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   135
            AnnotationDesc annotation) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   136
        throw new RuntimeException("Not implemented yet!");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   137
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   138
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   139
    public LinkOutput getTypeAnnotationLinks(LinkInfo linkInfo) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   140
        LinkOutput output = getOutputInstance();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   141
        AnnotationDesc[] annotations;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   142
        if (linkInfo.type instanceof AnnotatedType) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   143
            annotations = linkInfo.type.asAnnotatedType().annotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   144
        } else if (linkInfo.type instanceof TypeVariable) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   145
            annotations = linkInfo.type.asTypeVariable().annotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   146
        } else {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   147
            return output;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   148
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   149
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   150
        if (annotations.length == 0)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   151
            return output;
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
        List<String> annos = m_writer.getAnnotations(0, annotations, false, linkInfo.isJava5DeclarationLocation);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   154
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   155
        boolean isFirst = true;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   156
        for (String anno : annos) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   157
            if (!isFirst) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   158
                linkInfo.displayLength += 1;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   159
                output.append(" ");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   160
                isFirst = false;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   161
            }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   162
            output.append(anno);
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
        if (!annos.isEmpty()) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   165
            linkInfo.displayLength += 1;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   166
            output.append(" ");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   167
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   168
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   169
        return output;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   170
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14542
diff changeset
   171
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     * Given a class, return the appropriate tool tip.
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     * @param classDoc the class to get the tool tip for.
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     * @return the tool tip for the appropriate class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   179
        Configuration configuration = m_writer.configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        if (isTypeLink) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
            return configuration.getText("doclet.Href_Type_Param_Title",
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14358
diff changeset
   182
                classDoc.name());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        } else if (classDoc.isInterface()){
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
            return configuration.getText("doclet.Href_Interface_Title",
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
                Util.getPackageName(classDoc.containingPackage()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        } else if (classDoc.isAnnotationType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
            return configuration.getText("doclet.Href_Annotation_Title",
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
                Util.getPackageName(classDoc.containingPackage()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        } else if (classDoc.isEnum()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            return configuration.getText("doclet.Href_Enum_Title",
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
                Util.getPackageName(classDoc.containingPackage()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
            return configuration.getText("doclet.Href_Class_Title",
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
                Util.getPackageName(classDoc.containingPackage()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * Return path to the given file name in the given package. So if the name
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * passed is "Object.html" and the name of the package is "java.lang", and
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     * if the relative path is "../.." then returned string will be
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     * "../../java/lang/Object.html"
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     * @param linkInfo the information about the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   206
    private DocPath getPath(LinkInfoImpl linkInfo) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        if (linkInfo.context == LinkInfoImpl.PACKAGE_FRAME) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
            //Not really necessary to do this but we want to be consistent
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
            //with 1.4.2 output.
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   210
            return DocPath.forName(linkInfo.classDoc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        }
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14263
diff changeset
   212
        return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.classDoc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
}