|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.http.server.io.InputBuffer
public class InputBuffer
Abstraction exposing both byte and character methods to read content from the HTTP messaging system in Grizzly.
| Constructor Summary | |
|---|---|
InputBuffer()
|
|
| Method Summary | |
|---|---|
boolean |
append(Buffer buffer)
Appends the specified Buffer to the internal composite
Buffer. |
int |
available()
|
int |
availableChar()
|
void |
close()
|
void |
fillFully(int length)
Fill the buffer (blocking) up to the requested length. |
void |
finished()
When invoked, this method will call ReadHandler.onAllDataRead()
on the current ReadHandler (if any). |
Buffer |
getBuffer()
|
ReadHandler |
getReadHandler()
|
void |
initialize(HttpRequestPacket request,
FilterChainContext ctx)
Per-request initialization required for the InputBuffer to function properly. |
boolean |
isAsyncEnabled()
|
boolean |
isFinished()
|
void |
mark(int readAheadLimit)
Only supported with binary data. |
boolean |
markSupported()
Only supported with binary data. |
void |
notifyAvailable(ReadHandler handler)
Installs a ReadHandler that will be notified when any data
becomes available to read without blocking. |
void |
notifyAvailable(ReadHandler handler,
int size)
Installs a ReadHandler that will be notified when the specified
amount of data is available to be read without blocking. |
void |
processingChars()
This method should be called if the InputBuffer is being used in conjunction with a Reader implementation. |
int |
read(byte[] b,
int off,
int len)
|
int |
read(char[] cbuf,
int off,
int len)
|
int |
read(CharBuffer target)
|
int |
readByte()
This method always blocks. |
int |
readChar()
|
boolean |
ready()
|
void |
recycle()
Recycle this InputBuffer for reuse. |
void |
reset()
Only supported with binary data. |
void |
setAsyncEnabled(boolean asyncEnabled)
Sets the asynchronous processing state of this InputBuffer. |
long |
skip(long n,
boolean block)
Skips the specified number of bytes/characters. |
void |
terminate()
Invoke ReadHandler.onError(Throwable) (assuming a ReadHandler
is available) } passing a {#link CancellationException}
if the current Connection is open, or a {#link EOFException} if
the connection was unexpectedly closed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InputBuffer()
| Method Detail |
|---|
public void initialize(HttpRequestPacket request,
FilterChainContext ctx)
Per-request initialization required for the InputBuffer to function properly.
request - the current requestctx - the FilterChainContext for the chain processing this requestpublic void recycle()
Recycle this InputBuffer for reuse.
public void processingChars()
This method should be called if the InputBuffer is being used in conjunction
with a Reader implementation. If this method is not called,
any character-based methods called on this InputBuffer will
throw a IllegalStateException.
public int readByte()
throws IOException
IOExceptionInputStream.read()
public int read(byte[] b,
int off,
int len)
throws IOException
IOExceptionInputStream.read(byte[], int, int)public int available()
InputStream.available()public Buffer getBuffer()
Buffer used to buffer incoming request
data.public ReadHandler getReadHandler()
ReadHandler current in use, if any.
public int read(CharBuffer target)
throws IOException
IOExceptionReader.read(java.nio.CharBuffer)
public int readChar()
throws IOException
IOExceptionReader.read()
public int read(char[] cbuf,
int off,
int len)
throws IOException
IOExceptionReader.read(char[], int, int)public boolean ready()
Reader.ready()
public void fillFully(int length)
throws IOException
length -
IOExceptionpublic int availableChar()
public void mark(int readAheadLimit)
Only supported with binary data.
InputStream.mark(int)public boolean markSupported()
Only supported with binary data.
InputStream.markSupported()
public void reset()
throws IOException
Only supported with binary data.
IOExceptionInputStream.reset()
public void close()
throws IOException
IOExceptionCloseable.close()
public long skip(long n,
boolean block)
throws IOException
IllegalStateException - if the stream that is using this InputBuffer
is configured for asynchronous communication and the number of bytes/characters
being skipped exceeds the number of bytes available in the buffer.
IOExceptionInputStream.skip(long),
Reader.skip(long)
public void finished()
throws IOException
ReadHandler.onAllDataRead()
on the current ReadHandler (if any).
This method shouldn't be invoked by developers directly.
IOExceptionpublic boolean isFinished()
true if all request data has been read, otherwise
returns false.public void notifyAvailable(ReadHandler handler)
ReadHandler that will be notified when any data
becomes available to read without blocking.
handler - the ReadHandler to invoke.
IllegalArgumentException - if handler is null,
or if size is less than zero.
IllegalStateException - if an attempt is made to register a handler
before an existing registered handler has been invoked or if all request
data has already been read.
public void notifyAvailable(ReadHandler handler,
int size)
ReadHandler that will be notified when the specified
amount of data is available to be read without blocking.
handler - the ReadHandler to invoke.size - the minimum number of bytes that must be available before
the ReadHandler is notified.
IllegalArgumentException - if handler is null,
or if size is less than zero.
IllegalStateException - if an attempt is made to register a handler
before an existing registered handler has been invoked.
public boolean append(Buffer buffer)
throws IOException
Buffer to the internal composite
Buffer.
buffer - the Buffer to append
true if ReadHandler.onDataAvailable()
callback was invoked, otherwise returns false.
IOException - if an error occurs appending the Bufferpublic boolean isAsyncEnabled()
public void setAsyncEnabled(boolean asyncEnabled)
InputBuffer.
asyncEnabled - true if this InputBuffer
is to be used to process asynchronous request data.public void terminate()
Invoke ReadHandler.onError(Throwable) (assuming a ReadHandler
is available) } passing a {#link CancellationException}
if the current Connection is open, or a {#link EOFException} if
the connection was unexpectedly closed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||