|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
com.sun.grizzly.util.InputReader
public class InputReader
This class implement IO stream operations on top of a ByteBuffer.
Under the hood, this class use a temporary Selector pool for reading
bytes when the client ask for more and the current Selector is not yet ready.
| Nested Class Summary | |
|---|---|
static class |
InputReader.ChannelType
The Channel type is used to avoid invoking the instanceof
operation when registering the Socket|Datagram Channel to the Selector. |
| Field Summary | |
|---|---|
protected ByteBuffer |
byteBuffer
The wrapped ByteBuffer
|
protected SelectionKey |
key
The SelectionKey used by this stream. |
protected int |
readTimeout
The time to wait before timing out when reading bytes |
| Constructor Summary | |
|---|---|
InputReader()
|
|
InputReader(ByteBuffer byteBuffer)
|
|
| Method Summary | |
|---|---|
int |
available()
Return the available bytes |
void |
close()
Close this stream. |
protected int |
doClearRead()
|
protected int |
doRead()
Read bytes using the read ReadSelector |
protected int |
doSecureRead()
Read and decrypt bytes from the underlying SSL connections. |
ByteBuffer |
getByteBuffer()
Get the wrapped ByteBuffer |
InputReader.ChannelType |
getChannelType()
Return the Channel type. |
static int |
getDefaultReadTimeout()
Return the Selector.select() default time out. |
int |
getReadTimeout()
Return the timeout between two consecutives Selector.select() when a temporary Selector is used. |
boolean |
isSecure()
Is this Stream secure. |
boolean |
markSupported()
Return true if mark is supported. |
int |
read()
Read the first byte from the wrapped ByteBuffer. |
int |
read(byte[] b)
Read the bytes from the wrapped ByteBuffer. |
int |
read(byte[] b,
int offset,
int length)
Read the first byte of the wrapped ByteBuffer. |
int |
read(ByteBuffer bb)
Read the bytes of the wrapped ByteBuffer. |
void |
recycle()
Recycle this object. |
void |
setByteBuffer(ByteBuffer byteBuffer)
Set the wrapped ByteBuffer |
void |
setChannelType(InputReader.ChannelType channelType)
Set the Channel type, which is ocketChannel
or DatagramChannel. |
static void |
setDefaultReadTimeout(int aDefaultReadTimeout)
Set the default Selector.select() time out. |
void |
setReadTimeout(int rt)
Set the timeout between two consecutives Selector.select() when a temporary Selector is used. |
void |
setSecure(boolean secure)
Set this stream secure. |
void |
setSelectionKey(SelectionKey key)
Set the SelectionKey used to reads bytes. |
| Methods inherited from class java.io.InputStream |
|---|
mark, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ByteBuffer byteBuffer
ByteBuffer
protected SelectionKey key
SelectionKey used by this stream.
protected int readTimeout
| Constructor Detail |
|---|
public InputReader()
public InputReader(ByteBuffer byteBuffer)
| Method Detail |
|---|
public void setByteBuffer(ByteBuffer byteBuffer)
ByteBuffer
byteBuffer - The wrapped byteBufferpublic ByteBuffer getByteBuffer()
ByteBuffer
ByteBufferpublic int available()
available in class InputStreampublic void close()
close in interface Closeableclose in class InputStreampublic boolean markSupported()
markSupported in class InputStream
public int read()
throws IOException
ByteBuffer.
read in class InputStreamIOException
public int read(byte[] b)
throws IOException
ByteBuffer.
read in class InputStreamIOException
public int read(byte[] b,
int offset,
int length)
throws IOException
ByteBuffer.
read in class InputStreamoffset - length -
IOException
public int read(ByteBuffer bb)
throws IOException
ByteBuffer.
bb - ByteBuffer
IOExceptionpublic void recycle()
public void setSelectionKey(SelectionKey key)
SelectionKey used to reads bytes.
key - SelectionKey
protected int doRead()
throws IOException
ReadSelector
IOException
protected int doSecureRead()
throws IOException
SSLUtils.
IOException
protected int doClearRead()
throws IOException
IOExceptionpublic int getReadTimeout()
public void setReadTimeout(int rt)
rt - - read timeoutpublic static int getDefaultReadTimeout()
public static void setDefaultReadTimeout(int aDefaultReadTimeout)
aDefaultReadTimeout - time out valuepublic InputReader.ChannelType getChannelType()
Channel type. The return value is SocketChannel
or DatagramChannel.
Channel being usedpublic void setChannelType(InputReader.ChannelType channelType)
Channel type, which is ocketChannel
or DatagramChannel.
channelType - Channel to usepublic boolean isSecure()
public void setSecure(boolean secure)
secure - true to set stream secure, otherwise false
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||