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