|
||||||||||
| 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 java.nio.ByteBuffer |
byteBuffer
The wrapped ByteBuffer
|
protected java.nio.ByteBuffer |
inputBB
The encrypted ByteBuffer |
java.nio.channels.SelectionKey |
key
The SelectionKey used by this stream. |
protected int |
readTimeout
The time to wait before timing out when reading bytes |
protected javax.net.ssl.SSLEngine |
sslEngine
The SSLEngine to use for unwrapping bytes. |
| Constructor Summary | |
|---|---|
InputReader()
|
|
InputReader(java.nio.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. |
java.nio.ByteBuffer |
getByteBuffer()
Get the wrapped ByteBuffer |
InputReader.ChannelType |
getChannelType()
Return the Channel type. |
static int |
getDefaultReadTimeout()
Return the Selector.select() default time out. |
java.nio.ByteBuffer |
getInputBB()
|
int |
getReadTimeout()
Return the timeout between two consecutives Selector.select() when a temporary Selector is used. |
javax.net.ssl.SSLEngine |
getSslEngine()
|
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(java.nio.ByteBuffer bb)
Read the bytes of the wrapped ByteBuffer. |
void |
recycle()
Recycle this object. |
void |
setByteBuffer(java.nio.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 |
setInputBB(java.nio.ByteBuffer inputBB)
|
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(java.nio.channels.SelectionKey key)
Set the SelectionKey used to reads bytes. |
void |
setSslEngine(javax.net.ssl.SSLEngine sslEngine)
|
| 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 java.nio.ByteBuffer byteBuffer
ByteBuffer
protected java.nio.ByteBuffer inputBB
ByteBuffer
public java.nio.channels.SelectionKey key
SelectionKey used by this stream.
protected int readTimeout
protected javax.net.ssl.SSLEngine sslEngine
| Constructor Detail |
|---|
public InputReader()
public InputReader(java.nio.ByteBuffer byteBuffer)
| Method Detail |
|---|
public void setByteBuffer(java.nio.ByteBuffer byteBuffer)
ByteBuffer
byteBuffer - The wrapped byteBufferpublic java.nio.ByteBuffer getByteBuffer()
ByteBuffer
ByteBufferpublic int available()
available in class java.io.InputStreampublic void close()
close in interface java.io.Closeableclose in class java.io.InputStreampublic boolean markSupported()
markSupported in class java.io.InputStream
public int read()
throws java.io.IOException
ByteBuffer.
read in class java.io.InputStreamjava.io.IOException
public int read(byte[] b)
throws java.io.IOException
ByteBuffer.
read in class java.io.InputStreamjava.io.IOException
public int read(byte[] b,
int offset,
int length)
throws java.io.IOException
ByteBuffer.
read in class java.io.InputStreamoffset - length -
java.io.IOException
public int read(java.nio.ByteBuffer bb)
throws java.io.IOException
ByteBuffer.
bb - ByteBuffer
java.io.IOExceptionpublic void recycle()
public void setSelectionKey(java.nio.channels.SelectionKey key)
SelectionKey used to reads bytes.
key - SelectionKey
protected int doRead()
throws java.io.IOException
ReadSelector
java.io.IOException
protected int doSecureRead()
throws java.io.IOException
SSLUtils.
java.io.IOException
protected int doClearRead()
throws java.io.IOException
java.io.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 falsepublic javax.net.ssl.SSLEngine getSslEngine()
public void setSslEngine(javax.net.ssl.SSLEngine sslEngine)
public java.nio.ByteBuffer getInputBB()
public void setInputBB(java.nio.ByteBuffer inputBB)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||