001: /*
002: * Copyright (c) 2002-2006 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.webwork.views.sitemesh;
006:
007: import java.io.IOException;
008: import java.io.Writer;
009: import java.util.LinkedHashMap;
010: import java.util.Map;
011:
012: import javax.servlet.http.HttpServletRequest;
013:
014: import com.opensymphony.module.sitemesh.HTMLPage;
015:
016: /**
017: * @author tmjee
018: * @version $Date$ $Id$
019: */
020: public class MockPage implements HTMLPage {
021:
022: private String body;
023: private int contentLength;
024: private String page;
025: private String title;
026: private String head;
027: private HttpServletRequest request;
028: private Map properties = new LinkedHashMap();
029:
030: private boolean isFrameset;
031:
032: public void addProperty(String name, String value) {
033: properties.put(name, value);
034: }
035:
036: public void setBody(String body) {
037: this .body = body;
038: }
039:
040: public String getBody() {
041: return body;
042: }
043:
044: public void setBooleanProperty(String name, boolean value) {
045: properties.put(name, Boolean.valueOf(value));
046: }
047:
048: public boolean getBooleanProperty(String name) {
049: return ((Boolean) properties.get(name)).booleanValue();
050: }
051:
052: public void setContentLength(int contentLength) {
053: this .contentLength = contentLength;
054: }
055:
056: public int getContentLength() {
057: return contentLength;
058: }
059:
060: public void setIntProperty(String name, int value) {
061: this .properties.put(name, new Integer(value));
062: }
063:
064: public int getIntProperty(String name) {
065: return ((Integer) properties.get(name)).intValue();
066: }
067:
068: public void setLongProperty(String name, long value) {
069: this .properties.put(name, new Long(value));
070: }
071:
072: public long getLongProperty(String name) {
073: return ((Long) properties.get(name)).longValue();
074: }
075:
076: public void setPage(String page) {
077: this .page = page;
078: }
079:
080: public String getPage() {
081: return this .page;
082: }
083:
084: public void setProperties(Map properties) {
085: this .properties = properties;
086: }
087:
088: public Map getProperties() {
089: return this .properties;
090: }
091:
092: public void setProperty(String name, String value) {
093: this .properties.put(name, value);
094: }
095:
096: public String getProperty(String name) {
097: return (String) this .properties.get(name);
098: }
099:
100: public String[] getPropertyKeys() {
101: return (String[]) properties.keySet().toArray(new String[0]);
102: }
103:
104: public HttpServletRequest getRequest() {
105: return this .request;
106: }
107:
108: public void setTitle(String title) {
109: this .title = title;
110: }
111:
112: public String getTitle() {
113: return title;
114: }
115:
116: public boolean isPropertySet(String name) {
117: return properties.containsKey(name);
118: }
119:
120: public void setRequest(HttpServletRequest request) {
121: this .request = request;
122: }
123:
124: public void writeBody(Writer writer) throws IOException {
125: if (body != null)
126: writer.write(body);
127: }
128:
129: public void writePage(Writer writer) throws IOException {
130: if (page != null)
131: writer.write(page);
132: }
133:
134: public void setHead(String head) {
135: this .head = head;
136: }
137:
138: public String getHead() {
139: return head;
140: }
141:
142: public boolean isFrameSet() {
143: return isFrameset;
144: }
145:
146: public void setFrameSet(boolean isFrameset) {
147: this .isFrameset = isFrameset;
148: }
149:
150: public void writeHead(Writer writer) throws IOException {
151: }
152: }
|