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

Tue, 25 May 2010 15:54:51 -0700

author
ohair
date
Tue, 25 May 2010 15:54:51 -0700
changeset 554
9d9f26857129
parent 1
9a66ca7c79fa
child 1359
25e14ad23cef
permissions
-rw-r--r--

6943119: Rebrand source copyright notices
Reviewed-by: darcy

     1 /*
     2  * Copyright (c) 2001, 2003, 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  * This code is not part of an API.
    34  * It is implementation that is subject to change.
    35  * Do not use it as an API
    36  *
    37  * @author Jamie Ho
    38  */
    40 public class SimpleTaglet extends BaseTaglet {
    42     /**
    43      * The marker in the location string for excluded tags.
    44      */
    45     public static final String EXCLUDED = "x";
    47     /**
    48      * The marker in the location string for packages.
    49      */
    50     public static final String PACKAGE = "p";
    52     /**
    53      * The marker in the location string for types.
    54      */
    55     public static final String TYPE = "t";
    57     /**
    58      * The marker in the location string for constructors.
    59      */
    60     public static final String CONSTRUCTOR = "c";
    62     /**
    63      * The marker in the location string for fields.
    64      */
    65     public static final String FIELD = "f";
    67     /**
    68      * The marker in the location string for methods.
    69      */
    70     public static final String METHOD = "m";
    72     /**
    73      * The marker in the location string for overview.
    74      */
    75     public static final String OVERVIEW = "o";
    77     /**
    78      * Use in location string when the tag is to
    79      * appear in all locations.
    80      */
    81     public static final String ALL = "a";
    83     /**
    84      * The name of this tag.
    85      */
    86     protected String tagName;
    88     /**
    89      * The header to output.
    90      */
    91     protected String header;
    93     /**
    94      * The possible locations that this tag can appear in.
    95      */
    96     protected String locations;
    98     /**
    99      * Construct a <code>SimpleTaglet</code>.
   100      * @param tagName the name of this tag
   101      * @param header the header to output.
   102      * @param locations the possible locations that this tag
   103      * can appear in.  The <code>String</code> can contain 'p'
   104      * for package, 't' for type, 'm' for method, 'c' for constructor
   105      * and 'f' for field.
   106      */
   107     public SimpleTaglet(String tagName, String header, String locations) {
   108         this.tagName = tagName;
   109         this.header = header;
   110         locations = locations.toLowerCase();
   111         if (locations.indexOf(ALL) != -1 && locations.indexOf(EXCLUDED) == -1) {
   112             this.locations = PACKAGE + TYPE + FIELD + METHOD + CONSTRUCTOR + OVERVIEW;
   113         } else {
   114             this.locations = locations;
   115         }
   116     }
   118     /**
   119      * Return the name of this <code>Taglet</code>.
   120      */
   121     public String getName() {
   122         return tagName;
   123     }
   125     /**
   126      * Return true if this <code>SimpleTaglet</code>
   127      * is used in constructor documentation.
   128      * @return true if this <code>SimpleTaglet</code>
   129      * is used in constructor documentation and false
   130      * otherwise.
   131      */
   132     public boolean inConstructor() {
   133         return locations.indexOf(CONSTRUCTOR) != -1 && locations.indexOf(EXCLUDED) == -1;
   134     }
   136     /**
   137      * Return true if this <code>SimpleTaglet</code>
   138      * is used in field documentation.
   139      * @return true if this <code>SimpleTaglet</code>
   140      * is used in field documentation and false
   141      * otherwise.
   142      */
   143     public boolean inField() {
   144         return locations.indexOf(FIELD) != -1 && locations.indexOf(EXCLUDED) == -1;
   145     }
   147     /**
   148      * Return true if this <code>SimpleTaglet</code>
   149      * is used in method documentation.
   150      * @return true if this <code>SimpleTaglet</code>
   151      * is used in method documentation and false
   152      * otherwise.
   153      */
   154     public boolean inMethod() {
   155         return locations.indexOf(METHOD) != -1 && locations.indexOf(EXCLUDED) == -1;
   156     }
   158     /**
   159      * Return true if this <code>SimpleTaglet</code>
   160      * is used in overview documentation.
   161      * @return true if this <code>SimpleTaglet</code>
   162      * is used in overview documentation and false
   163      * otherwise.
   164      */
   165     public boolean inOverview() {
   166         return locations.indexOf(OVERVIEW) != -1 && locations.indexOf(EXCLUDED) == -1;
   167     }
   169     /**
   170      * Return true if this <code>SimpleTaglet</code>
   171      * is used in package documentation.
   172      * @return true if this <code>SimpleTaglet</code>
   173      * is used in package documentation and false
   174      * otherwise.
   175      */
   176     public boolean inPackage() {
   177         return locations.indexOf(PACKAGE) != -1 && locations.indexOf(EXCLUDED) == -1;
   178     }
   180     /**
   181      * Return true if this <code>SimpleTaglet</code>
   182      * is used in type documentation (classes or interfaces).
   183      * @return true if this <code>SimpleTaglet</code>
   184      * is used in type documentation and false
   185      * otherwise.
   186      */
   187     public boolean inType() {
   188         return locations.indexOf(TYPE) != -1&& locations.indexOf(EXCLUDED) == -1;
   189     }
   191     /**
   192      * Return true if this <code>Taglet</code>
   193      * is an inline tag.
   194      * @return true if this <code>Taglet</code>
   195      * is an inline tag and false otherwise.
   196      */
   197     public boolean isInlineTag() {
   198         return false;
   199     }
   201     /**
   202      * {@inheritDoc}
   203      */
   204     public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
   205         return header == null || tag == null ? null : writer.simpleTagOutput(tag, header);
   206     }
   208     /**
   209      * {@inheritDoc}
   210      */
   211     public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
   212         if (header == null || holder.tags(getName()).length == 0) {
   213             return null;
   214         }
   215         return writer.simpleTagOutput(holder.tags(getName()), header);
   216     }
   217 }

mercurial