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

Mon, 13 Dec 2010 13:44:47 -0800

author
bpatel
date
Mon, 13 Dec 2010 13:44:47 -0800
changeset 793
ffbf2b2a8611
parent 554
9d9f26857129
child 958
734144b6b22f
permissions
-rw-r--r--

7006270: Several javadoc regression tests are failing on windows
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2003, 2004, 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 public class LinkInfoImpl extends LinkInfo {
    35     /**
    36      * Indicate that the link appears in a class list.
    37      */
    38     public static final int ALL_CLASSES_FRAME = 1;
    40     /**
    41      * Indicate that the link appears in a class documentation.
    42      */
    43     public static final int CONTEXT_CLASS = 2;
    45     /**
    46      * Indicate that the link appears in member documentation.
    47      */
    48     public static final int CONTEXT_MEMBER = 3;
    50     /**
    51      * Indicate that the link appears in class use documentation.
    52      */
    53     public static final int CONTEXT_CLASS_USE = 4;
    55     /**
    56      * Indicate that the link appears in index documentation.
    57      */
    58     public static final int CONTEXT_INDEX = 5;
    60     /**
    61      * Indicate that the link appears in constant value summary.
    62      */
    63     public static final int CONTEXT_CONSTANT_SUMMARY = 6;
    65     /**
    66      * Indicate that the link appears in serialized form documentation.
    67      */
    68     public static final int CONTEXT_SERIALIZED_FORM = 7;
    70     /**
    71      * Indicate that the link appears in serial member documentation.
    72      */
    73     public static final int CONTEXT_SERIAL_MEMBER = 8;
    75     /**
    76      * Indicate that the link appears in package documentation.
    77      */
    78     public static final int CONTEXT_PACKAGE = 9;
    80     /**
    81      * Indicate that the link appears in see tag documentation.
    82      */
    83     public static final int CONTEXT_SEE_TAG = 10;
    85     /**
    86      * Indicate that the link appears in value tag documentation.
    87      */
    88     public static final int CONTEXT_VALUE_TAG = 11;
    90     /**
    91      * Indicate that the link appears in tree documentation.
    92      */
    93     public static final int CONTEXT_TREE = 12;
    95     /**
    96      * Indicate that the link appears in a class list.
    97      */
    98     public static final int PACKAGE_FRAME = 13;
   100     /**
   101      * The header in the class documentation.
   102      */
   103     public static final int CONTEXT_CLASS_HEADER = 14;
   105     /**
   106      * The signature in the class documentation.
   107      */
   108     public static final int CONTEXT_CLASS_SIGNATURE = 15;
   110     /**
   111      * The return type of a method.
   112      */
   113     public static final int CONTEXT_RETURN_TYPE = 16;
   115     /**
   116      * The return type of a method in a member summary.
   117      */
   118     public static final int CONTEXT_SUMMARY_RETURN_TYPE = 17;
   120     /**
   121      * The type of a method/constructor parameter.
   122      */
   123     public static final int CONTEXT_EXECUTABLE_MEMBER_PARAM = 18;
   125     /**
   126      * Super interface links.
   127      */
   128     public static final int CONTEXT_SUPER_INTERFACES = 19;
   130     /**
   131      * Implemented interface links.
   132      */
   133     public static final int CONTEXT_IMPLEMENTED_INTERFACES = 20;
   135     /**
   136      * Implemented class links.
   137      */
   138     public static final int CONTEXT_IMPLEMENTED_CLASSES = 21;
   140     /**
   141      * Subinterface links.
   142      */
   143     public static final int CONTEXT_SUBINTERFACES = 22;
   145     /**
   146      * Subclasses links.
   147      */
   148     public static final int CONTEXT_SUBCLASSES = 23;
   150     /**
   151      * The signature in the class documentation (implements/extends portion).
   152      */
   153     public static final int CONTEXT_CLASS_SIGNATURE_PARENT_NAME = 24;
   155     /**
   156      * The header for method documentation copied from parent.
   157      */
   158     public static final int CONTEXT_METHOD_DOC_COPY = 26;
   160     /**
   161      * Method "specified by" link.
   162      */
   163     public static final int CONTEXT_METHOD_SPECIFIED_BY = 27;
   165     /**
   166      * Method "overrides" link.
   167      */
   168     public static final int CONTEXT_METHOD_OVERRIDES = 28;
   170     /**
   171      * Annotation link.
   172      */
   173     public static final int CONTEXT_ANNOTATION = 29;
   175     /**
   176      * The header for field documentation copied from parent.
   177      */
   178     public static final int CONTEXT_FIELD_DOC_COPY = 30;
   180     /**
   181      * The parent nodes int the class tree.
   182      */
   183     public static final int CONTEXT_CLASS_TREE_PARENT = 31;
   185     /**
   186      * The type parameters of a method or constructor.
   187      */
   188     public static final int CONTEXT_MEMBER_TYPE_PARAMS = 32;
   190     /**
   191      * Indicate that the link appears in class use documentation.
   192      */
   193     public static final int CONTEXT_CLASS_USE_HEADER = 33;
   195     /**
   196      * The integer indicating the location of the link.
   197      */
   198     public int context;
   200     /**
   201      * The value of the marker #.
   202      */
   203     public String where = "";
   205     /**
   206      * String style of text defined in style sheet.
   207      */
   208     public String styleName ="";
   210     /**
   211      * The valueof the target.
   212      */
   213     public String target = "";
   215     /**
   216      * Construct a LinkInfo object.
   217      *
   218      * @param context    the context of the link.
   219      * @param classDoc   the class to link to.
   220      * @param label      the label for the link.
   221      * @param target     the value of the target attribute.
   222      */
   223     public LinkInfoImpl (int context, ClassDoc classDoc, String label,
   224             String target){
   225         this.classDoc = classDoc;
   226         this.label = label;
   227         this.target = target;
   228         setContext(context);
   229     }
   231     /**
   232      * Construct a LinkInfo object.
   233      *
   234      * @param context    the context of the link.
   235      * @param classDoc   the class to link to.
   236      * @param where      the value of the marker #.
   237      * @param label      the label for the link.
   238      * @param isStrong       true if the link should be strong.
   239      * @param styleName  String style of text defined in style sheet.
   240      */
   241     public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
   242             boolean isStrong, String styleName){
   243         this.classDoc = classDoc;
   244         this.where = where;
   245         this.label = label;
   246         this.isStrong = isStrong;
   247         this.styleName = styleName;
   248         setContext(context);
   249     }
   251     /**
   252      * Construct a LinkInfo object.
   253      *
   254      * @param context    the context of the link.
   255      * @param classDoc   the class to link to.
   256      * @param where      the value of the marker #.
   257      * @param label      the label for the link.
   258      * @param isStrong       true if the link should be strong.
   259      */
   260     public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
   261             boolean isStrong){
   262         this.classDoc = classDoc;
   263         this.where = where;
   264         this.label = label;
   265         this.isStrong = isStrong;
   266         setContext(context);
   267     }
   269     /**
   270      * Construct a LinkInfo object.
   271      *
   272      * @param classDoc   the class to link to.
   273      * @param label      the label for the link.
   274      */
   275     public LinkInfoImpl (ClassDoc classDoc, String label){
   276         this.classDoc = classDoc;
   277         this.label = label;
   278         setContext(context);
   279     }
   281     /**
   282      * Construct a LinkInfo object.
   283      *
   284      * @param context               the context of the link.
   285      * @param executableMemberDoc   the member to link to.
   286      * @param isStrong                true if the link should be strong.
   287      */
   288     public LinkInfoImpl (int context, ExecutableMemberDoc executableMemberDoc,
   289             boolean isStrong){
   290         this.executableMemberDoc = executableMemberDoc;
   291         this.isStrong = isStrong;
   292         setContext(context);
   293     }
   295     /**
   296      * Construct a LinkInfo object.
   297      *
   298      * @param context    the context of the link.
   299      * @param classDoc   the class to link to.
   300      * @param isStrong       true if the link should be strong.
   301      */
   302     public LinkInfoImpl (int context, ClassDoc classDoc,  boolean isStrong){
   303         this.classDoc = classDoc;
   304         this.isStrong = isStrong;
   305         setContext(context);
   306     }
   308     /**
   309      * Construct a LinkInfo object.
   310      *
   311      * @param context    the context of the link.
   312      * @param type       the class to link to.
   313      */
   314     public LinkInfoImpl (int context, Type type){
   315         this.type = type;
   316         setContext(context);
   317     }
   319     /**
   320      * Construct a LinkInfo object.
   321      *
   322      * @param context    the context of the link.
   323      * @param type       the class to link to.
   324      * @param isVarArg   true if this is a link to a var arg.
   325      */
   326     public LinkInfoImpl (int context, Type type, boolean isVarArg){
   327         this.type = type;
   328         this.isVarArg = isVarArg;
   329         setContext(context);
   330     }
   332     /**
   333      * Construct a LinkInfo object.
   334      *
   335      * @param context    the context of the link.
   336      * @param type       the class to link to.
   337      * @param label      the label for the link.
   338      * @param isStrong     true if the link should be strong.
   339      */
   340     public LinkInfoImpl (int context, Type type, String label,
   341             boolean isStrong){
   342         this.type = type;
   343         this.label = label;
   344         this.isStrong = isStrong;
   345         setContext(context);
   346     }
   348     /**
   349      * Construct a LinkInfo object.
   350      *
   351      * @param context    the context of the link.
   352      * @param classDoc   the class to link to.
   353      * @param label      the label for the link.
   354      * @param isStrong       true if the link should be strong.
   355      */
   356     public LinkInfoImpl (int context, ClassDoc classDoc, String label,
   357             boolean isStrong){
   358         this.classDoc = classDoc;
   359         this.label = label;
   360         this.isStrong = isStrong;
   361         setContext(context);
   362     }
   364     /**
   365      * {@inheritDoc}
   366      */
   367     public int getContext() {
   368         return context;
   369     }
   371     /**
   372      * {@inheritDoc}
   373      *
   374      * This method sets the link attributes to the appropriate values
   375      * based on the context.
   376      *
   377      * @param c the context id to set.
   378      */
   379     public void setContext(int c) {
   380         //NOTE:  Put context specific link code here.
   381         switch (c) {
   382             case ALL_CLASSES_FRAME:
   383             case PACKAGE_FRAME:
   384             case CONTEXT_IMPLEMENTED_CLASSES:
   385             case CONTEXT_SUBCLASSES:
   386             case CONTEXT_METHOD_DOC_COPY:
   387             case CONTEXT_FIELD_DOC_COPY:
   388             case CONTEXT_CLASS_USE_HEADER:
   389                 includeTypeInClassLinkLabel = false;
   390                 break;
   392             case CONTEXT_ANNOTATION:
   393                 excludeTypeParameterLinks = true;
   394                 excludeTypeBounds = true;
   395                 break;
   397             case CONTEXT_IMPLEMENTED_INTERFACES:
   398             case CONTEXT_SUPER_INTERFACES:
   399             case CONTEXT_SUBINTERFACES:
   400             case CONTEXT_CLASS_TREE_PARENT:
   401             case CONTEXT_TREE:
   402             case CONTEXT_CLASS_SIGNATURE_PARENT_NAME:
   403                 excludeTypeParameterLinks = true;
   404                 excludeTypeBounds = true;
   405                 includeTypeInClassLinkLabel = false;
   406                 includeTypeAsSepLink = true;
   407                 break;
   409             case CONTEXT_PACKAGE:
   410             case CONTEXT_CLASS_USE:
   411                 excludeTypeBoundsLinks = true;
   412                 excludeTypeParameterLinks = true;
   413                 break;
   415             case CONTEXT_CLASS_HEADER:
   416             case CONTEXT_CLASS_SIGNATURE:
   417                 excludeTypeParameterLinks = true;
   418                 includeTypeAsSepLink = true;
   419                 includeTypeInClassLinkLabel = false;
   420                 break;
   422             case CONTEXT_MEMBER_TYPE_PARAMS:
   423                 includeTypeAsSepLink = true;
   424                 includeTypeInClassLinkLabel = false;
   425                 break;
   427             case CONTEXT_RETURN_TYPE:
   428             case CONTEXT_SUMMARY_RETURN_TYPE:
   429             case CONTEXT_EXECUTABLE_MEMBER_PARAM:
   430                 excludeTypeBounds = true;
   431                 break;
   432         }
   433         context = c;
   434         if (type != null &&
   435             type.asTypeVariable()!= null &&
   436             type.asTypeVariable().owner() instanceof ExecutableMemberDoc){
   437             excludeTypeParameterLinks = true;
   438         }
   439     }
   441     /**
   442      * Return true if this link is linkable and false if we can't link to the
   443      * desired place.
   444      *
   445      * @return true if this link is linkable and false if we can't link to the
   446      * desired place.
   447      */
   448     public boolean isLinkable() {
   449         return Util.isLinkable(classDoc, ConfigurationImpl.getInstance());
   450     }
   451 }

mercurial