blob: 68b9ed26c05a2e45895423ec2f715098e9986736 (
plain)
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
|
package com.koushikdutta.async;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.spi.AbstractSelectableChannel;
abstract class ChannelWrapper implements ReadableByteChannel {
private AbstractSelectableChannel mChannel;
ChannelWrapper(AbstractSelectableChannel channel) throws IOException {
channel.configureBlocking(false);
mChannel = channel;
}
public abstract boolean isConnected();
public abstract int write(ByteBuffer src) throws IOException;
public abstract int write(ByteBuffer[] src) throws IOException;
// register for default events appropriate for this channel
public abstract SelectionKey register(Selector sel) throws ClosedChannelException;
public SelectionKey register(Selector sel, int ops) throws ClosedChannelException {
return mChannel.register(sel, ops);
}
public boolean isChunked() {
return false;
}
@Override
public boolean isOpen() {
return mChannel.isOpen();
}
@Override
public void close() throws IOException {
mChannel.close();
}
}
|