1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.portlet.servlet;
23
24 import java.io.IOException;
25 import java.io.InputStream;
26
27 import javax.servlet.ServletInputStream;
28
29 /***
30 * Wrapper object exposing a {@link InputStream} from a portlet as a {@link ServletInputStream} instance.
31 * Clients accessing this stream object will in fact operate on the
32 * {@link InputStream} object wrapped by this stream object.
33 */
34 public class PortletServletInputStream extends ServletInputStream {
35
36 private InputStream portletInputStream;
37
38 public PortletServletInputStream(InputStream portletInputStream) {
39 this.portletInputStream = portletInputStream;
40 }
41
42
43
44
45 @Override
46 public int read() throws IOException {
47 return portletInputStream.read();
48 }
49
50
51
52
53 @Override
54 public int available() throws IOException {
55 return portletInputStream.available();
56 }
57
58
59
60
61 @Override
62 public void close() throws IOException {
63 portletInputStream.close();
64 }
65
66
67
68
69 @Override
70 public synchronized void mark(int readlimit) {
71 portletInputStream.mark(readlimit);
72 }
73
74
75
76
77 @Override
78 public boolean markSupported() {
79 return portletInputStream.markSupported();
80 }
81
82
83
84
85 @Override
86 public int read(byte[] b, int off, int len) throws IOException {
87 return portletInputStream.read(b, off, len);
88 }
89
90
91
92
93 @Override
94 public int read(byte[] b) throws IOException {
95 return portletInputStream.read(b);
96 }
97
98
99
100
101 @Override
102 public synchronized void reset() throws IOException {
103 portletInputStream.reset();
104 }
105
106
107
108
109 @Override
110 public long skip(long n) throws IOException {
111 return portletInputStream.skip(n);
112 }
113
114 /***
115 * Get the wrapped {@link InputStream} instance.
116 * @return The wrapped {@link InputStream} instance.
117 */
118 public InputStream getInputStream() {
119 return portletInputStream;
120 }
121
122 }