1 5 package xdoclet.modules.web; 6 7 import xdoclet.XDocletException; 8 import xdoclet.XDocletMessages; 9 10 import xdoclet.XmlSubTask; 11 import xdoclet.util.Translator; 12 13 29 public class JspTaglibSubTask extends XmlSubTask 30 { 31 private static String DEFAULT_TEMPLATE_FILE = "resources/taglib_tld.xdt"; 32 33 private static String TLD_PUBLICID_2_0 = "http://java.sun.com/xml/ns/j2ee"; 34 36 private static String TLD_PUBLICID_1_2 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"; 37 38 private static String TLD_PUBLICID_1_1 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"; 39 40 private static String TLD_SYSTEMID_2_0 = "http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"; 41 42 private static String TLD_SYSTEMID_1_2 = "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"; 43 44 private static String TLD_SYSTEMID_1_1 = "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"; 45 46 private static String TLD_XSD_FILE_NAME_2_0 = "resources/web-jsptaglibrary_2_0.xsd"; 47 48 private static String TLD_DTD_FILE_NAME_1_2 = "resources/web-jsptaglibrary_1_2.dtd"; 49 50 private static String TLD_DTD_FILE_NAME_1_1 = "resources/web-jsptaglibrary_1_1.dtd"; 51 52 protected String taglibversion = "1.0"; 53 54 protected String jspversion = JspVersionTypes.VERSION_1_2; 55 56 protected String shortname = ""; 57 58 protected String uri = ""; 59 60 protected String displayname = ""; 61 62 protected String smallicon = ""; 63 64 protected String largeicon = ""; 65 66 protected String description = ""; 67 68 protected String filename = "taglib.tld"; 69 70 73 public JspTaglibSubTask() 74 { 75 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE)); 76 setDestinationFile(filename); 77 } 78 79 84 public String getJspversion() 85 { 86 return jspversion; 87 } 88 89 94 public String getTaglibversion() 95 { 96 return taglibversion; 97 } 98 99 104 public String getShortname() 105 { 106 return shortname; 107 } 108 109 114 public String getUri() 115 { 116 return uri; 117 } 118 119 124 public String getDisplayname() 125 { 126 return displayname; 127 } 128 129 134 public String getSmallicon() 135 { 136 return smallicon; 137 } 138 139 144 public String getLargeicon() 145 { 146 return largeicon; 147 } 148 149 154 public String getDescription() 155 { 156 return description; 157 } 158 159 164 public String getFilename() 165 { 166 return filename; 167 } 168 169 174 public void setJspversion(JspVersionTypes jspversion) 175 { 176 this.jspversion = jspversion.getValue(); 177 } 178 179 184 public void setTaglibversion(String taglibversion) 185 { 186 this.taglibversion = taglibversion; 187 } 188 189 195 public void setShortname(String shortname) 196 { 197 this.shortname = shortname; 198 } 199 200 205 public void setUri(String uri) 206 { 207 this.uri = uri; 208 } 209 210 215 public void setDisplayname(String new_display_name) 216 { 217 displayname = new_display_name; 218 } 219 220 225 public void setSmallicon(String new_icon) 226 { 227 smallicon = new_icon; 228 } 229 230 235 public void setLargeicon(String new_icon) 236 { 237 largeicon = new_icon; 238 } 239 240 245 public void setDescription(String new_description) 246 { 247 description = new_description; 248 } 249 250 255 public void setFilename(String new_filename) 256 { 257 filename = new_filename; 258 setDestinationFile(filename); 259 } 260 261 266 public void validateOptions() throws XDocletException 267 { 268 super.validateOptions(); 269 270 if (getShortname() == null || getShortname().trim().equals("")) { 271 throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String []{"shortName"})); 272 } 273 } 274 275 280 public void execute() throws XDocletException 281 { 282 if (getJspversion().equals(JspVersionTypes.VERSION_2_0)) { 283 setPublicId(TLD_PUBLICID_2_0); 284 setSystemId(TLD_SYSTEMID_2_0); 286 setSchema(TLD_XSD_FILE_NAME_2_0); 288 } 289 else if (getJspversion().equals(JspVersionTypes.VERSION_1_1)) { 290 setPublicId(TLD_PUBLICID_1_1); 291 setSystemId(TLD_SYSTEMID_1_1); 292 setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_1)); 293 } 294 else { 295 setPublicId(TLD_PUBLICID_1_2); 296 setSystemId(TLD_SYSTEMID_1_2); 297 setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_2)); 298 } 299 300 startProcess(); 301 } 302 303 308 protected void engineStarted() throws XDocletException 309 { 310 System.out.println(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATING_SOMETHING, new String []{getDestinationFile().toString()})); 311 } 312 313 319 public static class JspVersionTypes extends org.apache.tools.ant.types.EnumeratedAttribute 320 { 321 public final static String VERSION_1_1 = "1.1"; 322 public final static String VERSION_1_2 = "1.2"; 323 public final static String VERSION_2_0 = "2.0"; 324 325 327 332 public String [] getValues() 333 { 334 return (new String []{VERSION_1_1, VERSION_1_2, VERSION_2_0}); 335 } 336 } 337 338 } 339 | Popular Tags |