1 26 import com.sun.tools.doclets.Taglet; 27 import com.sun.javadoc.*; 28 import java.util.Map ; 29 import org.htmlparser.util.Translate; 30 31 61 public class HtmlTaglet implements Taglet 62 { 63 private static final String NAME = ".html"; 64 65 68 public HtmlTaglet () 69 { 70 } 71 72 75 public String getName () 76 { 77 return (NAME); 78 } 79 80 86 public boolean inField () 87 { 88 return (true); 89 } 90 91 97 public boolean inConstructor () 98 { 99 return (true); 100 } 101 102 108 public boolean inMethod () 109 { 110 return (true); 111 } 112 113 119 public boolean inOverview () 120 { 121 return (true); 122 } 123 124 130 public boolean inPackage () 131 { 132 return (true); 133 } 134 135 141 public boolean inType () 142 { 143 return (true); 144 } 145 146 152 153 public boolean isInlineTag () 154 { 155 return (true); 156 } 157 158 162 public static void register (Map tagletMap) 163 { 164 HtmlTaglet tag = new HtmlTaglet (); 165 tagletMap.put (tag.getName (), tag); 166 } 167 168 176 protected String format (String s) 177 { 178 int base; 179 int offset; 180 StringBuffer ret; 181 182 ret = new StringBuffer (512); 183 184 base = 0; 185 offset = 0; 186 while (-1 != (offset = s.indexOf ('\n', base))) 187 { 188 ret.append (Translate.encode (s.substring (base, offset))); 189 ret.append ("<br>\n"); 190 base = offset + 1; 191 } 192 if (base != s.length ()) 193 ret.append (Translate.encode (s.substring (base))); 194 195 s = ret.toString (); 196 ret.setLength (0); 197 for (int i = 0; i < s.length (); i++) 198 if (' ' == s.charAt (i)) 199 ret.append (" "); 200 else 201 ret.append (s.charAt (i)); 202 203 return (ret.toString ()); 204 } 205 206 211 public String toString (Tag tag) 212 { 213 return (format (tag.text ())); 214 } 215 216 221 public String toString(Tag[] tags) 222 { 223 StringBuffer ret; 224 225 if (0 == tags.length) 226 return (null); 227 else 228 { 229 ret = new StringBuffer (512); 230 for (int i = 0; i < tags.length; i++) 231 { 232 if (i > 0) 233 ret.append ("<br>\n"); 234 ret.append (format (tags[i].text())); 235 } 236 return (ret.toString ()); 237 } 238 } 239 } | Popular Tags |