org.freecompany.redline
Class WritableChannelWrapper
java.lang.Object
org.freecompany.redline.ChannelWrapper
org.freecompany.redline.WritableChannelWrapper
- All Implemented Interfaces:
- java.io.Closeable, java.nio.channels.Channel, java.nio.channels.WritableByteChannel
public class WritableChannelWrapper
- extends ChannelWrapper
- implements java.nio.channels.WritableByteChannel
Wrapper around a writable channel that allows
for observing written data.
|
Field Summary |
protected java.nio.channels.WritableByteChannel |
channel
|
|
Method Summary |
void |
close()
Closes the underlying channel and completes
any outstanding operations in the consumers. |
boolean |
isOpen()
Flag indicating whether the underlying channel
is open. |
int |
write(java.nio.ByteBuffer buffer)
Writes data to the wrapped channel, while passing an
exact copy to the registered consumers. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
channel
protected java.nio.channels.WritableByteChannel channel
WritableChannelWrapper
public WritableChannelWrapper(java.nio.channels.WritableByteChannel channel)
write
public int write(java.nio.ByteBuffer buffer)
throws java.io.IOException
- Writes data to the wrapped channel, while passing an
exact copy to the registered consumers.
- Specified by:
write in interface java.nio.channels.WritableByteChannel
- Parameters:
buffer - the buffer to write to the wrapped channel
- Returns:
- the number of bytes written
- Throws:
java.io.IOException - if an IO error occurs
close
public void close()
throws java.io.IOException
- Closes the underlying channel and completes
any outstanding operations in the consumers.
- Specified by:
close in interface java.io.Closeable- Specified by:
close in interface java.nio.channels.Channel- Overrides:
close in class ChannelWrapper
- Throws:
java.io.IOException - if an IO error occurs
isOpen
public boolean isOpen()
- Flag indicating whether the underlying channel
is open.
- Specified by:
isOpen in interface java.nio.channels.Channel
- Returns:
- true if it is open, false otherwise
Copyright © 2011. All Rights Reserved.