View Javadoc

1   /*
2    * $Id: StrutsMockBodyContent.java 651946 2008-04-27 13:41:38Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  package org.apache.struts2.views.jsp;
23  
24  import java.io.IOException;
25  import java.io.Reader;
26  import java.io.Writer;
27  
28  import javax.servlet.jsp.JspWriter;
29  import javax.servlet.jsp.tagext.BodyContent;
30  
31  
32  /***
33   * StrutsMockBodyContent
34   *
35   */
36  public class StrutsMockBodyContent extends BodyContent {
37  
38      private JspWriter jspWriter;
39      private String body = null;
40  
41  
42      public StrutsMockBodyContent(JspWriter jspWriter) {
43          super(jspWriter);
44          this.jspWriter = jspWriter;
45      }
46  
47  
48      public Reader getReader() {
49          return null;
50      }
51  
52      public int getRemaining() {
53          return jspWriter.getRemaining();
54      }
55  
56      public void setString(String body) {
57          this.body = body;
58      }
59  
60      public String getString() {
61          return body;
62      }
63  
64      public void clear() throws IOException {
65          jspWriter.clear();
66      }
67  
68      public void clearBuffer() throws IOException {
69          jspWriter.clearBuffer();
70      }
71  
72      public void close() throws IOException {
73          jspWriter.close();
74      }
75  
76      public void newLine() throws IOException {
77          jspWriter.newLine();
78      }
79  
80      public void print(double v) throws IOException {
81          jspWriter.print(v);
82      }
83  
84      public void print(int i) throws IOException {
85          jspWriter.print(i);
86      }
87  
88      public void print(long l) throws IOException {
89          jspWriter.print(l);
90      }
91  
92      public void print(float v) throws IOException {
93          jspWriter.print(v);
94      }
95  
96      public void print(boolean b) throws IOException {
97          jspWriter.print(b);
98      }
99  
100     public void print(String s) throws IOException {
101         jspWriter.print(s);
102     }
103 
104     public void print(char c) throws IOException {
105         jspWriter.print(c);
106     }
107 
108     public void print(Object o) throws IOException {
109         jspWriter.print(o);
110     }
111 
112     public void print(char[] chars) throws IOException {
113         jspWriter.print(chars);
114     }
115 
116     public void println() throws IOException {
117         jspWriter.println();
118     }
119 
120     public void println(char c) throws IOException {
121         jspWriter.println(c);
122     }
123 
124     public void println(String s) throws IOException {
125         jspWriter.println(s);
126     }
127 
128     public void println(char[] chars) throws IOException {
129         jspWriter.println(chars);
130     }
131 
132     public void println(boolean b) throws IOException {
133         jspWriter.println(b);
134     }
135 
136     public void println(long l) throws IOException {
137         jspWriter.println(l);
138     }
139 
140     public void println(int i) throws IOException {
141         jspWriter.println(i);
142     }
143 
144     public void println(float v) throws IOException {
145         jspWriter.println(v);
146     }
147 
148     public void println(double v) throws IOException {
149         jspWriter.println(v);
150     }
151 
152     public void println(Object o) throws IOException {
153         jspWriter.println(o);
154     }
155 
156     public void write(char[] chars, int i, int i1) throws IOException {
157         jspWriter.write(chars, i, i1);
158     }
159 
160     public void writeOut(Writer writer) throws IOException {
161         writer.write(body);
162     }
163 }