duke@1: /* jjg@1521: * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: duke@1: import com.sun.javadoc.*; jjg@1737: import com.sun.tools.doclets.formats.html.markup.ContentBuilder; jjg@1737: import com.sun.tools.doclets.formats.html.markup.StringContent; jjg@1737: import com.sun.tools.doclets.internal.toolkit.Content; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: import com.sun.tools.doclets.internal.toolkit.util.links.*; duke@1: jjg@1359: /** jjg@1359: *

This is NOT part of any supported API. jjg@1359: * If you write code that depends on this, you do so at your own risk. jjg@1359: * This code and its internal interfaces are subject to change or jjg@1359: * deletion without notice. jjg@1359: */ duke@1: public class LinkInfoImpl extends LinkInfo { duke@1: jjg@1735: public enum Kind { jjg@1735: DEFAULT, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in a class list. jjg@1735: */ jjg@1735: ALL_CLASSES_FRAME, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in a class documentation. jjg@1735: */ jjg@1735: CLASS, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in member documentation. jjg@1735: */ jjg@1735: MEMBER, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in class use documentation. jjg@1735: */ jjg@1735: CLASS_USE, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in index documentation. jjg@1735: */ jjg@1735: INDEX, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in constant value summary. jjg@1735: */ jjg@1735: CONSTANT_SUMMARY, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in serialized form documentation. jjg@1735: */ jjg@1735: SERIALIZED_FORM, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in serial member documentation. jjg@1735: */ jjg@1735: SERIAL_MEMBER, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in package documentation. jjg@1735: */ jjg@1735: PACKAGE, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in see tag documentation. jjg@1735: */ jjg@1735: SEE_TAG, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in value tag documentation. jjg@1735: */ jjg@1735: VALUE_TAG, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in tree documentation. jjg@1735: */ jjg@1735: TREE, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in a class list. jjg@1735: */ jjg@1735: PACKAGE_FRAME, duke@1: jjg@1735: /** jjg@1735: * The header in the class documentation. jjg@1735: */ jjg@1735: CLASS_HEADER, duke@1: jjg@1735: /** jjg@1735: * The signature in the class documentation. jjg@1735: */ jjg@1735: CLASS_SIGNATURE, duke@1: jjg@1735: /** jjg@1735: * The return type of a method. jjg@1735: */ jjg@1735: RETURN_TYPE, duke@1: jjg@1735: /** jjg@1735: * The return type of a method in a member summary. jjg@1735: */ jjg@1735: SUMMARY_RETURN_TYPE, duke@1: jjg@1735: /** jjg@1735: * The type of a method/constructor parameter. jjg@1735: */ jjg@1735: EXECUTABLE_MEMBER_PARAM, duke@1: jjg@1735: /** jjg@1735: * Super interface links. jjg@1735: */ jjg@1735: SUPER_INTERFACES, duke@1: jjg@1735: /** jjg@1735: * Implemented interface links. jjg@1735: */ jjg@1735: IMPLEMENTED_INTERFACES, duke@1: jjg@1735: /** jjg@1735: * Implemented class links. jjg@1735: */ jjg@1735: IMPLEMENTED_CLASSES, duke@1: jjg@1735: /** jjg@1735: * Subinterface links. jjg@1735: */ jjg@1735: SUBINTERFACES, duke@1: jjg@1735: /** jjg@1735: * Subclasses links. jjg@1735: */ jjg@1735: SUBCLASSES, duke@1: jjg@1735: /** jjg@1735: * The signature in the class documentation (implements/extends portion). jjg@1735: */ jjg@1735: CLASS_SIGNATURE_PARENT_NAME, duke@1: jjg@1735: /** jjg@1735: * The header for method documentation copied from parent. jjg@1735: */ jjg@1735: METHOD_DOC_COPY, duke@1: jjg@1735: /** jjg@1735: * Method "specified by" link. jjg@1735: */ jjg@1735: METHOD_SPECIFIED_BY, duke@1: jjg@1735: /** jjg@1735: * Method "overrides" link. jjg@1735: */ jjg@1735: METHOD_OVERRIDES, duke@1: jjg@1735: /** jjg@1735: * Annotation link. jjg@1735: */ jjg@1735: ANNOTATION, duke@1: jjg@1735: /** jjg@1735: * The header for field documentation copied from parent. jjg@1735: */ jjg@1735: FIELD_DOC_COPY, duke@1: jjg@1735: /** jjg@1735: * The parent nodes in the class tree. jjg@1735: */ jjg@1735: CLASS_TREE_PARENT, duke@1: jjg@1735: /** jjg@1735: * The type parameters of a method or constructor. jjg@1735: */ jjg@1735: MEMBER_TYPE_PARAMS, duke@1: jjg@1735: /** jjg@1735: * Indicate that the link appears in class use documentation. jjg@1735: */ jjg@1735: CLASS_USE_HEADER, jjg@1735: jjg@1735: /** jjg@1735: * The header for property documentation copied from parent. jjg@1735: */ jjg@1735: PROPERTY_DOC_COPY jjg@1735: } jjg@1606: jjg@1410: public final ConfigurationImpl configuration; jjg@1410: duke@1: /** jjg@1735: * The location of the link. duke@1: */ jjg@1735: public Kind context = Kind.DEFAULT; duke@1: duke@1: /** duke@1: * The value of the marker #. duke@1: */ duke@1: public String where = ""; duke@1: duke@1: /** duke@1: * String style of text defined in style sheet. duke@1: */ jjg@1737: public String styleName = ""; duke@1: duke@1: /** jjg@1410: * The value of the target. duke@1: */ duke@1: public String target = ""; duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param classDoc the class to link to. duke@1: * @param label the label for the link. duke@1: * @param target the value of the target attribute. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1737: Kind context, ClassDoc classDoc, Content label, String target) { jjg@1410: this.configuration = configuration; duke@1: this.classDoc = classDoc; duke@1: this.label = label; duke@1: this.target = target; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** jjg@1737: * {@inherotDoc} jjg@1737: */ jjg@1737: protected Content newContent() { jjg@1737: return new ContentBuilder(); jjg@1737: } jjg@1737: jjg@1737: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param classDoc the class to link to. duke@1: * @param where the value of the marker #. duke@1: * @param label the label for the link. bpatel@182: * @param isStrong true if the link should be strong. duke@1: * @param styleName String style of text defined in style sheet. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1737: Kind context, ClassDoc classDoc, String where, Content label, jjg@1410: boolean isStrong, String styleName) { jjg@1410: this.configuration = configuration; duke@1: this.classDoc = classDoc; duke@1: this.where = where; duke@1: this.label = label; bpatel@182: this.isStrong = isStrong; duke@1: this.styleName = styleName; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param classDoc the class to link to. duke@1: * @param where the value of the marker #. jjg@1737: * @param label the plain-text label for the link. bpatel@182: * @param isStrong true if the link should be strong. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1735: Kind context, ClassDoc classDoc, String where, String label, jjg@1410: boolean isStrong) { jjg@1737: this(configuration, context, classDoc, where, new StringContent(label), jjg@1737: isStrong, ""); jjg@1737: } jjg@1737: jjg@1737: /** jjg@1737: * Construct a LinkInfo object. jjg@1737: * jjg@1737: * @param configuration the configuration data for the doclet jjg@1737: * @param context the context of the link. jjg@1737: * @param classDoc the class to link to. jjg@1737: * @param where the value of the marker #. jjg@1737: * @param label the label for the link. jjg@1737: * @param isStrong true if the link should be strong. jjg@1737: */ jjg@1737: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1737: Kind context, ClassDoc classDoc, String where, Content label, jjg@1737: boolean isStrong) { jjg@1737: this(configuration, context, classDoc, where, label, jjg@1737: isStrong, ""); jjg@1737: } jjg@1737: jjg@1737: /** jjg@1737: * Construct a LinkInfo object. jjg@1737: * jjg@1737: * @param configuration the configuration data for the doclet jjg@1737: * @param classDoc the class to link to. jjg@1737: * @param label the label for the link. jjg@1737: */ jjg@1737: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1737: ClassDoc classDoc, Content label) { jjg@1410: this.configuration = configuration; duke@1: this.classDoc = classDoc; duke@1: this.label = label; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param classDoc the class to link to. duke@1: * @param label the label for the link. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1410: ClassDoc classDoc, String label) { jjg@1410: this.configuration = configuration; duke@1: this.classDoc = classDoc; jjg@1737: this.label = new StringContent(label); duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param executableMemberDoc the member to link to. bpatel@182: * @param isStrong true if the link should be strong. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1735: Kind context, ExecutableMemberDoc executableMemberDoc, jjg@1410: boolean isStrong) { jjg@1410: this.configuration = configuration; duke@1: this.executableMemberDoc = executableMemberDoc; bpatel@182: this.isStrong = isStrong; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param classDoc the class to link to. bpatel@182: * @param isStrong true if the link should be strong. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1735: Kind context, ClassDoc classDoc, boolean isStrong) { jjg@1410: this.configuration = configuration; duke@1: this.classDoc = classDoc; bpatel@182: this.isStrong = isStrong; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param type the class to link to. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1735: Kind context, Type type) { jjg@1410: this.configuration = configuration; duke@1: this.type = type; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param type the class to link to. duke@1: * @param isVarArg true if this is a link to a var arg. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1735: Kind context, Type type, boolean isVarArg) { jjg@1410: this.configuration = configuration; duke@1: this.type = type; duke@1: this.isVarArg = isVarArg; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param type the class to link to. jjg@1737: * @param label plain-text label for the link. jjg@1737: * @param isStrong true if the link should be strong. jjg@1737: */ jjg@1737: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1737: Kind context, Type type, String label, jjg@1737: boolean isStrong) { jjg@1737: this(configuration, context, type, new StringContent(label), isStrong); jjg@1737: } jjg@1737: jjg@1737: /** jjg@1737: * Construct a LinkInfo object. jjg@1737: * jjg@1737: * @param configuration the configuration data for the doclet jjg@1737: * @param context the context of the link. jjg@1737: * @param type the class to link to. duke@1: * @param label the label for the link. bpatel@182: * @param isStrong true if the link should be strong. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1737: Kind context, Type type, Content label, jjg@1410: boolean isStrong) { jjg@1410: this.configuration = configuration; duke@1: this.type = type; duke@1: this.label = label; bpatel@182: this.isStrong = isStrong; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * Construct a LinkInfo object. duke@1: * jjg@1410: * @param configuration the configuration data for the doclet duke@1: * @param context the context of the link. duke@1: * @param classDoc the class to link to. jjg@1737: * @param label plain-text label for the link. jjg@1737: * @param isStrong true if the link should be strong. jjg@1737: */ jjg@1737: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1737: Kind context, ClassDoc classDoc, String label, jjg@1737: boolean isStrong) { jjg@1737: this(configuration, context, classDoc, new StringContent(label), isStrong); jjg@1737: } jjg@1737: jjg@1737: /** jjg@1737: * Construct a LinkInfo object. jjg@1737: * jjg@1737: * @param configuration the configuration data for the doclet jjg@1737: * @param context the context of the link. jjg@1737: * @param classDoc the class to link to. duke@1: * @param label the label for the link. bpatel@182: * @param isStrong true if the link should be strong. duke@1: */ jjg@1410: public LinkInfoImpl(ConfigurationImpl configuration, jjg@1737: Kind context, ClassDoc classDoc, Content label, jjg@1410: boolean isStrong) { jjg@1410: this.configuration = configuration; duke@1: this.classDoc = classDoc; duke@1: this.label = label; bpatel@182: this.isStrong = isStrong; duke@1: setContext(context); duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ jjg@1735: public Kind getContext() { duke@1: return context; duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: * duke@1: * This method sets the link attributes to the appropriate values duke@1: * based on the context. duke@1: * duke@1: * @param c the context id to set. duke@1: */ jjg@1735: public final void setContext(Kind c) { duke@1: //NOTE: Put context specific link code here. duke@1: switch (c) { duke@1: case ALL_CLASSES_FRAME: duke@1: case PACKAGE_FRAME: jjg@1735: case IMPLEMENTED_CLASSES: jjg@1735: case SUBCLASSES: jjg@1735: case METHOD_DOC_COPY: jjg@1735: case FIELD_DOC_COPY: jjg@1735: case PROPERTY_DOC_COPY: jjg@1735: case CLASS_USE_HEADER: duke@1: includeTypeInClassLinkLabel = false; duke@1: break; duke@1: jjg@1735: case ANNOTATION: duke@1: excludeTypeParameterLinks = true; duke@1: excludeTypeBounds = true; duke@1: break; duke@1: jjg@1735: case IMPLEMENTED_INTERFACES: jjg@1735: case SUPER_INTERFACES: jjg@1735: case SUBINTERFACES: jjg@1735: case CLASS_TREE_PARENT: jjg@1735: case TREE: jjg@1735: case CLASS_SIGNATURE_PARENT_NAME: duke@1: excludeTypeParameterLinks = true; duke@1: excludeTypeBounds = true; duke@1: includeTypeInClassLinkLabel = false; duke@1: includeTypeAsSepLink = true; duke@1: break; duke@1: jjg@1735: case PACKAGE: jjg@1735: case CLASS_USE: jjg@1735: case CLASS_HEADER: jjg@1735: case CLASS_SIGNATURE: duke@1: excludeTypeParameterLinks = true; duke@1: includeTypeAsSepLink = true; duke@1: includeTypeInClassLinkLabel = false; duke@1: break; duke@1: jjg@1735: case MEMBER_TYPE_PARAMS: duke@1: includeTypeAsSepLink = true; duke@1: includeTypeInClassLinkLabel = false; duke@1: break; duke@1: jjg@1735: case RETURN_TYPE: jjg@1735: case SUMMARY_RETURN_TYPE: jjg@1521: excludeTypeBounds = true; jjg@1521: break; jjg@1735: case EXECUTABLE_MEMBER_PARAM: duke@1: excludeTypeBounds = true; duke@1: break; duke@1: } duke@1: context = c; duke@1: if (type != null && duke@1: type.asTypeVariable()!= null && duke@1: type.asTypeVariable().owner() instanceof ExecutableMemberDoc){ duke@1: excludeTypeParameterLinks = true; duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Return true if this link is linkable and false if we can't link to the duke@1: * desired place. duke@1: * duke@1: * @return true if this link is linkable and false if we can't link to the duke@1: * desired place. duke@1: */ duke@1: public boolean isLinkable() { jjg@1410: return Util.isLinkable(classDoc, configuration); duke@1: } duke@1: }