1 /* 2 * Copyright (c) 2003, 2013, 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 26 package com.sun.tools.doclets.internal.toolkit.util.links; 27 28 import com.sun.javadoc.*; 29 import com.sun.tools.doclets.internal.toolkit.Configuration; 30 import com.sun.tools.doclets.internal.toolkit.Content; 31 32 /** 33 * Encapsulates information about a link. 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 * @author Jamie Ho 41 * @since 1.5 42 */ 43 public abstract class LinkInfo { 44 45 /** 46 * The ClassDoc we want to link to. Null if we are not linking 47 * to a ClassDoc. 48 */ 49 public ClassDoc classDoc; 50 51 /** 52 * The executable member doc we want to link to. Null if we are not linking 53 * to an executable member. 54 */ 55 public ExecutableMemberDoc executableMemberDoc; 56 57 /** 58 * The Type we want to link to. Null if we are not linking to a type. 59 */ 60 public Type type; 61 62 /** 63 * True if this is a link to a VarArg. 64 */ 65 public boolean isVarArg = false; 66 67 /** 68 * Set this to true to indicate that you are linking to a type parameter. 69 */ 70 public boolean isTypeBound = false; 71 72 /** 73 * Whether the document element is in a Java 5 declaration 74 * location or not. 75 */ 76 public boolean isJava5DeclarationLocation = true; 77 78 /** 79 * The label for the link. 80 */ 81 public Content label; 82 83 /** 84 * True if the link should be strong. 85 */ 86 public boolean isStrong = false; 87 88 /** 89 * True if we should include the type in the link label. False otherwise. 90 */ 91 public boolean includeTypeInClassLinkLabel = true; 92 93 /** 94 * True if we should include the type as separate link. False otherwise. 95 */ 96 public boolean includeTypeAsSepLink = false; 97 98 /** 99 * True if we should exclude the type bounds for the type parameter. 100 */ 101 public boolean excludeTypeBounds = false; 102 103 /** 104 * True if we should print the type parameters, but not link them. 105 */ 106 public boolean excludeTypeParameterLinks = false; 107 108 /** 109 * True if we should print the type bounds, but not link them. 110 */ 111 public boolean excludeTypeBoundsLinks = false; 112 113 /** 114 * By default, the link can be to the page it's already on. However, 115 * there are cases where we don't want this (e.g. heading of class page). 116 */ 117 public boolean linkToSelf = true; 118 119 /** 120 * Return an empty instance of a content object. 121 * 122 * @return an empty instance of a content object. 123 */ 124 protected abstract Content newContent(); 125 126 /** 127 * Return true if this link is linkable and false if we can't link to the 128 * desired place. 129 * 130 * @return true if this link is linkable and false if we can't link to the 131 * desired place. 132 */ 133 public abstract boolean isLinkable(); 134 135 /** 136 * Return the label for this class link. 137 * 138 * @param configuration the current configuration of the doclet. 139 * @return the label for this class link. 140 */ 141 public Content getClassLinkLabel(Configuration configuration) { 142 if (label != null && !label.isEmpty()) { 143 return label; 144 } else if (isLinkable()) { 145 Content label = newContent(); 146 label.addContent(classDoc.name()); 147 return label; 148 } else { 149 Content label = newContent(); 150 label.addContent(configuration.getClassName(classDoc)); 151 return label; 152 } 153 } 154 }