src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java

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

author
jjg
date
Wed, 10 Oct 2012 16:48:21 -0700
changeset 1359
25e14ad23cef
parent 554
9d9f26857129
child 1724
d918b63a5509
permissions
-rw-r--r--

8000665: fix "internal API" comments on javadoc files
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 2001, 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  */
    26 package com.sun.tools.doclets.internal.toolkit.taglets;
    28 import com.sun.javadoc.*;
    30 /**
    31  * A simple single argument custom tag.
    32  *
    33  *  <p><b>This is NOT part of any supported API.
    34  *  If you write code that depends on this, you do so at your own risk.
    35  *  This code and its internal interfaces are subject to change or
    36  *  deletion without notice.</b>
    37  *
    38  * @author Jamie Ho
    39  */
    41 public class SimpleTaglet extends BaseTaglet {
    43     /**
    44      * The marker in the location string for excluded tags.
    45      */
    46     public static final String EXCLUDED = "x";
    48     /**
    49      * The marker in the location string for packages.
    50      */
    51     public static final String PACKAGE = "p";
    53     /**
    54      * The marker in the location string for types.
    55      */
    56     public static final String TYPE = "t";
    58     /**
    59      * The marker in the location string for constructors.
    60      */
    61     public static final String CONSTRUCTOR = "c";
    63     /**
    64      * The marker in the location string for fields.
    65      */
    66     public static final String FIELD = "f";
    68     /**
    69      * The marker in the location string for methods.
    70      */
    71     public static final String METHOD = "m";
    73     /**
    74      * The marker in the location string for overview.
    75      */
    76     public static final String OVERVIEW = "o";
    78     /**
    79      * Use in location string when the tag is to
    80      * appear in all locations.
    81      */
    82     public static final String ALL = "a";
    84     /**
    85      * The name of this tag.
    86      */
    87     protected String tagName;
    89     /**
    90      * The header to output.
    91      */
    92     protected String header;
    94     /**
    95      * The possible locations that this tag can appear in.
    96      */
    97     protected String locations;
    99     /**
   100      * Construct a <code>SimpleTaglet</code>.
   101      * @param tagName the name of this tag
   102      * @param header the header to output.
   103      * @param locations the possible locations that this tag
   104      * can appear in.  The <code>String</code> can contain 'p'
   105      * for package, 't' for type, 'm' for method, 'c' for constructor
   106      * and 'f' for field.
   107      */
   108     public SimpleTaglet(String tagName, String header, String locations) {
   109         this.tagName = tagName;
   110         this.header = header;
   111         locations = locations.toLowerCase();
   112         if (locations.indexOf(ALL) != -1 && locations.indexOf(EXCLUDED) == -1) {
   113             this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW;
   114         } else {
   115             this.locations = locations;
   116         }
   117     }
   119     /**
   120      * Return the name of this <code>Taglet</code>.
   121      */
   122     public String getName() {
   123         return tagName;
   124     }
   126     /**
   127      * Return true if this <code>SimpleTaglet</code>
   128      * is used in constructor documentation.
   129      * @return true if this <code>SimpleTaglet</code>
   130      * is used in constructor documentation and false
   131      * otherwise.
   132      */
   133     public boolean inConstructor() {
   134         return locations.indexOf(CONSTRUCTOR) != -1 && locations.indexOf(EXCLUDED) == -1;
   135     }
   137     /**
   138      * Return true if this <code>SimpleTaglet</code>
   139      * is used in field documentation.
   140      * @return true if this <code>SimpleTaglet</code>
   141      * is used in field documentation and false
   142      * otherwise.
   143      */
   144     public boolean inField() {
   145         return locations.indexOf(FIELD) != -1 && locations.indexOf(EXCLUDED) == -1;
   146     }
   148     /**
   149      * Return true if this <code>SimpleTaglet</code>
   150      * is used in method documentation.
   151      * @return true if this <code>SimpleTaglet</code>
   152      * is used in method documentation and false
   153      * otherwise.
   154      */
   155     public boolean inMethod() {
   156         return locations.indexOf(METHOD) != -1 && locations.indexOf(EXCLUDED) == -1;
   157     }
   159     /**
   160      * Return true if this <code>SimpleTaglet</code>
   161      * is used in overview documentation.
   162      * @return true if this <code>SimpleTaglet</code>
   163      * is used in overview documentation and false
   164      * otherwise.
   165      */
   166     public boolean inOverview() {
   167         return locations.indexOf(OVERVIEW) != -1 && locations.indexOf(EXCLUDED) == -1;
   168     }
   170     /**
   171      * Return true if this <code>SimpleTaglet</code>
   172      * is used in package documentation.
   173      * @return true if this <code>SimpleTaglet</code>
   174      * is used in package documentation and false
   175      * otherwise.
   176      */
   177     public boolean inPackage() {
   178         return locations.indexOf(PACKAGE) != -1 && locations.indexOf(EXCLUDED) == -1;
   179     }
   181     /**
   182      * Return true if this <code>SimpleTaglet</code>
   183      * is used in type documentation (classes or interfaces).
   184      * @return true if this <code>SimpleTaglet</code>
   185      * is used in type documentation and false
   186      * otherwise.
   187      */
   188     public boolean inType() {
   189         return locations.indexOf(TYPE) != -1&& locations.indexOf(EXCLUDED) == -1;
   190     }
   192     /**
   193      * Return true if this <code>Taglet</code>
   194      * is an inline tag.
   195      * @return true if this <code>Taglet</code>
   196      * is an inline tag and false otherwise.
   197      */
   198     public boolean isInlineTag() {
   199         return false;
   200     }
   202     /**
   203      * {@inheritDoc}
   204      */
   205     public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
   206         return header == null || tag == null ? null : writer.simpleTagOutput(tag, header);
   207     }
   209     /**
   210      * {@inheritDoc}
   211      */
   212     public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
   213         if (header == null || holder.tags(getName()).length == 0) {
   214             return null;
   215         }
   216         return writer.simpleTagOutput(holder.tags(getName()), header);
   217     }
   218 }

mercurial