1 58 package org.apache.ecs.html; 59 60 import org.apache.ecs.*; 61 62 69 public class Script extends MultiPartElement implements Printable 70 { 71 74 { 75 setElementType("script"); 76 setLanguage("JavaScript"); 77 } 78 81 public Script() 82 { 83 } 84 85 89 public Script(Element element) 90 { 91 addElement(element); 92 } 93 94 99 public Script(Element element, String src) 100 { 101 addElement(element); 102 setSrc(src); 103 } 104 105 111 public Script(Element element, String src, String type) 112 { 113 addElement(element); 114 setSrc(src); 115 setType(type); 116 } 117 118 125 public Script(Element element, String src, String type, String lang) 126 { 127 addElement(element); 128 setSrc(src); 129 setType(type); 130 setLanguage(lang); 131 } 132 133 137 public Script(String element) 138 { 139 addElement(element); 140 } 141 142 147 public Script(String element, String src) 148 { 149 addElement(element); 150 setSrc(src); 151 } 152 153 159 public Script(String element, String src, String type) 160 { 161 addElement(element); 162 setSrc(src); 163 setType(type); 164 } 165 166 173 public Script(String element, String src, String type, String lang) 174 { 175 addElement(element); 176 setSrc(src); 177 setType(type); 178 setLanguage(lang); 179 } 180 181 185 public Script setSrc(String src) 186 { 187 addAttribute("src",src); 188 return this; 189 } 190 191 195 public Script setType(String type) 196 { 197 addAttribute("type", type); 198 return this; 199 } 200 201 205 public Script setLanguage(String language) 206 { 207 addAttribute("language", language); 208 return this; 209 } 210 211 216 public Script addElement(String hashcode,Element element) 217 { 218 addElementToRegistry(hashcode,element); 219 return(this); 220 } 221 222 227 public Script addElement(String hashcode,String element) 228 { 229 addElementToRegistry(hashcode,element); 230 return(this); 231 } 232 233 237 public Script addElement(Element element) 238 { 239 addElementToRegistry(element); 240 return(this); 241 } 242 243 247 public Script addElement(String element) 248 { 249 addElementToRegistry(element); 250 return(this); 251 } 252 256 public Script removeElement(String hashcode) 257 { 258 removeElementFromRegistry(hashcode); 259 return(this); 260 } 261 262 268 public String createStartTag() 269 { 270 StringBuffer out = new StringBuffer (); 271 out.append(super.createStartTag()); 272 if (!(hasAttribute("src"))) { 273 out.append("\n"); 274 out.append("<!--"); 275 out.append("\n"); 276 } 277 return(out.toString()); 278 } 279 285 public String createEndTag() 286 { 287 StringBuffer out = new StringBuffer (); 288 if (!(hasAttribute("src"))) { 289 out.append("\n"); 290 out.append("// -->"); 291 out.append("\n"); 292 } 293 out.append(super.createEndTag()); 294 return(out.toString()); 295 } 296 } 297 | Popular Tags |