1 package JSci.doclet; 2 3 import com.sun.tools.doclets.*; 4 import com.sun.javadoc.*; 5 import java.util.Map ; 6 7 public class NoosphereTaglet implements Taglet { 8 private final String name; 9 private final String desc; 10 11 protected static void register(Map taglets, Taglet taglet) { 12 String 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 name, String desc) { 20 this.name = name; 21 this.desc = desc; 22 } 23 public String 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 toString(Tag tag) { 48 return "<dt><b>"+desc+" references:</b></dt><dd>"+createPMlink(tag.text())+"</dd>"; 49 } 50 public String toString(Tag[] tags) { 51 if(tags.length == 0) 52 return null; 53 54 StringBuffer buf = new StringBuffer ("<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 createPMlink(String cname) { 63 if(cname.indexOf(' ') != -1) 64 throw new IllegalArgumentException ("Invalid canonical name: "+cname); 65 String host = desc+".org"; 66 return "<a HREF=\"http://"+host+"/?op=getobj&from=objects&name="+cname+"\">"+cname+"</a>"; 67 } 68 } 69 | Popular Tags |