KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > doclet > NoosphereTaglet


1 package JSci.doclet;
2
3 import com.sun.tools.doclets.*;
4 import com.sun.javadoc.*;
5 import java.util.Map JavaDoc;
6
7 public class NoosphereTaglet implements Taglet {
8         private final String JavaDoc name;
9     private final String JavaDoc desc;
10
11     protected static void register(Map JavaDoc taglets, Taglet taglet) {
12         String JavaDoc name = taglet.getName();
13                 Taglet old = (Taglet) taglets.get(name);
14                 if(old != null)
15                         taglets.remove(name);
16                 taglets.put(name, taglet);
17     }
18
19     public NoosphereTaglet(String JavaDoc name, String JavaDoc desc) {
20         this.name = name;
21         this.desc = desc;
22     }
23         public String JavaDoc getName() {
24                 return name;
25         }
26         public boolean inConstructor() {
27                 return true;
28         }
29         public boolean inField() {
30                 return true;
31         }
32         public boolean inMethod() {
33                 return true;
34         }
35         public boolean inOverview() {
36                 return true;
37         }
38         public boolean inPackage() {
39                 return true;
40         }
41         public boolean inType() {
42                 return true;
43         }
44         public boolean isInlineTag() {
45                 return false;
46         }
47         public String JavaDoc toString(Tag tag) {
48                 return "<dt><b>"+desc+" references:</b></dt><dd>"+createPMlink(tag.text())+"</dd>";
49         }
50         public String JavaDoc toString(Tag[] tags) {
51                 if(tags.length == 0)
52                         return null;
53
54                 StringBuffer JavaDoc buf = new StringBuffer JavaDoc("<dt><b>"+desc+" references:</b></dt><dd>");
55                 for(int i=0; i<tags.length; i++) {
56                         if(i > 0)
57                                 buf.append(", ");
58                         buf.append(createPMlink(tags[i].text()));
59                 }
60                 return buf.append("</dd>").toString();
61         }
62         private String JavaDoc createPMlink(String JavaDoc cname) {
63         if(cname.indexOf(' ') != -1)
64             throw new IllegalArgumentException JavaDoc("Invalid canonical name: "+cname);
65         String JavaDoc host = desc+".org";
66                 return "<a HREF=\"http://"+host+"/?op=getobj&from=objects&name="+cname+"\">"+cname+"</a>";
67         }
68 }
69
Popular Tags