1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package org.simpleframework.http.core;
import java.io.IOException;
import org.simpleframework.transport.ByteCursor;
public class DribbleCursor implements ByteCursor {
private ByteCursor cursor;
private byte[] swap;
private int dribble;
public DribbleCursor(ByteCursor cursor, int dribble) {
this.cursor = cursor;
this.dribble = dribble;
this.swap = new byte[1];
}
public boolean isOpen() throws IOException {
return true;
}
public boolean isReady() throws IOException {
return cursor.isReady();
}
public int ready() throws IOException {
int ready = cursor.ready();
return Math.min(ready, dribble);
}
public int read() throws IOException {
if(read(swap) > 0) {
return swap[0] & 0xff;
}
return 0;
}
public int read(byte[] data) throws IOException {
return read(data, 0, data.length);
}
public int read(byte[] data, int off, int len) throws IOException {
int size = Math.min(len, dribble);
return cursor.read(data, off, size);
}
public int reset(int len) throws IOException {
return cursor.reset(len);
}
public void push(byte[] data) throws IOException {
cursor.push(data);
}
public void push(byte[] data, int off, int len) throws IOException {
cursor.push(data, off, len);
}
}
|