1 9 10 package com.opensymphony.module.sitemesh.parser; 11 12 import java.io.IOException ; 13 import java.io.Writer ; 14 import java.util.Iterator ; 15 import java.util.Map ; 16 17 23 public final class FastPage extends AbstractHTMLPage 24 { 25 private String head; 26 private String body; 27 28 public FastPage(Map sitemeshProps, Map htmlProps, Map metaProps, Map bodyProps, 29 String title, String head, String body, boolean frameSet) 30 { 31 this.head = head; 32 this.body = body; 33 setFrameSet(frameSet); 34 addAttributeList("", htmlProps); 35 addAttributeList("page.", sitemeshProps); 36 addAttributeList("body.", bodyProps); 37 addAttributeList("meta.", metaProps); 38 addProperty("title", title); 39 } 40 41 public void writeHead(Writer out) throws IOException 42 { 43 out.write(head); 44 } 45 46 public void writeBody(Writer out) throws IOException 47 { 48 out.write(body); 49 } 50 51 private void addAttributeList(String prefix, Map attributes) 52 { 53 if(attributes == null || attributes.isEmpty()) return; 54 55 String name, value; 56 Iterator i = attributes.entrySet().iterator(); 57 58 while (i.hasNext()) 59 { 60 Map.Entry entry = (Map.Entry ) i.next(); 61 name = (String ) entry.getKey(); 62 value = (String ) entry.getValue(); 63 64 if(value != null && value.trim().length() > 0) 65 { 66 addProperty(prefix + name, value); 67 } 68 } 69 } 70 71 public void setVerbatimPage(char[] v) 72 { 73 this.pageData = v; 74 } 75 76 public String getBody() 77 { 78 return body; 79 } 80 81 public String getHead() 82 { 83 return head; 84 } 85 } 86 | Popular Tags |