|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
org.norther.tammi.acorn.nio.ChannelInputStream
public class ChannelInputStream
A non-blocking channel input stream which may wait before ready.
If the timeout is positive, the stream adds OP_READ to the interest set of the key and waits for the buffer when it needs a filled one until a timeout has elapsed or until notified. If the timeout is negative, the interest set of the key is not modified and the stream waits for the buffer without a timeout until notified. The latter alternative allows better control over the selection process from outside of the stream.
Note that I/O operations are synchronized on the buffer.
| Constructor Summary | |
|---|---|
ChannelInputStream(SelectionKey key,
ReadableByteChannel c,
ByteBuffer b,
long t)
Constructs a new stream. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
|
long |
getTimeout()
Gets the waiting timeout of this stream. |
void |
mark(int readlimit)
|
boolean |
markSupported()
|
int |
read()
|
int |
read(byte[] bb,
int off,
int len)
|
void |
reset()
|
void |
setTimeout(long t)
Sets the waiting timeout of this stream. |
boolean |
sync()
Syncs the stream with the channel by notifying the thread waiting on the buffer. |
| Methods inherited from class java.io.InputStream |
|---|
read, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ChannelInputStream(SelectionKey key,
ReadableByteChannel c,
ByteBuffer b,
long t)
key - the selection key.c - the readable channel.b - the buffer in the get state.t - timeout in msecs to wait for the buffer.| Method Detail |
|---|
public int available()
throws IOException
available in class InputStreamIOException
public int read()
throws IOException
read in class InputStreamIOException
public int read(byte[] bb,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic void mark(int readlimit)
mark in class InputStream
public void reset()
throws IOException
reset in class InputStreamIOExceptionpublic boolean markSupported()
markSupported in class InputStream
public void close()
throws IOException
close in interface Closeableclose in class InputStreamIOExceptionpublic long getTimeout()
public void setTimeout(long t)
t - the timeout in msecs.
public boolean sync()
throws IOException
IOException - on I/O errors.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||