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

Thu, 15 Nov 2012 19:54:20 -0800

author
jjg
date
Thu, 15 Nov 2012 19:54:20 -0800
changeset 1412
400a4e8accd3
parent 1410
bfec2a1cc869
child 1521
71f35e4b93a5
permissions
-rw-r--r--

8002079: update DocFile to use a JavaFileManager
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 2003, 2012, 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  */
    27 package com.sun.tools.doclets.formats.html;
    29 import com.sun.javadoc.*;
    30 import com.sun.tools.doclets.internal.toolkit.util.*;
    31 import com.sun.tools.doclets.internal.toolkit.util.links.*;
    33 /**
    34  *  <p><b>This is NOT part of any supported API.
    35  *  If you write code that depends on this, you do so at your own risk.
    36  *  This code and its internal interfaces are subject to change or
    37  *  deletion without notice.</b>
    38  */
    39 public class LinkInfoImpl extends LinkInfo {
    41     /**
    42      * Indicate that the link appears in a class list.
    43      */
    44     public static final int ALL_CLASSES_FRAME = 1;
    46     /**
    47      * Indicate that the link appears in a class documentation.
    48      */
    49     public static final int CONTEXT_CLASS = 2;
    51     /**
    52      * Indicate that the link appears in member documentation.
    53      */
    54     public static final int CONTEXT_MEMBER = 3;
    56     /**
    57      * Indicate that the link appears in class use documentation.
    58      */
    59     public static final int CONTEXT_CLASS_USE = 4;
    61     /**
    62      * Indicate that the link appears in index documentation.
    63      */
    64     public static final int CONTEXT_INDEX = 5;
    66     /**
    67      * Indicate that the link appears in constant value summary.
    68      */
    69     public static final int CONTEXT_CONSTANT_SUMMARY = 6;
    71     /**
    72      * Indicate that the link appears in serialized form documentation.
    73      */
    74     public static final int CONTEXT_SERIALIZED_FORM = 7;
    76     /**
    77      * Indicate that the link appears in serial member documentation.
    78      */
    79     public static final int CONTEXT_SERIAL_MEMBER = 8;
    81     /**
    82      * Indicate that the link appears in package documentation.
    83      */
    84     public static final int CONTEXT_PACKAGE = 9;
    86     /**
    87      * Indicate that the link appears in see tag documentation.
    88      */
    89     public static final int CONTEXT_SEE_TAG = 10;
    91     /**
    92      * Indicate that the link appears in value tag documentation.
    93      */
    94     public static final int CONTEXT_VALUE_TAG = 11;
    96     /**
    97      * Indicate that the link appears in tree documentation.
    98      */
    99     public static final int CONTEXT_TREE = 12;
   101     /**
   102      * Indicate that the link appears in a class list.
   103      */
   104     public static final int PACKAGE_FRAME = 13;
   106     /**
   107      * The header in the class documentation.
   108      */
   109     public static final int CONTEXT_CLASS_HEADER = 14;
   111     /**
   112      * The signature in the class documentation.
   113      */
   114     public static final int CONTEXT_CLASS_SIGNATURE = 15;
   116     /**
   117      * The return type of a method.
   118      */
   119     public static final int CONTEXT_RETURN_TYPE = 16;
   121     /**
   122      * The return type of a method in a member summary.
   123      */
   124     public static final int CONTEXT_SUMMARY_RETURN_TYPE = 17;
   126     /**
   127      * The type of a method/constructor parameter.
   128      */
   129     public static final int CONTEXT_EXECUTABLE_MEMBER_PARAM = 18;
   131     /**
   132      * Super interface links.
   133      */
   134     public static final int CONTEXT_SUPER_INTERFACES = 19;
   136     /**
   137      * Implemented interface links.
   138      */
   139     public static final int CONTEXT_IMPLEMENTED_INTERFACES = 20;
   141     /**
   142      * Implemented class links.
   143      */
   144     public static final int CONTEXT_IMPLEMENTED_CLASSES = 21;
   146     /**
   147      * Subinterface links.
   148      */
   149     public static final int CONTEXT_SUBINTERFACES = 22;
   151     /**
   152      * Subclasses links.
   153      */
   154     public static final int CONTEXT_SUBCLASSES = 23;
   156     /**
   157      * The signature in the class documentation (implements/extends portion).
   158      */
   159     public static final int CONTEXT_CLASS_SIGNATURE_PARENT_NAME = 24;
   161     /**
   162      * The header for method documentation copied from parent.
   163      */
   164     public static final int CONTEXT_METHOD_DOC_COPY = 26;
   166     /**
   167      * Method "specified by" link.
   168      */
   169     public static final int CONTEXT_METHOD_SPECIFIED_BY = 27;
   171     /**
   172      * Method "overrides" link.
   173      */
   174     public static final int CONTEXT_METHOD_OVERRIDES = 28;
   176     /**
   177      * Annotation link.
   178      */
   179     public static final int CONTEXT_ANNOTATION = 29;
   181     /**
   182      * The header for field documentation copied from parent.
   183      */
   184     public static final int CONTEXT_FIELD_DOC_COPY = 30;
   186     /**
   187      * The parent nodes int the class tree.
   188      */
   189     public static final int CONTEXT_CLASS_TREE_PARENT = 31;
   191     /**
   192      * The type parameters of a method or constructor.
   193      */
   194     public static final int CONTEXT_MEMBER_TYPE_PARAMS = 32;
   196     /**
   197      * Indicate that the link appears in class use documentation.
   198      */
   199     public static final int CONTEXT_CLASS_USE_HEADER = 33;
   201     public final ConfigurationImpl configuration;
   203     /**
   204      * The integer indicating the location of the link.
   205      */
   206     public int context;
   208     /**
   209      * The value of the marker #.
   210      */
   211     public String where = "";
   213     /**
   214      * String style of text defined in style sheet.
   215      */
   216     public String styleName ="";
   218     /**
   219      * The value of the target.
   220      */
   221     public String target = "";
   223     /**
   224      * Construct a LinkInfo object.
   225      *
   226      * @param configuration the configuration data for the doclet
   227      * @param context    the context of the link.
   228      * @param classDoc   the class to link to.
   229      * @param label      the label for the link.
   230      * @param target     the value of the target attribute.
   231      */
   232     public LinkInfoImpl(ConfigurationImpl configuration,
   233             int context, ClassDoc classDoc, String label, String target) {
   234         this.configuration = configuration;
   235         this.classDoc = classDoc;
   236         this.label = label;
   237         this.target = target;
   238         setContext(context);
   239     }
   241     /**
   242      * Construct a LinkInfo object.
   243      *
   244      * @param configuration the configuration data for the doclet
   245      * @param context    the context of the link.
   246      * @param classDoc   the class to link to.
   247      * @param where      the value of the marker #.
   248      * @param label      the label for the link.
   249      * @param isStrong       true if the link should be strong.
   250      * @param styleName  String style of text defined in style sheet.
   251      */
   252     public LinkInfoImpl(ConfigurationImpl configuration,
   253             int context, ClassDoc classDoc, String where, String label,
   254             boolean isStrong, String styleName) {
   255         this.configuration = configuration;
   256         this.classDoc = classDoc;
   257         this.where = where;
   258         this.label = label;
   259         this.isStrong = isStrong;
   260         this.styleName = styleName;
   261         setContext(context);
   262     }
   264     /**
   265      * Construct a LinkInfo object.
   266      *
   267      * @param configuration the configuration data for the doclet
   268      * @param context    the context of the link.
   269      * @param classDoc   the class to link to.
   270      * @param where      the value of the marker #.
   271      * @param label      the label for the link.
   272      * @param isStrong       true if the link should be strong.
   273      */
   274     public LinkInfoImpl(ConfigurationImpl configuration,
   275             int context, ClassDoc classDoc, String where, String label,
   276             boolean isStrong) {
   277         this.configuration = configuration;
   278         this.classDoc = classDoc;
   279         this.where = where;
   280         this.label = label;
   281         this.isStrong = isStrong;
   282         setContext(context);
   283     }
   285     /**
   286      * Construct a LinkInfo object.
   287      *
   288      * @param configuration the configuration data for the doclet
   289      * @param classDoc   the class to link to.
   290      * @param label      the label for the link.
   291      */
   292     public LinkInfoImpl(ConfigurationImpl configuration,
   293             ClassDoc classDoc, String label) {
   294         this.configuration = configuration;
   295         this.classDoc = classDoc;
   296         this.label = label;
   297         setContext(context);
   298     }
   300     /**
   301      * Construct a LinkInfo object.
   302      *
   303      * @param configuration the configuration data for the doclet
   304      * @param context               the context of the link.
   305      * @param executableMemberDoc   the member to link to.
   306      * @param isStrong                true if the link should be strong.
   307      */
   308     public LinkInfoImpl(ConfigurationImpl configuration,
   309             int context, ExecutableMemberDoc executableMemberDoc,
   310             boolean isStrong) {
   311         this.configuration = configuration;
   312         this.executableMemberDoc = executableMemberDoc;
   313         this.isStrong = isStrong;
   314         setContext(context);
   315     }
   317     /**
   318      * Construct a LinkInfo object.
   319      *
   320      * @param configuration the configuration data for the doclet
   321      * @param context    the context of the link.
   322      * @param classDoc   the class to link to.
   323      * @param isStrong       true if the link should be strong.
   324      */
   325     public LinkInfoImpl(ConfigurationImpl configuration,
   326             int context, ClassDoc classDoc,  boolean isStrong) {
   327         this.configuration = configuration;
   328         this.classDoc = classDoc;
   329         this.isStrong = isStrong;
   330         setContext(context);
   331     }
   333     /**
   334      * Construct a LinkInfo object.
   335      *
   336      * @param configuration the configuration data for the doclet
   337      * @param context    the context of the link.
   338      * @param type       the class to link to.
   339      */
   340     public LinkInfoImpl(ConfigurationImpl configuration,
   341             int context, Type type) {
   342         this.configuration = configuration;
   343         this.type = type;
   344         setContext(context);
   345     }
   347     /**
   348      * Construct a LinkInfo object.
   349      *
   350      * @param configuration the configuration data for the doclet
   351      * @param context    the context of the link.
   352      * @param type       the class to link to.
   353      * @param isVarArg   true if this is a link to a var arg.
   354      */
   355     public LinkInfoImpl(ConfigurationImpl configuration,
   356             int context, Type type, boolean isVarArg) {
   357         this.configuration = configuration;
   358         this.type = type;
   359         this.isVarArg = isVarArg;
   360         setContext(context);
   361     }
   363     /**
   364      * Construct a LinkInfo object.
   365      *
   366      * @param configuration the configuration data for the doclet
   367      * @param context    the context of the link.
   368      * @param type       the class to link to.
   369      * @param label      the label for the link.
   370      * @param isStrong     true if the link should be strong.
   371      */
   372     public LinkInfoImpl(ConfigurationImpl configuration,
   373             int context, Type type, String label,
   374             boolean isStrong) {
   375         this.configuration = configuration;
   376         this.type = type;
   377         this.label = label;
   378         this.isStrong = isStrong;
   379         setContext(context);
   380     }
   382     /**
   383      * Construct a LinkInfo object.
   384      *
   385      * @param configuration the configuration data for the doclet
   386      * @param context    the context of the link.
   387      * @param classDoc   the class to link to.
   388      * @param label      the label for the link.
   389      * @param isStrong       true if the link should be strong.
   390      */
   391     public LinkInfoImpl(ConfigurationImpl configuration,
   392             int context, ClassDoc classDoc, String label,
   393             boolean isStrong) {
   394         this.configuration = configuration;
   395         this.classDoc = classDoc;
   396         this.label = label;
   397         this.isStrong = isStrong;
   398         setContext(context);
   399     }
   401     /**
   402      * {@inheritDoc}
   403      */
   404     public int getContext() {
   405         return context;
   406     }
   408     /**
   409      * {@inheritDoc}
   410      *
   411      * This method sets the link attributes to the appropriate values
   412      * based on the context.
   413      *
   414      * @param c the context id to set.
   415      */
   416     public void setContext(int c) {
   417         //NOTE:  Put context specific link code here.
   418         switch (c) {
   419             case ALL_CLASSES_FRAME:
   420             case PACKAGE_FRAME:
   421             case CONTEXT_IMPLEMENTED_CLASSES:
   422             case CONTEXT_SUBCLASSES:
   423             case CONTEXT_METHOD_DOC_COPY:
   424             case CONTEXT_FIELD_DOC_COPY:
   425             case CONTEXT_CLASS_USE_HEADER:
   426                 includeTypeInClassLinkLabel = false;
   427                 break;
   429             case CONTEXT_ANNOTATION:
   430                 excludeTypeParameterLinks = true;
   431                 excludeTypeBounds = true;
   432                 break;
   434             case CONTEXT_IMPLEMENTED_INTERFACES:
   435             case CONTEXT_SUPER_INTERFACES:
   436             case CONTEXT_SUBINTERFACES:
   437             case CONTEXT_CLASS_TREE_PARENT:
   438             case CONTEXT_TREE:
   439             case CONTEXT_CLASS_SIGNATURE_PARENT_NAME:
   440                 excludeTypeParameterLinks = true;
   441                 excludeTypeBounds = true;
   442                 includeTypeInClassLinkLabel = false;
   443                 includeTypeAsSepLink = true;
   444                 break;
   446             case CONTEXT_PACKAGE:
   447             case CONTEXT_CLASS_USE:
   448             case CONTEXT_CLASS_HEADER:
   449             case CONTEXT_CLASS_SIGNATURE:
   450                 excludeTypeParameterLinks = true;
   451                 includeTypeAsSepLink = true;
   452                 includeTypeInClassLinkLabel = false;
   453                 break;
   455             case CONTEXT_MEMBER_TYPE_PARAMS:
   456                 includeTypeAsSepLink = true;
   457                 includeTypeInClassLinkLabel = false;
   458                 break;
   460             case CONTEXT_RETURN_TYPE:
   461             case CONTEXT_SUMMARY_RETURN_TYPE:
   462             case CONTEXT_EXECUTABLE_MEMBER_PARAM:
   463                 excludeTypeBounds = true;
   464                 break;
   465         }
   466         context = c;
   467         if (type != null &&
   468             type.asTypeVariable()!= null &&
   469             type.asTypeVariable().owner() instanceof ExecutableMemberDoc){
   470             excludeTypeParameterLinks = true;
   471         }
   472     }
   474     /**
   475      * Return true if this link is linkable and false if we can't link to the
   476      * desired place.
   477      *
   478      * @return true if this link is linkable and false if we can't link to the
   479      * desired place.
   480      */
   481     public boolean isLinkable() {
   482         return Util.isLinkable(classDoc, configuration);
   483     }
   484 }

mercurial