1 /* |
|
2 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or |
|
5 * without modification, are permitted provided that the following |
|
6 * conditions are met: |
|
7 * |
|
8 * -Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * |
|
11 * -Redistribution in binary form must reproduce the above copyright |
|
12 * notice, this list of conditions and the following disclaimer in |
|
13 * the documentation and/or other materials provided with the |
|
14 * distribution. |
|
15 * |
|
16 * Neither the name of Oracle nor the names of |
|
17 * contributors may be used to endorse or promote products derived |
|
18 * from this software without specific prior written permission. |
|
19 * |
|
20 * This software is provided "AS IS," without a warranty of any |
|
21 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND |
|
22 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, |
|
23 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY |
|
24 * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY |
|
25 * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR |
|
26 * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR |
|
27 * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE |
|
28 * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, |
|
29 * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER |
|
30 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF |
|
31 * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN |
|
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
|
33 * |
|
34 * You acknowledge that Software is not designed, licensed or |
|
35 * intended for use in the design, construction, operation or |
|
36 * maintenance of any nuclear facility. |
|
37 */ |
|
38 |
|
39 import com.sun.tools.doclets.Taglet; |
|
40 import com.sun.javadoc.*; |
|
41 import java.util.Map; |
|
42 |
|
43 /** |
|
44 * A sample Inline Taglet representing {@underline ...}. This tag can |
|
45 * be used in any kind of {@link com.sun.javadoc.Doc}. |
|
46 * The text is underlined. For example, |
|
47 * "@underline UNDERLINE ME" would be shown as: <u>UNDERLINE ME</u>. |
|
48 * |
|
49 * @author Jamie Ho |
|
50 * @since 1.4 |
|
51 */ |
|
52 |
|
53 public class UnderlineTaglet implements Taglet { |
|
54 |
|
55 private static final String NAME = "underline"; |
|
56 |
|
57 /** |
|
58 * Return the name of this custom tag. |
|
59 */ |
|
60 public String getName() { |
|
61 return NAME; |
|
62 } |
|
63 |
|
64 /** |
|
65 * @return true since this tag can be used in a field |
|
66 * doc comment |
|
67 */ |
|
68 public boolean inField() { |
|
69 return true; |
|
70 } |
|
71 |
|
72 /** |
|
73 * @return true since this tag can be used in a constructor |
|
74 * doc comment |
|
75 */ |
|
76 public boolean inConstructor() { |
|
77 return true; |
|
78 } |
|
79 |
|
80 /** |
|
81 * @return true since this tag can be used in a method |
|
82 * doc comment |
|
83 */ |
|
84 public boolean inMethod() { |
|
85 return true; |
|
86 } |
|
87 |
|
88 /** |
|
89 * @return true since this tag can be used in an overview |
|
90 * doc comment |
|
91 */ |
|
92 public boolean inOverview() { |
|
93 return true; |
|
94 } |
|
95 |
|
96 /** |
|
97 * @return true since this tag can be used in a package |
|
98 * doc comment |
|
99 */ |
|
100 public boolean inPackage() { |
|
101 return true; |
|
102 } |
|
103 |
|
104 /** |
|
105 * @return true since this |
|
106 */ |
|
107 public boolean inType() { |
|
108 return true; |
|
109 } |
|
110 |
|
111 /** |
|
112 * Will return true since this is an inline tag. |
|
113 * @return true since this is an inline tag. |
|
114 */ |
|
115 |
|
116 public boolean isInlineTag() { |
|
117 return true; |
|
118 } |
|
119 |
|
120 /** |
|
121 * Register this Taglet. |
|
122 * @param tagletMap the map to register this tag to. |
|
123 */ |
|
124 public static void register(Map tagletMap) { |
|
125 UnderlineTaglet tag = new UnderlineTaglet(); |
|
126 Taglet t = (Taglet) tagletMap.get(tag.getName()); |
|
127 if (t != null) { |
|
128 tagletMap.remove(tag.getName()); |
|
129 } |
|
130 tagletMap.put(tag.getName(), tag); |
|
131 } |
|
132 |
|
133 /** |
|
134 * Given the <code>Tag</code> representation of this custom |
|
135 * tag, return its string representation. |
|
136 * @param tag he <code>Tag</code> representation of this custom tag. |
|
137 */ |
|
138 public String toString(Tag tag) { |
|
139 return "<u>" + tag.text() + "</u>"; |
|
140 } |
|
141 |
|
142 /** |
|
143 * This method should not be called since arrays of inline tags do not |
|
144 * exist. Method {@link #tostring(Tag)} should be used to convert this |
|
145 * inline tag to a string. |
|
146 * @param tags the array of <code>Tag</code>s representing of this custom tag. |
|
147 */ |
|
148 public String toString(Tag[] tags) { |
|
149 return null; |
|
150 } |
|
151 } |
|
152 |
|