001: /*
002: * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.tools.doclets.formats.html;
027:
028: import com.sun.javadoc.*;
029: import com.sun.tools.doclets.internal.toolkit.util.*;
030: import com.sun.tools.doclets.internal.toolkit.util.links.*;
031:
032: public class LinkInfoImpl extends LinkInfo {
033:
034: /**
035: * Indicate that the link appears in a class list.
036: */
037: public static final int ALL_CLASSES_FRAME = 1;
038:
039: /**
040: * Indicate that the link appears in a class documentation.
041: */
042: public static final int CONTEXT_CLASS = 2;
043:
044: /**
045: * Indicate that the link appears in member documentation.
046: */
047: public static final int CONTEXT_MEMBER = 3;
048:
049: /**
050: * Indicate that the link appears in class use documentation.
051: */
052: public static final int CONTEXT_CLASS_USE = 4;
053:
054: /**
055: * Indicate that the link appears in index documentation.
056: */
057: public static final int CONTEXT_INDEX = 5;
058:
059: /**
060: * Indicate that the link appears in constant value summary.
061: */
062: public static final int CONTEXT_CONSTANT_SUMMARY = 6;
063:
064: /**
065: * Indicate that the link appears in serialized form documentation.
066: */
067: public static final int CONTEXT_SERIALIZED_FORM = 7;
068:
069: /**
070: * Indicate that the link appears in serial member documentation.
071: */
072: public static final int CONTEXT_SERIAL_MEMBER = 8;
073:
074: /**
075: * Indicate that the link appears in package documentation.
076: */
077: public static final int CONTEXT_PACKAGE = 9;
078:
079: /**
080: * Indicate that the link appears in see tag documentation.
081: */
082: public static final int CONTEXT_SEE_TAG = 10;
083:
084: /**
085: * Indicate that the link appears in value tag documentation.
086: */
087: public static final int CONTEXT_VALUE_TAG = 11;
088:
089: /**
090: * Indicate that the link appears in tree documentation.
091: */
092: public static final int CONTEXT_TREE = 12;
093:
094: /**
095: * Indicate that the link appears in a class list.
096: */
097: public static final int PACKAGE_FRAME = 13;
098:
099: /**
100: * The header in the class documentation.
101: */
102: public static final int CONTEXT_CLASS_HEADER = 14;
103:
104: /**
105: * The signature in the class documentation.
106: */
107: public static final int CONTEXT_CLASS_SIGNATURE = 15;
108:
109: /**
110: * The return type of a method.
111: */
112: public static final int CONTEXT_RETURN_TYPE = 16;
113:
114: /**
115: * The return type of a method in a member summary.
116: */
117: public static final int CONTEXT_SUMMARY_RETURN_TYPE = 17;
118:
119: /**
120: * The type of a method/constructor parameter.
121: */
122: public static final int CONTEXT_EXECUTABLE_MEMBER_PARAM = 18;
123:
124: /**
125: * Super interface links.
126: */
127: public static final int CONTEXT_SUPER_INTERFACES = 19;
128:
129: /**
130: * Implemented interface links.
131: */
132: public static final int CONTEXT_IMPLEMENTED_INTERFACES = 20;
133:
134: /**
135: * Implemented class links.
136: */
137: public static final int CONTEXT_IMPLEMENTED_CLASSES = 21;
138:
139: /**
140: * Subinterface links.
141: */
142: public static final int CONTEXT_SUBINTERFACES = 22;
143:
144: /**
145: * Subclasses links.
146: */
147: public static final int CONTEXT_SUBCLASSES = 23;
148:
149: /**
150: * The signature in the class documentation (implements/extends portion).
151: */
152: public static final int CONTEXT_CLASS_SIGNATURE_PARENT_NAME = 24;
153:
154: /**
155: * The header for method documentation copied from parent.
156: */
157: public static final int CONTEXT_METHOD_DOC_COPY = 26;
158:
159: /**
160: * Method "specified by" link.
161: */
162: public static final int CONTEXT_METHOD_SPECIFIED_BY = 27;
163:
164: /**
165: * Method "overrides" link.
166: */
167: public static final int CONTEXT_METHOD_OVERRIDES = 28;
168:
169: /**
170: * Annotation link.
171: */
172: public static final int CONTEXT_ANNOTATION = 29;
173:
174: /**
175: * The header for field documentation copied from parent.
176: */
177: public static final int CONTEXT_FIELD_DOC_COPY = 30;
178:
179: /**
180: * The parent nodes int the class tree.
181: */
182: public static final int CONTEXT_CLASS_TREE_PARENT = 31;
183:
184: /**
185: * The type parameters of a method or constructor.
186: */
187: public static final int CONTEXT_MEMBER_TYPE_PARAMS = 32;
188:
189: /**
190: * Indicate that the link appears in class use documentation.
191: */
192: public static final int CONTEXT_CLASS_USE_HEADER = 33;
193:
194: /**
195: * The integer indicating the location of the link.
196: */
197: public int context;
198:
199: /**
200: * The value of the marker #.
201: */
202: public String where = "";
203:
204: /**
205: * String style of text defined in style sheet.
206: */
207: public String styleName = "";
208:
209: /**
210: * The valueof the target.
211: */
212: public String target = "";
213:
214: /**
215: * Construct a LinkInfo object.
216: *
217: * @param context the context of the link.
218: * @param classDoc the class to link to.
219: * @param label the label for the link.
220: * @param target the value of the target attribute.
221: */
222: public LinkInfoImpl(int context, ClassDoc classDoc, String label,
223: String target) {
224: this .classDoc = classDoc;
225: this .label = label;
226: this .target = target;
227: setContext(context);
228: }
229:
230: /**
231: * Construct a LinkInfo object.
232: *
233: * @param context the context of the link.
234: * @param classDoc the class to link to.
235: * @param where the value of the marker #.
236: * @param label the label for the link.
237: * @param isBold true if the link should be bold.
238: * @param styleName String style of text defined in style sheet.
239: */
240: public LinkInfoImpl(int context, ClassDoc classDoc, String where,
241: String label, boolean isBold, String styleName) {
242: this .classDoc = classDoc;
243: this .where = where;
244: this .label = label;
245: this .isBold = isBold;
246: this .styleName = styleName;
247: setContext(context);
248: }
249:
250: /**
251: * Construct a LinkInfo object.
252: *
253: * @param context the context of the link.
254: * @param classDoc the class to link to.
255: * @param where the value of the marker #.
256: * @param label the label for the link.
257: * @param isBold true if the link should be bold.
258: */
259: public LinkInfoImpl(int context, ClassDoc classDoc, String where,
260: String label, boolean isBold) {
261: this .classDoc = classDoc;
262: this .where = where;
263: this .label = label;
264: this .isBold = isBold;
265: setContext(context);
266: }
267:
268: /**
269: * Construct a LinkInfo object.
270: *
271: * @param classDoc the class to link to.
272: * @param label the label for the link.
273: */
274: public LinkInfoImpl(ClassDoc classDoc, String label) {
275: this .classDoc = classDoc;
276: this .label = label;
277: setContext(context);
278: }
279:
280: /**
281: * Construct a LinkInfo object.
282: *
283: * @param context the context of the link.
284: * @param executableMemberDoc the member to link to.
285: * @param isBold true if the link should be bold.
286: */
287: public LinkInfoImpl(int context,
288: ExecutableMemberDoc executableMemberDoc, boolean isBold) {
289: this .executableMemberDoc = executableMemberDoc;
290: this .isBold = isBold;
291: setContext(context);
292: }
293:
294: /**
295: * Construct a LinkInfo object.
296: *
297: * @param context the context of the link.
298: * @param classDoc the class to link to.
299: * @param isBold true if the link should be bold.
300: */
301: public LinkInfoImpl(int context, ClassDoc classDoc, boolean isBold) {
302: this .classDoc = classDoc;
303: this .isBold = isBold;
304: setContext(context);
305: }
306:
307: /**
308: * Construct a LinkInfo object.
309: *
310: * @param context the context of the link.
311: * @param type the class to link to.
312: */
313: public LinkInfoImpl(int context, Type type) {
314: this .type = type;
315: setContext(context);
316: }
317:
318: /**
319: * Construct a LinkInfo object.
320: *
321: * @param context the context of the link.
322: * @param type the class to link to.
323: * @param isVarArg true if this is a link to a var arg.
324: */
325: public LinkInfoImpl(int context, Type type, boolean isVarArg) {
326: this .type = type;
327: this .isVarArg = isVarArg;
328: setContext(context);
329: }
330:
331: /**
332: * Construct a LinkInfo object.
333: *
334: * @param context the context of the link.
335: * @param type the class to link to.
336: * @param label the label for the link.
337: * @param isBold true if the link should be bold.
338: */
339: public LinkInfoImpl(int context, Type type, String label,
340: boolean isBold) {
341: this .type = type;
342: this .label = label;
343: this .isBold = isBold;
344: setContext(context);
345: }
346:
347: /**
348: * Construct a LinkInfo object.
349: *
350: * @param context the context of the link.
351: * @param classDoc the class to link to.
352: * @param label the label for the link.
353: * @param isBold true if the link should be bold.
354: */
355: public LinkInfoImpl(int context, ClassDoc classDoc, String label,
356: boolean isBold) {
357: this .classDoc = classDoc;
358: this .label = label;
359: this .isBold = isBold;
360: setContext(context);
361: }
362:
363: /**
364: * {@inheritDoc}
365: */
366: public int getContext() {
367: return context;
368: }
369:
370: /**
371: * {@inheritDoc}
372: *
373: * This method sets the link attributes to the appropriate values
374: * based on the context.
375: *
376: * @param c the context id to set.
377: */
378: public void setContext(int c) {
379: //NOTE: Put context specific link code here.
380: switch (c) {
381: case ALL_CLASSES_FRAME:
382: case PACKAGE_FRAME:
383: case CONTEXT_IMPLEMENTED_CLASSES:
384: case CONTEXT_SUBCLASSES:
385: case CONTEXT_METHOD_DOC_COPY:
386: case CONTEXT_FIELD_DOC_COPY:
387: case CONTEXT_CLASS_USE_HEADER:
388: includeTypeInClassLinkLabel = false;
389: break;
390:
391: case CONTEXT_ANNOTATION:
392: excludeTypeParameterLinks = true;
393: excludeTypeBounds = true;
394: break;
395:
396: case CONTEXT_IMPLEMENTED_INTERFACES:
397: case CONTEXT_SUPER_INTERFACES:
398: case CONTEXT_SUBINTERFACES:
399: case CONTEXT_CLASS_TREE_PARENT:
400: case CONTEXT_TREE:
401: case CONTEXT_CLASS_SIGNATURE_PARENT_NAME:
402: excludeTypeParameterLinks = true;
403: excludeTypeBounds = true;
404: includeTypeInClassLinkLabel = false;
405: includeTypeAsSepLink = true;
406: break;
407:
408: case CONTEXT_PACKAGE:
409: case CONTEXT_CLASS_USE:
410: excludeTypeBoundsLinks = true;
411: excludeTypeParameterLinks = true;
412: break;
413:
414: case CONTEXT_CLASS_HEADER:
415: case CONTEXT_CLASS_SIGNATURE:
416: excludeTypeParameterLinks = true;
417: includeTypeAsSepLink = true;
418: includeTypeInClassLinkLabel = false;
419: break;
420:
421: case CONTEXT_MEMBER_TYPE_PARAMS:
422: includeTypeAsSepLink = true;
423: includeTypeInClassLinkLabel = false;
424: break;
425:
426: case CONTEXT_RETURN_TYPE:
427: case CONTEXT_SUMMARY_RETURN_TYPE:
428: case CONTEXT_EXECUTABLE_MEMBER_PARAM:
429: excludeTypeBounds = true;
430: break;
431: }
432: context = c;
433: if (type != null
434: && type.asTypeVariable() != null
435: && type.asTypeVariable().owner() instanceof ExecutableMemberDoc) {
436: excludeTypeParameterLinks = true;
437: }
438: }
439:
440: /**
441: * Return true if this link is linkable and false if we can't link to the
442: * desired place.
443: *
444: * @return true if this link is linkable and false if we can't link to the
445: * desired place.
446: */
447: public boolean isLinkable() {
448: return Util.isLinkable(classDoc, ConfigurationImpl
449: .getInstance());
450: }
451: }
|