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

Wed, 10 Oct 2012 16:48:21 -0700

author
jjg
date
Wed, 10 Oct 2012 16:48:21 -0700
changeset 1359
25e14ad23cef
parent 958
734144b6b22f
child 1410
bfec2a1cc869
permissions
-rw-r--r--

8000665: fix "internal API" comments on javadoc files
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     /**
   202      * The integer indicating the location of the link.
   203      */
   204     public int context;
   206     /**
   207      * The value of the marker #.
   208      */
   209     public String where = "";
   211     /**
   212      * String style of text defined in style sheet.
   213      */
   214     public String styleName ="";
   216     /**
   217      * The valueof the target.
   218      */
   219     public String target = "";
   221     /**
   222      * Construct a LinkInfo object.
   223      *
   224      * @param context    the context of the link.
   225      * @param classDoc   the class to link to.
   226      * @param label      the label for the link.
   227      * @param target     the value of the target attribute.
   228      */
   229     public LinkInfoImpl (int context, ClassDoc classDoc, String label,
   230             String target){
   231         this.classDoc = classDoc;
   232         this.label = label;
   233         this.target = target;
   234         setContext(context);
   235     }
   237     /**
   238      * Construct a LinkInfo object.
   239      *
   240      * @param context    the context of the link.
   241      * @param classDoc   the class to link to.
   242      * @param where      the value of the marker #.
   243      * @param label      the label for the link.
   244      * @param isStrong       true if the link should be strong.
   245      * @param styleName  String style of text defined in style sheet.
   246      */
   247     public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
   248             boolean isStrong, String styleName){
   249         this.classDoc = classDoc;
   250         this.where = where;
   251         this.label = label;
   252         this.isStrong = isStrong;
   253         this.styleName = styleName;
   254         setContext(context);
   255     }
   257     /**
   258      * Construct a LinkInfo object.
   259      *
   260      * @param context    the context of the link.
   261      * @param classDoc   the class to link to.
   262      * @param where      the value of the marker #.
   263      * @param label      the label for the link.
   264      * @param isStrong       true if the link should be strong.
   265      */
   266     public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
   267             boolean isStrong){
   268         this.classDoc = classDoc;
   269         this.where = where;
   270         this.label = label;
   271         this.isStrong = isStrong;
   272         setContext(context);
   273     }
   275     /**
   276      * Construct a LinkInfo object.
   277      *
   278      * @param classDoc   the class to link to.
   279      * @param label      the label for the link.
   280      */
   281     public LinkInfoImpl (ClassDoc classDoc, String label){
   282         this.classDoc = classDoc;
   283         this.label = label;
   284         setContext(context);
   285     }
   287     /**
   288      * Construct a LinkInfo object.
   289      *
   290      * @param context               the context of the link.
   291      * @param executableMemberDoc   the member to link to.
   292      * @param isStrong                true if the link should be strong.
   293      */
   294     public LinkInfoImpl (int context, ExecutableMemberDoc executableMemberDoc,
   295             boolean isStrong){
   296         this.executableMemberDoc = executableMemberDoc;
   297         this.isStrong = isStrong;
   298         setContext(context);
   299     }
   301     /**
   302      * Construct a LinkInfo object.
   303      *
   304      * @param context    the context of the link.
   305      * @param classDoc   the class to link to.
   306      * @param isStrong       true if the link should be strong.
   307      */
   308     public LinkInfoImpl (int context, ClassDoc classDoc,  boolean isStrong){
   309         this.classDoc = classDoc;
   310         this.isStrong = isStrong;
   311         setContext(context);
   312     }
   314     /**
   315      * Construct a LinkInfo object.
   316      *
   317      * @param context    the context of the link.
   318      * @param type       the class to link to.
   319      */
   320     public LinkInfoImpl (int context, Type type){
   321         this.type = type;
   322         setContext(context);
   323     }
   325     /**
   326      * Construct a LinkInfo object.
   327      *
   328      * @param context    the context of the link.
   329      * @param type       the class to link to.
   330      * @param isVarArg   true if this is a link to a var arg.
   331      */
   332     public LinkInfoImpl (int context, Type type, boolean isVarArg){
   333         this.type = type;
   334         this.isVarArg = isVarArg;
   335         setContext(context);
   336     }
   338     /**
   339      * Construct a LinkInfo object.
   340      *
   341      * @param context    the context of the link.
   342      * @param type       the class to link to.
   343      * @param label      the label for the link.
   344      * @param isStrong     true if the link should be strong.
   345      */
   346     public LinkInfoImpl (int context, Type type, String label,
   347             boolean isStrong){
   348         this.type = type;
   349         this.label = label;
   350         this.isStrong = isStrong;
   351         setContext(context);
   352     }
   354     /**
   355      * Construct a LinkInfo object.
   356      *
   357      * @param context    the context of the link.
   358      * @param classDoc   the class to link to.
   359      * @param label      the label for the link.
   360      * @param isStrong       true if the link should be strong.
   361      */
   362     public LinkInfoImpl (int context, ClassDoc classDoc, String label,
   363             boolean isStrong){
   364         this.classDoc = classDoc;
   365         this.label = label;
   366         this.isStrong = isStrong;
   367         setContext(context);
   368     }
   370     /**
   371      * {@inheritDoc}
   372      */
   373     public int getContext() {
   374         return context;
   375     }
   377     /**
   378      * {@inheritDoc}
   379      *
   380      * This method sets the link attributes to the appropriate values
   381      * based on the context.
   382      *
   383      * @param c the context id to set.
   384      */
   385     public void setContext(int c) {
   386         //NOTE:  Put context specific link code here.
   387         switch (c) {
   388             case ALL_CLASSES_FRAME:
   389             case PACKAGE_FRAME:
   390             case CONTEXT_IMPLEMENTED_CLASSES:
   391             case CONTEXT_SUBCLASSES:
   392             case CONTEXT_METHOD_DOC_COPY:
   393             case CONTEXT_FIELD_DOC_COPY:
   394             case CONTEXT_CLASS_USE_HEADER:
   395                 includeTypeInClassLinkLabel = false;
   396                 break;
   398             case CONTEXT_ANNOTATION:
   399                 excludeTypeParameterLinks = true;
   400                 excludeTypeBounds = true;
   401                 break;
   403             case CONTEXT_IMPLEMENTED_INTERFACES:
   404             case CONTEXT_SUPER_INTERFACES:
   405             case CONTEXT_SUBINTERFACES:
   406             case CONTEXT_CLASS_TREE_PARENT:
   407             case CONTEXT_TREE:
   408             case CONTEXT_CLASS_SIGNATURE_PARENT_NAME:
   409                 excludeTypeParameterLinks = true;
   410                 excludeTypeBounds = true;
   411                 includeTypeInClassLinkLabel = false;
   412                 includeTypeAsSepLink = true;
   413                 break;
   415             case CONTEXT_PACKAGE:
   416             case CONTEXT_CLASS_USE:
   417             case CONTEXT_CLASS_HEADER:
   418             case CONTEXT_CLASS_SIGNATURE:
   419                 excludeTypeParameterLinks = true;
   420                 includeTypeAsSepLink = true;
   421                 includeTypeInClassLinkLabel = false;
   422                 break;
   424             case CONTEXT_MEMBER_TYPE_PARAMS:
   425                 includeTypeAsSepLink = true;
   426                 includeTypeInClassLinkLabel = false;
   427                 break;
   429             case CONTEXT_RETURN_TYPE:
   430             case CONTEXT_SUMMARY_RETURN_TYPE:
   431             case CONTEXT_EXECUTABLE_MEMBER_PARAM:
   432                 excludeTypeBounds = true;
   433                 break;
   434         }
   435         context = c;
   436         if (type != null &&
   437             type.asTypeVariable()!= null &&
   438             type.asTypeVariable().owner() instanceof ExecutableMemberDoc){
   439             excludeTypeParameterLinks = true;
   440         }
   441     }
   443     /**
   444      * Return true if this link is linkable and false if we can't link to the
   445      * desired place.
   446      *
   447      * @return true if this link is linkable and false if we can't link to the
   448      * desired place.
   449      */
   450     public boolean isLinkable() {
   451         return Util.isLinkable(classDoc, ConfigurationImpl.getInstance());
   452     }
   453 }

mercurial