test/com/sun/javadoc/testLegacyTaglet/Check.java

changeset 1996
7a2fe98cb0e6
child 2147
130b8c0e570e
equal deleted inserted replaced
1995:dd64288f5659 1996:7a2fe98cb0e6
1 /*
2 * Copyright (c) 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import com.sun.tools.doclets.Taglet;
25 import com.sun.javadoc.*;
26 import java.util.Map;
27
28 public class Check implements Taglet {
29
30 private static final String TAG_NAME = "check";
31 private static final String TAG_HEADER = "Check:";
32
33 /**
34 * Return true since the tag can be used in package documentation.
35 *
36 * @return true since the tag can be used in package documentation.
37 */
38 public boolean inPackage() {
39 return true;
40 }
41
42 /**
43 * Return true since the tag can be used in overview documentation.
44 *
45 * @return true since the tag can be used in overview documentation.
46 */
47 public boolean inOverview() {
48 return true;
49 }
50
51 /**
52 * Return true since the tag can be used in type (class/interface)
53 * documentation.
54 *
55 * @return true since the tag can be used in type (class/interface)
56 * documentation.
57 */
58 public boolean inType() {
59 return true;
60 }
61
62 /**
63 * Return true since the tag can be used in constructor documentation.
64 *
65 * @return true since the tag can be used in constructor documentation.
66 */
67 public boolean inConstructor() {
68 return true;
69 }
70
71 /**
72 * Return true since the tag can be used in field documentation.
73 *
74 * @return true since the tag can be used in field documentation.
75 */
76 public boolean inField() {
77 return true;
78 }
79
80 /**
81 * Return true since the tag can be used in method documentation.
82 *
83 * @return true since the tag can be used in method documentation.
84 */
85 public boolean inMethod() {
86 return true;
87 }
88
89 /**
90 * Return false since the tag is not an inline tag.
91 *
92 * @return false since the tag is not an inline tag.
93 */
94 public boolean isInlineTag() {
95 return false;
96 }
97
98 /**
99 * Register this taglet.
100 *
101 * @param tagletMap the map to register this tag to.
102 */
103 @SuppressWarnings("unchecked")
104 public static void register(Map tagletMap) {
105 Check tag = new Check();
106 Taglet t = (Taglet) tagletMap.get(tag.getName());
107 if (t != null) {
108 tagletMap.remove(tag.getName());
109 }
110 tagletMap.put(tag.getName(), tag);
111 }
112
113 /**
114 * Return the name of this custom tag.
115 *
116 * @return the name of this tag.
117 */
118 public String getName() {
119 return TAG_NAME;
120 }
121
122 /**
123 * Given the tag representation of this custom tag, return its string
124 * representation.
125 *
126 * @param tag the tag representation of this custom tag.
127 */
128 public String toString(Tag tag) {
129 return "<dt><span class=\"strong\">" + TAG_HEADER + ":</span></dt><dd>" + tag.text() +
130 "</dd>\n";
131 }
132
133 /**
134 * Given an array of tags representing this custom tag, return its string
135 * representation.
136 *
137 * @param tags the array of tags representing of this custom tag.
138 * @return null to test if the javadoc throws an exception or not.
139 */
140 public String toString(Tag[] tags) {
141 return null;
142 }
143 }

mercurial