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

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 1738
6ea964c78845
parent 0
959103a6100f
permissions
-rw-r--r--

merge

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

mercurial