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