langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java
author chegar
Sun, 17 Aug 2014 15:52:32 +0100
changeset 25874 83c19f00452c
parent 17574 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java@044c7e1e4d53
child 38617 d93a7f64e231
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 5520
diff changeset
     2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.internal.toolkit.taglets;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.javadoc.*;
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17566
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.Content;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * The interface for a custom tag used by Doclets. A custom
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * tag must implement this interface.  To be loaded and used by
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * doclets at run-time, the taglet must have a static method called
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * <code>register</code> that accepts a {@link java.util.Map} as an
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * argument with the following signature:
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *   public void register(Map map)
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * This method should add an instance of the custom taglet to the map
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * with the name of the taglet as the key.  If overriding a taglet,
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * to avoid a name conflict, the overridden taglet must be deleted from
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * the map before an instance of the new taglet is added to the map.
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * It is recommended that the taglet throw an exception when it fails
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * to register itself.  The exception that it throws is up to the user.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * Here are two sample taglets: <br>
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 *     <li><a href="{@docRoot}/ToDoTaglet.java">ToDoTaglet.java</a>
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 *         - Standalone taglet</li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 *     <li><a href="{@docRoot}/UnderlineTaglet.java">UnderlineTaglet.java</a>
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 *         - Inline taglet</li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * For more information on how to create your own Taglets, please see the
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * <a href="{@docRoot}/overview.html">Taglet Overview</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * @since 1.4
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
public interface Taglet {
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * Return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * is used in field documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * @return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * is used in field documentation and false
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    public abstract boolean inField();
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * Return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * is used in constructor documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * @return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * is used in constructor documentation and false
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public abstract boolean inConstructor();
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * Return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     * is used in method documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * @return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     * is used in method documentation and false
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    public abstract boolean inMethod();
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * Return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * is used in overview documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * @return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * is used in method documentation and false
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    public abstract boolean inOverview();
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * Return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * is used in package documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * @return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * is used in package documentation and false
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    public abstract boolean inPackage();
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * Return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * is used in type documentation (classes or
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * interfaces).
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * @return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * is used in type documentation and false
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    public abstract boolean inType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * Return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * is an inline tag. Return false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * @return true if this <code>Taglet</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * is an inline tag and false otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    public abstract boolean isInlineTag();
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * Return the name of this custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * @return the name of this custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    public abstract String getName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * Given the <code>Tag</code> representation of this custom
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17566
diff changeset
   136
     * tag, return its Content representation, which is output
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * to the generated page.
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     * @param tag the <code>Tag</code> representation of this custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * @param writer a {@link TagletWriter} Taglet writer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17566
diff changeset
   141
     * @return the Content representation of this <code>Tag</code>.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17566
diff changeset
   143
    public abstract Content getTagletOutput(Tag tag, TagletWriter writer) throws IllegalArgumentException;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     * Given a <code>Doc</code> object, check if it holds any tags of
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     * this type.  If it does, return the string representing the output.
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     * If it does not, return null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     * @param holder a {@link Doc} object holding the custom tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     * @param writer a {@link TagletWriter} Taglet writer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * @throws IllegalArgumentException thrown when the method is not supported by the taglet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     * @return the TagletOutput representation of this <code>Tag</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     */
17574
044c7e1e4d53 8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents: 17566
diff changeset
   154
    public abstract Content getTagletOutput(Doc holder, TagletWriter writer) throws IllegalArgumentException;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
17566
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 5520
diff changeset
   156
    @Override
7e1a338e1085 8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents: 5520
diff changeset
   157
    public abstract String toString();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
}