1 58 package org.apache.ecs; 59 60 import java.io.OutputStream ; 61 import java.io.PrintWriter ; 62 import java.io.Serializable ; 63 import org.apache.ecs.html.Html; 64 import org.apache.ecs.html.Body; 65 import org.apache.ecs.html.Title; 66 import org.apache.ecs.html.Head; 67 import org.apache.ecs.html.FrameSet; 68 import org.apache.ecs.html.NoFrames; 69 70 77 public class FrameSetDocument implements Serializable ,Cloneable 78 { 79 80 private Html html; 82 private Head head; 83 84 private Body body; 85 86 private Title title; 87 88 private FrameSet frameset; 89 90 private NoFrames noframes; 91 92 private Doctype doctype = null; 93 94 95 private String codeset = null; 96 97 { 98 html = new Html(); 99 head = new Head(); 100 title = new Title(); 101 frameset = new FrameSet(); 102 noframes = new NoFrames(); 103 body = new Body(); 104 105 head.addElement("title",title); 106 html.addElement("head",head); 107 html.addElement("frameset",frameset); 108 html.addElement("noframes",noframes); 109 noframes.addElement("body",body); 110 } 111 112 115 public FrameSetDocument() 116 { 117 } 118 119 122 public FrameSetDocument(String codeset) 123 { 124 setCodeset(codeset); 125 } 126 127 130 public Doctype getDoctype() 131 { 132 return(doctype); 133 } 134 135 138 public FrameSetDocument setDoctype(Doctype set_doctype) 139 { 140 this.doctype = set_doctype; 141 return(this); 142 } 143 144 147 public Html getHtml() 148 { 149 return(html); 150 } 151 152 155 public FrameSetDocument setHtml(Html set_html) 156 { 157 this.html = set_html; 158 return(this); 159 } 160 161 164 public Head getHead() 165 { 166 return(head); 167 } 168 169 172 public FrameSetDocument setHead(Head set_head) 173 { 174 html.addElement("head",set_head); 175 this.head = set_head; 176 return(this); 177 } 178 179 183 public FrameSetDocument appendHead(Element value) 184 { 185 head.addElement(value); 186 return(this); 187 } 188 189 193 public FrameSetDocument appendHead(String value) 194 { 195 head.addElement(value); 196 return(this); 197 } 198 199 202 public FrameSet getFrameSet() 203 { 204 return(frameset); 205 } 206 207 210 public FrameSetDocument setFrameSet(FrameSet set_frameset) 211 { 212 html.addElement("frameset",set_frameset); 213 this.frameset = set_frameset; 214 return(this); 215 } 216 217 221 public FrameSetDocument appendFrameSet(Element value) 222 { 223 frameset.addElement(value); 224 return(this); 225 } 226 227 231 public FrameSetDocument appendFrameSet(String value) 232 { 233 frameset.addElement(value); 234 return(this); 235 } 236 239 public Body getBody() 240 { 241 return(body); 242 } 243 244 247 public FrameSetDocument setBody(Body set_body) 248 { 249 noframes.addElement("body",set_body); 250 this.body = set_body; 251 return(this); 252 } 253 254 258 public FrameSetDocument appendBody(Element value) 259 { 260 body.addElement(value); 261 return(this); 262 } 263 264 268 public FrameSetDocument appendBody(String value) 269 { 270 body.addElement(value); 271 return(this); 272 } 273 274 277 public Title getTitle() 278 { 279 return(title); 280 } 281 282 285 public FrameSetDocument setTitle(Title set_title) 286 { 287 head.addElement("title",set_title); 288 this.title = set_title; 289 return(this); 290 } 291 292 296 public FrameSetDocument appendTitle(Element value) 297 { 298 title.addElement(value); 299 return(this); 300 } 301 302 306 public FrameSetDocument appendTitle(String value) 307 { 308 title.addElement(value); 309 return(this); 310 } 311 312 315 public void setCodeset ( String codeset ) 316 { 317 this.codeset = codeset; 318 } 319 320 325 public String getCodeset() 326 { 327 return this.codeset; 328 } 329 330 333 public void output(OutputStream out) 334 { 335 if (doctype != null) 336 { 337 doctype.output(out); 338 try 339 { 340 out.write('\n'); 341 } 342 catch ( Exception e) 343 {} 344 } 345 html.output(out); 347 } 348 349 352 public void output(PrintWriter out) 353 { 354 if (doctype != null) 355 { 356 doctype.output(out); 357 try 358 { 359 out.write('\n'); 360 } 361 catch ( Exception e) 362 {} 363 } 364 html.output(out); 366 } 367 368 371 public final String toString() 372 { 373 StringBuffer sb = new StringBuffer (); 374 if ( getCodeset() != null ) 375 { 376 if (doctype != null) 377 sb.append (doctype.toString(getCodeset())); 378 sb.append (html.toString(getCodeset())); 379 return (sb.toString()); 380 } 381 else 382 { 383 if (doctype != null) 384 sb.append (doctype.toString()); 385 sb.append (html.toString()); 386 return(sb.toString()); 387 } 388 } 389 390 393 public final String toString(String codeset) 394 { 395 StringBuffer sb = new StringBuffer (); 396 if (doctype != null) 397 sb.append (doctype.toString(getCodeset())); 398 sb.append (html.toString(getCodeset())); 399 return(sb.toString()); 400 } 401 402 406 407 public Object clone() 408 { 409 return(html.clone()); 410 } 411 } 412 | Popular Tags |