|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.streams.AbstractStreamReader
public abstract class AbstractStreamReader
Each method reads data from the current ByteBuffer. If not enough data is present in the current ByteBuffer, discard is called on the current ByteBuffer and we advance to the next ByteBuffer, or block if not enough data is present. If close() is called, all subsequent method calls will throw an IllegalStateException, and any threads blocked waiting for more data will be unblocked, and continue with an IllegalStateException from the blocking method call.
dataReceived and close may be safely invoked by multiple threads. The other methods must be invoked only by one thread, which is the reader of this data stream.
| Field Summary | |
|---|---|
protected Connection |
connection
|
protected Input |
input
|
protected java.util.concurrent.atomic.AtomicBoolean |
isClosed
|
| Constructor Summary | |
|---|---|
protected |
AbstractStreamReader(Connection connection,
Input streamInput)
Create a new ByteBufferReader. |
| Method Summary | ||
|---|---|---|
int |
available()
Return the number of bytes available for get calls. |
|
void |
close()
Closes the StreamReader and causes all subsequent method calls on this object to throw IllegalStateException. |
|
|
decode(Transformer<Stream,E> decoder)
Read and decode data from the StreamReader |
|
|
decode(Transformer<Stream,E> decoder,
CompletionHandler<E> completionHandler)
Read and decode data from the StreamReader |
|
Buffer |
getBufferWindow()
|
|
Connection |
getConnection()
Get the Connection this StreamReader belongs to. |
|
boolean |
hasAvailable()
Return true if StreamReader has available data, which could be read, or false otherwise. |
|
boolean |
isClosed()
Returns true, if StreamReader has been closed, or false otherwise. |
|
boolean |
isSupportBufferWindow()
|
|
GrizzlyFuture<java.lang.Integer> |
notifyAvailable(int size)
Method returns Future, using which it's possible check if
StreamReader has required amount of bytes available
for reading reading. |
|
GrizzlyFuture<java.lang.Integer> |
notifyAvailable(int size,
CompletionHandler<java.lang.Integer> completionHandler)
Method returns Future, using which it's possible check if
StreamReader has required amount of bytes available
for reading reading. |
|
GrizzlyFuture<java.lang.Integer> |
notifyCondition(Condition condition)
Method returns Future, using which it's possible check if
StreamReader meets specific Condition. |
|
GrizzlyFuture<java.lang.Integer> |
notifyCondition(Condition condition,
CompletionHandler<java.lang.Integer> completionHandler)
Method returns Future, using which it's possible check if
StreamReader meets specific Condition. |
|
boolean |
readBoolean()
Get the next boolean in the stream. |
|
void |
readBooleanArray(boolean[] data)
Fill data with booleans (byte 1=true, 0=false) from the stream. |
|
byte |
readByte()
Get the next byte in the stream. |
|
void |
readByteArray(byte[] data)
Fill data with bytes from the stream. |
|
void |
readByteArray(byte[] data,
int offset,
int length)
Fill data with bytes from the stream. |
|
void |
readBytes(Buffer buffer)
Fill the buffer with data from the stream (that is, copy data from the stream to fill buffer from position to limit). |
|
char |
readChar()
Get the next character in the stream. |
|
void |
readCharArray(char[] data)
Fill data with characters from the stream. |
|
double |
readDouble()
Get the next double in the stream. |
|
void |
readDoubleArray(double[] data)
Fill data with characters from the stream. |
|
float |
readFloat()
Get the next float in the stream. |
|
void |
readFloatArray(float[] data)
Fill data with characters from the stream. |
|
int |
readInt()
Get the next int in the stream. |
|
void |
readIntArray(int[] data)
Fill data with characters from the stream. |
|
long |
readLong()
Get the next long in the stream. |
|
void |
readLongArray(long[] data)
Fill data with characters from the stream. |
|
short |
readShort()
Get the next short in the stream. |
|
void |
readShortArray(short[] data)
Fill data with characters from the stream. |
|
void |
skip(int length)
|
|
Buffer |
takeBufferWindow()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Connection connection
protected final Input input
protected final java.util.concurrent.atomic.AtomicBoolean isClosed
| Constructor Detail |
|---|
protected AbstractStreamReader(Connection connection,
Input streamInput)
connection - the Connection to be associated with this
AbstractStreamReaderstreamInput - the stream source| Method Detail |
|---|
public boolean readBoolean()
throws java.io.IOException
readBoolean in interface StreamReaderjava.io.IOException
public byte readByte()
throws java.io.IOException
readByte in interface StreamReaderjava.io.IOException
public char readChar()
throws java.io.IOException
readChar in interface StreamReaderjava.io.IOException
public short readShort()
throws java.io.IOException
readShort in interface StreamReaderjava.io.IOException
public int readInt()
throws java.io.IOException
readInt in interface StreamReaderjava.io.IOException
public long readLong()
throws java.io.IOException
readLong in interface StreamReaderjava.io.IOException
public final float readFloat()
throws java.io.IOException
readFloat in interface StreamReaderjava.io.IOException
public final double readDouble()
throws java.io.IOException
readDouble in interface StreamReaderjava.io.IOException
public void readBooleanArray(boolean[] data)
throws java.io.IOException
readBooleanArray in interface StreamReaderjava.io.IOException
public void readByteArray(byte[] data)
throws java.io.IOException
readByteArray in interface StreamReaderjava.io.IOException
public void readByteArray(byte[] data,
int offset,
int length)
throws java.io.IOException
readByteArray in interface StreamReaderjava.io.IOException
public void readBytes(Buffer buffer)
throws java.io.IOException
readBytes in interface StreamReaderjava.io.IOException
public void readCharArray(char[] data)
throws java.io.IOException
readCharArray in interface StreamReaderjava.io.IOException
public void readShortArray(short[] data)
throws java.io.IOException
readShortArray in interface StreamReaderjava.io.IOException
public void readIntArray(int[] data)
throws java.io.IOException
readIntArray in interface StreamReaderjava.io.IOException
public void readLongArray(long[] data)
throws java.io.IOException
readLongArray in interface StreamReaderjava.io.IOException
public void readFloatArray(float[] data)
throws java.io.IOException
readFloatArray in interface StreamReaderjava.io.IOException
public void readDoubleArray(double[] data)
throws java.io.IOException
readDoubleArray in interface StreamReaderjava.io.IOExceptionpublic void skip(int length)
skip in interface StreamReaderpublic <E> GrizzlyFuture<E> decode(Transformer<Stream,E> decoder)
decode in interface StreamReaderE - decoded data typedecoder - Transformer
Future, which will hold the decoding state.
public <E> GrizzlyFuture<E> decode(Transformer<Stream,E> decoder,
CompletionHandler<E> completionHandler)
decode in interface StreamReaderE - decoded data typedecoder - TransformercompletionHandler - CompletionHandler, which will be
notified, when decoder will become ready.
Future, which will hold the decoding state.public GrizzlyFuture<java.lang.Integer> notifyAvailable(int size)
Future, using which it's possible check if
StreamReader has required amount of bytes available
for reading reading.
notifyAvailable in interface StreamReadersize - number of bytes, which should become available on
StreamReader.
Future, using which it's possible to check whether
StreamReader has required amount of bytes available for reading.
public GrizzlyFuture<java.lang.Integer> notifyAvailable(int size,
CompletionHandler<java.lang.Integer> completionHandler)
Future, using which it's possible check if
StreamReader has required amount of bytes available
for reading reading.
CompletionHandler is also passed to get notified, once required
number of bytes will become available for reading.
notifyAvailable in interface StreamReadersize - number of bytes, which should become available on
StreamReader.completionHandler - CompletionHandler, which will be notified
once required number of bytes will become available.
Future, using which it's possible to check whether
StreamReader has required amount of bytes available for reading.public GrizzlyFuture<java.lang.Integer> notifyCondition(Condition condition)
Future, using which it's possible check if
StreamReader meets specific Condition.
notifyCondition in interface StreamReadercondition - Condition StreamReader should meet.
Future, using which it's possible to check whether
StreamReader meets the required Condition.
public GrizzlyFuture<java.lang.Integer> notifyCondition(Condition condition,
CompletionHandler<java.lang.Integer> completionHandler)
Future, using which it's possible check if
StreamReader meets specific Condition.
CompletionHandler is also passed to get notified, once
the Condition will be satisfied.
notifyCondition in interface StreamReadercondition - Condition StreamReader should meet.completionHandler - CompletionHandler, which will be
notified, once the Condition will be satisfied.
Future, using which it's possible to check whether
StreamReader meets the required Condition.public void close()
close in interface java.io.Closeablepublic boolean isClosed()
isClosed in interface StreamReaderpublic final boolean hasAvailable()
hasAvailable in interface StreamReaderpublic int available()
available in interface StreamReaderpublic boolean isSupportBufferWindow()
isSupportBufferWindow in interface StreamReaderpublic Buffer getBufferWindow()
getBufferWindow in interface StreamReaderpublic Buffer takeBufferWindow()
takeBufferWindow in interface StreamReaderpublic Connection getConnection()
Connection this StreamReader belongs to.
getConnection in interface StreamConnection this StreamReader belongs to.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||