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