1 18 package org.apache.beehive.netui.tools.tld; 19 20 import xdoclet.XDocletException; 21 import xdoclet.XDocletMessages; 22 23 import xdoclet.XmlSubTask; 24 import xdoclet.util.Translator; 25 26 34 public class JspTaglibSubTask extends XmlSubTask 35 { 36 private static String DEFAULT_TEMPLATE_FILE = "xdoclet/tld.xdt"; 37 38 private static String TLD_PUBLICID_1_2 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"; 39 40 private static String TLD_PUBLICID_1_1 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"; 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_DTD_FILE_NAME_1_2 = "xdoclet/modules/web/resources/web-jsptaglibrary_1_2.dtd"; 47 48 private static String TLD_DTD_FILE_NAME_1_1 = "xdoclet/modules/web/resources/web-jsptaglibrary_1_1.dtd"; 49 50 protected String taglibversion = "1.0"; 51 52 protected String jspversion = JspVersionTypes.VERSION_1_2; 53 54 protected String shortname = ""; 55 56 protected String uri = ""; 57 58 protected String displayname = ""; 59 60 protected String smallicon = ""; 61 62 protected String largeicon = ""; 63 64 protected String description = ""; 65 66 protected String filename = "taglib.tld"; 67 68 private String _packageName = null; 69 70 private String _functionPackage = null; 71 72 75 public JspTaglibSubTask() 76 { 77 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE)); 78 setDestinationFile(filename); 79 80 setPublicId(TLD_PUBLICID_1_2); 81 setSystemId(TLD_SYSTEMID_1_2); 82 setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_2)); 83 } 84 85 public void setPackageName(String packageName) 86 { 87 this._packageName = packageName; 88 } 89 90 public String getPackageName() 91 { 92 return _packageName; 93 } 94 95 public void setFunctionPackage(String functionPackage) { 96 _functionPackage = functionPackage; 97 } 98 99 public String getFunctionPackage() { 100 return _functionPackage; 101 } 102 103 108 public String getJspversion() 109 { 110 return jspversion; 111 } 112 113 118 public String getTaglibversion() 119 { 120 return taglibversion; 121 } 122 123 128 public String getShortname() 129 { 130 return shortname; 131 } 132 133 138 public String getUri() 139 { 140 return uri; 141 } 142 143 148 public String getDisplayname() 149 { 150 return displayname; 151 } 152 153 158 public String getSmallicon() 159 { 160 return smallicon; 161 } 162 163 168 public String getLargeicon() 169 { 170 return largeicon; 171 } 172 173 178 public String getDescription() 179 { 180 return description; 181 } 182 183 188 public String getFilename() 189 { 190 return filename; 191 } 192 193 198 public void setJspversion(JspVersionTypes jspversion) 199 { 200 this.jspversion = jspversion.getValue(); 201 } 202 203 208 public void setTaglibversion(String taglibversion) 209 { 210 this.taglibversion = taglibversion; 211 } 212 213 218 public void setShortname(String shortname) 219 { 220 this.shortname = shortname; 221 } 222 223 228 public void setUri(String uri) 229 { 230 this.uri = uri; 231 } 232 233 238 public void setDisplayname(String new_display_name) 239 { 240 displayname = new_display_name; 241 } 242 243 248 public void setSmallicon(String new_icon) 249 { 250 smallicon = new_icon; 251 } 252 253 258 public void setLargeicon(String new_icon) 259 { 260 largeicon = new_icon; 261 } 262 263 268 public void setDescription(String new_description) 269 { 270 description = new_description; 271 } 272 273 278 public void setFilename(String new_filename) 279 { 280 filename = new_filename; 281 setDestinationFile(filename); 282 } 283 284 289 public void validateOptions() throws XDocletException 290 { 291 super.validateOptions(); 292 293 if (getShortname() == null || getShortname().trim().equals("")) { 294 throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String []{"shortName"})); 295 } 296 } 297 298 303 public void execute() throws XDocletException 304 { 305 if (getJspversion().equals(JspVersionTypes.VERSION_1_1)) { 306 setPublicId(TLD_PUBLICID_1_1); 307 setSystemId(TLD_SYSTEMID_1_1); 308 setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_1)); 309 } 310 else { 311 setPublicId(TLD_PUBLICID_1_2); 312 setSystemId(TLD_SYSTEMID_1_2); 313 setDtdURL(getClass().getResource(TLD_DTD_FILE_NAME_1_2)); 314 } 315 316 startProcess(); 317 } 318 319 324 protected void engineStarted() throws XDocletException 325 { 326 System.out.println(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATING_SOMETHING, new String []{getDestinationFile().toString()})); 327 } 328 329 333 public static class ContextParam implements java.io.Serializable 334 { 335 private String paramName = null; 336 private String paramValue = null; 337 private String description = ""; 338 339 344 public String getName() 345 { 346 return paramName; 347 } 348 349 354 public String getValue() 355 { 356 return paramValue; 357 } 358 359 364 public String getDescription() 365 { 366 return description; 367 } 368 369 374 public void setName(String name) 375 { 376 paramName = name; 377 } 378 379 384 public void setValue(String value) 385 { 386 paramValue = value; 387 } 388 389 394 public void setDescription(String desc) 395 { 396 description = desc; 397 } 398 } 399 400 404 public static class TagLib implements java.io.Serializable 405 { 406 private String taglibURI = null; 407 private String taglibLocation = null; 408 409 414 public String getURI() 415 { 416 return taglibURI; 417 } 418 419 424 public String getLocation() 425 { 426 return taglibLocation; 427 } 428 429 434 public void setURI(String uri) 435 { 436 taglibURI = uri; 437 } 438 439 444 public void setLocation(String location) 445 { 446 taglibLocation = location; 447 } 448 } 449 450 454 public static class JspVersionTypes extends org.apache.tools.ant.types.EnumeratedAttribute 455 { 456 public final static String VERSION_1_1 = "1.1"; 457 public final static String VERSION_1_2 = "1.2"; 458 public final static String VERSION_2_0 = "2.0"; 459 460 462 467 public String [] getValues() 468 { 469 return (new String []{VERSION_1_1, VERSION_1_2, VERSION_2_0}); 470 } 471 } 472 473 } 474 | Popular Tags |