src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
equal deleted inserted replaced
-1:000000000000 0:959103a6100f
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 */
25
26
27 package com.sun.tools.doclets.formats.html;
28
29 import com.sun.javadoc.*;
30 import com.sun.tools.doclets.formats.html.markup.ContentBuilder;
31 import com.sun.tools.doclets.formats.html.markup.StringContent;
32 import com.sun.tools.doclets.internal.toolkit.Content;
33 import com.sun.tools.doclets.internal.toolkit.util.*;
34 import com.sun.tools.doclets.internal.toolkit.util.links.*;
35
36 /**
37 * <p><b>This is NOT part of any supported API.
38 * If you write code that depends on this, you do so at your own risk.
39 * This code and its internal interfaces are subject to change or
40 * deletion without notice.</b>
41 */
42 public class LinkInfoImpl extends LinkInfo {
43
44 public enum Kind {
45 DEFAULT,
46
47 /**
48 * Indicate that the link appears in a class list.
49 */
50 ALL_CLASSES_FRAME,
51
52 /**
53 * Indicate that the link appears in a class documentation.
54 */
55 CLASS,
56
57 /**
58 * Indicate that the link appears in member documentation.
59 */
60 MEMBER,
61
62 /**
63 * Indicate that the link appears in class use documentation.
64 */
65 CLASS_USE,
66
67 /**
68 * Indicate that the link appears in index documentation.
69 */
70 INDEX,
71
72 /**
73 * Indicate that the link appears in constant value summary.
74 */
75 CONSTANT_SUMMARY,
76
77 /**
78 * Indicate that the link appears in serialized form documentation.
79 */
80 SERIALIZED_FORM,
81
82 /**
83 * Indicate that the link appears in serial member documentation.
84 */
85 SERIAL_MEMBER,
86
87 /**
88 * Indicate that the link appears in package documentation.
89 */
90 PACKAGE,
91
92 /**
93 * Indicate that the link appears in see tag documentation.
94 */
95 SEE_TAG,
96
97 /**
98 * Indicate that the link appears in value tag documentation.
99 */
100 VALUE_TAG,
101
102 /**
103 * Indicate that the link appears in tree documentation.
104 */
105 TREE,
106
107 /**
108 * Indicate that the link appears in a class list.
109 */
110 PACKAGE_FRAME,
111
112 /**
113 * The header in the class documentation.
114 */
115 CLASS_HEADER,
116
117 /**
118 * The signature in the class documentation.
119 */
120 CLASS_SIGNATURE,
121
122 /**
123 * The return type of a method.
124 */
125 RETURN_TYPE,
126
127 /**
128 * The return type of a method in a member summary.
129 */
130 SUMMARY_RETURN_TYPE,
131
132 /**
133 * The type of a method/constructor parameter.
134 */
135 EXECUTABLE_MEMBER_PARAM,
136
137 /**
138 * Super interface links.
139 */
140 SUPER_INTERFACES,
141
142 /**
143 * Implemented interface links.
144 */
145 IMPLEMENTED_INTERFACES,
146
147 /**
148 * Implemented class links.
149 */
150 IMPLEMENTED_CLASSES,
151
152 /**
153 * Subinterface links.
154 */
155 SUBINTERFACES,
156
157 /**
158 * Subclasses links.
159 */
160 SUBCLASSES,
161
162 /**
163 * The signature in the class documentation (implements/extends portion).
164 */
165 CLASS_SIGNATURE_PARENT_NAME,
166
167 /**
168 * The header for method documentation copied from parent.
169 */
170 METHOD_DOC_COPY,
171
172 /**
173 * Method "specified by" link.
174 */
175 METHOD_SPECIFIED_BY,
176
177 /**
178 * Method "overrides" link.
179 */
180 METHOD_OVERRIDES,
181
182 /**
183 * Annotation link.
184 */
185 ANNOTATION,
186
187 /**
188 * The header for field documentation copied from parent.
189 */
190 FIELD_DOC_COPY,
191
192 /**
193 * The parent nodes in the class tree.
194 */
195 CLASS_TREE_PARENT,
196
197 /**
198 * The type parameters of a method or constructor.
199 */
200 MEMBER_TYPE_PARAMS,
201
202 /**
203 * Indicate that the link appears in class use documentation.
204 */
205 CLASS_USE_HEADER,
206
207 /**
208 * The header for property documentation copied from parent.
209 */
210 PROPERTY_DOC_COPY
211 }
212
213 public final ConfigurationImpl configuration;
214
215 /**
216 * The location of the link.
217 */
218 public Kind context = Kind.DEFAULT;
219
220 /**
221 * The value of the marker #.
222 */
223 public String where = "";
224
225 /**
226 * String style of text defined in style sheet.
227 */
228 public String styleName = "";
229
230 /**
231 * The value of the target.
232 */
233 public String target = "";
234
235 /**
236 * Construct a LinkInfo object.
237 *
238 * @param configuration the configuration data for the doclet
239 * @param context the context of the link.
240 * @param context the context of the link.
241 * @param executableMemberDoc the member to link to.
242 */
243 public LinkInfoImpl(ConfigurationImpl configuration,
244 Kind context, ExecutableMemberDoc executableMemberDoc) {
245 this.configuration = configuration;
246 this.executableMemberDoc = executableMemberDoc;
247 setContext(context);
248 }
249
250 /**
251 * {@inherotDoc}
252 */
253 protected Content newContent() {
254 return new ContentBuilder();
255 }
256
257 /**
258 * Construct a LinkInfo object.
259 *
260 * @param configuration the configuration data for the doclet
261 * @param context the context of the link.
262 * @param classDoc the class to link to.
263 */
264 public LinkInfoImpl(ConfigurationImpl configuration,
265 Kind context, ClassDoc classDoc) {
266 this.configuration = configuration;
267 this.classDoc = classDoc;
268 setContext(context);
269 }
270
271 /**
272 * Construct a LinkInfo object.
273 *
274 * @param configuration the configuration data for the doclet
275 * @param context the context of the link.
276 * @param type the class to link to.
277 */
278 public LinkInfoImpl(ConfigurationImpl configuration,
279 Kind context, Type type) {
280 this.configuration = configuration;
281 this.type = type;
282 setContext(context);
283 }
284
285
286 /**
287 * Set the label for the link.
288 * @param label plain-text label for the link
289 */
290 public LinkInfoImpl label(String label) {
291 this.label = new StringContent(label);
292 return this;
293 }
294
295 /**
296 * Set the label for the link.
297 */
298 public LinkInfoImpl label(Content label) {
299 this.label = label;
300 return this;
301 }
302
303 /**
304 * Set whether or not the link should be strong.
305 */
306 public LinkInfoImpl strong(boolean strong) {
307 this.isStrong = strong;
308 return this;
309 }
310
311 /**
312 * Set the style to be used for the link.
313 * @param styleName String style of text defined in style sheet.
314 */
315 public LinkInfoImpl styleName(String styleName) {
316 this.styleName = styleName;
317 return this;
318 }
319
320 /**
321 * Set the target to be used for the link.
322 * @param styleName String style of text defined in style sheet.
323 */
324 public LinkInfoImpl target(String target) {
325 this.target = target;
326 return this;
327 }
328
329 /**
330 * Set whether or not this is a link to a varargs parameter.
331 */
332 public LinkInfoImpl varargs(boolean varargs) {
333 this.isVarArg = varargs;
334 return this;
335 }
336
337 /**
338 * Set the fragment specifier for the link.
339 */
340 public LinkInfoImpl where(String where) {
341 this.where = where;
342 return this;
343 }
344
345 /**
346 * {@inheritDoc}
347 */
348 public Kind getContext() {
349 return context;
350 }
351
352 /**
353 * {@inheritDoc}
354 *
355 * This method sets the link attributes to the appropriate values
356 * based on the context.
357 *
358 * @param c the context id to set.
359 */
360 public final void setContext(Kind c) {
361 //NOTE: Put context specific link code here.
362 switch (c) {
363 case ALL_CLASSES_FRAME:
364 case PACKAGE_FRAME:
365 case IMPLEMENTED_CLASSES:
366 case SUBCLASSES:
367 case METHOD_DOC_COPY:
368 case FIELD_DOC_COPY:
369 case PROPERTY_DOC_COPY:
370 case CLASS_USE_HEADER:
371 includeTypeInClassLinkLabel = false;
372 break;
373
374 case ANNOTATION:
375 excludeTypeParameterLinks = true;
376 excludeTypeBounds = true;
377 break;
378
379 case IMPLEMENTED_INTERFACES:
380 case SUPER_INTERFACES:
381 case SUBINTERFACES:
382 case CLASS_TREE_PARENT:
383 case TREE:
384 case CLASS_SIGNATURE_PARENT_NAME:
385 excludeTypeParameterLinks = true;
386 excludeTypeBounds = true;
387 includeTypeInClassLinkLabel = false;
388 includeTypeAsSepLink = true;
389 break;
390
391 case PACKAGE:
392 case CLASS_USE:
393 case CLASS_HEADER:
394 case CLASS_SIGNATURE:
395 excludeTypeParameterLinks = true;
396 includeTypeAsSepLink = true;
397 includeTypeInClassLinkLabel = false;
398 break;
399
400 case MEMBER_TYPE_PARAMS:
401 includeTypeAsSepLink = true;
402 includeTypeInClassLinkLabel = false;
403 break;
404
405 case RETURN_TYPE:
406 case SUMMARY_RETURN_TYPE:
407 excludeTypeBounds = true;
408 break;
409 case EXECUTABLE_MEMBER_PARAM:
410 excludeTypeBounds = true;
411 break;
412 }
413 context = c;
414 if (type != null &&
415 type.asTypeVariable()!= null &&
416 type.asTypeVariable().owner() instanceof ExecutableMemberDoc) {
417 excludeTypeParameterLinks = true;
418 }
419 }
420
421 /**
422 * Return true if this link is linkable and false if we can't link to the
423 * desired place.
424 *
425 * @return true if this link is linkable and false if we can't link to the
426 * desired place.
427 */
428 public boolean isLinkable() {
429 return Util.isLinkable(classDoc, configuration);
430 }
431 }

mercurial