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