duke@1: /* jjg@1359: * Copyright (c) 2003, 2012, 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.*; 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: duke@1: /** duke@1: * Indicate that the link appears in a class list. duke@1: */ duke@1: public static final int ALL_CLASSES_FRAME = 1; duke@1: duke@1: /** duke@1: * Indicate that the link appears in a class documentation. duke@1: */ duke@1: public static final int CONTEXT_CLASS = 2; duke@1: duke@1: /** duke@1: * Indicate that the link appears in member documentation. duke@1: */ duke@1: public static final int CONTEXT_MEMBER = 3; duke@1: duke@1: /** duke@1: * Indicate that the link appears in class use documentation. duke@1: */ duke@1: public static final int CONTEXT_CLASS_USE = 4; duke@1: duke@1: /** duke@1: * Indicate that the link appears in index documentation. duke@1: */ duke@1: public static final int CONTEXT_INDEX = 5; duke@1: duke@1: /** duke@1: * Indicate that the link appears in constant value summary. duke@1: */ duke@1: public static final int CONTEXT_CONSTANT_SUMMARY = 6; duke@1: duke@1: /** duke@1: * Indicate that the link appears in serialized form documentation. duke@1: */ duke@1: public static final int CONTEXT_SERIALIZED_FORM = 7; duke@1: duke@1: /** duke@1: * Indicate that the link appears in serial member documentation. duke@1: */ duke@1: public static final int CONTEXT_SERIAL_MEMBER = 8; duke@1: duke@1: /** duke@1: * Indicate that the link appears in package documentation. duke@1: */ duke@1: public static final int CONTEXT_PACKAGE = 9; duke@1: duke@1: /** duke@1: * Indicate that the link appears in see tag documentation. duke@1: */ duke@1: public static final int CONTEXT_SEE_TAG = 10; duke@1: duke@1: /** duke@1: * Indicate that the link appears in value tag documentation. duke@1: */ duke@1: public static final int CONTEXT_VALUE_TAG = 11; duke@1: duke@1: /** duke@1: * Indicate that the link appears in tree documentation. duke@1: */ duke@1: public static final int CONTEXT_TREE = 12; duke@1: duke@1: /** duke@1: * Indicate that the link appears in a class list. duke@1: */ duke@1: public static final int PACKAGE_FRAME = 13; duke@1: duke@1: /** duke@1: * The header in the class documentation. duke@1: */ duke@1: public static final int CONTEXT_CLASS_HEADER = 14; duke@1: duke@1: /** duke@1: * The signature in the class documentation. duke@1: */ duke@1: public static final int CONTEXT_CLASS_SIGNATURE = 15; duke@1: duke@1: /** duke@1: * The return type of a method. duke@1: */ duke@1: public static final int CONTEXT_RETURN_TYPE = 16; duke@1: duke@1: /** duke@1: * The return type of a method in a member summary. duke@1: */ duke@1: public static final int CONTEXT_SUMMARY_RETURN_TYPE = 17; duke@1: duke@1: /** duke@1: * The type of a method/constructor parameter. duke@1: */ duke@1: public static final int CONTEXT_EXECUTABLE_MEMBER_PARAM = 18; duke@1: duke@1: /** duke@1: * Super interface links. duke@1: */ duke@1: public static final int CONTEXT_SUPER_INTERFACES = 19; duke@1: duke@1: /** duke@1: * Implemented interface links. duke@1: */ duke@1: public static final int CONTEXT_IMPLEMENTED_INTERFACES = 20; duke@1: duke@1: /** duke@1: * Implemented class links. duke@1: */ duke@1: public static final int CONTEXT_IMPLEMENTED_CLASSES = 21; duke@1: duke@1: /** duke@1: * Subinterface links. duke@1: */ duke@1: public static final int CONTEXT_SUBINTERFACES = 22; duke@1: duke@1: /** duke@1: * Subclasses links. duke@1: */ duke@1: public static final int CONTEXT_SUBCLASSES = 23; duke@1: duke@1: /** duke@1: * The signature in the class documentation (implements/extends portion). duke@1: */ duke@1: public static final int CONTEXT_CLASS_SIGNATURE_PARENT_NAME = 24; duke@1: duke@1: /** duke@1: * The header for method documentation copied from parent. duke@1: */ duke@1: public static final int CONTEXT_METHOD_DOC_COPY = 26; duke@1: duke@1: /** duke@1: * Method "specified by" link. duke@1: */ duke@1: public static final int CONTEXT_METHOD_SPECIFIED_BY = 27; duke@1: duke@1: /** duke@1: * Method "overrides" link. duke@1: */ duke@1: public static final int CONTEXT_METHOD_OVERRIDES = 28; duke@1: duke@1: /** duke@1: * Annotation link. duke@1: */ duke@1: public static final int CONTEXT_ANNOTATION = 29; duke@1: duke@1: /** duke@1: * The header for field documentation copied from parent. duke@1: */ duke@1: public static final int CONTEXT_FIELD_DOC_COPY = 30; duke@1: duke@1: /** duke@1: * The parent nodes int the class tree. duke@1: */ duke@1: public static final int CONTEXT_CLASS_TREE_PARENT = 31; duke@1: duke@1: /** duke@1: * The type parameters of a method or constructor. duke@1: */ duke@1: public static final int CONTEXT_MEMBER_TYPE_PARAMS = 32; duke@1: duke@1: /** duke@1: * Indicate that the link appears in class use documentation. duke@1: */ duke@1: public static final int CONTEXT_CLASS_USE_HEADER = 33; duke@1: jjg@1410: public final ConfigurationImpl configuration; jjg@1410: duke@1: /** duke@1: * The integer indicating the location of the link. duke@1: */ duke@1: public int context; 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: */ duke@1: 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@1410: int context, ClassDoc classDoc, String 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: /** 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@1410: int context, ClassDoc classDoc, String where, String 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 #. 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@1410: int context, ClassDoc classDoc, String where, String label, jjg@1410: boolean isStrong) { 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: 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; 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 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@1410: int 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@1410: int 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@1410: int 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@1410: int 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. 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@1410: int context, Type type, String 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. 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@1410: int context, ClassDoc classDoc, String 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: */ duke@1: public int 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: */ duke@1: public void setContext(int 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: duke@1: case CONTEXT_IMPLEMENTED_CLASSES: duke@1: case CONTEXT_SUBCLASSES: duke@1: case CONTEXT_METHOD_DOC_COPY: duke@1: case CONTEXT_FIELD_DOC_COPY: duke@1: case CONTEXT_CLASS_USE_HEADER: duke@1: includeTypeInClassLinkLabel = false; duke@1: break; duke@1: duke@1: case CONTEXT_ANNOTATION: duke@1: excludeTypeParameterLinks = true; duke@1: excludeTypeBounds = true; duke@1: break; duke@1: duke@1: case CONTEXT_IMPLEMENTED_INTERFACES: duke@1: case CONTEXT_SUPER_INTERFACES: duke@1: case CONTEXT_SUBINTERFACES: duke@1: case CONTEXT_CLASS_TREE_PARENT: duke@1: case CONTEXT_TREE: duke@1: case CONTEXT_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: duke@1: case CONTEXT_PACKAGE: duke@1: case CONTEXT_CLASS_USE: duke@1: case CONTEXT_CLASS_HEADER: duke@1: case CONTEXT_CLASS_SIGNATURE: duke@1: excludeTypeParameterLinks = true; duke@1: includeTypeAsSepLink = true; duke@1: includeTypeInClassLinkLabel = false; duke@1: break; duke@1: duke@1: case CONTEXT_MEMBER_TYPE_PARAMS: duke@1: includeTypeAsSepLink = true; duke@1: includeTypeInClassLinkLabel = false; duke@1: break; duke@1: duke@1: case CONTEXT_RETURN_TYPE: duke@1: case CONTEXT_SUMMARY_RETURN_TYPE: duke@1: case CONTEXT_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: }