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

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

     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  */
    26 package com.sun.tools.doclets.internal.toolkit.taglets;
    28 import com.sun.javadoc.*;
    29 import com.sun.tools.doclets.internal.toolkit.Content;
    31 /**
    32  * The interface for a custom tag used by Doclets. A custom
    33  * tag must implement this interface.  To be loaded and used by
    34  * doclets at run-time, the taglet must have a static method called
    35  * <code>register</code> that accepts a {@link java.util.Map} as an
    36  * argument with the following signature:
    37  * <pre>
    38  *   public void register(Map map)
    39  * </pre>
    40  * This method should add an instance of the custom taglet to the map
    41  * with the name of the taglet as the key.  If overriding a taglet,
    42  * to avoid a name conflict, the overridden taglet must be deleted from
    43  * the map before an instance of the new taglet is added to the map.
    44  * <p>
    45  * It is recommended that the taglet throw an exception when it fails
    46  * to register itself.  The exception that it throws is up to the user.
    47  * <p>
    48  * Here are two sample taglets: <br>
    49  * <ul>
    50  *     <li><a href="{@docRoot}/ToDoTaglet.java">ToDoTaglet.java</a>
    51  *         - Standalone taglet</li>
    52  *     <li><a href="{@docRoot}/UnderlineTaglet.java">UnderlineTaglet.java</a>
    53  *         - Inline taglet</li>
    54  * </ul>
    55  * <p>
    56  * For more information on how to create your own Taglets, please see the
    57  * <a href="{@docRoot}/overview.html">Taglet Overview</a>.
    58  *
    59  * @since 1.4
    60  * @author Jamie Ho
    61  */
    63 public interface Taglet {
    65     /**
    66      * Return true if this <code>Taglet</code>
    67      * is used in field documentation.
    68      * @return true if this <code>Taglet</code>
    69      * is used in field documentation and false
    70      * otherwise.
    71      */
    72     public abstract boolean inField();
    74     /**
    75      * Return true if this <code>Taglet</code>
    76      * is used in constructor documentation.
    77      * @return true if this <code>Taglet</code>
    78      * is used in constructor documentation and false
    79      * otherwise.
    80      */
    81     public abstract boolean inConstructor();
    83     /**
    84      * Return true if this <code>Taglet</code>
    85      * is used in method documentation.
    86      * @return true if this <code>Taglet</code>
    87      * is used in method documentation and false
    88      * otherwise.
    89      */
    90     public abstract boolean inMethod();
    92     /**
    93      * Return true if this <code>Taglet</code>
    94      * is used in overview documentation.
    95      * @return true if this <code>Taglet</code>
    96      * is used in method documentation and false
    97      * otherwise.
    98      */
    99     public abstract boolean inOverview();
   101     /**
   102      * Return true if this <code>Taglet</code>
   103      * is used in package documentation.
   104      * @return true if this <code>Taglet</code>
   105      * is used in package documentation and false
   106      * otherwise.
   107      */
   108     public abstract boolean inPackage();
   110     /**
   111      * Return true if this <code>Taglet</code>
   112      * is used in type documentation (classes or
   113      * interfaces).
   114      * @return true if this <code>Taglet</code>
   115      * is used in type documentation and false
   116      * otherwise.
   117      */
   118     public abstract boolean inType();
   120     /**
   121      * Return true if this <code>Taglet</code>
   122      * is an inline tag. Return false otherwise.
   123      * @return true if this <code>Taglet</code>
   124      * is an inline tag and false otherwise.
   125      */
   126     public abstract boolean isInlineTag();
   128     /**
   129      * Return the name of this custom tag.
   130      * @return the name of this custom tag.
   131      */
   132     public abstract String getName();
   134     /**
   135      * Given the <code>Tag</code> representation of this custom
   136      * tag, return its Content representation, which is output
   137      * to the generated page.
   138      * @param tag the <code>Tag</code> representation of this custom tag.
   139      * @param writer a {@link TagletWriter} Taglet writer.
   140      * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
   141      * @return the Content representation of this <code>Tag</code>.
   142      */
   143     public abstract Content getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException;
   145     /**
   146      * Given a <code>Doc</code> object, check if it holds any tags of
   147      * this type.  If it does, return the string representing the output.
   148      * If it does not, return null.
   149      * @param holder a {@link Doc} object holding the custom tag.
   150      * @param writer a {@link TagletWriter} Taglet writer.
   151      * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
   152      * @return the TagletOutput representation of this <code>Tag</code>.
   153      */
   154     public abstract Content getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException;
   156     @Override
   157     public abstract String toString();
   158 }

mercurial