1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.feedparser.network;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21
22
23
24
25
26
27
28 public class AdvancedInputStream extends InputStream {
29
30 private InputStream is = null;
31
32 private BaseResourceRequest request = null;
33
34
35
36
37
38
39
40 public AdvancedInputStream( InputStream is, ResourceRequest request ) {
41 this.is = is;
42 this.request = (BaseResourceRequest)request;
43 }
44
45 public int read() throws IOException {
46
47 int v = is.read();
48
49 request.fireDataEvent( 1 );
50
51 return v;
52 }
53
54 public int read( byte b[] ) throws IOException {
55
56 int v = is.read( b );
57
58 request.fireDataEvent( b.length );
59
60 return v;
61
62 }
63
64 public int read( byte b[], int off, int len ) throws IOException {
65
66 int v = is.read( b, off, len );
67
68 request.fireDataEvent( len );
69
70 return v;
71
72 }
73
74 public long skip( long n ) throws IOException {
75
76 long v = is.skip( n );
77
78 request.fireDataEvent( n );
79
80 return v;
81 }
82
83
84
85 public int available() throws IOException {
86 return is.available();
87 }
88
89 public void close() throws IOException {
90 is.close();
91
92 request.fireOnClosed();
93 }
94
95 public void mark(int readlimit) {
96 is.mark( readlimit );
97 }
98
99 public void reset() throws IOException {
100 is.reset();
101 }
102
103 public boolean markSupported() {
104 return is.markSupported();
105 }
106
107 }