0
|
1 package cachingfilter;
|
|
2
|
|
3 import java.io.InputStream;
|
|
4 import org.eclipse.jetty.io.Buffer;
|
|
5
|
|
6
|
|
7 public final class BufferInputStream extends InputStream {
|
|
8 private final Buffer buffer;
|
|
9
|
|
10 public BufferInputStream(Buffer buffer) {
|
|
11 this.buffer = buffer;
|
|
12 }
|
|
13
|
|
14 public int read() {
|
|
15 return buffer.length()==0 ? -1 : buffer.get();
|
|
16 }
|
|
17
|
|
18 public int read(byte b[], int off, int len) {
|
|
19 return buffer.get(b,off,len);
|
|
20 }
|
|
21
|
|
22 public long skip(long n) {
|
|
23 return buffer.skip( (int)n );
|
|
24 }
|
|
25
|
|
26 public int available() {
|
|
27 return buffer.length();
|
|
28 }
|
|
29
|
|
30 public void mark(int readlimit) {
|
|
31 buffer.mark();
|
|
32 }
|
|
33
|
|
34 public void reset() {
|
|
35 buffer.reset();
|
|
36 }
|
|
37
|
|
38 public boolean markSupported() {
|
|
39 return true;
|
|
40 }
|
|
41 }
|