01: /*
02: * Title: FastPage
03: * Description:
04: *
05: * This software is published under the terms of the OpenSymphony Software
06: * License version 1.1, of which a copy has been included with this
07: * distribution in the LICENSE.txt file.
08: */
09:
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: /**
18: * HTMLPage implementation produced by FastPageParser.
19: *
20: * @author <a href="mailto:salaman@qoretech.com">Victor Salaman</a>
21: * @version $Revision: 1.5 $
22: */
23: public final class FastPage extends AbstractHTMLPage {
24: private String head;
25: private String body;
26:
27: public FastPage(Map sitemeshProps, Map htmlProps, Map metaProps,
28: Map bodyProps, String title, String head, String body,
29: boolean frameSet) {
30: this .head = head;
31: this .body = body;
32: setFrameSet(frameSet);
33: addAttributeList("", htmlProps);
34: addAttributeList("page.", sitemeshProps);
35: addAttributeList("body.", bodyProps);
36: addAttributeList("meta.", metaProps);
37: addProperty("title", title);
38: }
39:
40: public void writeHead(Writer out) throws IOException {
41: out.write(head);
42: }
43:
44: public void writeBody(Writer out) throws IOException {
45: out.write(body);
46: }
47:
48: private void addAttributeList(String prefix, Map attributes) {
49: if (attributes == null || attributes.isEmpty())
50: return;
51:
52: String name, value;
53: Iterator i = attributes.entrySet().iterator();
54:
55: while (i.hasNext()) {
56: Map.Entry entry = (Map.Entry) i.next();
57: name = (String) entry.getKey();
58: value = (String) entry.getValue();
59:
60: if (value != null && value.trim().length() > 0) {
61: addProperty(prefix + name, value);
62: }
63: }
64: }
65:
66: public void setVerbatimPage(char[] v) {
67: this .pageData = v;
68: }
69:
70: public String getBody() {
71: return body;
72: }
73:
74: public String getHead() {
75: return head;
76: }
77: }
|