org.freecompany.redline
Class WritableChannelWrapper

java.lang.Object
  extended by org.freecompany.redline.ChannelWrapper
      extended by org.freecompany.redline.WritableChannelWrapper
All Implemented Interfaces:
Closeable, Channel, WritableByteChannel

public class WritableChannelWrapper
extends ChannelWrapper
implements WritableByteChannel

Wrapper around a writable channel that allows for observing written data.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.freecompany.redline.ChannelWrapper
ChannelWrapper.Consumer<T>, ChannelWrapper.Key<T>
 
Field Summary
protected  WritableByteChannel channel
           
 
Fields inherited from class org.freecompany.redline.ChannelWrapper
consumers
 
Constructor Summary
WritableChannelWrapper(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(ByteBuffer buffer)
          Writes data to the wrapped channel, while passing an exact copy to the registered consumers.
 
Methods inherited from class org.freecompany.redline.ChannelWrapper
finish, start, start, start, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

channel

protected WritableByteChannel channel
Constructor Detail

WritableChannelWrapper

public WritableChannelWrapper(WritableByteChannel channel)
Method Detail

write

public int write(ByteBuffer buffer)
          throws IOException
Writes data to the wrapped channel, while passing an exact copy to the registered consumers.

Specified by:
write in interface WritableByteChannel
Parameters:
buffer - the buffer to write to the wrapped channel
Returns:
the number of bytes written
Throws:
IOException - if an IO error occurs

close

public void close()
           throws IOException
Closes the underlying channel and completes any outstanding operations in the consumers.

Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Overrides:
close in class ChannelWrapper
Throws:
IOException - if an IO error occurs

isOpen

public boolean isOpen()
Flag indicating whether the underlying channel is open.

Specified by:
isOpen in interface Channel
Returns:
true if it is open, false otherwise


Copyright © 2012. All Rights Reserved.