org.freecompany.redline
Class ReadableChannelWrapper
java.lang.Object
org.freecompany.redline.ChannelWrapper
org.freecompany.redline.ReadableChannelWrapper
- All Implemented Interfaces:
- Closeable, Channel, ReadableByteChannel
public class ReadableChannelWrapper
- extends ChannelWrapper
- implements ReadableByteChannel
Wrapper for observing data read from a NIO channel. This wrapper is
used for operations that must be notified of incoming IO data.
|
Method Summary |
void |
close()
Close the underlying read channel and complete any operations in the
consumer. |
boolean |
isOpen()
Boolean flag indicating whether the channel is open or closed. |
int |
read(ByteBuffer buffer)
Reads data from the channel and passes it to the consumer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
channel
protected ReadableByteChannel channel
ReadableChannelWrapper
public ReadableChannelWrapper(ReadableByteChannel channel)
read
public int read(ByteBuffer buffer)
throws IOException
- Reads data from the channel and passes it to the consumer. This method
does not mutate the acutal data in the provided buffer, but makes it's
own copy to pass to the consumer.
- Specified by:
read in interface ReadableByteChannel
- Parameters:
buffer - the buffer to read into
- Returns:
- the number of bytes read from the underlying channel
- Throws:
IOException - if an IO error occurrs
close
public void close()
throws IOException
- Close the underlying read channel and complete any operations in the
consumer.
- Specified by:
close in interface Closeable- Specified by:
close in interface Channel- Overrides:
close in class ChannelWrapper
- Throws:
IOException - if an IO error occurrs
isOpen
public boolean isOpen()
- Boolean flag indicating whether the channel is open or closed.
- Specified by:
isOpen in interface Channel
- Returns:
- true if the channel is open, false if not
Copyright © 2012. All Rights Reserved.