Wed, 23 Jan 2013 13:27:24 -0800
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
1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
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 */
26 package com.sun.tools.doclets.internal.toolkit.util.links;
28 import com.sun.javadoc.*;
29 import com.sun.tools.doclets.internal.toolkit.Configuration;
31 /**
32 * Encapsulates information about a link.
33 *
34 * <p><b>This is NOT part of any supported API.
35 * If you write code that depends on this, you do so at your own risk.
36 * This code and its internal interfaces are subject to change or
37 * deletion without notice.</b>
38 *
39 * @author Jamie Ho
40 * @since 1.5
41 */
42 public abstract class LinkInfo {
44 /**
45 * The ClassDoc we want to link to. Null if we are not linking
46 * to a ClassDoc.
47 */
48 public ClassDoc classDoc;
50 /**
51 * The executable member doc we want to link to. Null if we are not linking
52 * to an executable member.
53 */
54 public ExecutableMemberDoc executableMemberDoc;
56 /**
57 * The Type we want to link to. Null if we are not linking to a type.
58 */
59 public Type type;
61 /**
62 * True if this is a link to a VarArg.
63 */
64 public boolean isVarArg = false;
66 /**
67 * Set this to true to indicate that you are linking to a type parameter.
68 */
69 public boolean isTypeBound = false;
71 /**
72 * Whether the document element is in a Java 5 declaration
73 * location or not.
74 */
75 public boolean isJava5DeclarationLocation = true;
77 /**
78 * The label for the link.
79 */
80 public String label;
82 /**
83 * True if the link should be strong.
84 */
85 public boolean isStrong = false;
87 /**
88 * True if we should include the type in the link label. False otherwise.
89 */
90 public boolean includeTypeInClassLinkLabel = true;
92 /**
93 * True if we should include the type as seperate link. False otherwise.
94 */
95 public boolean includeTypeAsSepLink = false;
97 /**
98 * True if we should exclude the type bounds for the type parameter.
99 */
100 public boolean excludeTypeBounds = false;
102 /**
103 * True if we should print the type parameters, but not link them.
104 */
105 public boolean excludeTypeParameterLinks = false;
107 /**
108 * True if we should print the type bounds, but not link them.
109 */
110 public boolean excludeTypeBoundsLinks = false;
112 /**
113 * By default, the link can be to the page it's already on. However,
114 * there are cases where we don't want this (e.g. heading of class page).
115 */
116 public boolean linkToSelf = true;
118 /**
119 * The display length for the link.
120 */
121 public int displayLength = 0;
123 /**
124 * Return the id indicating where the link appears in the documentation.
125 * This is used for special processing of different types of links.
126 *
127 * @return the id indicating where the link appears in the documentation.
128 */
129 public abstract int getContext();
131 /**
132 * Set the context.
133 *
134 * @param c the context id to set.
135 */
136 public abstract void setContext(int c);
138 /**
139 * Return true if this link is linkable and false if we can't link to the
140 * desired place.
141 *
142 * @return true if this link is linkable and false if we can't link to the
143 * desired place.
144 */
145 public abstract boolean isLinkable();
147 /**
148 * Return the label for this class link.
149 *
150 * @param configuration the current configuration of the doclet.
151 * @return the label for this class link.
152 */
153 public String getClassLinkLabel(Configuration configuration) {
154 if (label != null && label.length() > 0) {
155 return label;
156 } else if (isLinkable()) {
157 return classDoc.name();
158 } else {
159 return configuration.getClassName(classDoc);
160 }
161 }
162 }