?? todotaglet.java
字號:
package jodd.taglet;import java.util.Map;import com.sun.javadoc.Tag;import com.sun.tools.doclets.Taglet;/** * A sample To Do Taglet. This tag can be used in any kind of {@link * com.sun.javadoc.Doc}. It is not an inline tag. Every generated html text * element has its own CSS "to do" class. */public class ToDoTaglet implements Taglet { private static final String NAME = "2do"; private static final String HEADER = "To Do:"; private static final String CSS_CLASS = "todo"; /** * Return the name of this custom tag. */ public String getName() { return NAME; } /** * Will return true since <code>@2do</code> can be used in field * documentation. * * @return true since <code>@2do</code> can be used in field documentation and false * otherwise. */ public boolean inField() { return true; } /** * Will return true since <code>@2do</code> can be used in constructor * documentation. * * @return true since <code>@2do</code> can be used in constructor documentation and * false otherwise. */ public boolean inConstructor() { return true; } /** * Will return true since <code>@2do</code> can be used in method * documentation. * * @return true since <code>@2do</code> can be used in method documentation and * false otherwise. */ public boolean inMethod() { return true; } /** * Will return true since <code>@2do</code> can be used in method * documentation. * * @return true since <code>@2do</code> can be used in overview documentation and * false otherwise. */ public boolean inOverview() { return true; } /** * Will return true since <code>@2do</code> can be used in package * documentation. * * @return true since <code>@2do</code> can be used in package documentation and * false otherwise. */ public boolean inPackage() { return true; } /** * Will return true since <code>@2do</code> can be used in type * documentation (classes or interfaces). * * @return true since <code>@2do</code> can be used in type documentation and false * otherwise. */ public boolean inType() { return true; } /** * Will return false since <code>@2do</code> is not an inline tag. * * @return false since <code>@2do</code> is not an inline tag. */ public boolean isInlineTag() { return false; } /** * Register this Taglet. * * @param tagletMap the map to register this tag to. */ public static void register(Map tagletMap) { ToDoTaglet tag = new ToDoTaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } /** * Given the <code>Tag</code> representation of this custom tag, return its * string representation. * * @param tag the <code>Tag</code> representation of this custom tag. */ public String toString(Tag tag) { return getString(tag.text()); } /** * Given an array of <code>Tag</code>s representing this custom tag, return * its string representation. * * @param tags the array of <code>Tag</code>s representing of this custom tag. */ public String toString(Tag[] tags) { if (tags.length == 0) { return null; } String result = new String(); for (int i = 0; i < tags.length; i++) { if (i > 0) { result += "</dd>\n<dd class=\"" + CSS_CLASS + "\">"; } result += tags[i].text(); } return getString(result); } /** * Formats the output. * * @param tagtext */ private String getString(String tagtext) { String result = "\n<dt class=\"" + CSS_CLASS + "\">" + HEADER; result += "<dd class=\"" + CSS_CLASS + "\">"; result += "<span class=\"" + CSS_CLASS + "\">"; result += tagtext; result += "</span></dd></dt>\n"; return result; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -