KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > mock > web > DelegatingServletOutputStream


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.mock.web;
18
19 import java.io.IOException JavaDoc;
20 import java.io.OutputStream JavaDoc;
21
22 import javax.servlet.ServletOutputStream JavaDoc;
23
24 /**
25  * Delegating implementation of {@link javax.servlet.ServletOutputStream}.
26  *
27  * <p>Used by {@link MockHttpServletResponse}; typically not directly
28  * used for testing application controllers.
29  *
30  * @author Juergen Hoeller
31  * @since 1.0.2
32  * @see MockHttpServletResponse
33  */

34 public class DelegatingServletOutputStream extends ServletOutputStream JavaDoc {
35
36     private final OutputStream JavaDoc targetStream;
37
38
39     /**
40      * Create a new DelegatingServletOutputStream.
41      * @param targetStream the target OutputStream
42      */

43     public DelegatingServletOutputStream(OutputStream JavaDoc targetStream) {
44         this.targetStream = targetStream;
45     }
46
47     public OutputStream JavaDoc getTargetStream() {
48         return targetStream;
49     }
50
51
52     public void write(int b) throws IOException JavaDoc {
53         this.targetStream.write(b);
54     }
55
56     public void flush() throws IOException JavaDoc {
57         super.flush();
58         this.targetStream.flush();
59     }
60
61     public void close() throws IOException JavaDoc {
62         super.close();
63         this.targetStream.close();
64     }
65
66 }
67
Popular Tags