org.glassfish.grizzly.http.server.io
Interface NIOInputSource

All Known Subinterfaces:
BinaryNIOInputSource
All Known Implementing Classes:
NIOInputStream, NIOReader

public interface NIOInputSource

This interface defines methods to allow an InputStream or Reader to notify the developer when and how much data is ready to be read without blocking.

Since:
2.0

Method Summary
 boolean isFinished()
           
 boolean isReady()
           
 void notifyAvailable(ReadHandler handler)
           Notify the specified ReadHandler when any number of bytes can be read without blocking.
 void notifyAvailable(ReadHandler handler, int size)
           Notify the specified ReadHandler when the number of bytes that can be read without blocking is greater or equal to the specified size.
 int readyData()
           
 

Method Detail

notifyAvailable

void notifyAvailable(ReadHandler handler)

Notify the specified ReadHandler when any number of bytes can be read without blocking.

Invoking this method is equivalent to calling: notifyAvailable(handler, 0).

Parameters:
handler - the ReadHandler to notify.
Throws:
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.
See Also:
ReadHandler.onDataAvailable(), ReadHandler.onAllDataRead()

notifyAvailable

void notifyAvailable(ReadHandler handler,
                     int size)

Notify the specified ReadHandler when the number of bytes that can be read without blocking is greater or equal to the specified size.

Parameters:
handler - the ReadHandler to notify.
size - the least number of bytes that must be available before the ReadHandler is invoked. If size is 0, the handler will be notified as soon as data is available no matter the size.
Throws:
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.
See Also:
ReadHandler.onDataAvailable(), ReadHandler.onAllDataRead()

isFinished

boolean isFinished()
Returns:
true when all data for this particular request has been read, otherwise returns false.

readyData

int readyData()
Returns:
the number of bytes (or characters) that may be obtained without blocking. Note when dealing with characters, this method will return an estimate on the number of characters available.

isReady

boolean isReady()
Returns:
true if data can be obtained without blocking, otherwise returns false.


Copyright © 2013 Oracle Corporation. All Rights Reserved.