au.com.terabit.jproactor
Class OpWrite

java.lang.Object
  extended by au.com.terabit.jproactor.IOOperation
      extended by au.com.terabit.jproactor.OpWrite

public class OpWrite
extends IOOperation

The write operation implementation.

Version:
$Revision$ $Date$
Author:
Yevgeny Libman

Field Summary
protected  java.nio.ByteBuffer m_buffer
          data buffer
protected  int m_bytesCompleted
          The number of bytes processed by IO operation.
protected  boolean m_flgExactly
          This flag denotes that data needs to be written until buffer is empty.
 
Fields inherited from class au.com.terabit.jproactor.IOOperation
m_asynchChannel, m_errorCause
 
Method Summary
protected  boolean execute()
           
 java.nio.ByteBuffer getBuffer()
          Returns operations' data buffer.
 int getBytesCompleted()
           
 void onComplete()
          Called when IO operation has completed - notifies protocol instance that write operation has completed.
 int remaining()
          Tells the difference between a number of requested and processed bytes at present time.
 
Methods inherited from class au.com.terabit.jproactor.IOOperation
getChannel, getError, getState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_buffer

protected java.nio.ByteBuffer m_buffer
data buffer


m_bytesCompleted

protected int m_bytesCompleted
The number of bytes processed by IO operation.

-1 if error occured or channel is closed


m_flgExactly

protected boolean m_flgExactly
This flag denotes that data needs to be written until buffer is empty.

See Also:
java.nio.ByteBuffer#remaning()
Method Detail

getBytesCompleted

public int getBytesCompleted()
Returns:
a number of bytes available after io operation was completed; -1 if exception or end-of-channel happened

getBuffer

public java.nio.ByteBuffer getBuffer()
Returns operations' data buffer.

Returns:
data buffer

remaining

public int remaining()
Tells the difference between a number of requested and processed bytes at present time.

Example 1: Requested to read n bytes, actually read was m, so bytesRemaining is n-m

Example 2: Requested to write n bytes, actually written was m, so bytesRemaining is n-m

See Also:
java.nio.ByteBuffer#remaning()

execute

protected boolean execute()
Specified by:
execute in class IOOperation

onComplete

public void onComplete()
Called when IO operation has completed - notifies protocol instance that write operation has completed.

See Also:
IOOperation.onComplete()