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

Tue, 24 Dec 2013 09:17:37 -0800

author
ksrini
date
Tue, 24 Dec 2013 09:17:37 -0800
changeset 2227
998b10c43157
parent 1738
6ea964c78845
child 2525
2eb010b6cb22
permissions
-rw-r--r--

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

mercurial