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

Sun, 24 Feb 2013 11:36:58 -0800

author
jjg
date
Sun, 24 Feb 2013 11:36:58 -0800
changeset 1606
ccbe7ffdd867
parent 1521
71f35e4b93a5
child 1735
8ea30d59ac41
permissions
-rw-r--r--

7112427: The doclet needs to be able to generate JavaFX documentation.
Reviewed-by: jjg
Contributed-by: jan.valenta@oracle.com

duke@1 1 /*
jjg@1521 2 * Copyright (c) 2003, 2013, 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
jjg@1359 33 /**
jjg@1359 34 * <p><b>This is NOT part of any supported API.
jjg@1359 35 * If you write code that depends on this, you do so at your own risk.
jjg@1359 36 * This code and its internal interfaces are subject to change or
jjg@1359 37 * deletion without notice.</b>
jjg@1359 38 */
duke@1 39 public class LinkInfoImpl extends LinkInfo {
duke@1 40
duke@1 41 /**
duke@1 42 * Indicate that the link appears in a class list.
duke@1 43 */
duke@1 44 public static final int ALL_CLASSES_FRAME = 1;
duke@1 45
duke@1 46 /**
duke@1 47 * Indicate that the link appears in a class documentation.
duke@1 48 */
duke@1 49 public static final int CONTEXT_CLASS = 2;
duke@1 50
duke@1 51 /**
duke@1 52 * Indicate that the link appears in member documentation.
duke@1 53 */
duke@1 54 public static final int CONTEXT_MEMBER = 3;
duke@1 55
duke@1 56 /**
duke@1 57 * Indicate that the link appears in class use documentation.
duke@1 58 */
duke@1 59 public static final int CONTEXT_CLASS_USE = 4;
duke@1 60
duke@1 61 /**
duke@1 62 * Indicate that the link appears in index documentation.
duke@1 63 */
duke@1 64 public static final int CONTEXT_INDEX = 5;
duke@1 65
duke@1 66 /**
duke@1 67 * Indicate that the link appears in constant value summary.
duke@1 68 */
duke@1 69 public static final int CONTEXT_CONSTANT_SUMMARY = 6;
duke@1 70
duke@1 71 /**
duke@1 72 * Indicate that the link appears in serialized form documentation.
duke@1 73 */
duke@1 74 public static final int CONTEXT_SERIALIZED_FORM = 7;
duke@1 75
duke@1 76 /**
duke@1 77 * Indicate that the link appears in serial member documentation.
duke@1 78 */
duke@1 79 public static final int CONTEXT_SERIAL_MEMBER = 8;
duke@1 80
duke@1 81 /**
duke@1 82 * Indicate that the link appears in package documentation.
duke@1 83 */
duke@1 84 public static final int CONTEXT_PACKAGE = 9;
duke@1 85
duke@1 86 /**
duke@1 87 * Indicate that the link appears in see tag documentation.
duke@1 88 */
duke@1 89 public static final int CONTEXT_SEE_TAG = 10;
duke@1 90
duke@1 91 /**
duke@1 92 * Indicate that the link appears in value tag documentation.
duke@1 93 */
duke@1 94 public static final int CONTEXT_VALUE_TAG = 11;
duke@1 95
duke@1 96 /**
duke@1 97 * Indicate that the link appears in tree documentation.
duke@1 98 */
duke@1 99 public static final int CONTEXT_TREE = 12;
duke@1 100
duke@1 101 /**
duke@1 102 * Indicate that the link appears in a class list.
duke@1 103 */
duke@1 104 public static final int PACKAGE_FRAME = 13;
duke@1 105
duke@1 106 /**
duke@1 107 * The header in the class documentation.
duke@1 108 */
duke@1 109 public static final int CONTEXT_CLASS_HEADER = 14;
duke@1 110
duke@1 111 /**
duke@1 112 * The signature in the class documentation.
duke@1 113 */
duke@1 114 public static final int CONTEXT_CLASS_SIGNATURE = 15;
duke@1 115
duke@1 116 /**
duke@1 117 * The return type of a method.
duke@1 118 */
duke@1 119 public static final int CONTEXT_RETURN_TYPE = 16;
duke@1 120
duke@1 121 /**
duke@1 122 * The return type of a method in a member summary.
duke@1 123 */
duke@1 124 public static final int CONTEXT_SUMMARY_RETURN_TYPE = 17;
duke@1 125
duke@1 126 /**
duke@1 127 * The type of a method/constructor parameter.
duke@1 128 */
duke@1 129 public static final int CONTEXT_EXECUTABLE_MEMBER_PARAM = 18;
duke@1 130
duke@1 131 /**
duke@1 132 * Super interface links.
duke@1 133 */
duke@1 134 public static final int CONTEXT_SUPER_INTERFACES = 19;
duke@1 135
duke@1 136 /**
duke@1 137 * Implemented interface links.
duke@1 138 */
duke@1 139 public static final int CONTEXT_IMPLEMENTED_INTERFACES = 20;
duke@1 140
duke@1 141 /**
duke@1 142 * Implemented class links.
duke@1 143 */
duke@1 144 public static final int CONTEXT_IMPLEMENTED_CLASSES = 21;
duke@1 145
duke@1 146 /**
duke@1 147 * Subinterface links.
duke@1 148 */
duke@1 149 public static final int CONTEXT_SUBINTERFACES = 22;
duke@1 150
duke@1 151 /**
duke@1 152 * Subclasses links.
duke@1 153 */
duke@1 154 public static final int CONTEXT_SUBCLASSES = 23;
duke@1 155
duke@1 156 /**
duke@1 157 * The signature in the class documentation (implements/extends portion).
duke@1 158 */
duke@1 159 public static final int CONTEXT_CLASS_SIGNATURE_PARENT_NAME = 24;
duke@1 160
duke@1 161 /**
duke@1 162 * The header for method documentation copied from parent.
duke@1 163 */
duke@1 164 public static final int CONTEXT_METHOD_DOC_COPY = 26;
duke@1 165
duke@1 166 /**
duke@1 167 * Method "specified by" link.
duke@1 168 */
duke@1 169 public static final int CONTEXT_METHOD_SPECIFIED_BY = 27;
duke@1 170
duke@1 171 /**
duke@1 172 * Method "overrides" link.
duke@1 173 */
duke@1 174 public static final int CONTEXT_METHOD_OVERRIDES = 28;
duke@1 175
duke@1 176 /**
duke@1 177 * Annotation link.
duke@1 178 */
duke@1 179 public static final int CONTEXT_ANNOTATION = 29;
duke@1 180
duke@1 181 /**
duke@1 182 * The header for field documentation copied from parent.
duke@1 183 */
duke@1 184 public static final int CONTEXT_FIELD_DOC_COPY = 30;
duke@1 185
duke@1 186 /**
duke@1 187 * The parent nodes int the class tree.
duke@1 188 */
duke@1 189 public static final int CONTEXT_CLASS_TREE_PARENT = 31;
duke@1 190
duke@1 191 /**
duke@1 192 * The type parameters of a method or constructor.
duke@1 193 */
duke@1 194 public static final int CONTEXT_MEMBER_TYPE_PARAMS = 32;
duke@1 195
duke@1 196 /**
duke@1 197 * Indicate that the link appears in class use documentation.
duke@1 198 */
duke@1 199 public static final int CONTEXT_CLASS_USE_HEADER = 33;
duke@1 200
jjg@1606 201 /**
jjg@1606 202 * The header for property documentation copied from parent.
jjg@1606 203 */
jjg@1606 204 public static final int CONTEXT_PROPERTY_DOC_COPY = 34;
jjg@1606 205
jjg@1410 206 public final ConfigurationImpl configuration;
jjg@1410 207
duke@1 208 /**
duke@1 209 * The integer indicating the location of the link.
duke@1 210 */
duke@1 211 public int context;
duke@1 212
duke@1 213 /**
duke@1 214 * The value of the marker #.
duke@1 215 */
duke@1 216 public String where = "";
duke@1 217
duke@1 218 /**
duke@1 219 * String style of text defined in style sheet.
duke@1 220 */
duke@1 221 public String styleName ="";
duke@1 222
duke@1 223 /**
jjg@1410 224 * The value of the target.
duke@1 225 */
duke@1 226 public String target = "";
duke@1 227
duke@1 228 /**
duke@1 229 * Construct a LinkInfo object.
duke@1 230 *
jjg@1410 231 * @param configuration the configuration data for the doclet
duke@1 232 * @param context the context of the link.
duke@1 233 * @param classDoc the class to link to.
duke@1 234 * @param label the label for the link.
duke@1 235 * @param target the value of the target attribute.
duke@1 236 */
jjg@1410 237 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 238 int context, ClassDoc classDoc, String label, String target) {
jjg@1410 239 this.configuration = configuration;
duke@1 240 this.classDoc = classDoc;
duke@1 241 this.label = label;
duke@1 242 this.target = target;
duke@1 243 setContext(context);
duke@1 244 }
duke@1 245
duke@1 246 /**
duke@1 247 * Construct a LinkInfo object.
duke@1 248 *
jjg@1410 249 * @param configuration the configuration data for the doclet
duke@1 250 * @param context the context of the link.
duke@1 251 * @param classDoc the class to link to.
duke@1 252 * @param where the value of the marker #.
duke@1 253 * @param label the label for the link.
bpatel@182 254 * @param isStrong true if the link should be strong.
duke@1 255 * @param styleName String style of text defined in style sheet.
duke@1 256 */
jjg@1410 257 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 258 int context, ClassDoc classDoc, String where, String label,
jjg@1410 259 boolean isStrong, String styleName) {
jjg@1410 260 this.configuration = configuration;
duke@1 261 this.classDoc = classDoc;
duke@1 262 this.where = where;
duke@1 263 this.label = label;
bpatel@182 264 this.isStrong = isStrong;
duke@1 265 this.styleName = styleName;
duke@1 266 setContext(context);
duke@1 267 }
duke@1 268
duke@1 269 /**
duke@1 270 * Construct a LinkInfo object.
duke@1 271 *
jjg@1410 272 * @param configuration the configuration data for the doclet
duke@1 273 * @param context the context of the link.
duke@1 274 * @param classDoc the class to link to.
duke@1 275 * @param where the value of the marker #.
duke@1 276 * @param label the label for the link.
bpatel@182 277 * @param isStrong true if the link should be strong.
duke@1 278 */
jjg@1410 279 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 280 int context, ClassDoc classDoc, String where, String label,
jjg@1410 281 boolean isStrong) {
jjg@1410 282 this.configuration = configuration;
duke@1 283 this.classDoc = classDoc;
duke@1 284 this.where = where;
duke@1 285 this.label = label;
bpatel@182 286 this.isStrong = isStrong;
duke@1 287 setContext(context);
duke@1 288 }
duke@1 289
duke@1 290 /**
duke@1 291 * Construct a LinkInfo object.
duke@1 292 *
jjg@1410 293 * @param configuration the configuration data for the doclet
duke@1 294 * @param classDoc the class to link to.
duke@1 295 * @param label the label for the link.
duke@1 296 */
jjg@1410 297 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 298 ClassDoc classDoc, String label) {
jjg@1410 299 this.configuration = configuration;
duke@1 300 this.classDoc = classDoc;
duke@1 301 this.label = label;
duke@1 302 setContext(context);
duke@1 303 }
duke@1 304
duke@1 305 /**
duke@1 306 * Construct a LinkInfo object.
duke@1 307 *
jjg@1410 308 * @param configuration the configuration data for the doclet
duke@1 309 * @param context the context of the link.
duke@1 310 * @param executableMemberDoc the member to link to.
bpatel@182 311 * @param isStrong true if the link should be strong.
duke@1 312 */
jjg@1410 313 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 314 int context, ExecutableMemberDoc executableMemberDoc,
jjg@1410 315 boolean isStrong) {
jjg@1410 316 this.configuration = configuration;
duke@1 317 this.executableMemberDoc = executableMemberDoc;
bpatel@182 318 this.isStrong = isStrong;
duke@1 319 setContext(context);
duke@1 320 }
duke@1 321
duke@1 322 /**
duke@1 323 * Construct a LinkInfo object.
duke@1 324 *
jjg@1410 325 * @param configuration the configuration data for the doclet
duke@1 326 * @param context the context of the link.
duke@1 327 * @param classDoc the class to link to.
bpatel@182 328 * @param isStrong true if the link should be strong.
duke@1 329 */
jjg@1410 330 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 331 int context, ClassDoc classDoc, boolean isStrong) {
jjg@1410 332 this.configuration = configuration;
duke@1 333 this.classDoc = classDoc;
bpatel@182 334 this.isStrong = isStrong;
duke@1 335 setContext(context);
duke@1 336 }
duke@1 337
duke@1 338 /**
duke@1 339 * Construct a LinkInfo object.
duke@1 340 *
jjg@1410 341 * @param configuration the configuration data for the doclet
duke@1 342 * @param context the context of the link.
duke@1 343 * @param type the class to link to.
duke@1 344 */
jjg@1410 345 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 346 int context, Type type) {
jjg@1410 347 this.configuration = configuration;
duke@1 348 this.type = type;
duke@1 349 setContext(context);
duke@1 350 }
duke@1 351
duke@1 352 /**
duke@1 353 * Construct a LinkInfo object.
duke@1 354 *
jjg@1410 355 * @param configuration the configuration data for the doclet
duke@1 356 * @param context the context of the link.
duke@1 357 * @param type the class to link to.
duke@1 358 * @param isVarArg true if this is a link to a var arg.
duke@1 359 */
jjg@1410 360 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 361 int context, Type type, boolean isVarArg) {
jjg@1410 362 this.configuration = configuration;
duke@1 363 this.type = type;
duke@1 364 this.isVarArg = isVarArg;
duke@1 365 setContext(context);
duke@1 366 }
duke@1 367
duke@1 368 /**
duke@1 369 * Construct a LinkInfo object.
duke@1 370 *
jjg@1410 371 * @param configuration the configuration data for the doclet
duke@1 372 * @param context the context of the link.
duke@1 373 * @param type the class to link to.
duke@1 374 * @param label the label for the link.
bpatel@182 375 * @param isStrong true if the link should be strong.
duke@1 376 */
jjg@1410 377 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 378 int context, Type type, String label,
jjg@1410 379 boolean isStrong) {
jjg@1410 380 this.configuration = configuration;
duke@1 381 this.type = type;
duke@1 382 this.label = label;
bpatel@182 383 this.isStrong = isStrong;
duke@1 384 setContext(context);
duke@1 385 }
duke@1 386
duke@1 387 /**
duke@1 388 * Construct a LinkInfo object.
duke@1 389 *
jjg@1410 390 * @param configuration the configuration data for the doclet
duke@1 391 * @param context the context of the link.
duke@1 392 * @param classDoc the class to link to.
duke@1 393 * @param label the label for the link.
bpatel@182 394 * @param isStrong true if the link should be strong.
duke@1 395 */
jjg@1410 396 public LinkInfoImpl(ConfigurationImpl configuration,
jjg@1410 397 int context, ClassDoc classDoc, String label,
jjg@1410 398 boolean isStrong) {
jjg@1410 399 this.configuration = configuration;
duke@1 400 this.classDoc = classDoc;
duke@1 401 this.label = label;
bpatel@182 402 this.isStrong = isStrong;
duke@1 403 setContext(context);
duke@1 404 }
duke@1 405
duke@1 406 /**
duke@1 407 * {@inheritDoc}
duke@1 408 */
duke@1 409 public int getContext() {
duke@1 410 return context;
duke@1 411 }
duke@1 412
duke@1 413 /**
duke@1 414 * {@inheritDoc}
duke@1 415 *
duke@1 416 * This method sets the link attributes to the appropriate values
duke@1 417 * based on the context.
duke@1 418 *
duke@1 419 * @param c the context id to set.
duke@1 420 */
duke@1 421 public void setContext(int c) {
duke@1 422 //NOTE: Put context specific link code here.
duke@1 423 switch (c) {
duke@1 424 case ALL_CLASSES_FRAME:
duke@1 425 case PACKAGE_FRAME:
duke@1 426 case CONTEXT_IMPLEMENTED_CLASSES:
duke@1 427 case CONTEXT_SUBCLASSES:
duke@1 428 case CONTEXT_METHOD_DOC_COPY:
duke@1 429 case CONTEXT_FIELD_DOC_COPY:
jjg@1606 430 case CONTEXT_PROPERTY_DOC_COPY:
duke@1 431 case CONTEXT_CLASS_USE_HEADER:
duke@1 432 includeTypeInClassLinkLabel = false;
duke@1 433 break;
duke@1 434
duke@1 435 case CONTEXT_ANNOTATION:
duke@1 436 excludeTypeParameterLinks = true;
duke@1 437 excludeTypeBounds = true;
duke@1 438 break;
duke@1 439
duke@1 440 case CONTEXT_IMPLEMENTED_INTERFACES:
duke@1 441 case CONTEXT_SUPER_INTERFACES:
duke@1 442 case CONTEXT_SUBINTERFACES:
duke@1 443 case CONTEXT_CLASS_TREE_PARENT:
duke@1 444 case CONTEXT_TREE:
duke@1 445 case CONTEXT_CLASS_SIGNATURE_PARENT_NAME:
duke@1 446 excludeTypeParameterLinks = true;
duke@1 447 excludeTypeBounds = true;
duke@1 448 includeTypeInClassLinkLabel = false;
duke@1 449 includeTypeAsSepLink = true;
duke@1 450 break;
duke@1 451
duke@1 452 case CONTEXT_PACKAGE:
duke@1 453 case CONTEXT_CLASS_USE:
duke@1 454 case CONTEXT_CLASS_HEADER:
duke@1 455 case CONTEXT_CLASS_SIGNATURE:
duke@1 456 excludeTypeParameterLinks = true;
duke@1 457 includeTypeAsSepLink = true;
duke@1 458 includeTypeInClassLinkLabel = false;
duke@1 459 break;
duke@1 460
duke@1 461 case CONTEXT_MEMBER_TYPE_PARAMS:
duke@1 462 includeTypeAsSepLink = true;
duke@1 463 includeTypeInClassLinkLabel = false;
duke@1 464 break;
duke@1 465
duke@1 466 case CONTEXT_RETURN_TYPE:
duke@1 467 case CONTEXT_SUMMARY_RETURN_TYPE:
jjg@1521 468 excludeTypeBounds = true;
jjg@1521 469 break;
duke@1 470 case CONTEXT_EXECUTABLE_MEMBER_PARAM:
duke@1 471 excludeTypeBounds = true;
duke@1 472 break;
duke@1 473 }
duke@1 474 context = c;
duke@1 475 if (type != null &&
duke@1 476 type.asTypeVariable()!= null &&
duke@1 477 type.asTypeVariable().owner() instanceof ExecutableMemberDoc){
duke@1 478 excludeTypeParameterLinks = true;
duke@1 479 }
duke@1 480 }
duke@1 481
duke@1 482 /**
duke@1 483 * Return true if this link is linkable and false if we can't link to the
duke@1 484 * desired place.
duke@1 485 *
duke@1 486 * @return true if this link is linkable and false if we can't link to the
duke@1 487 * desired place.
duke@1 488 */
duke@1 489 public boolean isLinkable() {
jjg@1410 490 return Util.isLinkable(classDoc, configuration);
duke@1 491 }
duke@1 492 }

mercurial