Top Description Methods
org.glassfish.grizzly

public Interface InputSource

Imports
java.io.InputStream, .Reader

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

Modifier and TypeMethod and Description
public boolean
isFinished()

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

public boolean
isReady()

Returns: true if data can be obtained without blocking, otherwise returns false.

public void
notifyAvailable(final ReadHandler
the ReadHandler to notify.
handler
)

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

public void
notifyAvailable(final ReadHandler
the ReadHandler to notify.
handler
,
final int
the least number of bytes that must be available before the ReadHandler is invoked.
size
)

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

public int
readyData()

Returns: the number of bytes (or characters) that may be obtained without blocking.

Method Detail

isFinishedback to summary
public boolean isFinished()
Returns:boolean

true when all data for this particular request has been read, otherwise returns false.

isReadyback to summary
public boolean isReady()
Returns:boolean

true if data can be obtained without blocking, otherwise returns false.

notifyAvailableback to summary
public void notifyAvailable(final ReadHandler handler)

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

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

Parameters
handler:ReadHandler

the ReadHandler to notify.

Exceptions
IllegalArgumentException:
if handler is null.
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()
notifyAvailableback to summary
public void notifyAvailable(final ReadHandler handler, final 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:ReadHandler

the ReadHandler to notify.

size:int

the least number of bytes that must be available before the ReadHandler is invoked.

Exceptions
IllegalArgumentException:
if handler is null, or if size is less or equal to 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()
readyDataback to summary
public int readyData()
Returns:int

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