org.apache.mina.filter.codec.support
Class SimpleProtocolEncoderOutput

java.lang.Object
  extended by org.apache.mina.filter.codec.support.SimpleProtocolEncoderOutput
All Implemented Interfaces:
ProtocolEncoderOutput

public abstract class SimpleProtocolEncoderOutput
extends java.lang.Object
implements ProtocolEncoderOutput

A ProtocolEncoderOutput based on queue.


Constructor Summary
SimpleProtocolEncoderOutput()
           
 
Method Summary
protected abstract  WriteFuture doFlush(ByteBuffer buf)
           
 WriteFuture flush()
          Flushes all buffers you wrote via ProtocolEncoderOutput.write(ByteBuffer) to the session.
 java.util.Queue<ByteBuffer> getBufferQueue()
           
 void mergeAll()
          Merges all buffers you wrote via ProtocolEncoderOutput.write(ByteBuffer) into one ByteBuffer and replaces the old fragmented ones with it.
 void write(ByteBuffer buf)
          Callback for ProtocolEncoder to generate encoded ByteBuffers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleProtocolEncoderOutput

public SimpleProtocolEncoderOutput()
Method Detail

getBufferQueue

public java.util.Queue<ByteBuffer> getBufferQueue()

write

public void write(ByteBuffer buf)
Description copied from interface: ProtocolEncoderOutput
Callback for ProtocolEncoder to generate encoded ByteBuffers. ProtocolEncoder must call ProtocolEncoderOutput.write(ByteBuffer) for each encoded message.

Specified by:
write in interface ProtocolEncoderOutput
Parameters:
buf - the buffer which contains encoded data

mergeAll

public void mergeAll()
Description copied from interface: ProtocolEncoderOutput
Merges all buffers you wrote via ProtocolEncoderOutput.write(ByteBuffer) into one ByteBuffer and replaces the old fragmented ones with it. This method is useful when you want to control the way MINA generates network packets.

Specified by:
mergeAll in interface ProtocolEncoderOutput

flush

public WriteFuture flush()
Description copied from interface: ProtocolEncoderOutput
Flushes all buffers you wrote via ProtocolEncoderOutput.write(ByteBuffer) to the session. This operation is asynchronous; please wait for the returned WriteFuture if you want to wait for the buffers flushed.

Specified by:
flush in interface ProtocolEncoderOutput
Returns:
null if there is nothing to flush at all.

doFlush

protected abstract WriteFuture doFlush(ByteBuffer buf)