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

Sun, 24 Feb 2013 11:36:58 -0800

author
jjg
date
Sun, 24 Feb 2013 11:36:58 -0800
changeset 1606
ccbe7ffdd867
parent 1521
71f35e4b93a5
child 1735
8ea30d59ac41
permissions
-rw-r--r--

7112427: The doclet needs to be able to generate JavaFX documentation.
Reviewed-by: jjg
Contributed-by: jan.valenta@oracle.com

     1 /*
     2  * Copyright (c) 2003, 2013, 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 header for property documentation copied from parent.
   203      */
   204     public static final int CONTEXT_PROPERTY_DOC_COPY = 34;
   206     public final ConfigurationImpl configuration;
   208     /**
   209      * The integer indicating the location of the link.
   210      */
   211     public int context;
   213     /**
   214      * The value of the marker #.
   215      */
   216     public String where = "";
   218     /**
   219      * String style of text defined in style sheet.
   220      */
   221     public String styleName ="";
   223     /**
   224      * The value of the target.
   225      */
   226     public String target = "";
   228     /**
   229      * Construct a LinkInfo object.
   230      *
   231      * @param configuration the configuration data for the doclet
   232      * @param context    the context of the link.
   233      * @param classDoc   the class to link to.
   234      * @param label      the label for the link.
   235      * @param target     the value of the target attribute.
   236      */
   237     public LinkInfoImpl(ConfigurationImpl configuration,
   238             int context, ClassDoc classDoc, String label, String target) {
   239         this.configuration = configuration;
   240         this.classDoc = classDoc;
   241         this.label = label;
   242         this.target = target;
   243         setContext(context);
   244     }
   246     /**
   247      * Construct a LinkInfo object.
   248      *
   249      * @param configuration the configuration data for the doclet
   250      * @param context    the context of the link.
   251      * @param classDoc   the class to link to.
   252      * @param where      the value of the marker #.
   253      * @param label      the label for the link.
   254      * @param isStrong       true if the link should be strong.
   255      * @param styleName  String style of text defined in style sheet.
   256      */
   257     public LinkInfoImpl(ConfigurationImpl configuration,
   258             int context, ClassDoc classDoc, String where, String label,
   259             boolean isStrong, String styleName) {
   260         this.configuration = configuration;
   261         this.classDoc = classDoc;
   262         this.where = where;
   263         this.label = label;
   264         this.isStrong = isStrong;
   265         this.styleName = styleName;
   266         setContext(context);
   267     }
   269     /**
   270      * Construct a LinkInfo object.
   271      *
   272      * @param configuration the configuration data for the doclet
   273      * @param context    the context of the link.
   274      * @param classDoc   the class to link to.
   275      * @param where      the value of the marker #.
   276      * @param label      the label for the link.
   277      * @param isStrong       true if the link should be strong.
   278      */
   279     public LinkInfoImpl(ConfigurationImpl configuration,
   280             int context, ClassDoc classDoc, String where, String label,
   281             boolean isStrong) {
   282         this.configuration = configuration;
   283         this.classDoc = classDoc;
   284         this.where = where;
   285         this.label = label;
   286         this.isStrong = isStrong;
   287         setContext(context);
   288     }
   290     /**
   291      * Construct a LinkInfo object.
   292      *
   293      * @param configuration the configuration data for the doclet
   294      * @param classDoc   the class to link to.
   295      * @param label      the label for the link.
   296      */
   297     public LinkInfoImpl(ConfigurationImpl configuration,
   298             ClassDoc classDoc, String label) {
   299         this.configuration = configuration;
   300         this.classDoc = classDoc;
   301         this.label = label;
   302         setContext(context);
   303     }
   305     /**
   306      * Construct a LinkInfo object.
   307      *
   308      * @param configuration the configuration data for the doclet
   309      * @param context               the context of the link.
   310      * @param executableMemberDoc   the member to link to.
   311      * @param isStrong                true if the link should be strong.
   312      */
   313     public LinkInfoImpl(ConfigurationImpl configuration,
   314             int context, ExecutableMemberDoc executableMemberDoc,
   315             boolean isStrong) {
   316         this.configuration = configuration;
   317         this.executableMemberDoc = executableMemberDoc;
   318         this.isStrong = isStrong;
   319         setContext(context);
   320     }
   322     /**
   323      * Construct a LinkInfo object.
   324      *
   325      * @param configuration the configuration data for the doclet
   326      * @param context    the context of the link.
   327      * @param classDoc   the class to link to.
   328      * @param isStrong       true if the link should be strong.
   329      */
   330     public LinkInfoImpl(ConfigurationImpl configuration,
   331             int context, ClassDoc classDoc,  boolean isStrong) {
   332         this.configuration = configuration;
   333         this.classDoc = classDoc;
   334         this.isStrong = isStrong;
   335         setContext(context);
   336     }
   338     /**
   339      * Construct a LinkInfo object.
   340      *
   341      * @param configuration the configuration data for the doclet
   342      * @param context    the context of the link.
   343      * @param type       the class to link to.
   344      */
   345     public LinkInfoImpl(ConfigurationImpl configuration,
   346             int context, Type type) {
   347         this.configuration = configuration;
   348         this.type = type;
   349         setContext(context);
   350     }
   352     /**
   353      * Construct a LinkInfo object.
   354      *
   355      * @param configuration the configuration data for the doclet
   356      * @param context    the context of the link.
   357      * @param type       the class to link to.
   358      * @param isVarArg   true if this is a link to a var arg.
   359      */
   360     public LinkInfoImpl(ConfigurationImpl configuration,
   361             int context, Type type, boolean isVarArg) {
   362         this.configuration = configuration;
   363         this.type = type;
   364         this.isVarArg = isVarArg;
   365         setContext(context);
   366     }
   368     /**
   369      * Construct a LinkInfo object.
   370      *
   371      * @param configuration the configuration data for the doclet
   372      * @param context    the context of the link.
   373      * @param type       the class to link to.
   374      * @param label      the label for the link.
   375      * @param isStrong     true if the link should be strong.
   376      */
   377     public LinkInfoImpl(ConfigurationImpl configuration,
   378             int context, Type type, String label,
   379             boolean isStrong) {
   380         this.configuration = configuration;
   381         this.type = type;
   382         this.label = label;
   383         this.isStrong = isStrong;
   384         setContext(context);
   385     }
   387     /**
   388      * Construct a LinkInfo object.
   389      *
   390      * @param configuration the configuration data for the doclet
   391      * @param context    the context of the link.
   392      * @param classDoc   the class to link to.
   393      * @param label      the label for the link.
   394      * @param isStrong       true if the link should be strong.
   395      */
   396     public LinkInfoImpl(ConfigurationImpl configuration,
   397             int context, ClassDoc classDoc, String label,
   398             boolean isStrong) {
   399         this.configuration = configuration;
   400         this.classDoc = classDoc;
   401         this.label = label;
   402         this.isStrong = isStrong;
   403         setContext(context);
   404     }
   406     /**
   407      * {@inheritDoc}
   408      */
   409     public int getContext() {
   410         return context;
   411     }
   413     /**
   414      * {@inheritDoc}
   415      *
   416      * This method sets the link attributes to the appropriate values
   417      * based on the context.
   418      *
   419      * @param c the context id to set.
   420      */
   421     public void setContext(int c) {
   422         //NOTE:  Put context specific link code here.
   423         switch (c) {
   424             case ALL_CLASSES_FRAME:
   425             case PACKAGE_FRAME:
   426             case CONTEXT_IMPLEMENTED_CLASSES:
   427             case CONTEXT_SUBCLASSES:
   428             case CONTEXT_METHOD_DOC_COPY:
   429             case CONTEXT_FIELD_DOC_COPY:
   430             case CONTEXT_PROPERTY_DOC_COPY:
   431             case CONTEXT_CLASS_USE_HEADER:
   432                 includeTypeInClassLinkLabel = false;
   433                 break;
   435             case CONTEXT_ANNOTATION:
   436                 excludeTypeParameterLinks = true;
   437                 excludeTypeBounds = true;
   438                 break;
   440             case CONTEXT_IMPLEMENTED_INTERFACES:
   441             case CONTEXT_SUPER_INTERFACES:
   442             case CONTEXT_SUBINTERFACES:
   443             case CONTEXT_CLASS_TREE_PARENT:
   444             case CONTEXT_TREE:
   445             case CONTEXT_CLASS_SIGNATURE_PARENT_NAME:
   446                 excludeTypeParameterLinks = true;
   447                 excludeTypeBounds = true;
   448                 includeTypeInClassLinkLabel = false;
   449                 includeTypeAsSepLink = true;
   450                 break;
   452             case CONTEXT_PACKAGE:
   453             case CONTEXT_CLASS_USE:
   454             case CONTEXT_CLASS_HEADER:
   455             case CONTEXT_CLASS_SIGNATURE:
   456                 excludeTypeParameterLinks = true;
   457                 includeTypeAsSepLink = true;
   458                 includeTypeInClassLinkLabel = false;
   459                 break;
   461             case CONTEXT_MEMBER_TYPE_PARAMS:
   462                 includeTypeAsSepLink = true;
   463                 includeTypeInClassLinkLabel = false;
   464                 break;
   466             case CONTEXT_RETURN_TYPE:
   467             case CONTEXT_SUMMARY_RETURN_TYPE:
   468                 excludeTypeBounds = true;
   469                 break;
   470             case CONTEXT_EXECUTABLE_MEMBER_PARAM:
   471                 excludeTypeBounds = true;
   472                 break;
   473         }
   474         context = c;
   475         if (type != null &&
   476             type.asTypeVariable()!= null &&
   477             type.asTypeVariable().owner() instanceof ExecutableMemberDoc){
   478             excludeTypeParameterLinks = true;
   479         }
   480     }
   482     /**
   483      * Return true if this link is linkable and false if we can't link to the
   484      * desired place.
   485      *
   486      * @return true if this link is linkable and false if we can't link to the
   487      * desired place.
   488      */
   489     public boolean isLinkable() {
   490         return Util.isLinkable(classDoc, configuration);
   491     }
   492 }

mercurial