author | ksrini |
Mon, 05 Jun 2017 13:45:34 -0700 | |
changeset 45417 | f7479ee8de69 |
parent 35426 | 374342e56a56 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
45417 | 2 |
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.util.links; |
10 | 27 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
28 |
import javax.lang.model.element.ExecutableElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
29 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
30 |
import javax.lang.model.type.TypeMirror; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
31 |
|
45417 | 32 |
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
10 | 34 |
|
35 |
/** |
|
36 |
* Encapsulates information about a link. |
|
37 |
* |
|
14260 | 38 |
* <p><b>This is NOT part of any supported API. |
39 |
* If you write code that depends on this, you do so at your own risk. |
|
40 |
* This code and its internal interfaces are subject to change or |
|
41 |
* deletion without notice.</b> |
|
42 |
* |
|
10 | 43 |
* @author Jamie Ho |
44 |
*/ |
|
45 |
public abstract class LinkInfo { |
|
46 |
||
47 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
48 |
* The class we want to link to. Null if we are not linking |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
49 |
* to a class. |
10 | 50 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
51 |
public TypeElement typeElement; |
10 | 52 |
|
53 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
54 |
* The executable element we want to link to. Null if we are not linking |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
55 |
* to an executable element. |
10 | 56 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
57 |
public ExecutableElement executableElement; |
10 | 58 |
|
59 |
/** |
|
60 |
* The Type we want to link to. Null if we are not linking to a type. |
|
61 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
62 |
public TypeMirror type; |
10 | 63 |
|
64 |
/** |
|
65 |
* True if this is a link to a VarArg. |
|
66 |
*/ |
|
67 |
public boolean isVarArg = false; |
|
68 |
||
69 |
/** |
|
70 |
* Set this to true to indicate that you are linking to a type parameter. |
|
71 |
*/ |
|
72 |
public boolean isTypeBound = false; |
|
73 |
||
74 |
/** |
|
15385 | 75 |
* Whether the document element is in a Java 5 declaration |
76 |
* location or not. |
|
77 |
*/ |
|
78 |
public boolean isJava5DeclarationLocation = true; |
|
79 |
||
80 |
/** |
|
10 | 81 |
* The label for the link. |
82 |
*/ |
|
17560 | 83 |
public Content label; |
10 | 84 |
|
85 |
/** |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
86 |
* True if the link should be strong. |
10 | 87 |
*/ |
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
88 |
public boolean isStrong = false; |
10 | 89 |
|
90 |
/** |
|
91 |
* True if we should include the type in the link label. False otherwise. |
|
92 |
*/ |
|
93 |
public boolean includeTypeInClassLinkLabel = true; |
|
94 |
||
95 |
/** |
|
17564
c329fe11193d
8011288: Erratic/inconsistent indentation of signatures
jjg
parents:
17560
diff
changeset
|
96 |
* True if we should include the type as separate link. False otherwise. |
10 | 97 |
*/ |
98 |
public boolean includeTypeAsSepLink = false; |
|
99 |
||
100 |
/** |
|
101 |
* True if we should exclude the type bounds for the type parameter. |
|
102 |
*/ |
|
103 |
public boolean excludeTypeBounds = false; |
|
104 |
||
105 |
/** |
|
106 |
* True if we should print the type parameters, but not link them. |
|
107 |
*/ |
|
108 |
public boolean excludeTypeParameterLinks = false; |
|
109 |
||
110 |
/** |
|
111 |
* True if we should print the type bounds, but not link them. |
|
112 |
*/ |
|
113 |
public boolean excludeTypeBoundsLinks = false; |
|
114 |
||
115 |
/** |
|
116 |
* By default, the link can be to the page it's already on. However, |
|
117 |
* there are cases where we don't want this (e.g. heading of class page). |
|
118 |
*/ |
|
119 |
public boolean linkToSelf = true; |
|
120 |
||
121 |
/** |
|
17560 | 122 |
* Return an empty instance of a content object. |
123 |
* |
|
124 |
* @return an empty instance of a content object. |
|
125 |
*/ |
|
126 |
protected abstract Content newContent(); |
|
127 |
||
128 |
/** |
|
10 | 129 |
* Return true if this link is linkable and false if we can't link to the |
130 |
* desired place. |
|
131 |
* |
|
132 |
* @return true if this link is linkable and false if we can't link to the |
|
133 |
* desired place. |
|
134 |
*/ |
|
135 |
public abstract boolean isLinkable(); |
|
136 |
||
137 |
/** |
|
138 |
* Return the label for this class link. |
|
139 |
* |
|
140 |
* @param configuration the current configuration of the doclet. |
|
141 |
* @return the label for this class link. |
|
142 |
*/ |
|
45417 | 143 |
public Content getClassLinkLabel(BaseConfiguration configuration) { |
17560 | 144 |
if (label != null && !label.isEmpty()) { |
10 | 145 |
return label; |
146 |
} else if (isLinkable()) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
147 |
Content tlabel = newContent(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
148 |
tlabel.addContent(configuration.utils.getSimpleName(typeElement)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
149 |
return tlabel; |
10 | 150 |
} else { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
151 |
Content tlabel = newContent(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
152 |
tlabel.addContent(configuration.getClassName(typeElement)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
153 |
return tlabel; |
10 | 154 |
} |
155 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
156 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
157 |
@Override |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
158 |
public String toString() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
159 |
return "LinkInfo{" + "typeElement=" + typeElement + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
160 |
", executableElement=" + executableElement + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
161 |
", type=" + type + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
162 |
", isVarArg=" + isVarArg + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
163 |
", isTypeBound=" + isTypeBound + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
164 |
", isJava5DeclarationLocation=" + isJava5DeclarationLocation + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
165 |
", label=" + label + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
166 |
", isStrong=" + isStrong + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
167 |
", includeTypeInClassLinkLabel=" + includeTypeInClassLinkLabel + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
168 |
", includeTypeAsSepLink=" + includeTypeAsSepLink + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
169 |
", excludeTypeBounds=" + excludeTypeBounds + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
170 |
", excludeTypeParameterLinks=" + excludeTypeParameterLinks + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
171 |
", excludeTypeBoundsLinks=" + excludeTypeBoundsLinks + |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
172 |
", linkToSelf=" + linkToSelf + '}'; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
173 |
} |
10 | 174 |
} |