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

Tue, 25 May 2010 15:54:51 -0700

author
ohair
date
Tue, 25 May 2010 15:54:51 -0700
changeset 554
9d9f26857129
parent 182
47a62d8d98b4
child 958
734144b6b22f
permissions
-rw-r--r--

6943119: Rebrand source copyright notices
Reviewed-by: darcy

duke@1 1 /*
ohair@554 2 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26
duke@1 27 package com.sun.tools.doclets.formats.html;
duke@1 28
duke@1 29 import com.sun.javadoc.*;
duke@1 30 import com.sun.tools.doclets.internal.toolkit.util.*;
duke@1 31 import com.sun.tools.doclets.internal.toolkit.util.links.*;
duke@1 32
duke@1 33 public class LinkInfoImpl extends LinkInfo {
duke@1 34
duke@1 35 /**
duke@1 36 * Indicate that the link appears in a class list.
duke@1 37 */
duke@1 38 public static final int ALL_CLASSES_FRAME = 1;
duke@1 39
duke@1 40 /**
duke@1 41 * Indicate that the link appears in a class documentation.
duke@1 42 */
duke@1 43 public static final int CONTEXT_CLASS = 2;
duke@1 44
duke@1 45 /**
duke@1 46 * Indicate that the link appears in member documentation.
duke@1 47 */
duke@1 48 public static final int CONTEXT_MEMBER = 3;
duke@1 49
duke@1 50 /**
duke@1 51 * Indicate that the link appears in class use documentation.
duke@1 52 */
duke@1 53 public static final int CONTEXT_CLASS_USE = 4;
duke@1 54
duke@1 55 /**
duke@1 56 * Indicate that the link appears in index documentation.
duke@1 57 */
duke@1 58 public static final int CONTEXT_INDEX = 5;
duke@1 59
duke@1 60 /**
duke@1 61 * Indicate that the link appears in constant value summary.
duke@1 62 */
duke@1 63 public static final int CONTEXT_CONSTANT_SUMMARY = 6;
duke@1 64
duke@1 65 /**
duke@1 66 * Indicate that the link appears in serialized form documentation.
duke@1 67 */
duke@1 68 public static final int CONTEXT_SERIALIZED_FORM = 7;
duke@1 69
duke@1 70 /**
duke@1 71 * Indicate that the link appears in serial member documentation.
duke@1 72 */
duke@1 73 public static final int CONTEXT_SERIAL_MEMBER = 8;
duke@1 74
duke@1 75 /**
duke@1 76 * Indicate that the link appears in package documentation.
duke@1 77 */
duke@1 78 public static final int CONTEXT_PACKAGE = 9;
duke@1 79
duke@1 80 /**
duke@1 81 * Indicate that the link appears in see tag documentation.
duke@1 82 */
duke@1 83 public static final int CONTEXT_SEE_TAG = 10;
duke@1 84
duke@1 85 /**
duke@1 86 * Indicate that the link appears in value tag documentation.
duke@1 87 */
duke@1 88 public static final int CONTEXT_VALUE_TAG = 11;
duke@1 89
duke@1 90 /**
duke@1 91 * Indicate that the link appears in tree documentation.
duke@1 92 */
duke@1 93 public static final int CONTEXT_TREE = 12;
duke@1 94
duke@1 95 /**
duke@1 96 * Indicate that the link appears in a class list.
duke@1 97 */
duke@1 98 public static final int PACKAGE_FRAME = 13;
duke@1 99
duke@1 100 /**
duke@1 101 * The header in the class documentation.
duke@1 102 */
duke@1 103 public static final int CONTEXT_CLASS_HEADER = 14;
duke@1 104
duke@1 105 /**
duke@1 106 * The signature in the class documentation.
duke@1 107 */
duke@1 108 public static final int CONTEXT_CLASS_SIGNATURE = 15;
duke@1 109
duke@1 110 /**
duke@1 111 * The return type of a method.
duke@1 112 */
duke@1 113 public static final int CONTEXT_RETURN_TYPE = 16;
duke@1 114
duke@1 115 /**
duke@1 116 * The return type of a method in a member summary.
duke@1 117 */
duke@1 118 public static final int CONTEXT_SUMMARY_RETURN_TYPE = 17;
duke@1 119
duke@1 120 /**
duke@1 121 * The type of a method/constructor parameter.
duke@1 122 */
duke@1 123 public static final int CONTEXT_EXECUTABLE_MEMBER_PARAM = 18;
duke@1 124
duke@1 125 /**
duke@1 126 * Super interface links.
duke@1 127 */
duke@1 128 public static final int CONTEXT_SUPER_INTERFACES = 19;
duke@1 129
duke@1 130 /**
duke@1 131 * Implemented interface links.
duke@1 132 */
duke@1 133 public static final int CONTEXT_IMPLEMENTED_INTERFACES = 20;
duke@1 134
duke@1 135 /**
duke@1 136 * Implemented class links.
duke@1 137 */
duke@1 138 public static final int CONTEXT_IMPLEMENTED_CLASSES = 21;
duke@1 139
duke@1 140 /**
duke@1 141 * Subinterface links.
duke@1 142 */
duke@1 143 public static final int CONTEXT_SUBINTERFACES = 22;
duke@1 144
duke@1 145 /**
duke@1 146 * Subclasses links.
duke@1 147 */
duke@1 148 public static final int CONTEXT_SUBCLASSES = 23;
duke@1 149
duke@1 150 /**
duke@1 151 * The signature in the class documentation (implements/extends portion).
duke@1 152 */
duke@1 153 public static final int CONTEXT_CLASS_SIGNATURE_PARENT_NAME = 24;
duke@1 154
duke@1 155 /**
duke@1 156 * The header for method documentation copied from parent.
duke@1 157 */
duke@1 158 public static final int CONTEXT_METHOD_DOC_COPY = 26;
duke@1 159
duke@1 160 /**
duke@1 161 * Method "specified by" link.
duke@1 162 */
duke@1 163 public static final int CONTEXT_METHOD_SPECIFIED_BY = 27;
duke@1 164
duke@1 165 /**
duke@1 166 * Method "overrides" link.
duke@1 167 */
duke@1 168 public static final int CONTEXT_METHOD_OVERRIDES = 28;
duke@1 169
duke@1 170 /**
duke@1 171 * Annotation link.
duke@1 172 */
duke@1 173 public static final int CONTEXT_ANNOTATION = 29;
duke@1 174
duke@1 175 /**
duke@1 176 * The header for field documentation copied from parent.
duke@1 177 */
duke@1 178 public static final int CONTEXT_FIELD_DOC_COPY = 30;
duke@1 179
duke@1 180 /**
duke@1 181 * The parent nodes int the class tree.
duke@1 182 */
duke@1 183 public static final int CONTEXT_CLASS_TREE_PARENT = 31;
duke@1 184
duke@1 185 /**
duke@1 186 * The type parameters of a method or constructor.
duke@1 187 */
duke@1 188 public static final int CONTEXT_MEMBER_TYPE_PARAMS = 32;
duke@1 189
duke@1 190 /**
duke@1 191 * Indicate that the link appears in class use documentation.
duke@1 192 */
duke@1 193 public static final int CONTEXT_CLASS_USE_HEADER = 33;
duke@1 194
duke@1 195 /**
duke@1 196 * The integer indicating the location of the link.
duke@1 197 */
duke@1 198 public int context;
duke@1 199
duke@1 200 /**
duke@1 201 * The value of the marker #.
duke@1 202 */
duke@1 203 public String where = "";
duke@1 204
duke@1 205 /**
duke@1 206 * String style of text defined in style sheet.
duke@1 207 */
duke@1 208 public String styleName ="";
duke@1 209
duke@1 210 /**
duke@1 211 * The valueof the target.
duke@1 212 */
duke@1 213 public String target = "";
duke@1 214
duke@1 215 /**
duke@1 216 * Construct a LinkInfo object.
duke@1 217 *
duke@1 218 * @param context the context of the link.
duke@1 219 * @param classDoc the class to link to.
duke@1 220 * @param label the label for the link.
duke@1 221 * @param target the value of the target attribute.
duke@1 222 */
duke@1 223 public LinkInfoImpl (int context, ClassDoc classDoc, String label,
duke@1 224 String target){
duke@1 225 this.classDoc = classDoc;
duke@1 226 this.label = label;
duke@1 227 this.target = target;
duke@1 228 setContext(context);
duke@1 229 }
duke@1 230
duke@1 231 /**
duke@1 232 * Construct a LinkInfo object.
duke@1 233 *
duke@1 234 * @param context the context of the link.
duke@1 235 * @param classDoc the class to link to.
duke@1 236 * @param where the value of the marker #.
duke@1 237 * @param label the label for the link.
bpatel@182 238 * @param isStrong true if the link should be strong.
duke@1 239 * @param styleName String style of text defined in style sheet.
duke@1 240 */
duke@1 241 public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
bpatel@182 242 boolean isStrong, String styleName){
duke@1 243 this.classDoc = classDoc;
duke@1 244 this.where = where;
duke@1 245 this.label = label;
bpatel@182 246 this.isStrong = isStrong;
duke@1 247 this.styleName = styleName;
duke@1 248 setContext(context);
duke@1 249 }
duke@1 250
duke@1 251 /**
duke@1 252 * Construct a LinkInfo object.
duke@1 253 *
duke@1 254 * @param context the context of the link.
duke@1 255 * @param classDoc the class to link to.
duke@1 256 * @param where the value of the marker #.
duke@1 257 * @param label the label for the link.
bpatel@182 258 * @param isStrong true if the link should be strong.
duke@1 259 */
duke@1 260 public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
bpatel@182 261 boolean isStrong){
duke@1 262 this.classDoc = classDoc;
duke@1 263 this.where = where;
duke@1 264 this.label = label;
bpatel@182 265 this.isStrong = isStrong;
duke@1 266 setContext(context);
duke@1 267 }
duke@1 268
duke@1 269 /**
duke@1 270 * Construct a LinkInfo object.
duke@1 271 *
duke@1 272 * @param classDoc the class to link to.
duke@1 273 * @param label the label for the link.
duke@1 274 */
duke@1 275 public LinkInfoImpl (ClassDoc classDoc, String label){
duke@1 276 this.classDoc = classDoc;
duke@1 277 this.label = label;
duke@1 278 setContext(context);
duke@1 279 }
duke@1 280
duke@1 281 /**
duke@1 282 * Construct a LinkInfo object.
duke@1 283 *
duke@1 284 * @param context the context of the link.
duke@1 285 * @param executableMemberDoc the member to link to.
bpatel@182 286 * @param isStrong true if the link should be strong.
duke@1 287 */
duke@1 288 public LinkInfoImpl (int context, ExecutableMemberDoc executableMemberDoc,
bpatel@182 289 boolean isStrong){
duke@1 290 this.executableMemberDoc = executableMemberDoc;
bpatel@182 291 this.isStrong = isStrong;
duke@1 292 setContext(context);
duke@1 293 }
duke@1 294
duke@1 295 /**
duke@1 296 * Construct a LinkInfo object.
duke@1 297 *
duke@1 298 * @param context the context of the link.
duke@1 299 * @param classDoc the class to link to.
bpatel@182 300 * @param isStrong true if the link should be strong.
duke@1 301 */
bpatel@182 302 public LinkInfoImpl (int context, ClassDoc classDoc, boolean isStrong){
duke@1 303 this.classDoc = classDoc;
bpatel@182 304 this.isStrong = isStrong;
duke@1 305 setContext(context);
duke@1 306 }
duke@1 307
duke@1 308 /**
duke@1 309 * Construct a LinkInfo object.
duke@1 310 *
duke@1 311 * @param context the context of the link.
duke@1 312 * @param type the class to link to.
duke@1 313 */
duke@1 314 public LinkInfoImpl (int context, Type type){
duke@1 315 this.type = type;
duke@1 316 setContext(context);
duke@1 317 }
duke@1 318
duke@1 319 /**
duke@1 320 * Construct a LinkInfo object.
duke@1 321 *
duke@1 322 * @param context the context of the link.
duke@1 323 * @param type the class to link to.
duke@1 324 * @param isVarArg true if this is a link to a var arg.
duke@1 325 */
duke@1 326 public LinkInfoImpl (int context, Type type, boolean isVarArg){
duke@1 327 this.type = type;
duke@1 328 this.isVarArg = isVarArg;
duke@1 329 setContext(context);
duke@1 330 }
duke@1 331
duke@1 332 /**
duke@1 333 * Construct a LinkInfo object.
duke@1 334 *
duke@1 335 * @param context the context of the link.
duke@1 336 * @param type the class to link to.
duke@1 337 * @param label the label for the link.
bpatel@182 338 * @param isStrong true if the link should be strong.
duke@1 339 */
duke@1 340 public LinkInfoImpl (int context, Type type, String label,
bpatel@182 341 boolean isStrong){
duke@1 342 this.type = type;
duke@1 343 this.label = label;
bpatel@182 344 this.isStrong = isStrong;
duke@1 345 setContext(context);
duke@1 346 }
duke@1 347
duke@1 348 /**
duke@1 349 * Construct a LinkInfo object.
duke@1 350 *
duke@1 351 * @param context the context of the link.
duke@1 352 * @param classDoc the class to link to.
duke@1 353 * @param label the label for the link.
bpatel@182 354 * @param isStrong true if the link should be strong.
duke@1 355 */
duke@1 356 public LinkInfoImpl (int context, ClassDoc classDoc, String label,
bpatel@182 357 boolean isStrong){
duke@1 358 this.classDoc = classDoc;
duke@1 359 this.label = label;
bpatel@182 360 this.isStrong = isStrong;
duke@1 361 setContext(context);
duke@1 362 }
duke@1 363
duke@1 364 /**
duke@1 365 * {@inheritDoc}
duke@1 366 */
duke@1 367 public int getContext() {
duke@1 368 return context;
duke@1 369 }
duke@1 370
duke@1 371 /**
duke@1 372 * {@inheritDoc}
duke@1 373 *
duke@1 374 * This method sets the link attributes to the appropriate values
duke@1 375 * based on the context.
duke@1 376 *
duke@1 377 * @param c the context id to set.
duke@1 378 */
duke@1 379 public void setContext(int c) {
duke@1 380 //NOTE: Put context specific link code here.
duke@1 381 switch (c) {
duke@1 382 case ALL_CLASSES_FRAME:
duke@1 383 case PACKAGE_FRAME:
duke@1 384 case CONTEXT_IMPLEMENTED_CLASSES:
duke@1 385 case CONTEXT_SUBCLASSES:
duke@1 386 case CONTEXT_METHOD_DOC_COPY:
duke@1 387 case CONTEXT_FIELD_DOC_COPY:
duke@1 388 case CONTEXT_CLASS_USE_HEADER:
duke@1 389 includeTypeInClassLinkLabel = false;
duke@1 390 break;
duke@1 391
duke@1 392 case CONTEXT_ANNOTATION:
duke@1 393 excludeTypeParameterLinks = true;
duke@1 394 excludeTypeBounds = true;
duke@1 395 break;
duke@1 396
duke@1 397 case CONTEXT_IMPLEMENTED_INTERFACES:
duke@1 398 case CONTEXT_SUPER_INTERFACES:
duke@1 399 case CONTEXT_SUBINTERFACES:
duke@1 400 case CONTEXT_CLASS_TREE_PARENT:
duke@1 401 case CONTEXT_TREE:
duke@1 402 case CONTEXT_CLASS_SIGNATURE_PARENT_NAME:
duke@1 403 excludeTypeParameterLinks = true;
duke@1 404 excludeTypeBounds = true;
duke@1 405 includeTypeInClassLinkLabel = false;
duke@1 406 includeTypeAsSepLink = true;
duke@1 407 break;
duke@1 408
duke@1 409 case CONTEXT_PACKAGE:
duke@1 410 case CONTEXT_CLASS_USE:
duke@1 411 excludeTypeBoundsLinks = true;
duke@1 412 excludeTypeParameterLinks = true;
duke@1 413 break;
duke@1 414
duke@1 415 case CONTEXT_CLASS_HEADER:
duke@1 416 case CONTEXT_CLASS_SIGNATURE:
duke@1 417 excludeTypeParameterLinks = true;
duke@1 418 includeTypeAsSepLink = true;
duke@1 419 includeTypeInClassLinkLabel = false;
duke@1 420 break;
duke@1 421
duke@1 422 case CONTEXT_MEMBER_TYPE_PARAMS:
duke@1 423 includeTypeAsSepLink = true;
duke@1 424 includeTypeInClassLinkLabel = false;
duke@1 425 break;
duke@1 426
duke@1 427 case CONTEXT_RETURN_TYPE:
duke@1 428 case CONTEXT_SUMMARY_RETURN_TYPE:
duke@1 429 case CONTEXT_EXECUTABLE_MEMBER_PARAM:
duke@1 430 excludeTypeBounds = true;
duke@1 431 break;
duke@1 432 }
duke@1 433 context = c;
duke@1 434 if (type != null &&
duke@1 435 type.asTypeVariable()!= null &&
duke@1 436 type.asTypeVariable().owner() instanceof ExecutableMemberDoc){
duke@1 437 excludeTypeParameterLinks = true;
duke@1 438 }
duke@1 439 }
duke@1 440
duke@1 441 /**
duke@1 442 * Return true if this link is linkable and false if we can't link to the
duke@1 443 * desired place.
duke@1 444 *
duke@1 445 * @return true if this link is linkable and false if we can't link to the
duke@1 446 * desired place.
duke@1 447 */
duke@1 448 public boolean isLinkable() {
duke@1 449 return Util.isLinkable(classDoc, ConfigurationImpl.getInstance());
duke@1 450 }
duke@1 451 }

mercurial