Methods Summary |
---|
public boolean | isReady()Return true if this instance is ready to read.
return ready;
|
public int | read(byte[] buf)Read bytes without blocking.
return read(buf,0,buf.length);
|
public int | read(byte[] buf, int off, int len)Read bytes without blocking.
if (!ready){
throw new IllegalStateException("This CometReader is no longer usable");
}
// The CometTask has already read the first bytes for us.
if (byteBuffer != null){
byteBuffer.get(buf,off,len);
return nRead > len ? len : nRead;
}
return socketChannel.read(ByteBuffer.wrap(buf,off,len));
|
public void | recycle()Recycle this object.
nRead = 0;
byteBuffer = null;
socketChannel = null;
|
public void | setByteBuffer(java.nio.ByteBuffer byteBuffer)
this.byteBuffer = byteBuffer;
|
protected void | setChannel(java.nio.channels.SocketChannel socketChannel)Set the underlying SocketChannel.
this.socketChannel = socketChannel;
|
public void | setNRead(int nRead)
this.nRead = nRead;
|
public void | setReady(boolean ready)false if this instance is no longer ready to read.
this.ready = ready;
|